sys_alcor.c 7.9 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/config.h>
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/mm.h>
  14. #include <linux/sched.h>
  15. #include <linux/pci.h>
  16. #include <linux/init.h>
  17. #include <linux/reboot.h>
  18. #include <linux/bitops.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/system.h>
  21. #include <asm/io.h>
  22. #include <asm/dma.h>
  23. #include <asm/mmu_context.h>
  24. #include <asm/irq.h>
  25. #include <asm/pgtable.h>
  26. #include <asm/core_cia.h>
  27. #include <asm/tlbflush.h>
  28. #include "proto.h"
  29. #include "irq_impl.h"
  30. #include "pci_impl.h"
  31. #include "machvec_impl.h"
  32. /* Note mask bit is true for ENABLED irqs. */
  33. static unsigned long cached_irq_mask;
  34. static inline void
  35. alcor_update_irq_hw(unsigned long mask)
  36. {
  37. *(vuip)GRU_INT_MASK = mask;
  38. mb();
  39. }
  40. static inline void
  41. alcor_enable_irq(unsigned int irq)
  42. {
  43. alcor_update_irq_hw(cached_irq_mask |= 1UL << (irq - 16));
  44. }
  45. static void
  46. alcor_disable_irq(unsigned int irq)
  47. {
  48. alcor_update_irq_hw(cached_irq_mask &= ~(1UL << (irq - 16)));
  49. }
  50. static void
  51. alcor_mask_and_ack_irq(unsigned int irq)
  52. {
  53. alcor_disable_irq(irq);
  54. /* On ALCOR/XLT, need to dismiss interrupt via GRU. */
  55. *(vuip)GRU_INT_CLEAR = 1 << (irq - 16); mb();
  56. *(vuip)GRU_INT_CLEAR = 0; mb();
  57. }
  58. static unsigned int
  59. alcor_startup_irq(unsigned int irq)
  60. {
  61. alcor_enable_irq(irq);
  62. return 0;
  63. }
  64. static void
  65. alcor_isa_mask_and_ack_irq(unsigned int irq)
  66. {
  67. i8259a_mask_and_ack_irq(irq);
  68. /* On ALCOR/XLT, need to dismiss interrupt via GRU. */
  69. *(vuip)GRU_INT_CLEAR = 0x80000000; mb();
  70. *(vuip)GRU_INT_CLEAR = 0; mb();
  71. }
  72. static void
  73. alcor_end_irq(unsigned int irq)
  74. {
  75. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  76. alcor_enable_irq(irq);
  77. }
  78. static struct hw_interrupt_type alcor_irq_type = {
  79. .typename = "ALCOR",
  80. .startup = alcor_startup_irq,
  81. .shutdown = alcor_disable_irq,
  82. .enable = alcor_enable_irq,
  83. .disable = alcor_disable_irq,
  84. .ack = alcor_mask_and_ack_irq,
  85. .end = alcor_end_irq,
  86. };
  87. static void
  88. alcor_device_interrupt(unsigned long vector, struct pt_regs *regs)
  89. {
  90. unsigned long pld;
  91. unsigned int i;
  92. /* Read the interrupt summary register of the GRU */
  93. pld = (*(vuip)GRU_INT_REQ) & GRU_INT_REQ_BITS;
  94. /*
  95. * Now for every possible bit set, work through them and call
  96. * the appropriate interrupt handler.
  97. */
  98. while (pld) {
  99. i = ffz(~pld);
  100. pld &= pld - 1; /* clear least bit set */
  101. if (i == 31) {
  102. isa_device_interrupt(vector, regs);
  103. } else {
  104. handle_irq(16 + i, regs);
  105. }
  106. }
  107. }
  108. static void __init
  109. alcor_init_irq(void)
  110. {
  111. long i;
  112. if (alpha_using_srm)
  113. alpha_mv.device_interrupt = srm_device_interrupt;
  114. *(vuip)GRU_INT_MASK = 0; mb(); /* all disabled */
  115. *(vuip)GRU_INT_EDGE = 0; mb(); /* all are level */
  116. *(vuip)GRU_INT_HILO = 0x80000000U; mb(); /* ISA only HI */
  117. *(vuip)GRU_INT_CLEAR = 0; mb(); /* all clear */
  118. for (i = 16; i < 48; ++i) {
  119. /* On Alcor, at least, lines 20..30 are not connected
  120. and can generate spurrious interrupts if we turn them
  121. on while IRQ probing. */
  122. if (i >= 16+20 && i <= 16+30)
  123. continue;
  124. irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
  125. irq_desc[i].handler = &alcor_irq_type;
  126. }
  127. i8259a_irq_type.ack = alcor_isa_mask_and_ack_irq;
  128. init_i8259a_irqs();
  129. common_init_isa_dma();
  130. setup_irq(16+31, &isa_cascade_irqaction);
  131. }
  132. /*
  133. * PCI Fixup configuration.
  134. *
  135. * Summary @ GRU_INT_REQ:
  136. * Bit Meaning
  137. * 0 Interrupt Line A from slot 2
  138. * 1 Interrupt Line B from slot 2
  139. * 2 Interrupt Line C from slot 2
  140. * 3 Interrupt Line D from slot 2
  141. * 4 Interrupt Line A from slot 1
  142. * 5 Interrupt line B from slot 1
  143. * 6 Interrupt Line C from slot 1
  144. * 7 Interrupt Line D from slot 1
  145. * 8 Interrupt Line A from slot 0
  146. * 9 Interrupt Line B from slot 0
  147. *10 Interrupt Line C from slot 0
  148. *11 Interrupt Line D from slot 0
  149. *12 Interrupt Line A from slot 4
  150. *13 Interrupt Line B from slot 4
  151. *14 Interrupt Line C from slot 4
  152. *15 Interrupt Line D from slot 4
  153. *16 Interrupt Line D from slot 3
  154. *17 Interrupt Line D from slot 3
  155. *18 Interrupt Line D from slot 3
  156. *19 Interrupt Line D from slot 3
  157. *20-30 Reserved
  158. *31 EISA interrupt
  159. *
  160. * The device to slot mapping looks like:
  161. *
  162. * Slot Device
  163. * 6 built-in TULIP (XLT only)
  164. * 7 PCI on board slot 0
  165. * 8 PCI on board slot 3
  166. * 9 PCI on board slot 4
  167. * 10 PCEB (PCI-EISA bridge)
  168. * 11 PCI on board slot 2
  169. * 12 PCI on board slot 1
  170. *
  171. *
  172. * This two layered interrupt approach means that we allocate IRQ 16 and
  173. * above for PCI interrupts. The IRQ relates to which bit the interrupt
  174. * comes in on. This makes interrupt processing much easier.
  175. */
  176. static int __init
  177. alcor_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  178. {
  179. static char irq_tab[7][5] __initdata = {
  180. /*INT INTA INTB INTC INTD */
  181. /* note: IDSEL 17 is XLT only */
  182. {16+13, 16+13, 16+13, 16+13, 16+13}, /* IdSel 17, TULIP */
  183. { 16+8, 16+8, 16+9, 16+10, 16+11}, /* IdSel 18, slot 0 */
  184. {16+16, 16+16, 16+17, 16+18, 16+19}, /* IdSel 19, slot 3 */
  185. {16+12, 16+12, 16+13, 16+14, 16+15}, /* IdSel 20, slot 4 */
  186. { -1, -1, -1, -1, -1}, /* IdSel 21, PCEB */
  187. { 16+0, 16+0, 16+1, 16+2, 16+3}, /* IdSel 22, slot 2 */
  188. { 16+4, 16+4, 16+5, 16+6, 16+7}, /* IdSel 23, slot 1 */
  189. };
  190. const long min_idsel = 6, max_idsel = 12, irqs_per_slot = 5;
  191. return COMMON_TABLE_LOOKUP;
  192. }
  193. static void
  194. alcor_kill_arch(int mode)
  195. {
  196. cia_kill_arch(mode);
  197. #ifndef ALPHA_RESTORE_SRM_SETUP
  198. switch(mode) {
  199. case LINUX_REBOOT_CMD_RESTART:
  200. /* Who said DEC engineer's have no sense of humor? ;-) */
  201. if (alpha_using_srm) {
  202. *(vuip) GRU_RESET = 0x0000dead;
  203. mb();
  204. }
  205. break;
  206. case LINUX_REBOOT_CMD_HALT:
  207. break;
  208. case LINUX_REBOOT_CMD_POWER_OFF:
  209. break;
  210. }
  211. halt();
  212. #endif
  213. }
  214. static void __init
  215. alcor_init_pci(void)
  216. {
  217. struct pci_dev *dev;
  218. cia_init_pci();
  219. /*
  220. * Now we can look to see if we are really running on an XLT-type
  221. * motherboard, by looking for a 21040 TULIP in slot 6, which is
  222. * built into XLT and BRET/MAVERICK, but not available on ALCOR.
  223. */
  224. dev = pci_find_device(PCI_VENDOR_ID_DEC,
  225. PCI_DEVICE_ID_DEC_TULIP,
  226. NULL);
  227. if (dev && dev->devfn == PCI_DEVFN(6,0)) {
  228. alpha_mv.sys.cia.gru_int_req_bits = XLT_GRU_INT_REQ_BITS;
  229. printk(KERN_INFO "%s: Detected AS500 or XLT motherboard.\n",
  230. __FUNCTION__);
  231. }
  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. */