setup.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * arch/sh/mach-cayman/setup.c
  3. *
  4. * SH5 Cayman support
  5. *
  6. * Copyright (C) 2002 David J. Mckay & Benedict Gaster
  7. * Copyright (C) 2003 - 2007 Paul Mundt
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file "COPYING" in the main directory of this archive
  11. * for more details.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/io.h>
  15. #include <linux/kernel.h>
  16. #include <cpu/irq.h>
  17. /*
  18. * Platform Dependent Interrupt Priorities.
  19. */
  20. /* Using defaults defined in irq.h */
  21. #define RES NO_PRIORITY /* Disabled */
  22. #define IR0 IRL0_PRIORITY /* IRLs */
  23. #define IR1 IRL1_PRIORITY
  24. #define IR2 IRL2_PRIORITY
  25. #define IR3 IRL3_PRIORITY
  26. #define PCA INTA_PRIORITY /* PCI Ints */
  27. #define PCB INTB_PRIORITY
  28. #define PCC INTC_PRIORITY
  29. #define PCD INTD_PRIORITY
  30. #define SER TOP_PRIORITY
  31. #define ERR TOP_PRIORITY
  32. #define PW0 TOP_PRIORITY
  33. #define PW1 TOP_PRIORITY
  34. #define PW2 TOP_PRIORITY
  35. #define PW3 TOP_PRIORITY
  36. #define DM0 NO_PRIORITY /* DMA Ints */
  37. #define DM1 NO_PRIORITY
  38. #define DM2 NO_PRIORITY
  39. #define DM3 NO_PRIORITY
  40. #define DAE NO_PRIORITY
  41. #define TU0 TIMER_PRIORITY /* TMU Ints */
  42. #define TU1 NO_PRIORITY
  43. #define TU2 NO_PRIORITY
  44. #define TI2 NO_PRIORITY
  45. #define ATI NO_PRIORITY /* RTC Ints */
  46. #define PRI NO_PRIORITY
  47. #define CUI RTC_PRIORITY
  48. #define ERI SCIF_PRIORITY /* SCIF Ints */
  49. #define RXI SCIF_PRIORITY
  50. #define BRI SCIF_PRIORITY
  51. #define TXI SCIF_PRIORITY
  52. #define ITI TOP_PRIORITY /* WDT Ints */
  53. /* Setup for the SMSC FDC37C935 */
  54. #define SMSC_SUPERIO_BASE 0x04000000
  55. #define SMSC_CONFIG_PORT_ADDR 0x3f0
  56. #define SMSC_INDEX_PORT_ADDR SMSC_CONFIG_PORT_ADDR
  57. #define SMSC_DATA_PORT_ADDR 0x3f1
  58. #define SMSC_ENTER_CONFIG_KEY 0x55
  59. #define SMSC_EXIT_CONFIG_KEY 0xaa
  60. #define SMCS_LOGICAL_DEV_INDEX 0x07
  61. #define SMSC_DEVICE_ID_INDEX 0x20
  62. #define SMSC_DEVICE_REV_INDEX 0x21
  63. #define SMSC_ACTIVATE_INDEX 0x30
  64. #define SMSC_PRIMARY_BASE_INDEX 0x60
  65. #define SMSC_SECONDARY_BASE_INDEX 0x62
  66. #define SMSC_PRIMARY_INT_INDEX 0x70
  67. #define SMSC_SECONDARY_INT_INDEX 0x72
  68. #define SMSC_IDE1_DEVICE 1
  69. #define SMSC_KEYBOARD_DEVICE 7
  70. #define SMSC_CONFIG_REGISTERS 8
  71. #define SMSC_SUPERIO_READ_INDEXED(index) ({ \
  72. outb((index), SMSC_INDEX_PORT_ADDR); \
  73. inb(SMSC_DATA_PORT_ADDR); })
  74. #define SMSC_SUPERIO_WRITE_INDEXED(val, index) ({ \
  75. outb((index), SMSC_INDEX_PORT_ADDR); \
  76. outb((val), SMSC_DATA_PORT_ADDR); })
  77. #define IDE1_PRIMARY_BASE 0x01f0
  78. #define IDE1_SECONDARY_BASE 0x03f6
  79. unsigned long smsc_superio_virt;
  80. int platform_int_priority[NR_INTC_IRQS] = {
  81. IR0, IR1, IR2, IR3, PCA, PCB, PCC, PCD, /* IRQ 0- 7 */
  82. RES, RES, RES, RES, SER, ERR, PW3, PW2, /* IRQ 8-15 */
  83. PW1, PW0, DM0, DM1, DM2, DM3, DAE, RES, /* IRQ 16-23 */
  84. RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 24-31 */
  85. TU0, TU1, TU2, TI2, ATI, PRI, CUI, ERI, /* IRQ 32-39 */
  86. RXI, BRI, TXI, RES, RES, RES, RES, RES, /* IRQ 40-47 */
  87. RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 48-55 */
  88. RES, RES, RES, RES, RES, RES, RES, ITI, /* IRQ 56-63 */
  89. };
  90. static int __init smsc_superio_setup(void)
  91. {
  92. unsigned char devid, devrev;
  93. smsc_superio_virt = (unsigned long)ioremap_nocache(SMSC_SUPERIO_BASE, 1024);
  94. if (!smsc_superio_virt) {
  95. panic("Unable to remap SMSC SuperIO\n");
  96. }
  97. /* Initially the chip is in run state */
  98. /* Put it into configuration state */
  99. outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
  100. outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
  101. /* Read device ID info */
  102. devid = SMSC_SUPERIO_READ_INDEXED(SMSC_DEVICE_ID_INDEX);
  103. devrev = SMSC_SUPERIO_READ_INDEXED(SMSC_DEVICE_REV_INDEX);
  104. printk("SMSC SuperIO devid %02x rev %02x\n", devid, devrev);
  105. /* Select the keyboard device */
  106. SMSC_SUPERIO_WRITE_INDEXED(SMSC_KEYBOARD_DEVICE, SMCS_LOGICAL_DEV_INDEX);
  107. /* enable it */
  108. SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
  109. /* Select the interrupts */
  110. /* On a PC keyboard is IRQ1, mouse is IRQ12 */
  111. SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_PRIMARY_INT_INDEX);
  112. SMSC_SUPERIO_WRITE_INDEXED(12, SMSC_SECONDARY_INT_INDEX);
  113. #ifdef CONFIG_IDE
  114. /*
  115. * Only IDE1 exists on the Cayman
  116. */
  117. /* Power it on */
  118. SMSC_SUPERIO_WRITE_INDEXED(1 << SMSC_IDE1_DEVICE, 0x22);
  119. SMSC_SUPERIO_WRITE_INDEXED(SMSC_IDE1_DEVICE, SMCS_LOGICAL_DEV_INDEX);
  120. SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
  121. SMSC_SUPERIO_WRITE_INDEXED(IDE1_PRIMARY_BASE >> 8,
  122. SMSC_PRIMARY_BASE_INDEX + 0);
  123. SMSC_SUPERIO_WRITE_INDEXED(IDE1_PRIMARY_BASE & 0xff,
  124. SMSC_PRIMARY_BASE_INDEX + 1);
  125. SMSC_SUPERIO_WRITE_INDEXED(IDE1_SECONDARY_BASE >> 8,
  126. SMSC_SECONDARY_BASE_INDEX + 0);
  127. SMSC_SUPERIO_WRITE_INDEXED(IDE1_SECONDARY_BASE & 0xff,
  128. SMSC_SECONDARY_BASE_INDEX + 1);
  129. SMSC_SUPERIO_WRITE_INDEXED(14, SMSC_PRIMARY_INT_INDEX);
  130. SMSC_SUPERIO_WRITE_INDEXED(SMSC_CONFIG_REGISTERS,
  131. SMCS_LOGICAL_DEV_INDEX);
  132. SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc2); /* GP42 = nIDE1_OE */
  133. SMSC_SUPERIO_WRITE_INDEXED(0x01, 0xc5); /* GP45 = IDE1_IRQ */
  134. SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc6); /* GP46 = nIOROP */
  135. SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc7); /* GP47 = nIOWOP */
  136. #endif
  137. /* Exit the configuration state */
  138. outb(SMSC_EXIT_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
  139. return 0;
  140. }
  141. device_initcall(smsc_superio_setup);
  142. static void __iomem *cayman_ioport_map(unsigned long port, unsigned int len)
  143. {
  144. if (port < 0x400) {
  145. extern unsigned long smsc_superio_virt;
  146. return (void __iomem *)((port << 2) | smsc_superio_virt);
  147. }
  148. return (void __iomem *)port;
  149. }
  150. extern void init_cayman_irq(void);
  151. static struct sh_machine_vector mv_cayman __initmv = {
  152. .mv_name = "Hitachi Cayman",
  153. .mv_ioport_map = cayman_ioport_map,
  154. .mv_init_irq = init_cayman_irq,
  155. };