fixup-vr4133.c 5.7 KB

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