aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/pci
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-02-02 06:40:42 -0500
committerJohn Crispin <blogic@openwrt.org>2013-02-16 19:25:35 -0500
commit58d2e9bcd682d76bcb9575dc56c85f1d82a81bfa (patch)
tree7fb65c8e6f7a0786af67b91da6f45a2ce7c99913 /arch/mips/pci
parentd3d2b4200b5a42851365e903d101f8f0882eb9eb (diff)
MIPS: pci-ar724x: convert into a platform driver
The patch converts the pci-ar724x driver into a platform driver. This makes it possible to register the PCI controller as a plain platform device. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/4905/ Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch/mips/pci')
-rw-r--r--arch/mips/pci/pci-ar724x.c57
1 files changed, 55 insertions, 2 deletions
diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c
index c11c75be2d7e..e7aca88ba0c0 100644
--- a/arch/mips/pci/pci-ar724x.c
+++ b/arch/mips/pci/pci-ar724x.c
@@ -11,6 +11,8 @@
11 11
12#include <linux/irq.h> 12#include <linux/irq.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/module.h>
15#include <linux/platform_device.h>
14#include <asm/mach-ath79/ath79.h> 16#include <asm/mach-ath79/ath79.h>
15#include <asm/mach-ath79/ar71xx_regs.h> 17#include <asm/mach-ath79/ar71xx_regs.h>
16#include <asm/mach-ath79/pci.h> 18#include <asm/mach-ath79/pci.h>
@@ -262,7 +264,7 @@ static struct irq_chip ar724x_pci_irq_chip = {
262 .irq_mask_ack = ar724x_pci_irq_mask, 264 .irq_mask_ack = ar724x_pci_irq_mask,
263}; 265};
264 266
265static void __init ar724x_pci_irq_init(int irq) 267static void ar724x_pci_irq_init(int irq)
266{ 268{
267 void __iomem *base; 269 void __iomem *base;
268 int i; 270 int i;
@@ -282,7 +284,7 @@ static void __init ar724x_pci_irq_init(int irq)
282 irq_set_chained_handler(irq, ar724x_pci_irq_handler); 284 irq_set_chained_handler(irq, ar724x_pci_irq_handler);
283} 285}
284 286
285int __init ar724x_pcibios_init(int irq) 287int ar724x_pcibios_init(int irq)
286{ 288{
287 int ret; 289 int ret;
288 290
@@ -312,3 +314,54 @@ err_unmap_devcfg:
312err: 314err:
313 return ret; 315 return ret;
314} 316}
317
318static int ar724x_pci_probe(struct platform_device *pdev)
319{
320 struct resource *res;
321 int irq;
322
323 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl_base");
324 if (!res)
325 return -EINVAL;
326
327 ar724x_pci_ctrl_base = devm_request_and_ioremap(&pdev->dev, res);
328 if (ar724x_pci_ctrl_base == NULL)
329 return -EBUSY;
330
331 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg_base");
332 if (!res)
333 return -EINVAL;
334
335 ar724x_pci_devcfg_base = devm_request_and_ioremap(&pdev->dev, res);
336 if (!ar724x_pci_devcfg_base)
337 return -EBUSY;
338
339 irq = platform_get_irq(pdev, 0);
340 if (irq < 0)
341 return -EINVAL;
342
343 ar724x_pci_link_up = ar724x_pci_check_link();
344 if (!ar724x_pci_link_up)
345 dev_warn(&pdev->dev, "PCIe link is down\n");
346
347 ar724x_pci_irq_init(irq);
348
349 register_pci_controller(&ar724x_pci_controller);
350
351 return 0;
352}
353
354static struct platform_driver ar724x_pci_driver = {
355 .probe = ar724x_pci_probe,
356 .driver = {
357 .name = "ar724x-pci",
358 .owner = THIS_MODULE,
359 },
360};
361
362static int __init ar724x_pci_init(void)
363{
364 return platform_driver_register(&ar724x_pci_driver);
365}
366
367postcore_initcall(ar724x_pci_init);