1 From 42541838d9fdbad8573141d69cf8e38831a6cbb6 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Sat, 2 Feb 2013 11:40:42 +0000
4 Subject: [PATCH] MIPS: pci-ar724x: convert into a platform driver
6 commit 58d2e9bcd682d76bcb9575dc56c85f1d82a81bfa upstream.
8 The patch converts the pci-ar724x 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/4905/
14 Signed-off-by: John Crispin <blogic@openwrt.org>
16 arch/mips/pci/pci-ar724x.c | 57 ++++++++++++++++++++++++++++++++++++++++++--
17 1 file changed, 55 insertions(+), 2 deletions(-)
19 --- a/arch/mips/pci/pci-ar724x.c
20 +++ b/arch/mips/pci/pci-ar724x.c
23 #include <linux/irq.h>
24 #include <linux/pci.h>
25 +#include <linux/module.h>
26 +#include <linux/platform_device.h>
27 #include <asm/mach-ath79/ath79.h>
28 #include <asm/mach-ath79/ar71xx_regs.h>
29 #include <asm/mach-ath79/pci.h>
30 @@ -262,7 +264,7 @@ static struct irq_chip ar724x_pci_irq_ch
31 .irq_mask_ack = ar724x_pci_irq_mask,
34 -static void __init ar724x_pci_irq_init(int irq)
35 +static void ar724x_pci_irq_init(int irq)
39 @@ -282,7 +284,7 @@ static void __init ar724x_pci_irq_init(i
40 irq_set_chained_handler(irq, ar724x_pci_irq_handler);
43 -int __init ar724x_pcibios_init(int irq)
44 +int ar724x_pcibios_init(int irq)
48 @@ -312,3 +314,54 @@ err_unmap_devcfg:
53 +static int ar724x_pci_probe(struct platform_device *pdev)
55 + struct resource *res;
58 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl_base");
62 + ar724x_pci_ctrl_base = devm_request_and_ioremap(&pdev->dev, res);
63 + if (ar724x_pci_ctrl_base == NULL)
66 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg_base");
70 + ar724x_pci_devcfg_base = devm_request_and_ioremap(&pdev->dev, res);
71 + if (!ar724x_pci_devcfg_base)
74 + irq = platform_get_irq(pdev, 0);
78 + ar724x_pci_link_up = ar724x_pci_check_link();
79 + if (!ar724x_pci_link_up)
80 + dev_warn(&pdev->dev, "PCIe link is down\n");
82 + ar724x_pci_irq_init(irq);
84 + register_pci_controller(&ar724x_pci_controller);
89 +static struct platform_driver ar724x_pci_driver = {
90 + .probe = ar724x_pci_probe,
92 + .name = "ar724x-pci",
93 + .owner = THIS_MODULE,
97 +static int __init ar724x_pci_init(void)
99 + return platform_driver_register(&ar724x_pci_driver);
102 +postcore_initcall(ar724x_pci_init);