setup.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * arch/sh/boards/landisk/setup.c
  3. *
  4. * Copyright (C) 2002 Paul Mundt
  5. *
  6. * May be copied or modified under the terms of the GNU General Public
  7. * License. See linux/COPYING for more information.
  8. *
  9. * Setup code for an unknown machine (internal peripherials only)
  10. */
  11. /*
  12. * linux/arch/sh/kernel/setup_landisk.c
  13. *
  14. * Copyright (C) 2000 Kazumoto Kojima
  15. *
  16. * I-O DATA Device, Inc. LANDISK Support.
  17. *
  18. * Modified for LANDISK by
  19. * Atom Create Engineering Co., Ltd. 2002.
  20. */
  21. /*
  22. * modifed by kogiidena
  23. * 2005.09.16
  24. */
  25. #include <linux/config.h>
  26. #include <linux/init.h>
  27. #include <linux/irq.h>
  28. #include <linux/pm.h>
  29. #include <linux/hdreg.h>
  30. #include <linux/ide.h>
  31. #include <linux/pci.h>
  32. #include <asm/machvec.h>
  33. #include <asm/rtc.h>
  34. #include <asm/machvec_init.h>
  35. #include <asm/io.h>
  36. #include <asm/landisk/iodata_landisk.h>
  37. #include <asm/landisk/io.h>
  38. #include <linux/mm.h>
  39. #include <linux/vmalloc.h>
  40. extern void (*board_time_init) (void);
  41. void landisk_time_init(void);
  42. extern void init_landisk_IRQ(void);
  43. int landisk_ledparam;
  44. int landisk_buzzerparam;
  45. int landisk_arch;
  46. /* defined in mm/ioremap.c */
  47. extern void *p3_ioremap(unsigned long phys_addr, unsigned long size,
  48. unsigned long flags);
  49. /*
  50. * Initialize the board
  51. */
  52. const char *get_system_type(void)
  53. {
  54. return "LANDISK";
  55. }
  56. static void landisk_power_off(void)
  57. {
  58. ctrl_outb(0x01, PA_SHUTDOWN);
  59. }
  60. void check_usl5p(void)
  61. {
  62. volatile unsigned char *p = (volatile unsigned char *)PA_LED;
  63. unsigned char tmp1, tmp2;
  64. tmp1 = *p;
  65. *p = 0x40;
  66. tmp2 = *p;
  67. *p = tmp1;
  68. landisk_arch = (tmp2 == 0x40) ? 1 : 0;
  69. if (landisk_arch == 1) { /* arch == usl-5p */
  70. landisk_ledparam = 0x00000380;
  71. landisk_ledparam |= (tmp1 & 0x07c);
  72. } else { /* arch == landisk */
  73. landisk_ledparam = 0x02000180;
  74. landisk_ledparam |= 0x04;
  75. }
  76. return;
  77. }
  78. void __init platform_setup(void)
  79. {
  80. landisk_buzzerparam = 0;
  81. check_usl5p();
  82. printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
  83. board_time_init = landisk_time_init;
  84. pm_power_off = landisk_power_off;
  85. }
  86. void *area5_io_base;
  87. void *area6_io_base;
  88. int __init cf_init(void)
  89. {
  90. pgprot_t prot;
  91. unsigned long paddrbase, psize;
  92. /* open I/O area window */
  93. paddrbase = virt_to_phys((void *)PA_AREA5_IO);
  94. psize = PAGE_SIZE;
  95. prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
  96. area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
  97. if (!area5_io_base) {
  98. printk("allocate_cf_area : can't open CF I/O window!\n");
  99. return -ENOMEM;
  100. }
  101. paddrbase = virt_to_phys((void *)PA_AREA6_IO);
  102. psize = PAGE_SIZE;
  103. prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
  104. area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
  105. if (!area6_io_base) {
  106. printk("allocate_cf_area : can't open HDD I/O window!\n");
  107. return -ENOMEM;
  108. }
  109. printk(KERN_INFO "Allocate Area5/6 success.\n");
  110. /* XXX : do we need attribute and common-memory area also? */
  111. return 0;
  112. }
  113. __initcall(cf_init);
  114. #include <linux/sched.h>
  115. /* Cycle the LED's in the clasic knightrider/Sun pattern */
  116. void heartbeat_landisk(void)
  117. {
  118. static unsigned int cnt = 0, blink = 0x00, period = 25;
  119. volatile unsigned char *p = (volatile unsigned char *)PA_LED;
  120. char data;
  121. if ((landisk_ledparam & 0x080) == 0) {
  122. return;
  123. }
  124. cnt += 1;
  125. if (cnt < period) {
  126. return;
  127. }
  128. cnt = 0;
  129. blink++;
  130. data = (blink & 0x01) ? (landisk_ledparam >> 16) : 0;
  131. data |= (blink & 0x02) ? (landisk_ledparam >> 8) : 0;
  132. data |= landisk_ledparam;
  133. /* buzzer */
  134. if (landisk_buzzerparam & 0x1) {
  135. data |= 0x80;
  136. } else {
  137. data &= 0x7f;
  138. }
  139. *p = data;
  140. if (((landisk_ledparam & 0x007f7f00) == 0)
  141. && (landisk_buzzerparam == 0)) {
  142. landisk_ledparam &= (~0x0080);
  143. }
  144. landisk_buzzerparam >>= 1;
  145. }
  146. /*
  147. * The Machine Vector
  148. */
  149. struct sh_machine_vector mv_landisk __initmv = {
  150. .mv_nr_irqs = 72,
  151. .mv_inb = landisk_inb,
  152. .mv_inw = landisk_inw,
  153. .mv_inl = landisk_inl,
  154. .mv_outb = landisk_outb,
  155. .mv_outw = landisk_outw,
  156. .mv_outl = landisk_outl,
  157. .mv_inb_p = landisk_inb_p,
  158. .mv_inw_p = landisk_inw,
  159. .mv_inl_p = landisk_inl,
  160. .mv_outb_p = landisk_outb_p,
  161. .mv_outw_p = landisk_outw,
  162. .mv_outl_p = landisk_outl,
  163. .mv_insb = landisk_insb,
  164. .mv_insw = landisk_insw,
  165. .mv_insl = landisk_insl,
  166. .mv_outsb = landisk_outsb,
  167. .mv_outsw = landisk_outsw,
  168. .mv_outsl = landisk_outsl,
  169. .mv_readb = landisk_readb,
  170. .mv_readw = landisk_readw,
  171. .mv_readl = landisk_readl,
  172. .mv_writeb = landisk_writeb,
  173. .mv_writew = landisk_writew,
  174. .mv_writel = landisk_writel,
  175. .mv_ioremap = landisk_ioremap,
  176. .mv_iounmap = landisk_iounmap,
  177. .mv_isa_port2addr = landisk_isa_port2addr,
  178. .mv_init_irq = init_landisk_IRQ,
  179. #ifdef CONFIG_HEARTBEAT
  180. .mv_heartbeat = heartbeat_landisk,
  181. #endif
  182. };
  183. ALIAS_MV(landisk)