IRQ handler rewrite by Gabor Juhos, uses C no longer assembly
[openwrt/staging/florian.git] / target / linux / adm5120-2.6 / files / arch / mips / pci / fixup-adm5120.c
1 /*
2 * $Id$
3 *
4 * ADM5120 specific PCI fixups
5 *
6 * Copyright (C) ADMtek Incorporated.
7 * Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
8 * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
9 * Copyright (C) 2007 OpenWrt.org
10 *
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.
15 *
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.
20 *
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.
25 *
26 */
27
28 #include <linux/autoconf.h>
29 #include <linux/types.h>
30 #include <linux/kernel.h>
31 #include <linux/init.h>
32 #include <linux/pci.h>
33 #include <linux/pci_ids.h>
34 #include <linux/pci_regs.h>
35
36 #include <asm/delay.h>
37 #include <asm/bootinfo.h>
38
39 #include <asm/mach-adm5120/adm5120_info.h>
40 #include <asm/mach-adm5120/adm5120_defs.h>
41 #include <asm/mach-adm5120/adm5120_irq.h>
42
43 static void adm5120_pci_fixup(struct pci_dev *dev)
44 {
45 if (dev->devfn !=0)
46 return;
47
48 /* setup COMMAND register */
49 pci_write_config_word(dev, PCI_COMMAND,
50 (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER));
51
52 /* setup CACHE_LINE_SIZE register */
53 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 4);
54
55 /* setting up BARS */
56 pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0);
57 pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, 0);
58 }
59
60 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ADMTEK, PCI_DEVICE_ID_ADMTEK_ADM5120,
61 adm5120_pci_fixup);
62
63
64 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
65 {
66 int irq;
67
68 irq = -1;
69 #if 1
70 /* FIXME: this code should be working on all boards? */
71 if (slot > 0 && slot < 4)
72 irq = ADM5120_IRQ_PCI0+slot-1;
73 #else
74 switch (mips_machtype) {
75 case MACH_ADM5120_RB_111:
76 case MACH_ADM5120_RB_112:
77 case MACH_ADM5120_RB_133:
78 case MACH_ADM5120_RB_133C:
79 case MACH_ADM5120_RB_153:
80 if (slot > 0 && slot < 4)
81 irq = ADM5120_IRQ_PCI0+slot-1;
82 break;
83 default:
84 if (slot > 1 && slot < 5)
85 irq = ADM5120_IRQ_PCI0+slot-2;
86 break;
87 }
88 #endif
89 printk(KERN_INFO "PCI: mapping irq for device %s, slot:%u, pin:%u, "
90 "irq:%d\n", pci_name(dev), slot, pin, irq);
91
92 return irq;
93 }
94
95 int pcibios_plat_dev_init(struct pci_dev *dev)
96 {
97 return 0;
98 }
99