setup.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * arch/sh64/mach-cayman/setup.c
  7. *
  8. * SH5 Cayman support
  9. *
  10. * This file handles the architecture-dependent parts of initialization
  11. *
  12. * Copyright David J. Mckay.
  13. * Needs major work!
  14. *
  15. * benedict.gaster@superh.com: 3rd May 2002
  16. * Added support for ramdisk, removing statically linked romfs at the same time.
  17. *
  18. * lethal@linux-sh.org: 15th May 2003
  19. * Use the generic procfs cpuinfo interface, just return a valid board name.
  20. */
  21. #include <linux/stddef.h>
  22. #include <linux/init.h>
  23. #include <linux/mm.h>
  24. #include <linux/bootmem.h>
  25. #include <linux/delay.h>
  26. #include <linux/kernel.h>
  27. #include <linux/seq_file.h>
  28. #include <asm/processor.h>
  29. #include <asm/platform.h>
  30. #include <asm/io.h>
  31. #include <asm/irq.h>
  32. #include <asm/page.h>
  33. /*
  34. * Platform Dependent Interrupt Priorities.
  35. */
  36. /* Using defaults defined in irq.h */
  37. #define RES NO_PRIORITY /* Disabled */
  38. #define IR0 IRL0_PRIORITY /* IRLs */
  39. #define IR1 IRL1_PRIORITY
  40. #define IR2 IRL2_PRIORITY
  41. #define IR3 IRL3_PRIORITY
  42. #define PCA INTA_PRIORITY /* PCI Ints */
  43. #define PCB INTB_PRIORITY
  44. #define PCC INTC_PRIORITY
  45. #define PCD INTD_PRIORITY
  46. #define SER TOP_PRIORITY
  47. #define ERR TOP_PRIORITY
  48. #define PW0 TOP_PRIORITY
  49. #define PW1 TOP_PRIORITY
  50. #define PW2 TOP_PRIORITY
  51. #define PW3 TOP_PRIORITY
  52. #define DM0 NO_PRIORITY /* DMA Ints */
  53. #define DM1 NO_PRIORITY
  54. #define DM2 NO_PRIORITY
  55. #define DM3 NO_PRIORITY
  56. #define DAE NO_PRIORITY
  57. #define TU0 TIMER_PRIORITY /* TMU Ints */
  58. #define TU1 NO_PRIORITY
  59. #define TU2 NO_PRIORITY
  60. #define TI2 NO_PRIORITY
  61. #define ATI NO_PRIORITY /* RTC Ints */
  62. #define PRI NO_PRIORITY
  63. #define CUI RTC_PRIORITY
  64. #define ERI SCIF_PRIORITY /* SCIF Ints */
  65. #define RXI SCIF_PRIORITY
  66. #define BRI SCIF_PRIORITY
  67. #define TXI SCIF_PRIORITY
  68. #define ITI TOP_PRIORITY /* WDT Ints */
  69. /* Setup for the SMSC FDC37C935 */
  70. #define SMSC_SUPERIO_BASE 0x04000000
  71. #define SMSC_CONFIG_PORT_ADDR 0x3f0
  72. #define SMSC_INDEX_PORT_ADDR SMSC_CONFIG_PORT_ADDR
  73. #define SMSC_DATA_PORT_ADDR 0x3f1
  74. #define SMSC_ENTER_CONFIG_KEY 0x55
  75. #define SMSC_EXIT_CONFIG_KEY 0xaa
  76. #define SMCS_LOGICAL_DEV_INDEX 0x07
  77. #define SMSC_DEVICE_ID_INDEX 0x20
  78. #define SMSC_DEVICE_REV_INDEX 0x21
  79. #define SMSC_ACTIVATE_INDEX 0x30
  80. #define SMSC_PRIMARY_BASE_INDEX 0x60
  81. #define SMSC_SECONDARY_BASE_INDEX 0x62
  82. #define SMSC_PRIMARY_INT_INDEX 0x70
  83. #define SMSC_SECONDARY_INT_INDEX 0x72
  84. #define SMSC_IDE1_DEVICE 1
  85. #define SMSC_KEYBOARD_DEVICE 7
  86. #define SMSC_CONFIG_REGISTERS 8
  87. #define SMSC_SUPERIO_READ_INDEXED(index) ({ \
  88. outb((index), SMSC_INDEX_PORT_ADDR); \
  89. inb(SMSC_DATA_PORT_ADDR); })
  90. #define SMSC_SUPERIO_WRITE_INDEXED(val, index) ({ \
  91. outb((index), SMSC_INDEX_PORT_ADDR); \
  92. outb((val), SMSC_DATA_PORT_ADDR); })
  93. #define IDE1_PRIMARY_BASE 0x01f0
  94. #define IDE1_SECONDARY_BASE 0x03f6
  95. unsigned long smsc_superio_virt;
  96. /*
  97. * Platform dependent structures: maps and parms block.
  98. */
  99. struct resource io_resources[] = {
  100. /* To be updated with external devices */
  101. };
  102. struct resource kram_resources[] = {
  103. /* These must be last in the array */
  104. { .name = "Kernel code", .start = 0, .end = 0 },
  105. /* These must be last in the array */
  106. { .name = "Kernel data", .start = 0, .end = 0 }
  107. };
  108. struct resource xram_resources[] = {
  109. /* To be updated with external devices */
  110. };
  111. struct resource rom_resources[] = {
  112. /* To be updated with external devices */
  113. };
  114. struct sh64_platform platform_parms = {
  115. .readonly_rootfs = 1,
  116. .initial_root_dev = 0x0100,
  117. .loader_type = 1,
  118. .io_res_p = io_resources,
  119. .io_res_count = ARRAY_SIZE(io_resources),
  120. .kram_res_p = kram_resources,
  121. .kram_res_count = ARRAY_SIZE(kram_resources),
  122. .xram_res_p = xram_resources,
  123. .xram_res_count = ARRAY_SIZE(xram_resources),
  124. .rom_res_p = rom_resources,
  125. .rom_res_count = ARRAY_SIZE(rom_resources),
  126. };
  127. int platform_int_priority[NR_INTC_IRQS] = {
  128. IR0, IR1, IR2, IR3, PCA, PCB, PCC, PCD, /* IRQ 0- 7 */
  129. RES, RES, RES, RES, SER, ERR, PW3, PW2, /* IRQ 8-15 */
  130. PW1, PW0, DM0, DM1, DM2, DM3, DAE, RES, /* IRQ 16-23 */
  131. RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 24-31 */
  132. TU0, TU1, TU2, TI2, ATI, PRI, CUI, ERI, /* IRQ 32-39 */
  133. RXI, BRI, TXI, RES, RES, RES, RES, RES, /* IRQ 40-47 */
  134. RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 48-55 */
  135. RES, RES, RES, RES, RES, RES, RES, ITI, /* IRQ 56-63 */
  136. };
  137. static int __init smsc_superio_setup(void)
  138. {
  139. unsigned char devid, devrev;
  140. smsc_superio_virt = onchip_remap(SMSC_SUPERIO_BASE, 1024, "SMSC SuperIO");
  141. if (!smsc_superio_virt) {
  142. panic("Unable to remap SMSC SuperIO\n");
  143. }
  144. /* Initially the chip is in run state */
  145. /* Put it into configuration state */
  146. outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
  147. outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
  148. /* Read device ID info */
  149. devid = SMSC_SUPERIO_READ_INDEXED(SMSC_DEVICE_ID_INDEX);
  150. devrev = SMSC_SUPERIO_READ_INDEXED(SMSC_DEVICE_REV_INDEX);
  151. printk("SMSC SuperIO devid %02x rev %02x\n", devid, devrev);
  152. /* Select the keyboard device */
  153. SMSC_SUPERIO_WRITE_INDEXED(SMSC_KEYBOARD_DEVICE, SMCS_LOGICAL_DEV_INDEX);
  154. /* enable it */
  155. SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
  156. /* Select the interrupts */
  157. /* On a PC keyboard is IRQ1, mouse is IRQ12 */
  158. SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_PRIMARY_INT_INDEX);
  159. SMSC_SUPERIO_WRITE_INDEXED(12, SMSC_SECONDARY_INT_INDEX);
  160. #ifdef CONFIG_IDE
  161. /*
  162. * Only IDE1 exists on the Cayman
  163. */
  164. /* Power it on */
  165. SMSC_SUPERIO_WRITE_INDEXED(1 << SMSC_IDE1_DEVICE, 0x22);
  166. SMSC_SUPERIO_WRITE_INDEXED(SMSC_IDE1_DEVICE, SMCS_LOGICAL_DEV_INDEX);
  167. SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
  168. SMSC_SUPERIO_WRITE_INDEXED(IDE1_PRIMARY_BASE >> 8,
  169. SMSC_PRIMARY_BASE_INDEX + 0);
  170. SMSC_SUPERIO_WRITE_INDEXED(IDE1_PRIMARY_BASE & 0xff,
  171. SMSC_PRIMARY_BASE_INDEX + 1);
  172. SMSC_SUPERIO_WRITE_INDEXED(IDE1_SECONDARY_BASE >> 8,
  173. SMSC_SECONDARY_BASE_INDEX + 0);
  174. SMSC_SUPERIO_WRITE_INDEXED(IDE1_SECONDARY_BASE & 0xff,
  175. SMSC_SECONDARY_BASE_INDEX + 1);
  176. SMSC_SUPERIO_WRITE_INDEXED(14, SMSC_PRIMARY_INT_INDEX);
  177. SMSC_SUPERIO_WRITE_INDEXED(SMSC_CONFIG_REGISTERS,
  178. SMCS_LOGICAL_DEV_INDEX);
  179. SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc2); /* GP42 = nIDE1_OE */
  180. SMSC_SUPERIO_WRITE_INDEXED(0x01, 0xc5); /* GP45 = IDE1_IRQ */
  181. SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc6); /* GP46 = nIOROP */
  182. SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc7); /* GP47 = nIOWOP */
  183. #endif
  184. /* Exit the configuration state */
  185. outb(SMSC_EXIT_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
  186. return 0;
  187. }
  188. /* This is grotty, but, because kernel is always referenced on the link line
  189. * before any devices, this is safe.
  190. */
  191. __initcall(smsc_superio_setup);
  192. void __init platform_setup(void)
  193. {
  194. /* Cayman platform leaves the decision to head.S, for now */
  195. platform_parms.fpu_flags = fpu_in_use;
  196. }
  197. void __init platform_monitor(void)
  198. {
  199. /* Nothing yet .. */
  200. }
  201. void __init platform_reserve(void)
  202. {
  203. /* Nothing yet .. */
  204. }
  205. const char *get_system_type(void)
  206. {
  207. return "Hitachi Cayman";
  208. }