aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/pci
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-02-02 06:40:43 -0500
committerJohn Crispin <blogic@openwrt.org>2013-02-16 19:25:35 -0500
commitfb167e891d5cc6386840dd092af2d461b38eb802 (patch)
treee7755d28fff0333a2b50d282e015f7dbe0ccdded /arch/mips/pci
parent58d2e9bcd682d76bcb9575dc56c85f1d82a81bfa (diff)
MIPS: pci-ar71xx: convert into a platform driver
The patch converts the pci-ar71xx 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/4906/ Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch/mips/pci')
-rw-r--r--arch/mips/pci/pci-ar71xx.c60
1 files changed, 56 insertions, 4 deletions
diff --git a/arch/mips/pci/pci-ar71xx.c b/arch/mips/pci/pci-ar71xx.c
index 6eaa4f2d0e38..0d8412fc5047 100644
--- a/arch/mips/pci/pci-ar71xx.c
+++ b/arch/mips/pci/pci-ar71xx.c
@@ -18,6 +18,8 @@
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/pci_regs.h> 19#include <linux/pci_regs.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/module.h>
22#include <linux/platform_device.h>
21 23
22#include <asm/mach-ath79/ar71xx_regs.h> 24#include <asm/mach-ath79/ar71xx_regs.h>
23#include <asm/mach-ath79/ath79.h> 25#include <asm/mach-ath79/ath79.h>
@@ -309,7 +311,7 @@ static struct irq_chip ar71xx_pci_irq_chip = {
309 .irq_mask_ack = ar71xx_pci_irq_mask, 311 .irq_mask_ack = ar71xx_pci_irq_mask,
310}; 312};
311 313
312static __init void ar71xx_pci_irq_init(void) 314static void ar71xx_pci_irq_init(int irq)
313{ 315{
314 void __iomem *base = ath79_reset_base; 316 void __iomem *base = ath79_reset_base;
315 int i; 317 int i;
@@ -324,10 +326,10 @@ static __init void ar71xx_pci_irq_init(void)
324 irq_set_chip_and_handler(i, &ar71xx_pci_irq_chip, 326 irq_set_chip_and_handler(i, &ar71xx_pci_irq_chip,
325 handle_level_irq); 327 handle_level_irq);
326 328
327 irq_set_chained_handler(ATH79_CPU_IRQ_IP2, ar71xx_pci_irq_handler); 329 irq_set_chained_handler(irq, ar71xx_pci_irq_handler);
328} 330}
329 331
330static __init void ar71xx_pci_reset(void) 332static void ar71xx_pci_reset(void)
331{ 333{
332 void __iomem *ddr_base = ath79_ddr_base; 334 void __iomem *ddr_base = ath79_ddr_base;
333 335
@@ -367,9 +369,59 @@ __init int ar71xx_pcibios_init(void)
367 /* clear bus errors */ 369 /* clear bus errors */
368 ar71xx_pci_check_error(1); 370 ar71xx_pci_check_error(1);
369 371
370 ar71xx_pci_irq_init(); 372 ar71xx_pci_irq_init(ATH79_CPU_IRQ_IP2);
371 373
372 register_pci_controller(&ar71xx_pci_controller); 374 register_pci_controller(&ar71xx_pci_controller);
373 375
374 return 0; 376 return 0;
375} 377}
378
379static int ar71xx_pci_probe(struct platform_device *pdev)
380{
381 struct resource *res;
382 int irq;
383 u32 t;
384
385 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg_base");
386 if (!res)
387 return -EINVAL;
388
389 ar71xx_pcicfg_base = devm_request_and_ioremap(&pdev->dev, res);
390 if (!ar71xx_pcicfg_base)
391 return -ENOMEM;
392
393 irq = platform_get_irq(pdev, 0);
394 if (irq < 0)
395 return -EINVAL;
396
397 ar71xx_pci_reset();
398
399 /* setup COMMAND register */
400 t = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
401 | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK;
402 ar71xx_pci_local_write(PCI_COMMAND, 4, t);
403
404 /* clear bus errors */
405 ar71xx_pci_check_error(1);
406
407 ar71xx_pci_irq_init(irq);
408
409 register_pci_controller(&ar71xx_pci_controller);
410
411 return 0;
412}
413
414static struct platform_driver ar71xx_pci_driver = {
415 .probe = ar71xx_pci_probe,
416 .driver = {
417 .name = "ar71xx-pci",
418 .owner = THIS_MODULE,
419 },
420};
421
422static int __init ar71xx_pci_init(void)
423{
424 return platform_driver_register(&ar71xx_pci_driver);
425}
426
427postcore_initcall(ar71xx_pci_init);