fixup-rbtx4927.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. *
  3. * BRIEF MODULE DESCRIPTION
  4. * Board specific pci fixups for the Toshiba rbtx4927
  5. *
  6. * Copyright 2001 MontaVista Software Inc.
  7. * Author: MontaVista Software, Inc.
  8. * ppopov@mvista.com or source@mvista.com
  9. *
  10. * Copyright (C) 2000-2001 Toshiba Corporation
  11. *
  12. * Copyright (C) 2004 MontaVista Software Inc.
  13. * Author: Manish Lachwani (mlachwani@mvista.com)
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. *
  20. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  21. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  22. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  23. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  25. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  26. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  27. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. * You should have received a copy of the GNU General Public License along
  32. * with this program; if not, write to the Free Software Foundation, Inc.,
  33. * 675 Mass Ave, Cambridge, MA 02139, USA.
  34. */
  35. #include <linux/types.h>
  36. #include <linux/pci.h>
  37. #include <linux/kernel.h>
  38. #include <linux/init.h>
  39. #include <asm/tx4927/tx4927.h>
  40. #undef DEBUG
  41. #ifdef DEBUG
  42. #define DBG(x...) printk(x)
  43. #else
  44. #define DBG(x...)
  45. #endif
  46. /* look up table for backplane pci irq for slots 17-20 by pin # */
  47. static unsigned char backplane_pci_irq[4][4] = {
  48. /* PJ6 SLOT: 17, PIN: 1 */ {TX4927_IRQ_IOC_PCIA,
  49. /* PJ6 SLOT: 17, PIN: 2 */
  50. TX4927_IRQ_IOC_PCIB,
  51. /* PJ6 SLOT: 17, PIN: 3 */
  52. TX4927_IRQ_IOC_PCIC,
  53. /* PJ6 SLOT: 17, PIN: 4 */
  54. TX4927_IRQ_IOC_PCID},
  55. /* SB SLOT: 18, PIN: 1 */ {TX4927_IRQ_IOC_PCIB,
  56. /* SB SLOT: 18, PIN: 2 */
  57. TX4927_IRQ_IOC_PCIC,
  58. /* SB SLOT: 18, PIN: 3 */
  59. TX4927_IRQ_IOC_PCID,
  60. /* SB SLOT: 18, PIN: 4 */
  61. TX4927_IRQ_IOC_PCIA},
  62. /* PJ5 SLOT: 19, PIN: 1 */ {TX4927_IRQ_IOC_PCIC,
  63. /* PJ5 SLOT: 19, PIN: 2 */
  64. TX4927_IRQ_IOC_PCID,
  65. /* PJ5 SLOT: 19, PIN: 3 */
  66. TX4927_IRQ_IOC_PCIA,
  67. /* PJ5 SLOT: 19, PIN: 4 */
  68. TX4927_IRQ_IOC_PCIB},
  69. /* PJ4 SLOT: 20, PIN: 1 */ {TX4927_IRQ_IOC_PCID,
  70. /* PJ4 SLOT: 20, PIN: 2 */
  71. TX4927_IRQ_IOC_PCIA,
  72. /* PJ4 SLOT: 20, PIN: 3 */
  73. TX4927_IRQ_IOC_PCIB,
  74. /* PJ4 SLOT: 20, PIN: 4 */
  75. TX4927_IRQ_IOC_PCIC}
  76. };
  77. static int pci_get_irq(const struct pci_dev *dev, int pin)
  78. {
  79. unsigned char irq = pin;
  80. DBG("pci_get_irq: pin is %d\n", pin);
  81. /* IRQ rotation */
  82. irq--; /* 0-3 */
  83. if (dev->bus->parent == NULL &&
  84. PCI_SLOT(dev->devfn) == TX4927_PCIC_IDSEL_AD_TO_SLOT(23)) {
  85. printk("Onboard PCI_SLOT(dev->devfn) is %d\n",
  86. PCI_SLOT(dev->devfn));
  87. /* IDSEL=A23 is tx4927 onboard pci slot */
  88. irq = (irq + PCI_SLOT(dev->devfn)) % 4;
  89. irq++; /* 1-4 */
  90. DBG("irq is now %d\n", irq);
  91. switch (irq) {
  92. case 1:
  93. irq = TX4927_IRQ_IOC_PCIA;
  94. break;
  95. case 2:
  96. irq = TX4927_IRQ_IOC_PCIB;
  97. break;
  98. case 3:
  99. irq = TX4927_IRQ_IOC_PCIC;
  100. break;
  101. case 4:
  102. irq = TX4927_IRQ_IOC_PCID;
  103. break;
  104. }
  105. } else {
  106. /* PCI Backplane */
  107. DBG("PCI Backplane PCI_SLOT(dev->devfn) is %d\n",
  108. PCI_SLOT(dev->devfn));
  109. irq = backplane_pci_irq[PCI_SLOT(dev->devfn) - 17][irq];
  110. }
  111. DBG("assigned irq %d\n", irq);
  112. return irq;
  113. }
  114. int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  115. {
  116. unsigned char irq;
  117. printk("PCI Setup for pin %d \n", pin);
  118. if (dev->device == 0x9130) /* IDE */
  119. irq = 14;
  120. else
  121. irq = pci_get_irq(dev, pin);
  122. return irq;
  123. }
  124. /* Do platform specific device initialization at pci_enable_device() time */
  125. int pcibios_plat_dev_init(struct pci_dev *dev)
  126. {
  127. return 0;
  128. }