All of lore.kernel.org
 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

* [PATCH 2/5] MIPS: pci-ar71xx: convert into a platform driver
  2013-02-02 12:40 [PATCH 1/5] MIPS: pci-ar724x: convert into a platform driver Gabor Juhos
@ 2013-02-02 12:40 ` Gabor Juhos
  2013-02-02 12:44 ` [PATCH 3/5] MIPS: ath79: move global PCI defines into a common header Gabor Juhos
                   ` (2 subsequent siblings)
  3 siblings, 0 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-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>
---
Note:

In order to make the patch simple, the registration
of the corresponding platform device, and the removal
of the ar71xx_pcibios_init function is implemented in
subsequent patches.
---
 arch/mips/pci/pci-ar71xx.c |   60 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 4 deletions(-)

diff --git a/arch/mips/pci/pci-ar71xx.c b/arch/mips/pci/pci-ar71xx.c
index 6eaa4f2..0d8412f 100644
--- a/arch/mips/pci/pci-ar71xx.c
+++ b/arch/mips/pci/pci-ar71xx.c
@@ -18,6 +18,8 @@
 #include <linux/pci.h>
 #include <linux/pci_regs.h>
 #include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
 
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include <asm/mach-ath79/ath79.h>
@@ -309,7 +311,7 @@ static struct irq_chip ar71xx_pci_irq_chip = {
 	.irq_mask_ack	= ar71xx_pci_irq_mask,
 };
 
-static __init void ar71xx_pci_irq_init(void)
+static void ar71xx_pci_irq_init(int irq)
 {
 	void __iomem *base = ath79_reset_base;
 	int i;
@@ -324,10 +326,10 @@ static __init void ar71xx_pci_irq_init(void)
 		irq_set_chip_and_handler(i, &ar71xx_pci_irq_chip,
 					 handle_level_irq);
 
-	irq_set_chained_handler(ATH79_CPU_IRQ_IP2, ar71xx_pci_irq_handler);
+	irq_set_chained_handler(irq, ar71xx_pci_irq_handler);
 }
 
-static __init void ar71xx_pci_reset(void)
+static void ar71xx_pci_reset(void)
 {
 	void __iomem *ddr_base = ath79_ddr_base;
 
@@ -367,9 +369,59 @@ __init int ar71xx_pcibios_init(void)
 	/* clear bus errors */
 	ar71xx_pci_check_error(1);
 
-	ar71xx_pci_irq_init();
+	ar71xx_pci_irq_init(ATH79_CPU_IRQ_IP2);
 
 	register_pci_controller(&ar71xx_pci_controller);
 
 	return 0;
 }
+
+static int ar71xx_pci_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+	int irq;
+	u32 t;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg_base");
+	if (!res)
+		return -EINVAL;
+
+	ar71xx_pcicfg_base = devm_request_and_ioremap(&pdev->dev, res);
+	if (!ar71xx_pcicfg_base)
+		return -ENOMEM;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return -EINVAL;
+
+	ar71xx_pci_reset();
+
+	/* setup COMMAND register */
+	t = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
+	  | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK;
+	ar71xx_pci_local_write(PCI_COMMAND, 4, t);
+
+	/* clear bus errors */
+	ar71xx_pci_check_error(1);
+
+	ar71xx_pci_irq_init(irq);
+
+	register_pci_controller(&ar71xx_pci_controller);
+
+	return 0;
+}
+
+static struct platform_driver ar71xx_pci_driver = {
+	.probe = ar71xx_pci_probe,
+	.driver = {
+		.name = "ar71xx-pci",
+		.owner = THIS_MODULE,
+	},
+};
+
+static int __init ar71xx_pci_init(void)
+{
+	return platform_driver_register(&ar71xx_pci_driver);
+}
+
+postcore_initcall(ar71xx_pci_init);
-- 
1.7.10

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

* [PATCH 3/5] MIPS: ath79: move global PCI defines into a common header
  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 ` 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
  3 siblings, 1 reply; 7+ messages in thread
From: Gabor Juhos @ 2013-02-02 12:44 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, John Crispin, Gabor Juhos

The constants will be used by a subsequent patch.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h |   24 ++++++++++++++++++++++++
 arch/mips/pci/pci-ar71xx.c                     |   16 ----------------
 arch/mips/pci/pci-ar724x.c                     |    8 --------
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
index 7d44b5d..7c87bfe 100644
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
@@ -41,11 +41,35 @@
 #define AR71XX_RESET_BASE	(AR71XX_APB_BASE + 0x00060000)
 #define AR71XX_RESET_SIZE	0x100
 
