blob: cedc37b968b7470f17fbba38dfcd18204af3968c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Lennert Buytenhek3f7e5812006-09-18 23:10:26 +01002 * arch/arm/mach-iop32x/iq80321-pci.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * PCI support for the Intel IQ80321 reference board
5 *
6 * Author: Rory Bolt <rorybolt@pacbell.net>
7 * Copyright (C) 2002 Rory Bolt
8 * Copyright (C) 2004 Intel Corp.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/init.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080017#include <linux/string.h>
18#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20#include <asm/hardware.h>
21#include <asm/irq.h>
22#include <asm/mach/pci.h>
23#include <asm/mach-types.h>
24
25/*
26 * The following macro is used to lookup irqs in a standard table
27 * format for those systems that do not already have PCI
28 * interrupts properly routed. We assume 1 <= pin <= 4
29 */
30#define PCI_IRQ_TABLE_LOOKUP(minid,maxid) \
31({ int _ctl_ = -1; \
32 unsigned int _idsel = idsel - minid; \
33 if (_idsel <= maxid) \
34 _ctl_ = pci_irq_table[_idsel][pin-1]; \
35 _ctl_; })
36
37#define INTA IRQ_IQ80321_INTA
38#define INTB IRQ_IQ80321_INTB
39#define INTC IRQ_IQ80321_INTC
40#define INTD IRQ_IQ80321_INTD
41
42#define INTE IRQ_IQ80321_I82544
43
44static inline int __init
45iq80321_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
46{
47 static int pci_irq_table[][4] = {
48 /*
49 * PCI IDSEL/INTPIN->INTLINE
50 * A B C D
51 */
52 {INTE, INTE, INTE, INTE}, /* Gig-E */
53 {-1, -1, -1, -1}, /* Unused */
54 {INTC, INTD, INTA, INTB}, /* PCI-X Slot */
55 {-1, -1, -1, -1},
56 };
57
58 BUG_ON(pin < 1 || pin > 4);
59
60// return PCI_IRQ_TABLE_LOOKUP(4, 7);
61 return pci_irq_table[idsel%4][pin-1];
62}
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064static struct hw_pci iq80321_pci __initdata = {
65 .swizzle = pci_std_swizzle,
66 .nr_controllers = 1,
Lennert Buytenhek7e9740b2006-09-18 23:17:36 +010067 .setup = iop3xx_pci_setup,
68 .scan = iop3xx_pci_scan_bus,
69 .preinit = iop3xx_pci_preinit,
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 .map_irq = iq80321_map_irq
71};
72
73static int __init iq80321_pci_init(void)
74{
75 if (machine_is_iq80321())
76 pci_common_init(&iq80321_pci);
77 return 0;
78}
79
80subsys_initcall(iq80321_pci_init);
81
82
83
84