sys_alcor.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. /*
  2. * linux/arch/alpha/kernel/sys_alcor.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996 Jay A Estabrook
  6. * Copyright (C) 1998, 1999 Richard Henderson
  7. *
  8. * Code supporting the ALCOR and XLT (XL-300/366/433).
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/types.h>
  12. #include <linux/mm.h>
  13. #include <linux/sched.h>
  14. #include <linux/pci.h>
  15. #include <linux/init.h>
  16. #include <linux/reboot.h>
  17. #include <linux/bitops.h>
  18. #include <asm/ptrace.h>
  19. #include <asm/system.h>
  20. #include <asm/io.h>
  21. #include <asm/dma.h>
  22. #include <asm/mmu_context.h>
  23. #include <asm/irq.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/core_cia.h>
  26. #include <asm/tlbflush.h>
  27. #include "proto.h"
  28. #include "irq_impl.h"
  29. #include "pci_impl.h"
  30. #include "machvec_impl.h"
  31. /* Note mask bit is true for ENABLED irqs. */
  32. static unsigned long cached_irq_mask;
  33. static inline void
  34. alcor_update_irq_hw(unsigned long mask)
  35. {
  36. *(vuip)GRU_INT_MASK = mask;
  37. mb();
  38. }
  39. static inline void
  40. alcor_enable_irq(struct irq_data *d)
  41. {
  42. alcor_update_irq_hw(cached_irq_mask |= 1UL << (d->irq - 16));
  43. }
  44. static void
  45. alcor_disable_irq(struct irq_data *d)
  46. {
  47. alcor_update_irq_hw(cached_irq_mask &= ~(1UL << (d->irq - 16)));
  48. }
  49. static void
  50. alcor_mask_and_ack_irq(struct irq_data *d)
  51. {
  52. alcor_disable_irq(d);
  53. /* On ALCOR/XLT, need to dismiss interrupt via GRU. */
  54. *(vuip)GRU_INT_CLEAR = 1 << (d->irq - 16); mb();
  55. *(vuip)GRU_INT_CLEAR = 0; mb();
  56. }
  57. static void
  58. alcor_isa_mask_and_ack_irq(struct irq_data *d)
  59. {
  60. i8259a_mask_and_ack_irq(d);
  61. /* On ALCOR/XLT, need to dismiss interrupt via GRU. */
  62. *(vuip)GRU_INT_CLEAR = 0x80000000; mb();
  63. *(vuip)GRU_INT_CLEAR = 0; mb();
  64. }
  65. static struct irq_chip alcor_irq_type = {
  66. .name = "ALCOR",
  67. .irq_unmask = alcor_enable_irq,
  68. .irq_mask = alcor_disable_irq,
  69. .irq_mask_ack = alcor_mask_and_ack_irq,
  70. };
  71. static void
  72. alcor_device_interrupt(unsigned long vector)
  73. {
  74. unsigned long pld;
  75. unsigned int i;
  76. /* Read the interrupt summary register of the GRU */
  77. pld = (*(vuip)GRU_INT_REQ) & GRU_INT_REQ_BITS;
  78. /*
  79. * Now for every possible bit set, work through them and call
  80. * the appropriate interrupt handler.
  81. */
  82. while (pld) {
  83. i = ffz(~pld);
  84. pld &= pld - 1; /* clear least bit set */
  85. if (i == 31) {
  86. isa_device_interrupt(vector);
  87. } else {
  88. handle_irq(16 + i);
  89. }
  90. }
  91. }
  92. static void __init
  93. alcor_init_irq(void)
  94. {
  95. long i;
  96. if (alpha_using_srm)
  97. alpha_mv.device_interrupt = srm_device_interrupt;
  98. *(vuip)GRU_INT_MASK = 0; mb(); /* all disabled */
  99. *(vuip)GRU_INT_EDGE = 0; mb(); /* all are level */
  100. *(vuip)GRU_INT_HILO = 0x80000000U; mb(); /* ISA only HI */
  101. *(vuip)GRU_INT_CLEAR = 0; mb(); /* all clear */
  102. for (i = 16; i < 48; ++i) {
  103. /* On Alcor, at least, lines 20..30 are not connected
  104. and can generate spurious interrupts if we turn them
  105. on while IRQ probing. */
  106. if (i >= 16+20 && i <= 16+30)
  107. continue;
  108. irq_set_chip_and_handler(i, &alcor_irq_type, handle_level_irq);
  109. irq_set_status_flags(i, IRQ_LEVEL);
  110. }
  111. i8259a_irq_type.irq_ack = alcor_isa_mask_and_ack_irq;
  112. init_i8259a_irqs();
  113. common_init_isa_dma();
  114. setup_irq(16+31, &isa_cascade_irqaction);
  115. }
  116. /*
  117. * PCI Fixup configuration.
  118. *
  119. * Summary @ GRU_INT_REQ:
  120. * Bit Meaning
  121. * 0 Interrupt Line A from slot 2
  122. * 1 Interrupt Line B from slot 2
  123. * 2 Interrupt Line C from slot 2
  124. * 3 Interrupt Line D from slot 2
  125. * 4 Interrupt Line A from slot 1
  126. * 5 Interrupt line B from slot 1
  127. * 6 Interrupt Line C from slot 1
  128. * 7 Interrupt Line D from slot 1
  129. * 8 Interrupt Line A from slot 0
  130. * 9 Interrupt Line B from slot 0
  131. *10 Interrupt Line C from slot 0
  132. *11 Interrupt Line D from slot 0
  133. *12 Interrupt Line A from slot 4
  134. *13 Interrupt Line B from slot 4
  135. *14 Interrupt Line C from slot 4
  136. *15 Interrupt Line D from slot 4
  137. *16 Interrupt Line D from slot 3
  138. *17 Interrupt Line D from slot 3
  139. *18 Interrupt Line D from slot 3
  140. *19 Interrupt Line D from slot 3
  141. *20-30 Reserved
  142. *31 EISA interrupt
  143. *
  144. * The device to slot mapping looks like:
  145. *
  146. * Slot Device
  147. * 6 built-in TULIP (XLT only)
  148. * 7 PCI on board slot 0
  149. * 8 PCI on board slot 3
  150. * 9 PCI on board slot 4
  151. * 10 PCEB (PCI-EISA bridge)
  152. * 11 PCI on board slot 2
  153. * 12 PCI on board slot 1
  154. *
  155. *
  156. * This two layered interrupt approach means that we allocate IRQ 16 and
  157. * above for PCI interrupts. The IRQ relates to which bit the interrupt
  158. * comes in on. This makes interrupt processing much easier.
  159. */
  160. static int __init
  161. alcor_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  162. {
  163. static char irq_tab[7][5] __initdata = {
  164. /*INT INTA INTB INTC INTD */
  165. /* note: IDSEL 17 is XLT only */
  166. {16+13, 16+13, 16+13, 16+13, 16+13}, /* IdSel 17, TULIP */
  167. { 16+8, 16+8, 16+9, 16+10, 16+11}, /* IdSel 18, slot 0 */
  168. {16+16, 16+16, 16+17, 16+18, 16+19}, /* IdSel 19, slot 3 */
  169. {16+12, 16+12, 16+13, 16+14, 16+15}, /* IdSel 20, slot 4 */
  170. { -1, -1, -1, -1, -1}, /* IdSel 21, PCEB */
  171. { 16+0, 16+0, 16+1, 16+2, 16+3}, /* IdSel 22, slot 2 */
  172. { 16+4, 16+4, 16+5, 16+6, 16+7}, /* IdSel 23, slot 1 */
  173. };
  174. const long min_idsel = 6, max_idsel = 12, irqs_per_slot = 5;
  175. return COMMON_TABLE_LOOKUP;
  176. }
  177. static void
  178. alcor_kill_arch(int mode)
  179. {
  180. cia_kill_arch(mode);
  181. #ifndef ALPHA_RESTORE_SRM_SETUP
  182. switch(mode) {
  183. case LINUX_REBOOT_CMD_RESTART:
  184. /* Who said DEC engineer's have no sense of humor? ;-) */
  185. if (alpha_using_srm) {
  186. *(vuip) GRU_RESET = 0x0000dead;
  187. mb();
  188. }
  189. break;
  190. case LINUX_REBOOT_CMD_HALT:
  191. break;
  192. case LINUX_REBOOT_CMD_POWER_OFF:
  193. break;
  194. }
  195. halt();
  196. #endif
  197. }
  198. static void __init
  199. alcor_init_pci(void)
  200. {
  201. struct pci_dev *dev;
  202. cia_init_pci();
  203. /*
  204. * Now we can look to see if we are really running on an XLT-type
  205. * motherboard, by looking for a 21040 TULIP in slot 6, which is
  206. * built into XLT and BRET/MAVERICK, but not available on ALCOR.
  207. */
  208. dev = pci_get_device(PCI_VENDOR_ID_DEC,
  209. PCI_DEVICE_ID_DEC_TULIP,
  210. NULL);
  211. if (dev && dev->devfn == PCI_DEVFN(6,0)) {
  212. alpha_mv.sys.cia.gru_int_req_bits = XLT_GRU_INT_REQ_BITS;
  213. printk(KERN_INFO "%s: Detected AS500 or XLT motherboard.\n",
  214. __func__);
  215. }
  216. pci_dev_put(dev);
  217. }
  218. /*
  219. * The System Vectors
  220. */
  221. struct alpha_machine_vector alcor_mv __initmv = {
  222. .vector_name = "Alcor",
  223. DO_EV5_MMU,
  224. DO_DEFAULT_RTC,
  225. DO_CIA_IO,
  226. .machine_check = cia_machine_check,
  227. .max_isa_dma_address = ALPHA_ALCOR_MAX_ISA_DMA_ADDRESS,
  228. .min_io_address = EISA_DEFAULT_IO_BASE,
  229. .min_mem_address = CIA_DEFAULT_MEM_BASE,
  230. .nr_irqs = 48,
  231. .device_interrupt = alcor_device_interrupt,
  232. .init_arch = cia_init_arch,
  233. .init_irq = alcor_init_irq,
  234. .init_rtc = common_init_rtc,
  235. .init_pci = alcor_init_pci,
  236. .kill_arch = alcor_kill_arch,
  237. .pci_map_irq = alcor_map_irq,
  238. .pci_swizzle = common_swizzle,
  239. .sys = { .cia = {
  240. .gru_int_req_bits = ALCOR_GRU_INT_REQ_BITS
  241. }}
  242. };
  243. ALIAS_MV(alcor)
  244. struct alpha_machine_vector xlt_mv __initmv = {
  245. .vector_name = "XLT",
  246. DO_EV5_MMU,
  247. DO_DEFAULT_RTC,
  248. DO_CIA_IO,
  249. .machine_check = cia_machine_check,
  250. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  251. .min_io_address = EISA_DEFAULT_IO_BASE,
  252. .min_mem_address = CIA_DEFAULT_MEM_BASE,
  253. .nr_irqs = 48,
  254. .device_interrupt = alcor_device_interrupt,
  255. .init_arch = cia_init_arch,
  256. .init_irq = alcor_init_irq,
  257. .init_rtc = common_init_rtc,
  258. .init_pci = alcor_init_pci,
  259. .kill_arch = alcor_kill_arch,
  260. .pci_map_irq = alcor_map_irq,
  261. .pci_swizzle = common_swizzle,
  262. .sys = { .cia = {
  263. .gru_int_req_bits = XLT_GRU_INT_REQ_BITS
  264. }}
  265. };
  266. /* No alpha_mv alias for XLT, since we compile it in unconditionally
  267. with ALCOR; setup_arch knows how to cope. */