sys_alcor.c 7.8 KB

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