4 * ADM5120 specific PCI fixups
6 * Copyright (C) ADMtek Incorporated.
7 * Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
8 * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
9 * Copyright (C) 2007 OpenWrt.org
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the
23 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
28 #include <linux/types.h>
29 #include <linux/kernel.h>
30 #include <linux/init.h>
31 #include <linux/pci.h>
32 #include <linux/pci_ids.h>
33 #include <linux/pci_regs.h>
35 #include <asm/delay.h>
36 #include <asm/bootinfo.h>
38 #include <asm/mach-adm5120/adm5120_info.h>
39 #include <asm/mach-adm5120/adm5120_defs.h>
40 #include <asm/mach-adm5120/adm5120_irq.h>
42 struct adm5120_pci_irq
{
49 #define PCIIRQ(s,f,p,i) { \
56 static struct adm5120_pci_irq default_pci_irqs
[] __initdata
= {
57 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0
),
60 static struct adm5120_pci_irq rb1xx_pci_irqs
[] __initdata
= {
61 PCIIRQ(1, 0, 1, ADM5120_IRQ_PCI0
),
62 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI1
),
63 PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI2
)
66 static struct adm5120_pci_irq cas771_pci_irqs
[] __initdata
= {
67 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0
),
68 PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI1
),
69 PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2
)
72 static struct adm5120_pci_irq np28g_pci_irqs
[] __initdata
= {
73 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0
),
74 PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI0
),
75 PCIIRQ(3, 1, 2, ADM5120_IRQ_PCI1
),
76 PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2
)
79 #define GETMAP(n) do { \
80 nr_irqs = ARRAY_SIZE(n ## _pci_irqs); \
84 int __init
pcibios_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
86 struct adm5120_pci_irq
*p
;
92 if (slot
< 1 || slot
> 3) {
93 printk(KERN_ALERT
"PCI: slot number %u is not supported\n",
100 switch (mips_machtype
) {
101 case MACH_ADM5120_RB_111
:
102 case MACH_ADM5120_RB_112
:
103 case MACH_ADM5120_RB_133
:
104 case MACH_ADM5120_RB_133C
:
105 case MACH_ADM5120_RB_153
:
108 case MACH_ADM5120_NP28G
:
111 case MACH_ADM5120_P335
:
112 case MACH_ADM5120_P334WT
:
113 /* using default mapping */
115 case MACH_ADM5120_CAS771
:
119 case MACH_ADM5120_NP27G
:
120 case MACH_ADM5120_NP28GHS
:
121 case MACH_ADM5120_WP54AG
:
122 case MACH_ADM5120_WP54G
:
123 case MACH_ADM5120_WP54G_WRT
:
124 case MACH_ADM5120_WPP54AG
:
125 case MACH_ADM5120_WPP54G
:
127 printk(KERN_ALERT
"PCI: irq map is unknown, using defaults.\n");
131 for (i
=0; i
<nr_irqs
; i
++, p
++) {
132 if ((p
->slot
== slot
) && (PCI_FUNC(dev
->devfn
) == p
->func
) &&
140 printk(KERN_ALERT
"PCI: no irq found for %s pin:%u\n",
143 printk(KERN_INFO
"PCI: mapping irq for %s pin:%u, irq:%d\n",
144 pci_name(dev
), pin
, irq
);
151 static void adm5120_pci_fixup(struct pci_dev
*dev
)
156 /* setup COMMAND register */
157 pci_write_config_word(dev
, PCI_COMMAND
,
158 (PCI_COMMAND_IO
| PCI_COMMAND_MEMORY
| PCI_COMMAND_MASTER
));
160 /* setup CACHE_LINE_SIZE register */
161 pci_write_config_byte(dev
, PCI_CACHE_LINE_SIZE
, 4);
163 /* setting up BARS */
164 pci_write_config_dword(dev
, PCI_BASE_ADDRESS_0
, 0);
165 pci_write_config_dword(dev
, PCI_BASE_ADDRESS_1
, 0);
168 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ADMTEK
, PCI_DEVICE_ID_ADMTEK_ADM5120
,
171 int pcibios_plat_dev_init(struct pci_dev
*dev
)