Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH 1/5] MIPS: pci-ar724x: convert into a platform driver
@ 2013-02-02 12:40 Gabor Juhos
  2013-02-02 12:40 ` [PATCH 2/5] MIPS: pci-ar71xx: " Gabor Juhos
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-02-02 12:40 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, John Crispin, Gabor Juhos

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>
---
Note:

In order to make the patch simple, the registration
of the corresponding platform device, and the removal
of the ar724x_pcibios_init function is implemented in
subsequent patches.
---
 arch/mips/pci/pci-ar724x.c |   57 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c
index c11c75b..e7aca88b 100644
--- a/arch/mips/pci/pci-ar724x.c
+++ b/arch/mips/pci/pci-ar724x.c
@@ -11,6 +11,8 @@
 
 #include <linux/irq.h>
 #include <linux/pci.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include <asm/mach-ath79/pci.h>
@@ -262,7 +264,7 @@ static struct irq_chip ar724x_pci_irq_chip = {
 	.irq_mask_ack	= ar724x_pci_irq_mask,
 };
 
-static void __init ar724x_pci_irq_init(int irq)
+static void ar724x_pci_irq_init(int irq)
 {
 	void __iomem *base;
 	int i;
@@ -282,7 +284,7 @@ static void __init ar724x_pci_irq_init(int irq)
 	irq_set_chained_handler(irq, ar724x_pci_irq_handler);
 }
 
-int __init ar724x_pcibios_init(int irq)
+int ar724x_pcibios_init(int irq)
 {
 	int ret;
 
@@ -312,3 +314,54 @@ err_unmap_devcfg:
 err:
 	return ret;
 }
+
+static int ar724x_pci_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+	int irq;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl_base");
+	if (!res)
+		return -EINVAL;
+
+	ar724x_pci_ctrl_base = devm_request_and_ioremap(&pdev->dev, res);
+	if (ar724x_pci_ctrl_base == NULL)
+		return -EBUSY;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg_base");
+	if (!res)
+		return -EINVAL;
+
+	ar724x_pci_devcfg_base = devm_request_and_ioremap(&pdev->dev, res);
+	if (!ar724x_pci_devcfg_base)
+		return -EBUSY;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return -EINVAL;
+
+	ar724x_pci_link_up = ar724x_pci_check_link();
+	if (!ar724x_pci_link_up)
+		dev_warn(&pdev->dev, "PCIe link is down\n");
+
+	ar724x_pci_irq_init(irq);
+
+	register_pci_controller(&ar724x_pci_controller);
+
+	return 0;
+}
+
+static struct platform_driver ar724x_pci_driver = {
+	.probe = ar724x_pci_probe,
+	.driver = {
+		.name = "ar724x-pci",
+		.owner = THIS_MODULE,
+	},
+};
+
+static int __init ar724x_pci_init(void)
+{
+	return platform_driver_register(&ar724x_pci_driver);
+}
+
+postcore_initcall(ar724x_pci_init);
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-02-02 14:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-02 12:40 [PATCH 1/5] MIPS: pci-ar724x: convert into a platform driver Gabor Juhos
2013-02-02 12:40 ` [PATCH 2/5] MIPS: pci-ar71xx: " Gabor Juhos
2013-02-02 12:44 ` [PATCH 3/5] MIPS: ath79: move global PCI defines into a common header Gabor Juhos
2013-02-02 12:44   ` [PATCH 4/5] MIPS: ath79: register platform devices for the PCI controllers Gabor Juhos
2013-02-02 12:45 ` [PATCH 5/5] MIPS: ath79: remove unused ar7{1x,24}x_pcibios_init functions Gabor Juhos
2013-02-02 14:17 ` [PATCH 1/5] MIPS: pci-ar724x: convert into a platform driver John Crispin
2013-02-02 14:27   ` Gabor Juhos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox