fixup-sni.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 inline int is_rm300_revd(void)
  107. {
  108. unsigned char csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
  109. return (csmsr & 0xa0) == 0x20;
  110. }
  111. int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  112. {
  113. switch (sni_brd_type) {
  114. case SNI_BRD_PCI_TOWER:
  115. case SNI_BRD_PCI_TOWER_CPLUS:
  116. return irq_tab_pcit[slot][pin];
  117. case SNI_BRD_PCI_MTOWER:
  118. if (is_rm300_revd())
  119. return irq_tab_rm300d[slot][pin];
  120. /* fall through */
  121. case SNI_BRD_PCI_DESKTOP:
  122. return irq_tab_rm200[slot][pin];
  123. case SNI_BRD_PCI_MTOWER_CPLUS:
  124. return irq_tab_rm300e[slot][pin];
  125. }
  126. return 0;
  127. }
  128. /* Do platform specific device initialization at pci_enable_device() time */
  129. int pcibios_plat_dev_init(struct pci_dev *dev)
  130. {
  131. return 0;
  132. }