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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *
  3.  * BRIEF MODULE DESCRIPTION
  4.  * 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. }
  63. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  64. slot = PCI_SLOT(dev->devfn);
  65. func = PCI_FUNC(dev->devfn);
  66. switch (slot) {
  67. case 0x01:
  68.     /*
  69.      * Internal device 1 is actually 7 different 
  70.      * internal devices on the IT8172G (a multi-
  71.      * function device).
  72.      */
  73.     if (func < 7)
  74. dev->irq = internal_func_irqs[func];
  75.     break;
  76. case 0x10:
  77. switch (pin) {
  78. case 1: /* pin A */
  79. dev->irq = IT8172_PCI_INTA_IRQ;
  80. break;
  81. case 2: /* pin B */
  82. dev->irq = IT8172_PCI_INTB_IRQ;
  83. break;
  84. case 3: /* pin C */
  85. dev->irq = IT8172_PCI_INTC_IRQ;
  86. break;
  87. case 4: /* pin D */
  88. dev->irq = IT8172_PCI_INTD_IRQ;
  89. break;
  90. default:
  91. dev->irq = 0xff; 
  92. break;
  93. }
  94. break;
  95. case 0x11:
  96. switch (pin) {
  97. case 1: /* pin A */
  98. dev->irq = IT8172_PCI_INTA_IRQ;
  99. break;
  100. case 2: /* pin B */
  101. dev->irq = IT8172_PCI_INTB_IRQ;
  102. break;
  103. case 3: /* pin C */
  104. dev->irq = IT8172_PCI_INTC_IRQ;
  105. break;
  106. case 4: /* pin D */
  107. dev->irq = IT8172_PCI_INTD_IRQ;
  108. break;
  109. default:
  110. dev->irq = 0xff; 
  111. break;
  112. }
  113. break;
  114. case 0x12:
  115. switch (pin) {
  116. case 1: /* pin A */
  117. dev->irq = IT8172_PCI_INTB_IRQ;
  118. break;
  119. case 2: /* pin B */
  120. dev->irq = IT8172_PCI_INTC_IRQ;
  121. break;
  122. case 3: /* pin C */
  123. dev->irq = IT8172_PCI_INTD_IRQ;
  124. break;
  125. case 4: /* pin D */
  126. dev->irq = IT8172_PCI_INTA_IRQ;
  127. break;
  128. default:
  129. dev->irq = 0xff; 
  130. break;
  131. }
  132. break;
  133. case 0x13:
  134. switch (pin) {
  135. case 1: /* pin A */
  136. dev->irq = IT8172_PCI_INTC_IRQ;
  137. break;
  138. case 2: /* pin B */
  139. dev->irq = IT8172_PCI_INTD_IRQ;
  140. break;
  141. case 3: /* pin C */
  142. dev->irq = IT8172_PCI_INTA_IRQ;
  143. break;
  144. case 4: /* pin D */
  145. dev->irq = IT8172_PCI_INTB_IRQ;
  146. break;
  147. default:
  148. dev->irq = 0xff; 
  149. break;
  150. }
  151. break;
  152. case 0x14:
  153. switch (pin) {
  154. case 1: /* pin A */
  155. dev->irq = IT8172_PCI_INTD_IRQ;
  156. break;
  157. case 2: /* pin B */
  158. dev->irq = IT8172_PCI_INTA_IRQ;
  159. break;
  160. case 3: /* pin C */
  161. dev->irq = IT8172_PCI_INTB_IRQ;
  162. break;
  163. case 4: /* pin D */
  164. dev->irq = IT8172_PCI_INTC_IRQ;
  165. break;
  166. default:
  167. dev->irq = 0xff; 
  168. break;
  169. }
  170. break;
  171. default:
  172. continue; /* do nothing */
  173. }
  174. #ifdef DEBUG
  175. printk("irq fixup: slot %d, int line %d, int number %dn",
  176. slot, pin, dev->irq);
  177. #endif
  178. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  179. }
  180. }
  181. #endif