aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2013-01-29 11:14:18 -0500
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:47:19 -0400
commite5af716e20cba515138ef8b8c04005c98765f426 (patch)
treec98c6f6e2aa1394d75165c66f9e27a450d4c9eb1
parent1961a2f447ff2e9a6011dfba4493b33841e030a8 (diff)
ARM: integrator: merge PCIv3 driver into one file
The Integrator/AP PCI bridget, "v3" is contained in two files, where pci.c is a socket container to plug in the v3 device. However to transition the v3 to enable device tree probing, it need to be converted to a platform device (so that it can have a device node in the device tree) and then we want the PCI driver in a single file, as any other device driver, so we can handle variants using compatible strings and device name, and get the base address etc from resources connected to the device node. To move toward this goal we consolidate all code in the pci_v3.c file. Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--arch/arm/include/asm/mach/pci.h5
-rw-r--r--arch/arm/mach-integrator/Makefile2
-rw-r--r--arch/arm/mach-integrator/pci.c113
-rw-r--r--arch/arm/mach-integrator/pci_v3.c88
4 files changed, 85 insertions, 123 deletions
diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h
index 7d2c3c843801..ef5053527ba7 100644
--- a/arch/arm/include/asm/mach/pci.h
+++ b/arch/arm/include/asm/mach/pci.h
@@ -96,9 +96,4 @@ extern struct pci_ops via82c505_ops;
96extern int via82c505_setup(int nr, struct pci_sys_data *); 96extern int via82c505_setup(int nr, struct pci_sys_data *);
97extern void via82c505_init(void *sysdata); 97extern void via82c505_init(void *sysdata);
98 98
99extern struct pci_ops pci_v3_ops;
100extern int pci_v3_setup(int nr, struct pci_sys_data *);
101extern void pci_v3_preinit(void);
102extern void pci_v3_postinit(void);
103
104#endif /* __ASM_MACH_PCI_H */ 99#endif /* __ASM_MACH_PCI_H */
diff --git a/arch/arm/mach-integrator/Makefile b/arch/arm/mach-integrator/Makefile
index d14d6b76f4c2..ec759ded7b60 100644
--- a/arch/arm/mach-integrator/Makefile
+++ b/arch/arm/mach-integrator/Makefile
@@ -8,5 +8,5 @@ obj-y := core.o lm.o leds.o
8obj-$(CONFIG_ARCH_INTEGRATOR_AP) += integrator_ap.o 8obj-$(CONFIG_ARCH_INTEGRATOR_AP) += integrator_ap.o
9obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o 9obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o
10 10
11obj-$(CONFIG_PCI) += pci_v3.o pci.o 11obj-$(CONFIG_PCI) += pci_v3.o
12obj-$(CONFIG_INTEGRATOR_IMPD1) += impd1.o 12obj-$(CONFIG_INTEGRATOR_IMPD1) += impd1.o
diff --git a/arch/arm/mach-integrator/pci.c b/arch/arm/mach-integrator/pci.c
deleted file mode 100644
index 6c1667e728f5..000000000000
--- a/arch/arm/mach-integrator/pci.c
+++ /dev/null
@@ -1,113 +0,0 @@
1/*
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>
26#include <linux/interrupt.h>
27#include <linux/init.h>
28
29#include <asm/mach/pci.h>
30#include <asm/mach-types.h>
31
32#include <mach/irqs.h>
33
34/*
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
66 */
67
68/*
69 * This routine handles multiple bridges.
70 */
71static u8 __init integrator_swizzle(struct pci_dev *dev, u8 *pinp)
72{
73 if (*pinp == 0)
74 *pinp = 1;
75
76 return pci_common_swizzle(dev, pinp);
77}
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 */
87static int __init integrator_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
88{
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,
101 .ops = &pci_v3_ops,
102 .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);
diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c
index e7fcea7f3300..b8d7033da2b5 100644
--- a/arch/arm/mach-integrator/pci_v3.c
+++ b/arch/arm/mach-integrator/pci_v3.c
@@ -35,6 +35,7 @@
35#include <asm/signal.h> 35#include <asm/signal.h>
36#include <asm/mach/pci.h> 36#include <asm/mach/pci.h>
37#include <asm/irq_regs.h> 37#include <asm/irq_regs.h>
38#include <asm/mach-types.h>
38 39
39#include <asm/hardware/pci_v3.h> 40#include <asm/hardware/pci_v3.h>
40 41
@@ -337,7 +338,7 @@ static int v3_write_config(struct pci_bus *bus, unsigned int devfn, int where,
337 return PCIBIOS_SUCCESSFUL; 338 return PCIBIOS_SUCCESSFUL;
338} 339}
339 340
340struct pci_ops pci_v3_ops = { 341static struct pci_ops pci_v3_ops = {
341 .read = v3_read_config, 342 .read = v3_read_config,
342 .write = v3_write_config, 343 .write = v3_write_config,
343}; 344};
@@ -471,7 +472,7 @@ static irqreturn_t v3_irq(int dummy, void *devid)
471 return IRQ_HANDLED; 472 return IRQ_HANDLED;
472} 473}
473 474
474int __init pci_v3_setup(int nr, struct pci_sys_data *sys) 475static int __init pci_v3_setup(int nr, struct pci_sys_data *sys)
475{ 476{
476 int ret = 0; 477 int ret = 0;
477 478
@@ -490,7 +491,7 @@ int __init pci_v3_setup(int nr, struct pci_sys_data *sys)
490 * V3_LB_BASE? - local bus address 491 * V3_LB_BASE? - local bus address
491 * V3_LB_MAP? - pci bus address 492 * V3_LB_MAP? - pci bus address
492 */ 493 */
493void __init pci_v3_preinit(void) 494static void __init pci_v3_preinit(void)
494{ 495{
495 unsigned long flags; 496 unsigned long flags;
496 unsigned int temp; 497 unsigned int temp;
@@ -589,7 +590,7 @@ void __init pci_v3_preinit(void)
589 raw_spin_unlock_irqrestore(&v3_lock, flags); 590 raw_spin_unlock_irqrestore(&v3_lock, flags);
590} 591}
591 592
592void __init pci_v3_postinit(void) 593static void __init pci_v3_postinit(void)
593{ 594{
594 unsigned int pci_cmd; 595 unsigned int pci_cmd;
595 596
@@ -610,3 +611,82 @@ void __init pci_v3_postinit(void)
610 611
611 register_isa_ports(PHYS_PCI_MEM_BASE, PHYS_PCI_IO_BASE, 0); 612 register_isa_ports(PHYS_PCI_MEM_BASE, PHYS_PCI_IO_BASE, 0);
612} 613}
614
615/*
616 * A small note about bridges and interrupts. The DECchip 21050 (and
617 * later) adheres to the PCI-PCI bridge specification. This says that
618 * the interrupts on the other side of a bridge are swizzled in the
619 * following manner:
620 *
621 * Dev Interrupt Interrupt
622 * Pin on Pin on
623 * Device Connector
624 *
625 * 4 A A
626 * B B
627 * C C
628 * D D
629 *
630 * 5 A B
631 * B C
632 * C D
633 * D A
634 *
635 * 6 A C
636 * B D
637 * C A
638 * D B
639 *
640 * 7 A D
641 * B A
642 * C B
643 * D C
644 *
645 * Where A = pin 1, B = pin 2 and so on and pin=0 = default = A.
646 * Thus, each swizzle is ((pin-1) + (device#-4)) % 4
647 */
648
649/*
650 * This routine handles multiple bridges.
651 */
652static u8 __init integrator_swizzle(struct pci_dev *dev, u8 *pinp)
653{
654 if (*pinp == 0)
655 *pinp = 1;
656
657 return pci_common_swizzle(dev, pinp);
658}
659
660static int irq_tab[4] __initdata = {
661 IRQ_AP_PCIINT0, IRQ_AP_PCIINT1, IRQ_AP_PCIINT2, IRQ_AP_PCIINT3
662};
663
664/*
665 * map the specified device/slot/pin to an IRQ. This works out such
666 * that slot 9 pin 1 is INT0, pin 2 is INT1, and slot 10 pin 1 is INT1.
667 */
668static int __init integrator_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
669{
670 int intnr = ((slot - 9) + (pin - 1)) & 3;
671
672 return irq_tab[intnr];
673}
674
675static struct hw_pci integrator_pci __initdata = {
676 .swizzle = integrator_swizzle,
677 .map_irq = integrator_map_irq,
678 .setup = pci_v3_setup,
679 .nr_controllers = 1,
680 .ops = &pci_v3_ops,
681 .preinit = pci_v3_preinit,
682 .postinit = pci_v3_postinit,
683};
684
685static int __init integrator_pci_init(void)
686{
687 if (machine_is_integrator())
688 pci_common_init(&integrator_pci);
689 return 0;
690}
691
692subsys_initcall(integrator_pci_init);