netifd: update to latest version, fixes interface error reporting for shell proto...
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / patches-3.3 / 143-MIPS-pci-ar724x-convert-to-a-platform-driver.patch
1 From f2d2d928c3900b67a5f95e53b86de5b61a3ab12c Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Mon, 11 Jun 2012 13:19:44 +0200
4 Subject: [PATCH 04/34] MIPS: pci-ar724x: convert to a platform driver
5
6 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
7 ---
8 arch/mips/pci/pci-ar724x.c | 57 ++++++++++++++++++++++++++++++++++++++++++-
9 1 files changed, 55 insertions(+), 2 deletions(-)
10
11 --- a/arch/mips/pci/pci-ar724x.c
12 +++ b/arch/mips/pci/pci-ar724x.c
13 @@ -11,6 +11,8 @@
14
15 #include <linux/irq.h>
16 #include <linux/pci.h>
17 +#include <linux/module.h>
18 +#include <linux/platform_device.h>
19 #include <asm/mach-ath79/ath79.h>
20 #include <asm/mach-ath79/ar71xx_regs.h>
21 #include <asm/mach-ath79/pci.h>
22 @@ -262,7 +264,7 @@ static struct irq_chip ar724x_pci_irq_ch
23 .irq_mask_ack = ar724x_pci_irq_mask,
24 };
25
26 -static void __init ar724x_pci_irq_init(int irq)
27 +static void __devinit ar724x_pci_irq_init(int irq)
28 {
29 void __iomem *base;
30 int i;
31 @@ -282,7 +284,7 @@ static void __init ar724x_pci_irq_init(i
32 irq_set_chained_handler(irq, ar724x_pci_irq_handler);
33 }
34
35 -int __init ar724x_pcibios_init(int irq)
36 +int __devinit ar724x_pcibios_init(int irq)
37 {
38 int ret;
39
40 @@ -312,3 +314,54 @@ err_unmap_devcfg:
41 err:
42 return ret;
43 }
44 +
45 +static int __devinit ar724x_pci_probe(struct platform_device *pdev)
46 +{
47 + struct resource *res;
48 + int irq;
49 +
50 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl_base");
51 + if (!res)
52 + return -EINVAL;
53 +
54 + ar724x_pci_ctrl_base = devm_request_and_ioremap(&pdev->dev, res);
55 + if (ar724x_pci_ctrl_base == NULL)
56 + return -EBUSY;
57 +
58 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg_base");
59 + if (!res)
60 + return -EINVAL;
61 +
62 + ar724x_pci_devcfg_base = devm_request_and_ioremap(&pdev->dev, res);
63 + if (!ar724x_pci_devcfg_base)
64 + return -EBUSY;
65 +
66 + irq = platform_get_irq(pdev, 0);
67 + if (irq < 0)
68 + return -EINVAL;
69 +
70 + ar724x_pci_link_up = ar724x_pci_check_link();
71 + if (!ar724x_pci_link_up)
72 + dev_warn(&pdev->dev, "PCIe link is down\n");
73 +
74 + ar724x_pci_irq_init(irq);
75 +
76 + register_pci_controller(&ar724x_pci_controller);
77 +
78 + return 0;
79 +}
80 +
81 +static struct platform_driver ar724x_pci_driver = {
82 + .probe = ar724x_pci_probe,
83 + .driver = {
84 + .name = "ar724x-pci",
85 + .owner = THIS_MODULE,
86 + },
87 +};
88 +
89 +static int __init ar724x_pci_init(void)
90 +{
91 + return platform_driver_register(&ar724x_pci_driver);
92 +}
93 +
94 +postcore_initcall(ar724x_pci_init);