1 From 060c9a226a25e044167e877d9830ec53f836da9e Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Sat, 2 Feb 2013 11:40:43 +0000
4 Subject: [PATCH] MIPS: pci-ar71xx: convert into a platform driver
6 commit fb167e891d5cc6386840dd092af2d461b38eb802 upstream.
8 The patch converts the pci-ar71xx driver into a
9 platform driver. This makes it possible to register
10 the PCI controller as a plain platform device.
12 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
13 Patchwork: http://patchwork.linux-mips.org/patch/4906/
14 Signed-off-by: John Crispin <blogic@openwrt.org>
16 arch/mips/pci/pci-ar71xx.c | 60 +++++++++++++++++++++++++++++++++++++++++---
17 1 file changed, 56 insertions(+), 4 deletions(-)
19 --- a/arch/mips/pci/pci-ar71xx.c
20 +++ b/arch/mips/pci/pci-ar71xx.c
22 #include <linux/pci.h>
23 #include <linux/pci_regs.h>
24 #include <linux/interrupt.h>
25 +#include <linux/module.h>
26 +#include <linux/platform_device.h>
28 #include <asm/mach-ath79/ar71xx_regs.h>
29 #include <asm/mach-ath79/ath79.h>
30 @@ -309,7 +311,7 @@ static struct irq_chip ar71xx_pci_irq_ch
31 .irq_mask_ack = ar71xx_pci_irq_mask,
34 -static __init void ar71xx_pci_irq_init(void)
35 +static void ar71xx_pci_irq_init(int irq)
37 void __iomem *base = ath79_reset_base;
39 @@ -324,10 +326,10 @@ static __init void ar71xx_pci_irq_init(v
40 irq_set_chip_and_handler(i, &ar71xx_pci_irq_chip,
43 - irq_set_chained_handler(ATH79_CPU_IRQ_IP2, ar71xx_pci_irq_handler);
44 + irq_set_chained_handler(irq, ar71xx_pci_irq_handler);
47 -static __init void ar71xx_pci_reset(void)
48 +static void ar71xx_pci_reset(void)
50 void __iomem *ddr_base = ath79_ddr_base;
52 @@ -367,9 +369,59 @@ __init int ar71xx_pcibios_init(void)
53 /* clear bus errors */
54 ar71xx_pci_check_error(1);
56 - ar71xx_pci_irq_init();
57 + ar71xx_pci_irq_init(ATH79_CPU_IRQ_IP2);
59 register_pci_controller(&ar71xx_pci_controller);
64 +static int ar71xx_pci_probe(struct platform_device *pdev)
66 + struct resource *res;
70 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg_base");
74 + ar71xx_pcicfg_base = devm_request_and_ioremap(&pdev->dev, res);
75 + if (!ar71xx_pcicfg_base)
78 + irq = platform_get_irq(pdev, 0);
84 + /* setup COMMAND register */
85 + t = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
86 + | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK;
87 + ar71xx_pci_local_write(PCI_COMMAND, 4, t);
89 + /* clear bus errors */
90 + ar71xx_pci_check_error(1);
92 + ar71xx_pci_irq_init(irq);
94 + register_pci_controller(&ar71xx_pci_controller);
99 +static struct platform_driver ar71xx_pci_driver = {
100 + .probe = ar71xx_pci_probe,
102 + .name = "ar71xx-pci",
103 + .owner = THIS_MODULE,
107 +static int __init ar71xx_pci_init(void)
109 + return platform_driver_register(&ar71xx_pci_driver);
112 +postcore_initcall(ar71xx_pci_init);