sys_miata.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/alpha/kernel/sys_miata.c
  4. *
  5. * Copyright (C) 1995 David A Rusling
  6. * Copyright (C) 1996 Jay A Estabrook
  7. * Copyright (C) 1998, 1999, 2000 Richard Henderson
  8. *
  9. * Code supporting the MIATA (EV56+PYXIS).
  10. */
  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 <asm/ptrace.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/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. if (request_irq(16 + 2, no_action, 0, "halt-switch", NULL))
  70. pr_err("Failed to register halt-switch interrupt\n");
  71. if (request_irq(16 + 6, no_action, 0, "timer-cascade", NULL))
  72. pr_err("Failed to register timer-cascade interrupt\n");
  73. }
  74. /*
  75. * PCI Fixup configuration.
  76. *
  77. * Summary @ PYXIS_INT_REQ:
  78. * Bit Meaning
  79. * 0 Fan Fault
  80. * 1 NMI
  81. * 2 Halt/Reset switch
  82. * 3 none
  83. * 4 CID0 (Riser ID)
  84. * 5 CID1 (Riser ID)
  85. * 6 Interval timer
  86. * 7 PCI-ISA Bridge
  87. * 8 Ethernet
  88. * 9 EIDE (deprecated, ISA 14/15 used)
  89. *10 none
  90. *11 USB
  91. *12 Interrupt Line A from slot 4
  92. *13 Interrupt Line B from slot 4
  93. *14 Interrupt Line C from slot 4
  94. *15 Interrupt Line D from slot 4
  95. *16 Interrupt Line A from slot 5
  96. *17 Interrupt line B from slot 5
  97. *18 Interrupt Line C from slot 5
  98. *19 Interrupt Line D from slot 5
  99. *20 Interrupt Line A from slot 1
  100. *21 Interrupt Line B from slot 1
  101. *22 Interrupt Line C from slot 1
  102. *23 Interrupt Line D from slot 1
  103. *24 Interrupt Line A from slot 2
  104. *25 Interrupt Line B from slot 2
  105. *26 Interrupt Line C from slot 2
  106. *27 Interrupt Line D from slot 2
  107. *27 Interrupt Line A from slot 3
  108. *29 Interrupt Line B from slot 3
  109. *30 Interrupt Line C from slot 3
  110. *31 Interrupt Line D from slot 3
  111. *
  112. * The device to slot mapping looks like:
  113. *
  114. * Slot Device
  115. * 3 DC21142 Ethernet
  116. * 4 EIDE CMD646
  117. * 5 none
  118. * 6 USB
  119. * 7 PCI-ISA bridge
  120. * 8 PCI-PCI Bridge (SBU Riser)
  121. * 9 none
  122. * 10 none
  123. * 11 PCI on board slot 4 (SBU Riser)
  124. * 12 PCI on board slot 5 (SBU Riser)
  125. *
  126. * These are behind the bridge, so I'm not sure what to do...
  127. *
  128. * 13 PCI on board slot 1 (SBU Riser)
  129. * 14 PCI on board slot 2 (SBU Riser)
  130. * 15 PCI on board slot 3 (SBU Riser)
  131. *
  132. *
  133. * This two layered interrupt approach means that we allocate IRQ 16 and
  134. * above for PCI interrupts. The IRQ relates to which bit the interrupt
  135. * comes in on. This makes interrupt processing much easier.
  136. */
  137. static int
  138. miata_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  139. {
  140. static char irq_tab[18][5] = {
  141. /*INT INTA INTB INTC INTD */
  142. {16+ 8, 16+ 8, 16+ 8, 16+ 8, 16+ 8}, /* IdSel 14, DC21142 */
  143. { -1, -1, -1, -1, -1}, /* IdSel 15, EIDE */
  144. { -1, -1, -1, -1, -1}, /* IdSel 16, none */
  145. { -1, -1, -1, -1, -1}, /* IdSel 17, none */
  146. { -1, -1, -1, -1, -1}, /* IdSel 18, PCI-ISA */
  147. { -1, -1, -1, -1, -1}, /* IdSel 19, PCI-PCI */
  148. { -1, -1, -1, -1, -1}, /* IdSel 20, none */
  149. { -1, -1, -1, -1, -1}, /* IdSel 21, none */
  150. {16+12, 16+12, 16+13, 16+14, 16+15}, /* IdSel 22, slot 4 */
  151. {16+16, 16+16, 16+17, 16+18, 16+19}, /* IdSel 23, slot 5 */
  152. /* the next 7 are actually on PCI bus 1, across the bridge */
  153. {16+11, 16+11, 16+11, 16+11, 16+11}, /* IdSel 24, QLISP/GL*/
  154. { -1, -1, -1, -1, -1}, /* IdSel 25, none */
  155. { -1, -1, -1, -1, -1}, /* IdSel 26, none */
  156. { -1, -1, -1, -1, -1}, /* IdSel 27, none */
  157. {16+20, 16+20, 16+21, 16+22, 16+23}, /* IdSel 28, slot 1 */
  158. {16+24, 16+24, 16+25, 16+26, 16+27}, /* IdSel 29, slot 2 */
  159. {16+28, 16+28, 16+29, 16+30, 16+31}, /* IdSel 30, slot 3 */
  160. /* This bridge is on the main bus of the later orig MIATA */
  161. { -1, -1, -1, -1, -1}, /* IdSel 31, PCI-PCI */
  162. };
  163. const long min_idsel = 3, max_idsel = 20, irqs_per_slot = 5;
  164. /* the USB function of the 82c693 has it's interrupt connected to
  165. the 2nd 8259 controller. So we have to check for it first. */
  166. if((slot == 7) && (PCI_FUNC(dev->devfn) == 3)) {
  167. u8 irq=0;
  168. struct pci_dev *pdev = pci_get_slot(dev->bus, dev->devfn & ~7);
  169. if(pdev == NULL || pci_read_config_byte(pdev, 0x40,&irq) != PCIBIOS_SUCCESSFUL) {
  170. pci_dev_put(pdev);
  171. return -1;
  172. }
  173. else {
  174. pci_dev_put(pdev);
  175. return irq;
  176. }
  177. }
  178. return COMMON_TABLE_LOOKUP;
  179. }
  180. static u8
  181. miata_swizzle(struct pci_dev *dev, u8 *pinp)
  182. {
  183. int slot, pin = *pinp;
  184. if (dev->bus->number == 0) {
  185. slot = PCI_SLOT(dev->devfn);
  186. }
  187. /* Check for the built-in bridge. */
  188. else if ((PCI_SLOT(dev->bus->self->devfn) == 8) ||
  189. (PCI_SLOT(dev->bus->self->devfn) == 20)) {
  190. slot = PCI_SLOT(dev->devfn) + 9;
  191. }
  192. else
  193. {
  194. /* Must be a card-based bridge. */
  195. do {
  196. if ((PCI_SLOT(dev->bus->self->devfn) == 8) ||
  197. (PCI_SLOT(dev->bus->self->devfn) == 20)) {
  198. slot = PCI_SLOT(dev->devfn) + 9;
  199. break;
  200. }
  201. pin = pci_swizzle_interrupt_pin(dev, pin);
  202. /* Move up the chain of bridges. */
  203. dev = dev->bus->self;
  204. /* Slot of the next bridge. */
  205. slot = PCI_SLOT(dev->devfn);
  206. } while (dev->bus->self);
  207. }
  208. *pinp = pin;
  209. return slot;
  210. }
  211. static void __init
  212. miata_init_pci(void)
  213. {
  214. cia_init_pci();
  215. SMC669_Init(0); /* it might be a GL (fails harmlessly if not) */
  216. es1888_init();
  217. }
  218. static void
  219. miata_kill_arch(int mode)
  220. {
  221. cia_kill_arch(mode);
  222. #ifndef ALPHA_RESTORE_SRM_SETUP
  223. switch(mode) {
  224. case LINUX_REBOOT_CMD_RESTART:
  225. /* Who said DEC engineers have no sense of humor? ;-) */
  226. if (alpha_using_srm) {
  227. *(vuip) PYXIS_RESET = 0x0000dead;
  228. mb();
  229. }
  230. break;
  231. case LINUX_REBOOT_CMD_HALT:
  232. break;
  233. case LINUX_REBOOT_CMD_POWER_OFF:
  234. break;
  235. }
  236. halt();
  237. #endif
  238. }
  239. /*
  240. * The System Vector
  241. */
  242. struct alpha_machine_vector miata_mv __initmv = {
  243. .vector_name = "Miata",
  244. DO_EV5_MMU,
  245. DO_DEFAULT_RTC,
  246. DO_PYXIS_IO,
  247. .machine_check = cia_machine_check,
  248. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  249. .min_io_address = DEFAULT_IO_BASE,
  250. .min_mem_address = DEFAULT_MEM_BASE,
  251. .pci_dac_offset = PYXIS_DAC_OFFSET,
  252. .nr_irqs = 48,
  253. .device_interrupt = pyxis_device_interrupt,
  254. .init_arch = pyxis_init_arch,
  255. .init_irq = miata_init_irq,
  256. .init_rtc = common_init_rtc,
  257. .init_pci = miata_init_pci,
  258. .kill_arch = miata_kill_arch,
  259. .pci_map_irq = miata_map_irq,
  260. .pci_swizzle = miata_swizzle,
  261. };
  262. ALIAS_MV(miata)