sys_miata.c 8.0 KB

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