pci_fixup.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *
  3.  * BRIEF MODULE DESCRIPTION
  4.  * Globespan IVR board-specific pci fixups.
  5.  *
  6.  * Copyright 2000 MontaVista Software Inc.
  7.  * Author: MontaVista Software, Inc.
  8.  *          ppopov@mvista.com or source@mvista.com
  9.  *
  10.  *  This program is free software; you can redistribute  it and/or modify it
  11.  *  under  the terms of  the GNU General  Public License as published by the
  12.  *  Free Software Foundation;  either version 2 of the  License, or (at your
  13.  *  option) any later version.
  14.  *
  15.  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
  16.  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
  17.  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
  18.  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
  19.  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20.  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
  21.  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  22.  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
  23.  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  24.  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25.  *
  26.  *  You should have received a copy of the  GNU General Public License along
  27.  *  with this program; if not, write  to the Free Software Foundation, Inc.,
  28.  *  675 Mass Ave, Cambridge, MA 02139, USA.
  29.  */
  30. #include <linux/config.h>
  31. #ifdef CONFIG_PCI
  32. #include <linux/types.h>
  33. #include <linux/pci.h>
  34. #include <linux/kernel.h>
  35. #include <linux/init.h>
  36. #include <asm/it8172/it8172.h>
  37. #include <asm/it8172/it8172_pci.h>
  38. #include <asm/it8172/it8172_int.h>
  39. void __init pcibios_fixup_resources(struct pci_dev *dev)
  40. {
  41. }
  42. void __init pcibios_fixup(void)
  43. {
  44. }
  45. void __init pcibios_fixup_irqs(void)
  46. {
  47. unsigned int slot, func;
  48. unsigned char pin;
  49. struct pci_dev *dev;
  50.         const int internal_func_irqs[7] = {
  51.             IT8172_AC97_IRQ,
  52.             IT8172_DMA_IRQ,
  53.             IT8172_CDMA_IRQ,
  54.             IT8172_USB_IRQ,
  55.             IT8172_BRIDGE_MASTER_IRQ,
  56.             IT8172_IDE_IRQ,
  57.             IT8172_MC68K_IRQ
  58.         };
  59. pci_for_each_dev(dev) {
  60. if (dev->bus->number != 0)
  61. return;
  62. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  63. slot = PCI_SLOT(dev->devfn);
  64. func = PCI_FUNC(dev->devfn);
  65. switch (slot) {
  66. case 0x01:
  67.     /*
  68.      * Internal device 1 is actually 7 different 
  69.      * internal devices on the IT8172G (multi-function 
  70.      * device).
  71.      */
  72.     if (func < 7)
  73. dev->irq = internal_func_irqs[func];
  74.     break;
  75. case 0x11:   // Realtek RTL-8139
  76. switch (pin) {
  77. case 0: /* pin A, hardware bug */
  78. case 1: /* pin A */
  79. dev->irq = IT8172_PCI_INTC_IRQ;
  80. break;
  81. case 2: /* pin B */
  82. dev->irq = IT8172_PCI_INTD_IRQ;
  83. break;
  84. case 3: /* pin C */
  85. dev->irq = IT8172_PCI_INTA_IRQ;
  86. break;
  87. case 4: /* pin D */
  88. dev->irq = IT8172_PCI_INTB_IRQ;
  89. break;
  90. default:
  91. dev->irq = 0xff; 
  92. break;
  93. }
  94. break;
  95. case 0x12:   // ivr slot
  96. switch (pin) {
  97. case 0: /* pin A, hardware bug */
  98. case 1: /* pin A */
  99. dev->irq = IT8172_PCI_INTB_IRQ;
  100. break;
  101. case 2: /* pin B */
  102. dev->irq = IT8172_PCI_INTB_IRQ;
  103. break;
  104. case 3: /* pin C */
  105. dev->irq = IT8172_PCI_INTC_IRQ;
  106. break;
  107. case 4: /* pin D */
  108. dev->irq = IT8172_PCI_INTD_IRQ;
  109. break;
  110. default:
  111. dev->irq = 0xff; 
  112. break;
  113. }
  114. break;
  115. case 0x13:   // expansion slot
  116. switch (pin) {
  117. case 0: /* pin A, hardware bug */
  118. case 1: /* pin A */
  119. dev->irq = IT8172_PCI_INTA_IRQ;
  120. break;
  121. case 2: /* pin B */
  122. dev->irq = IT8172_PCI_INTB_IRQ;
  123. break;
  124. case 3: /* pin C */
  125. dev->irq = IT8172_PCI_INTC_IRQ;
  126. break;
  127. case 4: /* pin D */
  128. dev->irq = IT8172_PCI_INTD_IRQ;
  129. break;
  130. default:
  131. dev->irq = 0xff; 
  132. break;
  133. }
  134. break;
  135. default:
  136. break;
  137. }
  138. #ifdef DEBUG
  139. printk("irq fixup: slot %d, int line %d, int number %dn",
  140. slot, pin, dev->irq);
  141. #endif
  142. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  143. }
  144. }
  145. #endif