+#define AR71XX_PCI_MEM_BASE	0x10000000
+#define AR71XX_PCI_MEM_SIZE	0x07000000
+
+#define AR71XX_PCI_WIN0_OFFS	0x10000000
+#define AR71XX_PCI_WIN1_OFFS	0x11000000
+#define AR71XX_PCI_WIN2_OFFS	0x12000000
+#define AR71XX_PCI_WIN3_OFFS	0x13000000
+#define AR71XX_PCI_WIN4_OFFS	0x14000000
+#define AR71XX_PCI_WIN5_OFFS	0x15000000
+#define AR71XX_PCI_WIN6_OFFS	0x16000000
+#define AR71XX_PCI_WIN7_OFFS	0x07000000
+
+#define AR71XX_PCI_CFG_BASE	\
+	(AR71XX_PCI_MEM_BASE + AR71XX_PCI_WIN7_OFFS + 0x10000)
+#define AR71XX_PCI_CFG_SIZE	0x100
+
 #define AR7240_USB_CTRL_BASE	(AR71XX_APB_BASE + 0x00030000)
 #define AR7240_USB_CTRL_SIZE	0x100
 #define AR7240_OHCI_BASE	0x1b000000
 #define AR7240_OHCI_SIZE	0x1000
 
+#define AR724X_PCI_MEM_BASE	0x10000000
+#define AR724X_PCI_MEM_SIZE	0x04000000
+
+#define AR724X_PCI_CFG_BASE	0x14000000
+#define AR724X_PCI_CFG_SIZE	0x1000
+#define AR724X_PCI_CTRL_BASE	(AR71XX_APB_BASE + 0x000f0000)
+#define AR724X_PCI_CTRL_SIZE	0x100
+
 #define AR724X_EHCI_BASE	0x1b000000
 #define AR724X_EHCI_SIZE	0x1000
 
diff --git a/arch/mips/pci/pci-ar71xx.c b/arch/mips/pci/pci-ar71xx.c
index 0d8412f..35ee234 100644
--- a/arch/mips/pci/pci-ar71xx.c
+++ b/arch/mips/pci/pci-ar71xx.c
@@ -25,22 +25,6 @@
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/pci.h>
 
-#define AR71XX_PCI_MEM_BASE	0x10000000
-#define AR71XX_PCI_MEM_SIZE	0x07000000
-
-#define AR71XX_PCI_WIN0_OFFS		0x10000000
-#define AR71XX_PCI_WIN1_OFFS		0x11000000
-#define AR71XX_PCI_WIN2_OFFS		0x12000000
-#define AR71XX_PCI_WIN3_OFFS		0x13000000
-#define AR71XX_PCI_WIN4_OFFS		0x14000000
-#define AR71XX_PCI_WIN5_OFFS		0x15000000
-#define AR71XX_PCI_WIN6_OFFS		0x16000000
-#define AR71XX_PCI_WIN7_OFFS		0x07000000
-
-#define AR71XX_PCI_CFG_BASE		\
-	(AR71XX_PCI_MEM_BASE + AR71XX_PCI_WIN7_OFFS + 0x10000)
-#define AR71XX_PCI_CFG_SIZE		0x100
-
 #define AR71XX_PCI_REG_CRP_AD_CBE	0x00
 #define AR71XX_PCI_REG_CRP_WRDATA	0x04
 #define AR71XX_PCI_REG_CRP_RDDATA	0x08
diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c
index e7aca88b..b3f9d09 100644
--- a/arch/mips/pci/pci-ar724x.c
+++ b/arch/mips/pci/pci-ar724x.c
@@ -17,14 +17,6 @@
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include <asm/mach-ath79/pci.h>
 
-#define AR724X_PCI_CFG_BASE	0x14000000
-#define AR724X_PCI_CFG_SIZE	0x1000
-#define AR724X_PCI_CTRL_BASE	(AR71XX_APB_BASE + 0x000f0000)
-#define AR724X_PCI_CTRL_SIZE	0x100
-
-#define AR724X_PCI_MEM_BASE	0x10000000
-#define AR724X_PCI_MEM_SIZE	0x04000000
-
 #define AR724X_PCI_REG_RESET		0x18
 #define AR724X_PCI_REG_INT_STATUS	0x4c
 #define AR724X_PCI_REG_INT_MASK		0x50
