ar71xx: use backported PCI patches
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / patches-3.8 / 010-MIPS-pci-ar724x-convert-into-a-platform-driver.patch
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
5
6 commit 58d2e9bcd682d76bcb9575dc56c85f1d82a81bfa upstream.
7
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.
11
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>
15 ---
16 arch/mips/pci/pci-ar724x.c | 57 ++++++++++++++++++++++++++++++++++++++++++--
17 1 file changed, 55 insertions(+), 2 deletions(-)
18
19 --- a/arch/mips/pci/pci-ar724x.c
20 +++ b/arch/mips/pci/pci-ar724x.c
21 @@ -11,6 +11,8 @@
22
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,
32 };
33
34 -static void __init ar724x_pci_irq_init(int irq)
35 +static void ar724x_pci_irq_init(int irq)
36 {
37 void __iomem *base;
38 int i;
39 @@ -282,7 +284,7 @@ static void __init ar724x_pci_irq_init(i
40 irq_set_chained_handler(irq, ar724x_pci_irq_handler);
41 }
42
43 -int __init ar724x_pcibios_init(int irq)
44 +int ar724x_pcibios_init(int irq)
45 {
46 int ret;
47
48 @@ -312,3 +314,54 @@ err_unmap_devcfg:
49 err:
50 return ret;
51 }
52 +
53 +static int ar724x_pci_probe(struct platform_device *pdev)
54 +{
55 + struct resource *res;
56 + int irq;
57 +
58 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl_base");
59 + if (!res)
60 + return -EINVAL;
61 +
62 + ar724x_pci_ctrl_base = devm_request_and_ioremap(&pdev->dev, res);
63 + if (ar724x_pci_ctrl_base == NULL)
64 + return -EBUSY;
65 +
66 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg_base");
67 + if (!res)
68 + return -EINVAL;
69 +
70 + ar724x_pci_devcfg_base = devm_request_and_ioremap(&pdev->dev, res);
71 + if (!ar724x_pci_devcfg_base)
72 + return -EBUSY;
73 +
74 + irq = platform_get_irq(pdev, 0);
75 + if (irq < 0)
76 + return -EINVAL;
77 +
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");
81 +
82 + ar724x_pci_irq_init(irq);
83 +
84 + register_pci_controller(&ar724x_pci_controller);
85 +
86 + return 0;
87 +}
88 +
89 +static struct platform_driver ar724x_pci_driver = {
90 + .probe = ar724x_pci_probe,
91 + .driver = {
92 + .name = "ar724x-pci",
93 + .owner = THIS_MODULE,
94 + },
95 +};
96 +
97 +static int __init ar724x_pci_init(void)
98 +{
99 + return platform_driver_register(&ar724x_pci_driver);
100 +}
101 +
102 +postcore_initcall(ar724x_pci_init);