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