-- 
1.7.10

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

* [PATCH 4/5] MIPS: ath79: register platform devices for the PCI controllers
  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   ` Gabor Juhos
  0 siblings, 0 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-02-02 12:44 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, John Crispin, Gabor Juhos

The pci-ar71xx and pci-ar724x drivers were converted
into platform drivers. Register the corresponding
platform devices for the PCI controllers instead
of using the ar7{1x,24}x_pcibios_init functions.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/ath79/pci.c |   87 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 78 insertions(+), 9 deletions(-)

diff --git a/arch/mips/ath79/pci.c b/arch/mips/ath79/pci.c
index ca83abd..81ef579 100644
--- a/arch/mips/ath79/pci.c
+++ b/arch/mips/ath79/pci.c
@@ -14,6 +14,8 @@
 
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/resource.h>
+#include <linux/platform_device.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/irq.h>
@@ -110,21 +112,88 @@ void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev))
 	ath79_pci_plat_dev_init = func;
 }
 
-int __init ath79_register_pci(void)
+static struct platform_device *
+ath79_register_pci_ar71xx(void)
+{
+	struct platform_device *pdev;
+	struct resource res[2];
+
+	memset(res, 0, sizeof(res));
+
+	res[0].name = "cfg_base";
+	res[0].flags = IORESOURCE_MEM;
+	res[0].start = AR71XX_PCI_CFG_BASE;
+	res[0].end = AR71XX_PCI_CFG_BASE + AR71XX_PCI_CFG_SIZE - 1;
+
+	res[1].flags = IORESOURCE_IRQ;
+	res[1].start = ATH79_CPU_IRQ_IP2;
+	res[1].end = ATH79_CPU_IRQ_IP2;
+
+	pdev = platform_device_register_simple("ar71xx-pci", -1,
+					       res, ARRAY_SIZE(res));
+	return pdev;
+}
+
+static struct platform_device *
+ath79_register_pci_ar724x(int id,
+			  unsigned long cfg_base,
+			  unsigned long ctrl_base,
+			  int irq)
 {
-	if (soc_is_ar71xx())
-		return ar71xx_pcibios_init();
+	struct platform_device *pdev;
+	struct resource res[3];
 
-	if (soc_is_ar724x())
-		return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2);
+	memset(res, 0, sizeof(res));
 
-	if (soc_is_ar9342() || soc_is_ar9344()) {
+	res[0].name = "cfg_base";
+	res[0].flags = IORESOURCE_MEM;
+	res[0].start = cfg_base;
+	res[0].end = cfg_base + AR724X_PCI_CFG_SIZE - 1;
+
+	res[1].name = "ctrl_base";
+	res[1].flags = IORESOURCE_MEM;
+	res[1].start = ctrl_base;
+	res[1].end = ctrl_base + AR724X_PCI_CTRL_SIZE - 1;
+
+	res[2].flags = IORESOURCE_IRQ;
+	res[2].start = irq;
+	res[2].end = irq;
+
+	pdev = platform_device_register_simple("ar724x-pci", id,
+					       res, ARRAY_SIZE(res));
+	return pdev;
+}
+
+int __init ath79_register_pci(void)
+{
+	struct platform_device *pdev = NULL;
+
+	if (soc_is_ar71xx()) {
+		pdev = ath79_register_pci_ar71xx();
+	} else if (soc_is_ar724x()) {
+		pdev = ath79_register_pci_ar724x(-1,
+						 AR724X_PCI_CFG_BASE,
+						 AR724X_PCI_CTRL_BASE,
+						 ATH79_CPU_IRQ_IP2);
+	} else if (soc_is_ar9342() ||
+		   soc_is_ar9344()) {
 		u32 bootstrap;
 
 		bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
-		if (bootstrap & AR934X_BOOTSTRAP_PCIE_RC)
-			return ar724x_pcibios_init(ATH79_IP2_IRQ(0));
+		if ((bootstrap & AR934X_BOOTSTRAP_PCIE_RC) == 0)
+			return -ENODEV;
+
+		pdev = ath79_register_pci_ar724x(-1,
+						 AR724X_PCI_CFG_BASE,
+						 AR724X_PCI_CTRL_BASE,
+						 ATH79_IP2_IRQ(0));
+	} else {
+		/* No PCI support */
+		return -ENODEV;
 	}
 
-	return -ENODEV;
+	if (!pdev)
+		pr_err("unable to register PCI controller device\n");
+
+	return pdev ? 0 : -ENODEV;
 }
-- 
1.7.10

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

* [PATCH 5/5] MIPS: ath79: remove unused ar7{1x,24}x_pcibios_init functions
  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:45 ` Gabor Juhos
  2013-02-02 14:17 ` [PATCH 1/5] MIPS: pci-ar724x: convert into a platform driver John Crispin
  3 siblings, 0 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-02-02 12:45 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, John Crispin, Gabor Juhos

The functions are unused now, so remove them.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/ath79/pci.c                  |    1 -
 arch/mips/include/asm/mach-ath79/pci.h |   28 ----------------------------
 arch/mips/pci/pci-ar71xx.c             |   26 --------------------------
 arch/mips/pci/pci-ar724x.c             |   32 --------------------------------
 4 files changed, 87 deletions(-)
 delete mode 100644 arch/mips/include/asm/mach-ath79/pci.h

diff --git a/arch/mips/ath79/pci.c b/arch/mips/ath79/pci.c
index 81ef579..c94bcec 100644
--- a/arch/mips/ath79/pci.c
+++ b/arch/mips/ath79/pci.c
@@ -19,7 +19,6 @@
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/irq.h>
-#include <asm/mach-ath79/pci.h>
 #include "pci.h"
 
 static int (*ath79_pci_plat_dev_init)(struct pci_dev *dev);
diff --git a/arch/mips/include/asm/mach-ath79/pci.h b/arch/mips/include/asm/mach-ath79/pci.h
deleted file mode 100644
index 7868f7f..0000000
--- a/arch/mips/include/asm/mach-ath79/pci.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *  Atheros AR71XX/AR724X PCI support
- *
- *  Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
- *  Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
- *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License version 2 as published
- *  by the Free Software Foundation.
- */
-
-#ifndef __ASM_MACH_ATH79_PCI_H
-#define __ASM_MACH_ATH79_PCI_H
-
-#if defined(CONFIG_PCI) && defined(CONFIG_SOC_AR71XX)
-int ar71xx_pcibios_init(void);
-#else
-static inline int ar71xx_pcibios_init(void) { return 0; }
-#endif
-
-#if defined(CONFIG_PCI_AR724X)
-int ar724x_pcibios_init(int irq);
-#else
-static inline int ar724x_pcibios_init(int irq) { return 0; }
-#endif
-
-#endif /* __ASM_MACH_ATH79_PCI_H */
diff --git a/arch/mips/pci/pci-ar71xx.c b/arch/mips/pci/pci-ar71xx.c
index 35ee234..69e0bb4 100644
--- a/arch/mips/pci/pci-ar71xx.c
+++ b/arch/mips/pci/pci-ar71xx.c
@@ -23,7 +23,6 @@
 
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include <asm/mach-ath79/ath79.h>
-#include <asm/mach-ath79/pci.h>
 
 #define AR71XX_PCI_REG_CRP_AD_CBE	0x00
 #define AR71XX_PCI_REG_CRP_WRDATA	0x04
@@ -335,31 +334,6 @@ static void ar71xx_pci_reset(void)
 	mdelay(100);
 }
 
-__init int ar71xx_pcibios_init(void)
-{
-	u32 t;
-
-	ar71xx_pcicfg_base = ioremap(AR71XX_PCI_CFG_BASE, AR71XX_PCI_CFG_SIZE);
-	if (ar71xx_pcicfg_base == NULL)
-		return -ENOMEM;
-
-	ar71xx_pci_reset();
-
-	/* setup COMMAND register */
-	t = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
-	  | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK;
-	ar71xx_pci_local_write(PCI_COMMAND, 4, t);
-
-	/* clear bus errors */
-	ar71xx_pci_check_error(1);
-
-	ar71xx_pci_irq_init(ATH79_CPU_IRQ_IP2);
-
-	register_pci_controller(&ar71xx_pci_controller);
-
-	return 0;
-}
-
 static int ar71xx_pci_probe(struct platform_device *pdev)
 {
 	struct resource *res;
diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c
index b3f9d09..8f008d9 100644
--- a/arch/mips/pci/pci-ar724x.c
+++ b/arch/mips/pci/pci-ar724x.c
@@ -15,7 +15,6 @@
 #include <linux/platform_device.h>
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
-#include <asm/mach-ath79/pci.h>
 
 #define AR724X_PCI_REG_RESET		0x18
 #define AR724X_PCI_REG_INT_STATUS	0x4c
@@ -276,37 +275,6 @@ static void ar724x_pci_irq_init(int irq)
 	irq_set_chained_handler(irq, ar724x_pci_irq_handler);
 }
 
-int ar724x_pcibios_init(int irq)
-{
-	int ret;
-
-	ret = -ENOMEM;
-
-	ar724x_pci_devcfg_base = ioremap(AR724X_PCI_CFG_BASE,
-					 AR724X_PCI_CFG_SIZE);
-	if (ar724x_pci_devcfg_base == NULL)
-		goto err;
-
-	ar724x_pci_ctrl_base = ioremap(AR724X_PCI_CTRL_BASE,
-				       AR724X_PCI_CTRL_SIZE);
-	if (ar724x_pci_ctrl_base == NULL)
-		goto err_unmap_devcfg;
-
-	ar724x_pci_link_up = ar724x_pci_check_link();
-	if (!ar724x_pci_link_up)
-		pr_warn("ar724x: PCIe link is down\n");
-
-	ar724x_pci_irq_init(irq);
-	register_pci_controller(&ar724x_pci_controller);
-
-	return PCIBIOS_SUCCESSFUL;
-
-err_unmap_devcfg:
-	iounmap(ar724x_pci_devcfg_base);
-err:
-	return ret;
-}
-
 static int ar724x_pci_probe(struct platform_device *pdev)
 {
 	struct resource *res;
-- 
1.7.10

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

* Re: [PATCH 1/5] MIPS: pci-ar724x: convert into a platform driver
  2013-02-02 12:40 [PATCH 1/5] MIPS: pci-ar724x: convert into a platform driver Gabor Juhos
                   ` (2 preceding siblings ...)
  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 ` John Crispin
  2013-02-02 14:27   ` Gabor Juhos
  3 siblings, 1 reply; 7+ messages in thread
