fixup-sni.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * SNI specific PCI support for RM200/RM300.
  7. *
  8. * Copyright (C) 1997 - 2000, 2003, 04 Ralf Baechle (ralf@linux-mips.org)
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/pci.h>
  13. #include <asm/mipsregs.h>
  14. #include <asm/sni.h>
  15. #include <irq.h>
  16. /*
  17. * PCIMT Shortcuts ...
  18. */
  19. #define SCSI PCIMT_IRQ_SCSI
  20. #define ETH PCIMT_IRQ_ETHERNET
  21. #define INTA PCIMT_IRQ_INTA
  22. #define INTB PCIMT_IRQ_INTB
  23. #define INTC PCIMT_IRQ_INTC
  24. #define INTD PCIMT_IRQ_INTD
  25. /*
  26. * Device 0: PCI EISA Bridge (directly routed)
  27. * Device 1: NCR53c810 SCSI (directly routed)
  28. * Device 2: PCnet32 Ethernet (directly routed)
  29. * Device 3: VGA (routed to INTB)
  30. * Device 4: Unused
  31. * Device 5: Slot 2
  32. * Device 6: Slot 3
  33. * Device 7: Slot 4
  34. *
  35. * Documentation says the VGA is device 5 and device 3 is unused but that
  36. * seem to be a documentation error. At least on my RM200C the Cirrus
  37. * Logic CL-GD5434 VGA is device 3.
  38. */
  39. static char irq_tab_rm200[8][5] __initdata = {
  40. /* INTA INTB INTC INTD */
  41. { 0, 0, 0, 0, 0 }, /* EISA bridge */
  42. { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
  43. { ETH, ETH, ETH, ETH, ETH }, /* Ethernet */
  44. { INTB, INTB, INTB, INTB, INTB }, /* VGA */
  45. { 0, 0, 0, 0, 0 }, /* Unused */
  46. { 0, INTB, INTC, INTD, INTA }, /* Slot 2 */
  47. { 0, INTC, INTD, INTA, INTB }, /* Slot 3 */
  48. { 0, INTD, INTA, INTB, INTC }, /* Slot 4 */
  49. };
  50. /*
  51. * In Revision D of the RM300 Device 2 has become a normal purpose Slot 1
  52. *
  53. * The VGA card is optional for RM300 systems.
  54. */
  55. static char irq_tab_rm300d[8][5] __initdata = {
  56. /* INTA INTB INTC INTD */
  57. { 0, 0, 0, 0, 0 }, /* EISA bridge */
  58. { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
  59. { 0, INTC, INTD, INTA, INTB }, /* Slot 1 */
  60. { INTB, INTB, INTB, INTB, INTB }, /* VGA */
  61. { 0, 0, 0, 0, 0 }, /* Unused */
  62. { 0, INTB, INTC, INTD, INTA }, /* Slot 2 */
  63. { 0, INTC, INTD, INTA, INTB }, /* Slot 3 */
  64. { 0, INTD, INTA, INTB, INTC }, /* Slot 4 */
  65. };
  66. static char irq_tab_rm300e[5][5] __initdata = {
  67. /* INTA INTB INTC INTD */
  68. { 0, 0, 0, 0, 0 }, /* HOST bridge */
  69. { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
  70. { 0, INTC, INTD, INTA, INTB }, /* Bridge/i960 */
  71. { 0, INTD, INTA, INTB, INTC }, /* Slot 1 */
  72. { 0, INTA, INTB, INTC, INTD }, /* Slot 2 */
  73. };
  74. #undef SCSI
  75. #undef ETH
  76. #undef INTA
  77. #undef INTB
  78. #undef INTC
  79. #undef INTD
  80. /*
  81. * PCIT Shortcuts ...
  82. */
  83. #define SCSI0 PCIT_IRQ_SCSI0
  84. #define SCSI1 PCIT_IRQ_SCSI1
  85. #define ETH PCIT_IRQ_ETHERNET
  86. #define INTA PCIT_IRQ_INTA
  87. #define INTB PCIT_IRQ_INTB
  88. #define INTC PCIT_IRQ_INTC
  89. #define INTD PCIT_IRQ_INTD
  90. static char irq_tab_pcit[13][5] __initdata = {
  91. /* INTA INTB INTC INTD */
  92. { 0, 0, 0, 0, 0 }, /* HOST bridge */
  93. { SCSI0, SCSI0, SCSI0, SCSI0, SCSI0 }, /* SCSI */
  94. { SCSI1, SCSI1, SCSI1, SCSI1, SCSI1 }, /* SCSI */
  95. { ETH, ETH, ETH, ETH, ETH }, /* Ethernet */
  96. { 0, INTA, INTB, INTC, INTD }, /* PCI-PCI bridge */
  97. { 0, 0, 0, 0, 0 }, /* Unused */
  98. { 0, 0, 0, 0, 0 }, /* Unused */
  99. { 0, 0, 0, 0, 0 }, /* Unused */
  100. { 0, INTA, INTB, INTC, INTD }, /* Slot 1 */
  101. { 0, INTB, INTC, INTD, INTA }, /* Slot 2 */
  102. { 0, INTC, INTD, INTA, INTB }, /* Slot 3 */
  103. { 0, INTD, INTA, INTB, INTC }, /* Slot 4 */
  104. { 0, INTA, INTB, INTC, INTD }, /* Slot 5 */
  105. };
  106. static char irq_tab_pcit_cplus[13][5] __initdata = {
  107. /* INTA INTB INTC INTD */
  108. { 0, 0, 0, 0, 0 }, /* HOST bridge */
  109. { 0, INTB, INTC, INTD, INTA }, /* PCI Slot 9 */
  110. { 0, 0, 0, 0, 0 }, /* PCI-EISA */
  111. { 0, 0, 0, 0, 0 }, /* Unused */
  112. { 0, INTA, INTB, INTC, INTD }, /* PCI-PCI bridge */
  113. { 0, INTB, INTC, INTD, INTA }, /* fixup */
  114. };
  115. static inline int is_rm300_revd(void)
  116. {
  117. unsigned char csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
  118. return (csmsr & 0xa0) == 0x20;
  119. }
  120. int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  121. {
  122. switch (sni_brd_type) {
  123. case SNI_BRD_PCI_TOWER_CPLUS:
  124. if (slot == 4) {
  125. /*
  126. * SNI messed up interrupt wiring for onboard
  127. * PCI bus 1; we need to fix this up here
  128. */
  129. while (dev && dev->bus->number != 1)
  130. dev = dev->bus->self;
  131. if (dev && dev->devfn >= PCI_DEVFN(4, 0))
  132. slot = 5;
  133. }
  134. return irq_tab_pcit_cplus[slot][pin];
  135. case SNI_BRD_PCI_TOWER:
  136. return irq_tab_pcit[slot][pin];
  137. case SNI_BRD_PCI_MTOWER:
  138. if (is_rm300_revd())
  139. return irq_tab_rm300d[slot][pin];
  140. /* fall through */
  141. case SNI_BRD_PCI_DESKTOP:
  142. return irq_tab_rm200[slot][pin];
  143. case SNI_BRD_PCI_MTOWER_CPLUS:
  144. return irq_tab_rm300e[slot][pin];
  145. }
  146. return 0;
  147. }
  148. /* Do platform specific device initialization at pci_enable_device() time */
  149. int pcibios_plat_dev_init(struct pci_dev *dev)
  150. {
  151. return 0;
  152. }