fixup-vr4133.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * arch/mips/vr41xx/nec-cmbvr4133/pci_fixup.c
  3. *
  4. * The NEC CMB-VR4133 Board specific PCI fixups.
  5. *
  6. * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> and
  7. * Alex Sapkov <asapkov@ru.mvista.com>
  8. *
  9. * 2003-2004 (c) MontaVista, Software, Inc. This file is licensed under
  10. * the terms of the GNU General Public License version 2. This program
  11. * is licensed "as is" without any warranty of any kind, whether express
  12. * or implied.
  13. *
  14. * Modified for support in 2.6
  15. * Author: Manish Lachwani (mlachwani@mvista.com)
  16. *
  17. */
  18. #include <linux/config.h>
  19. #include <linux/init.h>
  20. #include <linux/pci.h>
  21. #include <asm/io.h>
  22. #include <asm/vr41xx/cmbvr4133.h>
  23. extern int vr4133_rockhopper;
  24. extern void ali_m1535plus_init(struct pci_dev *dev);
  25. extern void ali_m5229_init(struct pci_dev *dev);
  26. /* Do platform specific device initialization at pci_enable_device() time */
  27. int pcibios_plat_dev_init(struct pci_dev *dev)
  28. {
  29. /*
  30. * We have to reset AMD PCnet adapter on Rockhopper since
  31. * PMON leaves it enabled and generating interrupts. This leads
  32. * to a lock if some PCI device driver later enables the IRQ line
  33. * shared with PCnet and there is no AMD PCnet driver to catch its
  34. * interrupts.
  35. */
  36. #ifdef CONFIG_ROCKHOPPER
  37. if (dev->vendor == PCI_VENDOR_ID_AMD &&
  38. dev->device == PCI_DEVICE_ID_AMD_LANCE) {
  39. inl(pci_resource_start(dev, 0) + 0x18);
  40. }
  41. #endif
  42. /*
  43. * we have to open the bridges' windows down to 0 because otherwise
  44. * we cannot access ISA south bridge I/O registers that get mapped from
  45. * 0. for example, 8259 PIC would be unaccessible without that
  46. */
  47. if(dev->vendor == PCI_VENDOR_ID_INTEL && dev->device == PCI_DEVICE_ID_INTEL_S21152BB) {
  48. pci_write_config_byte(dev, PCI_IO_BASE, 0);
  49. if(dev->bus->number == 0) {
  50. pci_write_config_word(dev, PCI_IO_BASE_UPPER16, 0);
  51. } else {
  52. pci_write_config_word(dev, PCI_IO_BASE_UPPER16, 1);
  53. }
  54. }
  55. return 0;
  56. }
  57. /*
  58. * M1535 IRQ mapping
  59. * Feel free to change this, although it shouldn't be needed
  60. */
  61. #define M1535_IRQ_INTA 7
  62. #define M1535_IRQ_INTB 9
  63. #define M1535_IRQ_INTC 10
  64. #define M1535_IRQ_INTD 11
  65. #define M1535_IRQ_USB 9
  66. #define M1535_IRQ_IDE 14
  67. #define M1535_IRQ_IDE2 15
  68. #define M1535_IRQ_PS2 12
  69. #define M1535_IRQ_RTC 8
  70. #define M1535_IRQ_FDC 6
  71. #define M1535_IRQ_AUDIO 5
  72. #define M1535_IRQ_COM1 4
  73. #define M1535_IRQ_COM2 4
  74. #define M1535_IRQ_IRDA 3
  75. #define M1535_IRQ_KBD 1
  76. #define M1535_IRQ_TMR 0
  77. /* Rockhopper "slots" assignment; this is hard-coded ... */
  78. #define ROCKHOPPER_M5451_SLOT 1
  79. #define ROCKHOPPER_M1535_SLOT 2
  80. #define ROCKHOPPER_M5229_SLOT 11
  81. #define ROCKHOPPER_M5237_SLOT 15
  82. #define ROCKHOPPER_PMU_SLOT 12
  83. /* ... and hard-wired. */
  84. #define ROCKHOPPER_PCI1_SLOT 3
  85. #define ROCKHOPPER_PCI2_SLOT 4
  86. #define ROCKHOPPER_PCI3_SLOT 5
  87. #define ROCKHOPPER_PCI4_SLOT 6
  88. #define ROCKHOPPER_PCNET_SLOT 1
  89. #define M1535_IRQ_MASK(n) (1 << (n))
  90. #define M1535_IRQ_EDGE (M1535_IRQ_MASK(M1535_IRQ_TMR) | \
  91. M1535_IRQ_MASK(M1535_IRQ_KBD) | \
  92. M1535_IRQ_MASK(M1535_IRQ_COM1) | \
  93. M1535_IRQ_MASK(M1535_IRQ_COM2) | \
  94. M1535_IRQ_MASK(M1535_IRQ_IRDA) | \
  95. M1535_IRQ_MASK(M1535_IRQ_RTC) | \
  96. M1535_IRQ_MASK(M1535_IRQ_FDC) | \
  97. M1535_IRQ_MASK(M1535_IRQ_PS2))
  98. #define M1535_IRQ_LEVEL (M1535_IRQ_MASK(M1535_IRQ_IDE) | \
  99. M1535_IRQ_MASK(M1535_IRQ_USB) | \
  100. M1535_IRQ_MASK(M1535_IRQ_INTA) | \
  101. M1535_IRQ_MASK(M1535_IRQ_INTB) | \
  102. M1535_IRQ_MASK(M1535_IRQ_INTC) | \
  103. M1535_IRQ_MASK(M1535_IRQ_INTD))
  104. struct irq_map_entry {
  105. u16 bus;
  106. u8 slot;
  107. u8 irq;
  108. };
  109. static struct irq_map_entry int_map[] = {
  110. {1, ROCKHOPPER_M5451_SLOT, M1535_IRQ_AUDIO}, /* Audio controller */
  111. {1, ROCKHOPPER_PCI1_SLOT, M1535_IRQ_INTD}, /* PCI slot #1 */
  112. {1, ROCKHOPPER_PCI2_SLOT, M1535_IRQ_INTC}, /* PCI slot #2 */
  113. {1, ROCKHOPPER_M5237_SLOT, M1535_IRQ_USB}, /* USB host controller */
  114. {1, ROCKHOPPER_M5229_SLOT, IDE_PRIMARY_IRQ}, /* IDE controller */
  115. {2, ROCKHOPPER_PCNET_SLOT, M1535_IRQ_INTD}, /* AMD Am79c973 on-board
  116. ethernet */
  117. {2, ROCKHOPPER_PCI3_SLOT, M1535_IRQ_INTB}, /* PCI slot #3 */
  118. {2, ROCKHOPPER_PCI4_SLOT, M1535_IRQ_INTC} /* PCI slot #4 */
  119. };
  120. static int pci_intlines[] =
  121. { M1535_IRQ_INTA, M1535_IRQ_INTB, M1535_IRQ_INTC, M1535_IRQ_INTD };
  122. /* Determine the Rockhopper IRQ line number for the PCI device */
  123. int rockhopper_get_irq(struct pci_dev *dev, u8 pin, u8 slot)
  124. {
  125. struct pci_bus *bus;
  126. int i;
  127. bus = dev->bus;
  128. if (bus == NULL)
  129. return -1;
  130. for (i = 0; i < sizeof (int_map) / sizeof (int_map[0]); i++) {
  131. if (int_map[i].bus == bus->number && int_map[i].slot == slot) {
  132. int line;
  133. for (line = 0; line < 4; line++)
  134. if (pci_intlines[line] == int_map[i].irq)
  135. break;
  136. if (line < 4)
  137. return pci_intlines[(line + (pin - 1)) % 4];
  138. else
  139. return int_map[i].irq;
  140. }
  141. }
  142. return -1;
  143. }
  144. #ifdef CONFIG_ROCKHOPPER
  145. void i8259_init(void)
  146. {
  147. outb(0x11, 0x20); /* Master ICW1 */
  148. outb(I8259_IRQ_BASE, 0x21); /* Master ICW2 */
  149. outb(0x04, 0x21); /* Master ICW3 */
  150. outb(0x01, 0x21); /* Master ICW4 */
  151. outb(0xff, 0x21); /* Master IMW */
  152. outb(0x11, 0xa0); /* Slave ICW1 */
  153. outb(I8259_IRQ_BASE + 8, 0xa1); /* Slave ICW2 */
  154. outb(0x02, 0xa1); /* Slave ICW3 */
  155. outb(0x01, 0xa1); /* Slave ICW4 */
  156. outb(0xff, 0xa1); /* Slave IMW */
  157. outb(0x00, 0x4d0);
  158. outb(0x02, 0x4d1); /* USB IRQ9 is level */
  159. }
  160. #endif
  161. int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  162. {
  163. extern int pci_probe_only;
  164. pci_probe_only = 1;
  165. #ifdef CONFIG_ROCKHOPPER
  166. if( dev->bus->number == 1 && vr4133_rockhopper ) {
  167. if(slot == ROCKHOPPER_PCI1_SLOT || slot == ROCKHOPPER_PCI2_SLOT)
  168. dev->irq = CMBVR41XX_INTA_IRQ;
  169. else
  170. dev->irq = rockhopper_get_irq(dev, pin, slot);
  171. } else
  172. dev->irq = CMBVR41XX_INTA_IRQ;
  173. #else
  174. dev->irq = CMBVR41XX_INTA_IRQ;
  175. #endif
  176. return dev->irq;
  177. }
  178. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, ali_m1535plus_init);
  179. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5229, ali_m5229_init);