Feed the mess through indent.
[linux-2.6/linux-mips.git] / arch / mips / pci / fixup-ite8172g.c
bloba1c56a5c55ca9cba09d3672b73e46e11e0b310de
1 /*
2 * BRIEF MODULE DESCRIPTION
3 * Board specific pci fixups.
5 * Copyright 2000 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc.
7 * ppopov@mvista.com or source@mvista.com
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <linux/types.h>
30 #include <linux/pci.h>
31 #include <linux/kernel.h>
32 #include <linux/init.h>
34 #include <asm/it8172/it8172.h>
35 #include <asm/it8172/it8172_pci.h>
36 #include <asm/it8172/it8172_int.h>
38 void __init pcibios_fixup_resources(struct pci_dev *dev)
42 void __init pcibios_fixup(void)
46 void __init pcibios_fixup_irqs(void)
48 unsigned int slot, func;
49 unsigned char pin;
50 struct pci_dev *dev;
51 const int internal_func_irqs[7] = {
52 IT8172_AC97_IRQ,
53 IT8172_DMA_IRQ,
54 IT8172_CDMA_IRQ,
55 IT8172_USB_IRQ,
56 IT8172_BRIDGE_MASTER_IRQ,
57 IT8172_IDE_IRQ,
58 IT8172_MC68K_IRQ
61 pci_for_each_dev(dev) {
62 if (dev->bus->number != 0) {
63 return;
66 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
67 slot = PCI_SLOT(dev->devfn);
68 func = PCI_FUNC(dev->devfn);
70 switch (slot) {
71 case 0x01:
73 * Internal device 1 is actually 7 different
74 * internal devices on the IT8172G (a multi-
75 * function device).
77 if (func < 7)
78 dev->irq = internal_func_irqs[func];
79 break;
80 case 0x10:
81 switch (pin) {
82 case 1: /* pin A */
83 dev->irq = IT8172_PCI_INTA_IRQ;
84 break;
85 case 2: /* pin B */
86 dev->irq = IT8172_PCI_INTB_IRQ;
87 break;
88 case 3: /* pin C */
89 dev->irq = IT8172_PCI_INTC_IRQ;
90 break;
91 case 4: /* pin D */
92 dev->irq = IT8172_PCI_INTD_IRQ;
93 break;
94 default:
95 dev->irq = 0xff;
96 break;
99 break;
100 case 0x11:
101 switch (pin) {
102 case 1: /* pin A */
103 dev->irq = IT8172_PCI_INTA_IRQ;
104 break;
105 case 2: /* pin B */
106 dev->irq = IT8172_PCI_INTB_IRQ;
107 break;
108 case 3: /* pin C */
109 dev->irq = IT8172_PCI_INTC_IRQ;
110 break;
111 case 4: /* pin D */
112 dev->irq = IT8172_PCI_INTD_IRQ;
113 break;
114 default:
115 dev->irq = 0xff;
116 break;
119 break;
120 case 0x12:
121 switch (pin) {
122 case 1: /* pin A */
123 dev->irq = IT8172_PCI_INTB_IRQ;
124 break;
125 case 2: /* pin B */
126 dev->irq = IT8172_PCI_INTC_IRQ;
127 break;
128 case 3: /* pin C */
129 dev->irq = IT8172_PCI_INTD_IRQ;
130 break;
131 case 4: /* pin D */
132 dev->irq = IT8172_PCI_INTA_IRQ;
133 break;
134 default:
135 dev->irq = 0xff;
136 break;
139 break;
140 case 0x13:
141 switch (pin) {
142 case 1: /* pin A */
143 dev->irq = IT8172_PCI_INTC_IRQ;
144 break;
145 case 2: /* pin B */
146 dev->irq = IT8172_PCI_INTD_IRQ;
147 break;
148 case 3: /* pin C */
149 dev->irq = IT8172_PCI_INTA_IRQ;
150 break;
151 case 4: /* pin D */
152 dev->irq = IT8172_PCI_INTB_IRQ;
153 break;
154 default:
155 dev->irq = 0xff;
156 break;
159 break;
160 case 0x14:
161 switch (pin) {
162 case 1: /* pin A */
163 dev->irq = IT8172_PCI_INTD_IRQ;
164 break;
165 case 2: /* pin B */
166 dev->irq = IT8172_PCI_INTA_IRQ;
167 break;
168 case 3: /* pin C */
169 dev->irq = IT8172_PCI_INTB_IRQ;
170 break;
171 case 4: /* pin D */
172 dev->irq = IT8172_PCI_INTC_IRQ;
173 break;
174 default:
175 dev->irq = 0xff;
176 break;
179 break;
180 default:
181 continue; /* do nothing */
183 #ifdef DEBUG
184 printk("irq fixup: slot %d, int line %d, int number %d\n",
185 slot, pin, dev->irq);
186 #endif
187 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);