1 /*
2  * FILE NAME
3  *	arch/mips/vr41xx/nec-eagle/pci_fixup.c
4  *
5  * BRIEF MODULE DESCRIPTION
6  *	The NEC Eagle/Hawk Board specific PCI fixups.
7  *
8  * Author: Yoichi Yuasa
9  *         yyuasa@mvista.com or source@mvista.com
10  *
11  * Copyright 2001,2002 MontaVista Software Inc.
12  *
13  *  This program is free software; you can redistribute it and/or modify it
14  *  under the terms of the GNU General Public License as published by the
15  *  Free Software Foundation; either version 2 of the License, or (at your
16  *  option) any later version.
17  *
18  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  *  You should have received a copy of the GNU General Public License along
30  *  with this program; if not, write to the Free Software Foundation, Inc.,
31  *  675 Mass Ave, Cambridge, MA 02139, USA.
32  */
33 /*
34  * Changes:
35  *  MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com>
36  *  - Moved mips_pci_channels[] to arch/mips/vr41xx/vr4122/eagle/setup.c.
37  *  - Added support for NEC Hawk.
38  *
39  *  Paul Mundt <lethal@chaoticdreams.org>
40  *  - Fix empty break statements, remove useless CONFIG_PCI.
41  *
42  *  MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com>
43  *  - New creation, NEC Eagle is supported.
44  */
45 #include <linux/config.h>
46 #include <linux/init.h>
47 #include <linux/pci.h>
48 
49 #include <asm/vr41xx/eagle.h>
50 #include <asm/vr41xx/vrc4173.h>
51 
pcibios_fixup_resources(struct pci_dev * dev)52 void __init pcibios_fixup_resources(struct pci_dev *dev)
53 {
54 }
55 
pcibios_fixup(void)56 void __init pcibios_fixup(void)
57 {
58 }
59 
pcibios_fixup_irqs(void)60 void __init pcibios_fixup_irqs(void)
61 {
62 	struct pci_dev *dev;
63 	u8 slot, func, pin;
64 
65 	pci_for_each_dev(dev) {
66 		slot = PCI_SLOT(dev->devfn);
67 		func = PCI_FUNC(dev->devfn);
68 		pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
69 		dev->irq = 0;
70 
71 		switch (slot) {
72 		case 8:
73 			switch (pin) {
74 			case 1:
75 				dev->irq = CP_INTA_IRQ;
76 				break;
77 			case 2:
78 				dev->irq = CP_INTB_IRQ;
79 				break;
80 			case 3:
81 				dev->irq = CP_INTC_IRQ;
82 				break;
83 			case 4:
84 				dev->irq = CP_INTD_IRQ;
85 				break;
86 			}
87 			break;
88 		case 9:
89 			switch (pin) {
90 			case 1:
91 				dev->irq = CP_INTD_IRQ;
92 				break;
93 			case 2:
94 				dev->irq = CP_INTA_IRQ;
95 				break;
96 			case 3:
97 				dev->irq = CP_INTB_IRQ;
98 				break;
99 			case 4:
100 				dev->irq = CP_INTC_IRQ;
101 				break;
102 			}
103 			break;
104 		case 10:
105 			switch (pin) {
106 			case 1:
107 				dev->irq = CP_INTC_IRQ;
108 				break;
109 			case 2:
110 				dev->irq = CP_INTD_IRQ;
111 				break;
112 			case 3:
113 				dev->irq = CP_INTA_IRQ;
114 				break;
115 			case 4:
116 				dev->irq = CP_INTB_IRQ;
117 				break;
118 			}
119 			break;
120 		case 12:
121 			dev->irq = VRC4173_PCMCIA1_IRQ;
122 			break;
123 		case 13:
124 			dev->irq = VRC4173_PCMCIA2_IRQ;
125 			break;
126 		case 28:
127 			dev->irq = LANINTA_IRQ;
128 			break;
129 		case 29:
130 			switch (pin) {
131 			case 1:
132 				dev->irq = PCISLOT_IRQ;
133 				break;
134 			case 2:
135 				dev->irq = CP_INTB_IRQ;
136 				break;
137 			case 3:
138 				dev->irq = CP_INTC_IRQ;
139 				break;
140 			case 4:
141 				dev->irq = CP_INTD_IRQ;
142 				break;
143 			}
144 			break;
145 		case 30:
146 			switch (func) {
147 			case 0:
148 				dev->irq = VRC4173_CASCADE_IRQ;
149 				break;
150 			case 1:
151 				dev->irq = VRC4173_AC97_IRQ;
152 				break;
153 			case 2:
154 				dev->irq = VRC4173_USB_IRQ;
155 				break;
156 			}
157 			break;
158 		}
159 
160 		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
161 	}
162 }
163 
pcibios_assign_all_busses(void)164 unsigned int pcibios_assign_all_busses(void)
165 {
166 	return 0;
167 }
168