blob: 6c1667e728f563b7201c0794184c1685f4187c12 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-integrator/pci-integrator.c
3 *
4 * Copyright (C) 1999 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 *
22 * PCI functions for Integrator
23 */
24#include <linux/kernel.h>
25#include <linux/pci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/interrupt.h>
27#include <linux/init.h>
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <asm/mach/pci.h>
30#include <asm/mach-types.h>
31
Linus Walleij695436e2012-02-26 10:46:48 +010032#include <mach/irqs.h>
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034/*
35 * A small note about bridges and interrupts. The DECchip 21050 (and
36 * later) adheres to the PCI-PCI bridge specification. This says that
37 * the interrupts on the other side of a bridge are swizzled in the
38 * following manner:
39 *
40 * Dev Interrupt Interrupt
41 * Pin on Pin on
42 * Device Connector
43 *
44 * 4 A A
45 * B B
46 * C C
47 * D D
48 *
49 * 5 A B
50 * B C
51 * C D
52 * D A
53 *
54 * 6 A C
55 * B D
56 * C A
57 * D B
58 *
59 * 7 A D
60 * B A
61 * C B
62 * D C
63 *
64 * Where A = pin 1, B = pin 2 and so on and pin=0 = default = A.
65 * Thus, each swizzle is ((pin-1) + (device#-4)) % 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68/*
69 * This routine handles multiple bridges.
70 */
71static u8 __init integrator_swizzle(struct pci_dev *dev, u8 *pinp)
72{
Russell Kingb28626d2012-03-10 11:30:46 +000073 if (*pinp == 0)
74 *pinp = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Russell Kingb28626d2012-03-10 11:30:46 +000076 return pci_common_swizzle(dev, pinp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077}
78
79static int irq_tab[4] __initdata = {
80 IRQ_AP_PCIINT0, IRQ_AP_PCIINT1, IRQ_AP_PCIINT2, IRQ_AP_PCIINT3
81};
82
83/*
84 * map the specified device/slot/pin to an IRQ. This works out such
85 * that slot 9 pin 1 is INT0, pin 2 is INT1, and slot 10 pin 1 is INT1.
86 */
Ralf Baechled5341942011-06-10 15:30:21 +010087static int __init integrator_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088{
89 int intnr = ((slot - 9) + (pin - 1)) & 3;
90
91 return irq_tab[intnr];
92}
93
94extern void pci_v3_init(void *);
95
96static struct hw_pci integrator_pci __initdata = {
97 .swizzle = integrator_swizzle,
98 .map_irq = integrator_map_irq,
99 .setup = pci_v3_setup,
100 .nr_controllers = 1,
Russell Kingc23bfc32012-03-10 12:49:16 +0000101 .ops = &pci_v3_ops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 .preinit = pci_v3_preinit,
103 .postinit = pci_v3_postinit,
104};
105
106static int __init integrator_pci_init(void)
107{
108 if (machine_is_integrator())
109 pci_common_init(&integrator_pci);
110 return 0;
111}
112
113subsys_initcall(integrator_pci_init);