setup.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * arch/sh/boards/landisk/setup.c
  3. *
  4. * Copyright (C) 2000 Kazumoto Kojima
  5. * Copyright (C) 2002 Paul Mundt
  6. *
  7. * I-O DATA Device, Inc. LANDISK Support.
  8. *
  9. * Modified for LANDISK by
  10. * Atom Create Engineering Co., Ltd. 2002.
  11. *
  12. * modifed by kogiidena
  13. * 2005.09.16
  14. *
  15. * This file is subject to the terms and conditions of the GNU General Public
  16. * License. See the file "COPYING" in the main directory of this archive
  17. * for more details.
  18. */
  19. #include <linux/config.h>
  20. #include <linux/init.h>
  21. #include <linux/pm.h>
  22. #include <linux/mm.h>
  23. #include <asm/machvec.h>
  24. #include <asm/rtc.h>
  25. #include <asm/landisk/iodata_landisk.h>
  26. #include <asm/io.h>
  27. void landisk_time_init(void);
  28. void init_landisk_IRQ(void);
  29. int landisk_ledparam;
  30. int landisk_buzzerparam;
  31. int landisk_arch;
  32. /* cycle the led's in the clasic knightrider/sun pattern */
  33. static void heartbeat_landisk(void)
  34. {
  35. static unsigned int cnt = 0, blink = 0x00, period = 25;
  36. volatile u8 *p = (volatile u8 *)PA_LED;
  37. char data;
  38. if ((landisk_ledparam & 0x080) == 0)
  39. return;
  40. cnt += 1;
  41. if (cnt < period)
  42. return;
  43. cnt = 0;
  44. blink++;
  45. data = (blink & 0x01) ? (landisk_ledparam >> 16) : 0;
  46. data |= (blink & 0x02) ? (landisk_ledparam >> 8) : 0;
  47. data |= landisk_ledparam;
  48. /* buzzer */
  49. if (landisk_buzzerparam & 0x1) {
  50. data |= 0x80;
  51. } else {
  52. data &= 0x7f;
  53. }
  54. *p = data;
  55. if (((landisk_ledparam & 0x007f7f00) == 0) &&
  56. (landisk_buzzerparam == 0))
  57. landisk_ledparam &= (~0x0080);
  58. landisk_buzzerparam >>= 1;
  59. }
  60. static void landisk_power_off(void)
  61. {
  62. ctrl_outb(0x01, PA_SHUTDOWN);
  63. }
  64. static void check_usl5p(void)
  65. {
  66. volatile u8 *p = (volatile u8 *)PA_LED;
  67. u8 tmp1, tmp2;
  68. tmp1 = *p;
  69. *p = 0x40;
  70. tmp2 = *p;
  71. *p = tmp1;
  72. landisk_arch = (tmp2 == 0x40);
  73. if (landisk_arch == 1) {
  74. /* arch == usl-5p */
  75. landisk_ledparam = 0x00000380;
  76. landisk_ledparam |= (tmp1 & 0x07c);
  77. } else {
  78. /* arch == landisk */
  79. landisk_ledparam = 0x02000180;
  80. landisk_ledparam |= 0x04;
  81. }
  82. }
  83. void *area5_io_base;
  84. void *area6_io_base;
  85. static int __init landisk_cf_init(void)
  86. {
  87. pgprot_t prot;
  88. unsigned long paddrbase, psize;
  89. /* open I/O area window */
  90. paddrbase = virt_to_phys((void *)PA_AREA5_IO);
  91. psize = PAGE_SIZE;
  92. prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
  93. area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
  94. if (!area5_io_base) {
  95. printk("allocate_cf_area : can't open CF I/O window!\n");
  96. return -ENOMEM;
  97. }
  98. paddrbase = virt_to_phys((void *)PA_AREA6_IO);
  99. psize = PAGE_SIZE;
  100. prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
  101. area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
  102. if (!area6_io_base) {
  103. printk("allocate_cf_area : can't open HDD I/O window!\n");
  104. return -ENOMEM;
  105. }
  106. printk(KERN_INFO "Allocate Area5/6 success.\n");
  107. /* XXX : do we need attribute and common-memory area also? */
  108. return 0;
  109. }
  110. static void __init landisk_setup(char **cmdline_p)
  111. {
  112. device_initcall(landisk_cf_init);
  113. landisk_buzzerparam = 0;
  114. check_usl5p();
  115. printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
  116. board_time_init = landisk_time_init;
  117. pm_power_off = landisk_power_off;
  118. }
  119. /*
  120. * The Machine Vector
  121. */
  122. struct sh_machine_vector mv_landisk __initmv = {
  123. .mv_name = "LANDISK",
  124. .mv_setup = landisk_setup,
  125. .mv_nr_irqs = 72,
  126. .mv_inb = landisk_inb,
  127. .mv_inw = landisk_inw,
  128. .mv_inl = landisk_inl,
  129. .mv_outb = landisk_outb,
  130. .mv_outw = landisk_outw,
  131. .mv_outl = landisk_outl,
  132. .mv_inb_p = landisk_inb_p,
  133. .mv_inw_p = landisk_inw,
  134. .mv_inl_p = landisk_inl,
  135. .mv_outb_p = landisk_outb_p,
  136. .mv_outw_p = landisk_outw,
  137. .mv_outl_p = landisk_outl,
  138. .mv_insb = landisk_insb,
  139. .mv_insw = landisk_insw,
  140. .mv_insl = landisk_insl,
  141. .mv_outsb = landisk_outsb,
  142. .mv_outsw = landisk_outsw,
  143. .mv_outsl = landisk_outsl,
  144. .mv_ioport_map = landisk_ioport_map,
  145. .mv_init_irq = init_landisk_IRQ,
  146. #ifdef CONFIG_HEARTBEAT
  147. .mv_heartbeat = heartbeat_landisk,
  148. #endif
  149. };
  150. ALIAS_MV(landisk)