From: John Crispin @ 2013-02-02 14:17 UTC (permalink / raw)
  To: linux-mips

On 02/02/13 13:40, Gabor Juhos wrote:
> +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;


Hi,

maybe better use platform_get_resource(pdev, IORESOURCE_MEM, 0/1) ... 
you will otherwise have to patch this again when you convert to OF

	John

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

* Re: [PATCH 1/5] MIPS: pci-ar724x: convert into a platform driver
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-02-02 14:27 UTC (permalink / raw)
  To: John Crispin; +Cc: linux-mips

2013.02.02. 15:17 keltezéssel, John Crispin írta:
> On 02/02/13 13:40, Gabor Juhos wrote:
>> +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;
> 
> 
> Hi,
> 
> maybe better use platform_get_resource(pdev, IORESOURCE_MEM, 0/1) ... you will
> otherwise have to patch this again when you convert to OF

I will not have to convert that. The node can have a reg-names property like this:

> 	pci0: pcie@180f0000 {
> 		#address-cells = <3>;
> 		#size-cells = <2>;
> 		#interrupt-cells = <1>;
> 		device_type = "pci";
> 		interrupt-controller;
> 		compatible = "qca,qca9558-pcie", "qca,ar7240-pcie";
> 		bus-range = <0 255>;
> 		ranges = <0x02000000 0 0x00000000 0x10000000 0 0x02000000   /* pci memory */
> 				0x01000000 0 0x00000000 0x00000000 0 0x00000001>; /* io space */
> 		reg = <0x180f0000 0x0100	/* controller base */
> 			0x14000000 0x1000	/* config space */
> 			0x180c0000 0x1000>;	/* CRP base */
> 		reg-names = "ctrl_base", "cfg_base", "crp_base";
> 
> 		interrupt-map-mask = <0xf800 0 0 7>;
> 		interrupt-map = <0 0 0 1 &pci0 0
> 					0 0 0 2 &pci0 0
> 					0 0 0 3 &pci0 0
> 					0 0 0 4 &pci0 0>;
> 
> 		interrupt-parent = <&EINTC>;
> 		interrupts = <0>;
> 	};



-Gabor

^ permalink raw reply	[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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.