sys_miata.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. * linux/arch/alpha/kernel/sys_miata.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996 Jay A Estabrook
  6. * Copyright (C) 1998, 1999, 2000 Richard Henderson
  7. *
  8. * Code supporting the MIATA (EV56+PYXIS).
  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 <asm/ptrace.h>
  18. #include <asm/dma.h>
  19. #include <asm/irq.h>
  20. #include <asm/mmu_context.h>
  21. #include <asm/io.h>
  22. #include <asm/pgtable.h>
  23. #include <asm/core_cia.h>
  24. #include <asm/tlbflush.h>
  25. #include "proto.h"
  26. #include "irq_impl.h"
  27. #include "pci_impl.h"
  28. #include "machvec_impl.h"
  29. static void
  30. miata_srm_device_interrupt(unsigned long vector)
  31. {
  32. int irq;
  33. irq = (vector - 0x800) >> 4;
  34. /*
  35. * I really hate to do this, but the MIATA SRM console ignores the
  36. * low 8 bits in the interrupt summary register, and reports the
  37. * vector 0x80 *lower* than I expected from the bit numbering in
  38. * the documentation.
  39. * This was done because the low 8 summary bits really aren't used
  40. * for reporting any interrupts (the PCI-ISA bridge, bit 7, isn't
  41. * used for this purpose, as PIC interrupts are delivered as the
  42. * vectors 0x800-0x8f0).
  43. * But I really don't want to change the fixup code for allocation
  44. * of IRQs, nor the alpha_irq_mask maintenance stuff, both of which
  45. * look nice and clean now.
  46. * So, here's this grotty hack... :-(
  47. */
  48. if (irq >= 16)
  49. irq = irq + 8;
  50. handle_irq(irq);
  51. }
  52. static void __init
  53. miata_init_irq(void)
  54. {
  55. if (alpha_using_srm)
  56. alpha_mv.device_interrupt = miata_srm_device_interrupt;
  57. #if 0
  58. /* These break on MiataGL so we'll try not to do it at all. */
  59. *(vulp)PYXIS_INT_HILO = 0x000000B2UL; mb(); /* ISA/NMI HI */
  60. *(vulp)PYXIS_RT_COUNT = 0UL; mb(); /* clear count */
  61. #endif
  62. init_i8259a_irqs();
  63. /* Not interested in the bogus interrupts (3,10), Fan Fault (0),
  64. NMI (1), or EIDE (9).
  65. We also disable the risers (4,5), since we don't know how to
  66. route the interrupts behind the bridge. */
  67. init_pyxis_irqs(0x63b0000);
  68. common_init_isa_dma();
  69. setup_irq(16+2, &halt_switch_irqaction); /* SRM only? */
  70. setup_irq(16+6, &timer_cascade_irqaction);
  71. }
  72. /*
  73. * PCI Fixup configuration.
  74. *
  75. * Summary @ PYXIS_INT_REQ:
  76. * Bit Meaning
  77. * 0 Fan Fault
  78. * 1 NMI
  79. * 2 Halt/Reset switch
  80. * 3 none
  81. * 4 CID0 (Riser ID)
  82. * 5 CID1 (Riser ID)
  83. * 6 Interval timer
  84. * 7 PCI-ISA Bridge
  85. * 8 Ethernet
  86. * 9 EIDE (deprecated, ISA 14/15 used)
  87. *10 none
  88. *11 USB
  89. *12 Interrupt Line A from slot 4
  90. *13 Interrupt Line B from slot 4
  91. *14 Interrupt Line C from slot 4
  92. *15 Interrupt Line D from slot 4
  93. *16 Interrupt Line A from slot 5
  94. *17 Interrupt line B from slot 5
  95. *18 Interrupt Line C from slot 5
  96. *19 Interrupt Line D from slot 5
  97. *20 Interrupt Line A from slot 1
  98. *21 Interrupt Line B from slot 1
  99. *22 Interrupt Line C from slot 1
  100. *23 Interrupt Line D from slot 1
  101. *24 Interrupt Line A from slot 2
  102. *25 Interrupt Line B from slot 2
  103. *26 Interrupt Line C from slot 2
  104. *27 Interrupt Line D from slot 2
  105. *27 Interrupt Line A from slot 3
  106. *29 Interrupt Line B from slot 3
  107. *30 Interrupt Line C from slot 3
  108. *31 Interrupt Line D from slot 3
  109. *
  110. * The device to slot mapping looks like:
  111. *
  112. * Slot Device
  113. * 3 DC21142 Ethernet
  114. * 4 EIDE CMD646
  115. * 5 none
  116. * 6 USB
  117. * 7 PCI-ISA bridge
  118. * 8 PCI-PCI Bridge (SBU Riser)
  119. * 9 none
  120. * 10 none
  121. * 11 PCI on board slot 4 (SBU Riser)
  122. * 12 PCI on board slot 5 (SBU Riser)
  123. *
  124. * These are behind the bridge, so I'm not sure what to do...
  125. *
  126. * 13 PCI on board slot 1 (SBU Riser)
  127. * 14 PCI on board slot 2 (SBU Riser)
  128. * 15 PCI on board slot 3 (SBU Riser)
  129. *
  130. *
  131. * This two layered interrupt approach means that we allocate IRQ 16 and
  132. * above for PCI interrupts. The IRQ relates to which bit the interrupt
  133. * comes in on. This makes interrupt processing much easier.
  134. */
  135. static int __init
  136. miata_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  137. {
  138. static char irq_tab[18][5] __initdata = {
  139. /*INT INTA INTB INTC INTD */
  140. {16+ 8, 16+ 8, 16+ 8, 16+ 8, 16+ 8}, /* IdSel 14, DC21142 */
  141. { -1, -1, -1, -1, -1}, /* IdSel 15, EIDE */
  142. { -1, -1, -1, -1, -1}, /* IdSel 16, none */
  143. { -1, -1, -1, -1, -1}, /* IdSel 17, none */
  144. { -1, -1, -1, -1, -1}, /* IdSel 18, PCI-ISA */
  145. { -1, -1, -1, -1, -1}, /* IdSel 19, PCI-PCI */
  146. { -1, -1, -1, -1, -1}, /* IdSel 20, none */
  147. { -1, -1, -1, -1, -1}, /* IdSel 21, none */
  148. {16+12, 16+12, 16+13, 16+14, 16+15}, /* IdSel 22, slot 4 */
  149. {16+16, 16+16, 16+17, 16+18, 16+19}, /* IdSel 23, slot 5 */
  150. /* the next 7 are actually on PCI bus 1, across the bridge */
  151. {16+11, 16+11, 16+11, 16+11, 16+11}, /* IdSel 24, QLISP/GL*/
  152. { -1, -1, -1, -1, -1}, /* IdSel 25, none */
  153. { -1, -1, -1, -1, -1}, /* IdSel 26, none */
  154. { -1, -1, -1, -1, -1}, /* IdSel 27, none */
  155. {16+20, 16+20, 16+21, 16+22, 16+23}, /* IdSel 28, slot 1 */
  156. {16+24, 16+24, 16+25, 16+26, 16+27}, /* IdSel 29, slot 2 */
  157. {16+28, 16+28, 16+29, 16+30, 16+31}, /* IdSel 30, slot 3 */
  158. /* This bridge is on the main bus of the later orig MIATA */
  159. { -1, -1, -1, -1, -1}, /* IdSel 31, PCI-PCI */
  160. };
  161. const long min_idsel = 3, max_idsel = 20, irqs_per_slot = 5;
  162. /* the USB function of the 82c693 has it's interrupt connected to
  163. the 2nd 8259 controller. So we have to check for it first. */
  164. if((slot == 7) && (PCI_FUNC(dev->devfn) == 3)) {
  165. u8 irq=0;
  166. struct pci_dev *pdev = pci_get_slot(dev->bus, dev->devfn & ~7);
  167. if(pdev == NULL || pci_read_config_byte(pdev, 0x40,&irq) != PCIBIOS_SUCCESSFUL) {
  168. pci_dev_put(pdev);
  169. return -1;
  170. }
  171. else {
  172. pci_dev_put(pdev);
  173. return irq;
  174. }
  175. }
  176. return COMMON_TABLE_LOOKUP;
  177. }
  178. static u8 __init
  179. miata_swizzle(struct pci_dev *dev, u8 *pinp)
  180. {
  181. int slot, pin = *pinp;
  182. if (dev->bus->number == 0) {
  183. slot = PCI_SLOT(dev->devfn);
  184. }
  185. /* Check for the built-in bridge. */
  186. else if ((PCI_SLOT(dev->bus->self->devfn) == 8) ||
  187. (PCI_SLOT(dev->bus->self->devfn) == 20)) {
  188. slot = PCI_SLOT(dev->devfn) + 9;
  189. }
  190. else
  191. {
  192. /* Must be a card-based bridge. */
  193. do {
  194. if ((PCI_SLOT(dev->bus->self->devfn) == 8) ||
  195. (PCI_SLOT(dev->bus->self->devfn) == 20)) {
  196. slot = PCI_SLOT(dev->devfn) + 9;
  197. break;
  198. }
  199. pin = pci_swizzle_interrupt_pin(dev, pin);
  200. /* Move up the chain of bridges. */
  201. dev = dev->bus->self;
  202. /* Slot of the next bridge. */
  203. slot = PCI_SLOT(dev->devfn);
  204. } while (dev->bus->self);
  205. }
  206. *pinp = pin;
  207. return slot;
  208. }
  209. static void __init
  210. miata_init_pci(void)
  211. {
  212. cia_init_pci();
  213. SMC669_Init(0); /* it might be a GL (fails harmlessly if not) */
  214. es1888_init();
  215. }
  216. static void
  217. miata_kill_arch(int mode)
  218. {
  219. cia_kill_arch(mode);
  220. #ifndef ALPHA_RESTORE_SRM_SETUP
  221. switch(mode) {
  222. case LINUX_REBOOT_CMD_RESTART:
  223. /* Who said DEC engineers have no sense of humor? ;-) */
  224. if (alpha_using_srm) {
  225. *(vuip) PYXIS_RESET = 0x0000dead;
  226. mb();
  227. }
  228. break;
  229. case LINUX_REBOOT_CMD_HALT:
  230. break;
  231. case LINUX_REBOOT_CMD_POWER_OFF:
  232. break;
  233. }
  234. halt();
  235. #endif
  236. }
  237. /*
  238. * The System Vector
  239. */
  240. struct alpha_machine_vector miata_mv __initmv = {
  241. .vector_name = "Miata",
  242. DO_EV5_MMU,
  243. DO_DEFAULT_RTC,
  244. DO_PYXIS_IO,
  245. .machine_check = cia_machine_check,
  246. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  247. .min_io_address = DEFAULT_IO_BASE,
  248. .min_mem_address = DEFAULT_MEM_BASE,
  249. .pci_dac_offset = PYXIS_DAC_OFFSET,
  250. .nr_irqs = 48,
  251. .device_interrupt = pyxis_device_interrupt,
  252. .init_arch = pyxis_init_arch,
  253. .init_irq = miata_init_irq,
  254. .init_rtc = common_init_rtc,
  255. .init_pci = miata_init_pci,
  256. .kill_arch = miata_kill_arch,
  257. .pci_map_irq = miata_map_irq,
  258. .pci_swizzle = miata_swizzle,
  259. };
  260. ALIAS_MV(miata)