All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] MIPS: ath79: separate common PCI code
@ 2011-11-18 15:21 Gabor Juhos
  2011-11-18 15:21 ` [PATCH 2/7] MIPS: ath79: rename pci-ath724x.h Gabor Juhos
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Gabor Juhos @ 2011-11-18 15:21 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Rene Bolldorf, linux-mips, Gabor Juhos

The 'pcibios_map_irq' and 'pcibios_plat_dev_init'
are common functions and only instance one of them
can be present in a single kernel.

Currently these functions can be built only if the
CONFIG_SOC_AR724X option is selected. However the
ath79 platform contain support for the AR71XX SoCs,.
The AR71XX SoCs have a differnet PCI controller,
and those will require a different code.

Move the common PCI code into a separeate file in
order to be able to use that with other SoCs as
well.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/ath79/Makefile    |    1 +
 arch/mips/ath79/pci.c       |   46 +++++++++++++++++++++++++++++++++++++++++++
 arch/mips/pci/pci-ath724x.c |   34 -------------------------------
 3 files changed, 47 insertions(+), 34 deletions(-)
 create mode 100644 arch/mips/ath79/pci.c

diff --git a/arch/mips/ath79/Makefile b/arch/mips/ath79/Makefile
index 3b911e09..221a76a9 100644
--- a/arch/mips/ath79/Makefile
+++ b/arch/mips/ath79/Makefile
@@ -11,6 +11,7 @@
 obj-y	:= prom.o setup.o irq.o common.o clock.o gpio.o
 
 obj-$(CONFIG_EARLY_PRINTK)		+= early_printk.o
+obj-$(CONFIG_PCI)			+= pci.o
 
 #
 # Devices
diff --git a/arch/mips/ath79/pci.c b/arch/mips/ath79/pci.c
new file mode 100644
index 0000000..8db076e
--- /dev/null
+++ b/arch/mips/ath79/pci.c
@@ -0,0 +1,46 @@
+/*
+ *  Atheros AR71XX/AR724X specific PCI setup code
+ *
+ *  Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
+ *
+ *  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.
+ */
+
+#include <linux/pci.h>
+#include <asm/mach-ath79/pci-ath724x.h>
+
+static struct ath724x_pci_data *pci_data;
+static int pci_data_size;
+
+void ath724x_pci_add_data(struct ath724x_pci_data *data, int size)
+{
+	pci_data	= data;
+	pci_data_size	= size;
+}
+
+int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
+{
+	unsigned int devfn = dev->devfn;
+	int irq = -1;
+
+	if (devfn > pci_data_size - 1)
+		return irq;
+
+	irq = pci_data[devfn].irq;
+
+	return irq;
+}
+
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	unsigned int devfn = dev->devfn;
+
+	if (devfn > pci_data_size - 1)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	dev->dev.platform_data = pci_data[devfn].pdata;
+
+	return PCIBIOS_SUCCESSFUL;
+}
diff --git a/arch/mips/pci/pci-ath724x.c b/arch/mips/pci/pci-ath724x.c
index a4dd24a..1e810be 100644
--- a/arch/mips/pci/pci-ath724x.c
+++ b/arch/mips/pci/pci-ath724x.c
@@ -9,7 +9,6 @@
  */
 
 #include <linux/pci.h>
-#include <asm/mach-ath79/pci-ath724x.h>
 
 #define reg_read(_phys)		(*(unsigned int *) KSEG1ADDR(_phys))
 #define reg_write(_phys, _val)	((*(unsigned int *) KSEG1ADDR(_phys)) = (_val))
@@ -19,8 +18,6 @@
 #define ATH724X_PCI_MEM_SIZE	0x08000000
 
 static DEFINE_SPINLOCK(ath724x_pci_lock);
-static struct ath724x_pci_data *pci_data;
-static int pci_data_size;
 
 static int ath724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
 			    int size, uint32_t *value)
@@ -133,37 +130,6 @@ static struct pci_controller ath724x_pci_controller = {
 	.mem_resource	= &ath724x_mem_resource,
 };
 
-void ath724x_pci_add_data(struct ath724x_pci_data *data, int size)
-{
-	pci_data	= data;
-	pci_data_size	= size;
-}
-
-int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
-{
-	unsigned int devfn = dev->devfn;
-	int irq = -1;
-
-	if (devfn > pci_data_size - 1)
-		return irq;
-
-	irq = pci_data[devfn].irq;
-
-	return irq;
-}
-
-int pcibios_plat_dev_init(struct pci_dev *dev)
-{
-	unsigned int devfn = dev->devfn;
-
-	if (devfn > pci_data_size - 1)
-		return PCIBIOS_DEVICE_NOT_FOUND;
-
-	dev->dev.platform_data = pci_data[devfn].pdata;
-
-	return PCIBIOS_SUCCESSFUL;
-}
-
 static int __init ath724x_pcibios_init(void)
 {
 	register_pci_controller(&ath724x_pci_controller);
-- 
1.7.2.1

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

* [PATCH 2/7] MIPS: ath79: rename pci-ath724x.h
  2011-11-18 15:21 [PATCH 1/7] MIPS: ath79: separate common PCI code Gabor Juhos
@ 2011-11-18 15:21 ` Gabor Juhos
  2011-11-18 15:21 ` [PATCH 3/7] MIPS: ath79: make ath724x_pcibios_init visible for external code Gabor Juhos
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Gabor Juhos @ 2011-11-18 15:21 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Rene Bolldorf, linux-mips, Gabor Juhos

The declared function in this header file is used by the
ath79 platform code only. Move the header to the platform
directory.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/ath79/mach-ubnt-xm.c                     |    2 +-
 arch/mips/ath79/pci.c                              |    2 +-
 .../asm/mach-ath79/pci-ath724x.h => ath79/pci.h}   |    0
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename arch/mips/{include/asm/mach-ath79/pci-ath724x.h => ath79/pci.h} (100%)

diff --git a/arch/mips/ath79/mach-ubnt-xm.c b/arch/mips/ath79/mach-ubnt-xm.c
index 3c311a5..5853bd7 100644
--- a/arch/mips/ath79/mach-ubnt-xm.c
+++ b/arch/mips/ath79/mach-ubnt-xm.c
@@ -15,7 +15,7 @@
 
 #ifdef CONFIG_PCI
 #include <linux/ath9k_platform.h>
-#include <asm/mach-ath79/pci-ath724x.h>
+#include "pci.h"
 #endif /* CONFIG_PCI */
 
 #include "machtypes.h"
diff --git a/arch/mips/ath79/pci.c b/arch/mips/ath79/pci.c
index 8db076e..4957428 100644
--- a/arch/mips/ath79/pci.c
+++ b/arch/mips/ath79/pci.c
@@ -9,7 +9,7 @@
  */
 
 #include <linux/pci.h>
-#include <asm/mach-ath79/pci-ath724x.h>
+#include "pci.h"
 
 static struct ath724x_pci_data *pci_data;
 static int pci_data_size;
diff --git a/arch/mips/include/asm/mach-ath79/pci-ath724x.h b/arch/mips/ath79/pci.h
similarity index 100%
rename from arch/mips/include/asm/mach-ath79/pci-ath724x.h
rename to arch/mips/ath79/pci.h
-- 
1.7.2.1

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

* [PATCH 3/7] MIPS: ath79: make ath724x_pcibios_init visible for external code
  2011-11-18 15:21 [PATCH 1/7] MIPS: ath79: separate common PCI code Gabor Juhos
  2011-11-18 15:21 ` [PATCH 2/7] MIPS: ath79: rename pci-ath724x.h Gabor Juhos
@ 2011-11-18 15:21 ` Gabor Juhos
  2011-11-18 15:21 ` [PATCH 4/7] MIPS: ath79: add a common PCI registration function Gabor Juhos
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Gabor Juhos @ 2011-11-18 15:21 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Rene Bolldorf, linux-mips, Gabor Juhos, Gabor Juhos

Signed-off-by: Gabor Juhos <juhsog@openwrt.org>
---
 arch/mips/include/asm/mach-ath79/pci.h |   20 ++++++++++++++++++++
 arch/mips/pci/pci-ath724x.c            |    3 ++-
 2 files changed, 22 insertions(+), 1 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-ath79/pci.h

diff --git a/arch/mips/include/asm/mach-ath79/pci.h b/arch/mips/include/asm/mach-ath79/pci.h
new file mode 100644
index 0000000..7ef8a49
--- /dev/null
+++ b/arch/mips/include/asm/mach-ath79/pci.h
@@ -0,0 +1,20 @@
+/*
+ *  Atheros 724x PCI support
+ *
+ *  Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
+ *
+ *  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_AR724X)
+int ath724x_pcibios_init(void);
+#else
+static inline int ath724x_pcibios_init(void) { return 0 };
+#endif
+
+#endif /* __ASM_MACH_ATH79_PCI_H */
diff --git a/arch/mips/pci/pci-ath724x.c b/arch/mips/pci/pci-ath724x.c
index 1e810be..be01b7f 100644
--- a/arch/mips/pci/pci-ath724x.c
+++ b/arch/mips/pci/pci-ath724x.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/pci.h>
+#include <asm/mach-ath79/pci.h>
 
 #define reg_read(_phys)		(*(unsigned int *) KSEG1ADDR(_phys))
 #define reg_write(_phys, _val)	((*(unsigned int *) KSEG1ADDR(_phys)) = (_val))
@@ -130,7 +131,7 @@ static struct pci_controller ath724x_pci_controller = {
 	.mem_resource	= &ath724x_mem_resource,
 };
 
-static int __init ath724x_pcibios_init(void)
+int __init ath724x_pcibios_init(void)
 {
 	register_pci_controller(&ath724x_pci_controller);
 
-- 
1.7.2.1

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

* [PATCH 4/7] MIPS: ath79: add a common PCI registration function
  2011-11-18 15:21 [PATCH 1/7] MIPS: ath79: separate common PCI code Gabor Juhos
  2011-11-18 15:21 ` [PATCH 2/7] MIPS: ath79: rename pci-ath724x.h Gabor Juhos
  2011-11-18 15:21 ` [PATCH 3/7] MIPS: ath79: make ath724x_pcibios_init visible for external code Gabor Juhos
@ 2011-11-18 15:21 ` Gabor Juhos
  2011-11-18 18:32   ` René Bolldorf
  2011-11-18 15:21 ` [PATCH 5/7] MIPS: ath79: rename pci-ath724x.c to make it reflect the real SoC name Gabor Juhos
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Gabor Juhos @ 2011-11-18 15:21 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Rene Bolldorf, linux-mips, Gabor Juhos

The current code unconditionally registers the AR724X
specific PCI controller, even if the kernel is running
on a different SoC.

Add a common function for PCI controller registration,
and only register the AR724X PCI controller if the kernel
is running on an AR724X SoC.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/ath79/mach-ubnt-xm.c |    1 +
 arch/mips/ath79/pci.c          |   14 ++++++++++++++
 arch/mips/ath79/pci.h          |    6 ++++++
 arch/mips/pci/pci-ath724x.c    |    2 --
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/mips/ath79/mach-ubnt-xm.c b/arch/mips/ath79/mach-ubnt-xm.c
index 5853bd7..1d44cc2 100644
--- a/arch/mips/ath79/mach-ubnt-xm.c
+++ b/arch/mips/ath79/mach-ubnt-xm.c
@@ -111,6 +111,7 @@ static void __init ubnt_xm_init(void)
 	ath724x_pci_add_data(ubnt_xm_pci_data, ARRAY_SIZE(ubnt_xm_pci_data));
 #endif /* CONFIG_PCI */
 
+	ath79_register_pci();
 }
 
 MIPS_MACHINE(ATH79_MACH_UBNT_XM,
diff --git a/arch/mips/ath79/pci.c b/arch/mips/ath79/pci.c
index 4957428..a2dae75 100644
--- a/arch/mips/ath79/pci.c
+++ b/arch/mips/ath79/pci.c
@@ -9,6 +9,8 @@
  */
 
 #include <linux/pci.h>
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/pci.h>
 #include "pci.h"
 
 static struct ath724x_pci_data *pci_data;
@@ -44,3 +46,15 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
 
 	return PCIBIOS_SUCCESSFUL;
 }
+
+int ath79_register_pci(void)
+{
+	int ret;
+
+	if (soc_is_ar724x())
+		ret = ath724x_pcibios_init();
+	else
+		ret = -ENODEV;
+
+	return ret;
+}
diff --git a/arch/mips/ath79/pci.h b/arch/mips/ath79/pci.h
index 454885f..4653ca8 100644
--- a/arch/mips/ath79/pci.h
+++ b/arch/mips/ath79/pci.h
@@ -18,4 +18,10 @@ struct ath724x_pci_data {
 
 void ath724x_pci_add_data(struct ath724x_pci_data *data, int size);
 
+#ifdef CONFIG_PCI
+int ath79_register_pci(void);
+#else
+static inline int ath79_register_pci(void) {};
+#endif
+
 #endif /* __ASM_MACH_ATH79_PCI_ATH724X_H */
diff --git a/arch/mips/pci/pci-ath724x.c b/arch/mips/pci/pci-ath724x.c
index be01b7f..ebefc16 100644
--- a/arch/mips/pci/pci-ath724x.c
+++ b/arch/mips/pci/pci-ath724x.c
@@ -137,5 +137,3 @@ int __init ath724x_pcibios_init(void)
 
 	return PCIBIOS_SUCCESSFUL;
 }
-
-arch_initcall(ath724x_pcibios_init);
-- 
1.7.2.1

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

* [PATCH 5/7] MIPS: ath79: rename pci-ath724x.c to make it reflect the real SoC name
  2011-11-18 15:21 [PATCH 1/7] MIPS: ath79: separate common PCI code Gabor Juhos
                   ` (2 preceding siblings ...)
  2011-11-18 15:21 ` [PATCH 4/7] MIPS: ath79: add a common PCI registration function Gabor Juhos
@ 2011-11-18 15:21 ` Gabor Juhos
  2011-11-18 15:21 ` [PATCH 6/7] MIPS: ath79: replace ath724x to ar724x Gabor Juhos
  2011-11-18 15:22 ` [PATCH 7/7] MIPS: ath79: use io-accessor macros in pci-ar724x.c Gabor Juhos
  5 siblings, 0 replies; 11+ messages in thread
From: Gabor Juhos @ 2011-11-18 15:21 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Rene Bolldorf, linux-mips, Gabor Juhos

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/pci/Makefile                        |    2 +-
 arch/mips/pci/{pci-ath724x.c => pci-ar724x.c} |    0
 2 files changed, 1 insertions(+), 1 deletions(-)
 rename arch/mips/pci/{pci-ath724x.c => pci-ar724x.c} (100%)

diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index c3ac4b0..172277c 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -19,7 +19,7 @@ obj-$(CONFIG_BCM47XX)		+= pci-bcm47xx.o
 obj-$(CONFIG_BCM63XX)		+= pci-bcm63xx.o fixup-bcm63xx.o \
 					ops-bcm63xx.o
 obj-$(CONFIG_MIPS_ALCHEMY)	+= pci-alchemy.o
-obj-$(CONFIG_SOC_AR724X)	+= pci-ath724x.o
+obj-$(CONFIG_SOC_AR724X)	+= pci-ar724x.o
 
 #
 # These are still pretty much in the old state, watch, go blind.
diff --git a/arch/mips/pci/pci-ath724x.c b/arch/mips/pci/pci-ar724x.c
similarity index 100%
rename from arch/mips/pci/pci-ath724x.c
rename to arch/mips/pci/pci-ar724x.c
-- 
1.7.2.1

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

* [PATCH 6/7] MIPS: ath79: replace ath724x to ar724x
  2011-11-18 15:21 [PATCH 1/7] MIPS: ath79: separate common PCI code Gabor Juhos
                   ` (3 preceding siblings ...)
  2011-11-18 15:21 ` [PATCH 5/7] MIPS: ath79: rename pci-ath724x.c to make it reflect the real SoC name Gabor Juhos
@ 2011-11-18 15:21 ` Gabor Juhos
  2011-11-18 15:22 ` [PATCH 7/7] MIPS: ath79: use io-accessor macros in pci-ar724x.c Gabor Juhos
  5 siblings, 0 replies; 11+ messages in thread
From: Gabor Juhos @ 2011-11-18 15:21 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Rene Bolldorf, linux-mips, Gabor Juhos

Replace the 'ath724x' to 'ar724x' in function, variable and
structure names to reflect the name of the real SoC.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/ath79/mach-ubnt-xm.c         |    4 +-
 arch/mips/ath79/pci.c                  |    6 ++--
 arch/mips/ath79/pci.h                  |   10 +++---
 arch/mips/include/asm/mach-ath79/pci.h |    4 +-
 arch/mips/pci/pci-ar724x.c             |   62 ++++++++++++++++----------------
 5 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/arch/mips/ath79/mach-ubnt-xm.c b/arch/mips/ath79/mach-ubnt-xm.c
index 1d44cc2..2147b3a 100644
--- a/arch/mips/ath79/mach-ubnt-xm.c
+++ b/arch/mips/ath79/mach-ubnt-xm.c
@@ -84,7 +84,7 @@ static struct ath79_spi_platform_data ubnt_xm_spi_data = {
 #ifdef CONFIG_PCI
 static struct ath9k_platform_data ubnt_xm_eeprom_data;
 
-static struct ath724x_pci_data ubnt_xm_pci_data[] = {
+static struct ar724x_pci_data ubnt_xm_pci_data[] = {
 	{
 		.irq	= UBNT_XM_PCI_IRQ,
 		.pdata	= &ubnt_xm_eeprom_data,
@@ -108,7 +108,7 @@ static void __init ubnt_xm_init(void)
 	memcpy(ubnt_xm_eeprom_data.eeprom_data, UBNT_XM_EEPROM_ADDR,
 	       sizeof(ubnt_xm_eeprom_data.eeprom_data));
 
-	ath724x_pci_add_data(ubnt_xm_pci_data, ARRAY_SIZE(ubnt_xm_pci_data));
+	ar724x_pci_add_data(ubnt_xm_pci_data, ARRAY_SIZE(ubnt_xm_pci_data));
 #endif /* CONFIG_PCI */
 
 	ath79_register_pci();
diff --git a/arch/mips/ath79/pci.c b/arch/mips/ath79/pci.c
index a2dae75..9970e18 100644
--- a/arch/mips/ath79/pci.c
+++ b/arch/mips/ath79/pci.c
@@ -13,10 +13,10 @@
 #include <asm/mach-ath79/pci.h>
 #include "pci.h"
 
-static struct ath724x_pci_data *pci_data;
+static struct ar724x_pci_data *pci_data;
 static int pci_data_size;
 
-void ath724x_pci_add_data(struct ath724x_pci_data *data, int size)
+void ar724x_pci_add_data(struct ar724x_pci_data *data, int size)
 {
 	pci_data	= data;
 	pci_data_size	= size;
@@ -52,7 +52,7 @@ int ath79_register_pci(void)
 	int ret;
 
 	if (soc_is_ar724x())
-		ret = ath724x_pcibios_init();
+		ret = ar724x_pcibios_init();
 	else
 		ret = -ENODEV;
 
diff --git a/arch/mips/ath79/pci.h b/arch/mips/ath79/pci.h
index 4653ca8..34349bc 100644
--- a/arch/mips/ath79/pci.h
+++ b/arch/mips/ath79/pci.h
@@ -8,15 +8,15 @@
  *  by the Free Software Foundation.
  */
 
-#ifndef __ASM_MACH_ATH79_PCI_ATH724X_H
-#define __ASM_MACH_ATH79_PCI_ATH724X_H
+#ifndef _ATH79_PCI_H
+#define _ATH79_PCI_H
 
-struct ath724x_pci_data {
+struct ar724x_pci_data {
 	int irq;
 	void *pdata;
 };
 
-void ath724x_pci_add_data(struct ath724x_pci_data *data, int size);
+void ar724x_pci_add_data(struct ar724x_pci_data *data, int size);
 
 #ifdef CONFIG_PCI
 int ath79_register_pci(void);
@@ -24,4 +24,4 @@ int ath79_register_pci(void);
 static inline int ath79_register_pci(void) {};
 #endif
 
-#endif /* __ASM_MACH_ATH79_PCI_ATH724X_H */
+#endif /* _ATH79_PCI_H */
diff --git a/arch/mips/include/asm/mach-ath79/pci.h b/arch/mips/include/asm/mach-ath79/pci.h
index 7ef8a49..0aaf41f 100644
--- a/arch/mips/include/asm/mach-ath79/pci.h
+++ b/arch/mips/include/asm/mach-ath79/pci.h
@@ -12,9 +12,9 @@
 #define __ASM_MACH_ATH79_PCI_H
 
 #if defined(CONFIG_PCI) && defined(CONFIG_SOC_AR724X)
-int ath724x_pcibios_init(void);
+int ar724x_pcibios_init(void);
 #else
-static inline int ath724x_pcibios_init(void) { return 0 };
+static inline int ar724x_pcibios_init(void) { return 0 };
 #endif
 
 #endif /* __ASM_MACH_ATH79_PCI_H */
diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c
index ebefc16..772d12c 100644
--- a/arch/mips/pci/pci-ar724x.c
+++ b/arch/mips/pci/pci-ar724x.c
@@ -14,13 +14,13 @@
 #define reg_read(_phys)		(*(unsigned int *) KSEG1ADDR(_phys))
 #define reg_write(_phys, _val)	((*(unsigned int *) KSEG1ADDR(_phys)) = (_val))
 
-#define ATH724X_PCI_DEV_BASE	0x14000000
-#define ATH724X_PCI_MEM_BASE	0x10000000
-#define ATH724X_PCI_MEM_SIZE	0x08000000
+#define AR724X_PCI_DEV_BASE	0x14000000
+#define AR724X_PCI_MEM_BASE	0x10000000
+#define AR724X_PCI_MEM_SIZE	0x08000000
 
-static DEFINE_SPINLOCK(ath724x_pci_lock);
+static DEFINE_SPINLOCK(ar724x_pci_lock);
 
-static int ath724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
+static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
 			    int size, uint32_t *value)
 {
 	unsigned long flags, addr, tval, mask;
@@ -31,38 +31,38 @@ static int ath724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
 	if (where & (size - 1))
 		return PCIBIOS_BAD_REGISTER_NUMBER;
 
-	spin_lock_irqsave(&ath724x_pci_lock, flags);
+	spin_lock_irqsave(&ar724x_pci_lock, flags);
 
 	switch (size) {
 	case 1:
 		addr = where & ~3;
 		mask = 0xff000000 >> ((where % 4) * 8);
-		tval = reg_read(ATH724X_PCI_DEV_BASE + addr);
+		tval = reg_read(AR724X_PCI_DEV_BASE + addr);
 		tval = tval & ~mask;
 		*value = (tval >> ((4 - (where % 4))*8));
 		break;
 	case 2:
 		addr = where & ~3;
 		mask = 0xffff0000 >> ((where % 4)*8);
-		tval = reg_read(ATH724X_PCI_DEV_BASE + addr);
+		tval = reg_read(AR724X_PCI_DEV_BASE + addr);
 		tval = tval & ~mask;
 		*value = (tval >> ((4 - (where % 4))*8));
 		break;
 	case 4:
-		*value = reg_read(ATH724X_PCI_DEV_BASE + where);
+		*value = reg_read(AR724X_PCI_DEV_BASE + where);
 		break;
 	default:
-		spin_unlock_irqrestore(&ath724x_pci_lock, flags);
+		spin_unlock_irqrestore(&ar724x_pci_lock, flags);
 
 		return PCIBIOS_BAD_REGISTER_NUMBER;
 	}
 
-	spin_unlock_irqrestore(&ath724x_pci_lock, flags);
+	spin_unlock_irqrestore(&ar724x_pci_lock, flags);
 
 	return PCIBIOS_SUCCESSFUL;
 }
 
-static int ath724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
+static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
 			     int size, uint32_t value)
 {
 	unsigned long flags, tval, addr, mask;
@@ -73,11 +73,11 @@ static int ath724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
 	if (where & (size - 1))
 		return PCIBIOS_BAD_REGISTER_NUMBER;
 
-	spin_lock_irqsave(&ath724x_pci_lock, flags);
+	spin_lock_irqsave(&ar724x_pci_lock, flags);
 
 	switch (size) {
 	case 1:
-		addr = (ATH724X_PCI_DEV_BASE + where) & ~3;
+		addr = (AR724X_PCI_DEV_BASE + where) & ~3;
 		mask = 0xff000000 >> ((where % 4)*8);
 		tval = reg_read(addr);
 		tval = tval & ~mask;
@@ -85,7 +85,7 @@ static int ath724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
 		reg_write(addr, tval);
 		break;
 	case 2:
-		addr = (ATH724X_PCI_DEV_BASE + where) & ~3;
+		addr = (AR724X_PCI_DEV_BASE + where) & ~3;
 		mask = 0xffff0000 >> ((where % 4)*8);
 		tval = reg_read(addr);
 		tval = tval & ~mask;
@@ -93,47 +93,47 @@ static int ath724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
 		reg_write(addr, tval);
 		break;
 	case 4:
-		reg_write((ATH724X_PCI_DEV_BASE + where), value);
+		reg_write((AR724X_PCI_DEV_BASE + where), value);
 		break;
 	default:
-		spin_unlock_irqrestore(&ath724x_pci_lock, flags);
+		spin_unlock_irqrestore(&ar724x_pci_lock, flags);
 
 		return PCIBIOS_BAD_REGISTER_NUMBER;
 	}
 
-	spin_unlock_irqrestore(&ath724x_pci_lock, flags);
+	spin_unlock_irqrestore(&ar724x_pci_lock, flags);
 
 	return PCIBIOS_SUCCESSFUL;
 }
 
-static struct pci_ops ath724x_pci_ops = {
-	.read	= ath724x_pci_read,
-	.write	= ath724x_pci_write,
+static struct pci_ops ar724x_pci_ops = {
+	.read	= ar724x_pci_read,
+	.write	= ar724x_pci_write,
 };
 
-static struct resource ath724x_io_resource = {
+static struct resource ar724x_io_resource = {
 	.name   = "PCI IO space",
 	.start  = 0,
 	.end    = 0,
 	.flags  = IORESOURCE_IO,
 };
 
-static struct resource ath724x_mem_resource = {
+static struct resource ar724x_mem_resource = {
 	.name   = "PCI memory space",
-	.start  = ATH724X_PCI_MEM_BASE,
-	.end    = ATH724X_PCI_MEM_BASE + ATH724X_PCI_MEM_SIZE - 1,
+	.start  = AR724X_PCI_MEM_BASE,
+	.end    = AR724X_PCI_MEM_BASE + AR724X_PCI_MEM_SIZE - 1,
 	.flags  = IORESOURCE_MEM,
 };
 
-static struct pci_controller ath724x_pci_controller = {
-	.pci_ops        = &ath724x_pci_ops,
-	.io_resource    = &ath724x_io_resource,
-	.mem_resource	= &ath724x_mem_resource,
+static struct pci_controller ar724x_pci_controller = {
+	.pci_ops        = &ar724x_pci_ops,
+	.io_resource    = &ar724x_io_resource,
+	.mem_resource	= &ar724x_mem_resource,
 };
 
-int __init ath724x_pcibios_init(void)
+int __init ar724x_pcibios_init(void)
 {
-	register_pci_controller(&ath724x_pci_controller);
+	register_pci_controller(&ar724x_pci_controller);
 
 	return PCIBIOS_SUCCESSFUL;
 }
-- 
1.7.2.1

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

* [PATCH 7/7] MIPS: ath79: use io-accessor macros in pci-ar724x.c
  2011-11-18 15:21 [PATCH 1/7] MIPS: ath79: separate common PCI code Gabor Juhos
                   ` (4 preceding siblings ...)
  2011-11-18 15:21 ` [PATCH 6/7] MIPS: ath79: replace ath724x to ar724x Gabor Juhos
@ 2011-11-18 15:22 ` Gabor Juhos
  2011-11-18 17:26   ` Gabor Juhos
  5 siblings, 1 reply; 11+ messages in thread
From: Gabor Juhos @ 2011-11-18 15:22 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Rene Bolldorf, linux-mips, Gabor Juhos

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/pci/pci-ar724x.c |   43 +++++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c
index 772d12c..27083d3 100644
--- a/arch/mips/pci/pci-ar724x.c
+++ b/arch/mips/pci/pci-ar724x.c
@@ -11,19 +11,19 @@
 #include <linux/pci.h>
 #include <asm/mach-ath79/pci.h>
 
-#define reg_read(_phys)		(*(unsigned int *) KSEG1ADDR(_phys))
-#define reg_write(_phys, _val)	((*(unsigned int *) KSEG1ADDR(_phys)) = (_val))
-
-#define AR724X_PCI_DEV_BASE	0x14000000
+#define AR724X_PCI_CFG_BASE	0x14000000
+#define AR724X_PCI_CFG_SIZE	0x1000
 #define AR724X_PCI_MEM_BASE	0x10000000
 #define AR724X_PCI_MEM_SIZE	0x08000000
 
 static DEFINE_SPINLOCK(ar724x_pci_lock);
+static void __iomem *ar724x_pci_devcfg_base;
 
 static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
 			    int size, uint32_t *value)
 {
 	unsigned long flags, addr, tval, mask;
+	void __iomem *base;
 
 	if (devfn)
 		return PCIBIOS_DEVICE_NOT_FOUND;
@@ -31,25 +31,27 @@ static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
 	if (where & (size - 1))
 		return PCIBIOS_BAD_REGISTER_NUMBER;
 
+	base = ar724x_pci_devcfg_base;
+
 	spin_lock_irqsave(&ar724x_pci_lock, flags);
 
 	switch (size) {
 	case 1:
 		addr = where & ~3;
 		mask = 0xff000000 >> ((where % 4) * 8);
-		tval = reg_read(AR724X_PCI_DEV_BASE + addr);
+		tval = __raw_readl(base + addr);
 		tval = tval & ~mask;
 		*value = (tval >> ((4 - (where % 4))*8));
 		break;
 	case 2:
 		addr = where & ~3;
 		mask = 0xffff0000 >> ((where % 4)*8);
-		tval = reg_read(AR724X_PCI_DEV_BASE + addr);
+		tval = __raw_readl(base + addr);
 		tval = tval & ~mask;
 		*value = (tval >> ((4 - (where % 4))*8));
 		break;
 	case 4:
-		*value = reg_read(AR724X_PCI_DEV_BASE + where);
+		*value = __raw_readl(base + where);
 		break;
 	default:
 		spin_unlock_irqrestore(&ar724x_pci_lock, flags);
@@ -66,6 +68,7 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
 			     int size, uint32_t value)
 {
 	unsigned long flags, tval, addr, mask;
+	void __iomem *base;
 
 	if (devfn)
 		return PCIBIOS_DEVICE_NOT_FOUND;
@@ -73,27 +76,29 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
 	if (where & (size - 1))
 		return PCIBIOS_BAD_REGISTER_NUMBER;
 
+	base = ar724x_pci_devcfg_base;
+
 	spin_lock_irqsave(&ar724x_pci_lock, flags);
 
 	switch (size) {
 	case 1:
-		addr = (AR724X_PCI_DEV_BASE + where) & ~3;
+		addr = where & ~3;
 		mask = 0xff000000 >> ((where % 4)*8);
-		tval = reg_read(addr);
+		tval = __raw_readl(base + addr);
 		tval = tval & ~mask;
 		tval |= (value << ((4 - (where % 4))*8)) & mask;
-		reg_write(addr, tval);
+		__raw_writel(tval, base + addr);
 		break;
 	case 2:
-		addr = (AR724X_PCI_DEV_BASE + where) & ~3;
+		addr = where & ~3;
 		mask = 0xffff0000 >> ((where % 4)*8);
-		tval = reg_read(addr);
+		tval = __raw_readl(base + addr);
 		tval = tval & ~mask;
 		tval |= (value << ((4 - (where % 4))*8)) & mask;
-		reg_write(addr, tval);
+		__raw_writel(tval, base + addr);
 		break;
 	case 4:
-		reg_write((AR724X_PCI_DEV_BASE + where), value);
+		__raw_writel(value, (base + where));
 		break;
 	default:
 		spin_unlock_irqrestore(&ar724x_pci_lock, flags);
@@ -133,7 +138,17 @@ static struct pci_controller ar724x_pci_controller = {
 
 int __init ar724x_pcibios_init(void)
 {
+	int ret;
+
+	ar724x_pci_devcfg_base = ioremap(AR724X_PCI_CFG_BASE,
+					 AR724X_PCI_CFG_SIZE);
+	if (ar724x_pci_devcfg_base == NULL)
+		goto err;
+
 	register_pci_controller(&ar724x_pci_controller);
 
 	return PCIBIOS_SUCCESSFUL;
+
+err:
+	return ret;
 }
-- 
1.7.2.1

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

* Re: [PATCH 7/7] MIPS: ath79: use io-accessor macros in pci-ar724x.c
  2011-11-18 15:22 ` [PATCH 7/7] MIPS: ath79: use io-accessor macros in pci-ar724x.c Gabor Juhos
@ 2011-11-18 17:26   ` Gabor Juhos
  0 siblings, 0 replies; 11+ messages in thread
From: Gabor Juhos @ 2011-11-18 17:26 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: Ralf Baechle, Rene Bolldorf, linux-mips

2011.11.18. 16:22 keltezéssel, Gabor Juhos írta:
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> ---
>  arch/mips/pci/pci-ar724x.c |   43 +++++++++++++++++++++++++++++--------------
>  1 files changed, 29 insertions(+), 14 deletions(-)
> 

<...>

>  
>  int __init ar724x_pcibios_init(void)
>  {
> +	int ret;
> +
> +	ar724x_pci_devcfg_base = ioremap(AR724X_PCI_CFG_BASE,
> +					 AR724X_PCI_CFG_SIZE);
> +	if (ar724x_pci_devcfg_base == NULL)
> +		goto err;
> +
>  	register_pci_controller(&ar724x_pci_controller);
>  
>  	return PCIBIOS_SUCCESSFUL;
> +
> +err:
> +	return ret;
>  }

I have messed up this part, will send a replacement patch.

Gabor

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

* Re: [PATCH 4/7] MIPS: ath79: add a common PCI registration function
  2011-11-18 15:21 ` [PATCH 4/7] MIPS: ath79: add a common PCI registration function Gabor Juhos
@ 2011-11-18 18:32   ` René Bolldorf
  2011-11-18 18:41     ` Gabor Juhos
  0 siblings, 1 reply; 11+ messages in thread
From: René Bolldorf @ 2011-11-18 18:32 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: Ralf Baechle, linux-mips

On Fri, Nov 18, 2011 at 4:21 PM, Gabor Juhos <juhosg@openwrt.org> wrote:
> The current code unconditionally registers the AR724X
> specific PCI controller, even if the kernel is running
> on a different SoC.
>
This is not true, take a look in the ath79 Kconfig file...

> Add a common function for PCI controller registration,
> and only register the AR724X PCI controller if the kernel
> is running on an AR724X SoC.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> ---
>  arch/mips/ath79/mach-ubnt-xm.c |    1 +
>  arch/mips/ath79/pci.c          |   14 ++++++++++++++
>  arch/mips/ath79/pci.h          |    6 ++++++
>  arch/mips/pci/pci-ath724x.c    |    2 --
>  4 files changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips/ath79/mach-ubnt-xm.c b/arch/mips/ath79/mach-ubnt-xm.c
> index 5853bd7..1d44cc2 100644
> --- a/arch/mips/ath79/mach-ubnt-xm.c
> +++ b/arch/mips/ath79/mach-ubnt-xm.c
> @@ -111,6 +111,7 @@ static void __init ubnt_xm_init(void)
>        ath724x_pci_add_data(ubnt_xm_pci_data, ARRAY_SIZE(ubnt_xm_pci_data));
>  #endif /* CONFIG_PCI */
>
> +       ath79_register_pci();
>  }
>
>  MIPS_MACHINE(ATH79_MACH_UBNT_XM,
> diff --git a/arch/mips/ath79/pci.c b/arch/mips/ath79/pci.c
> index 4957428..a2dae75 100644
> --- a/arch/mips/ath79/pci.c
> +++ b/arch/mips/ath79/pci.c
> @@ -9,6 +9,8 @@
>  */
>
>  #include <linux/pci.h>
> +#include <asm/mach-ath79/ath79.h>
> +#include <asm/mach-ath79/pci.h>
>  #include "pci.h"
>
>  static struct ath724x_pci_data *pci_data;
> @@ -44,3 +46,15 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
>
>        return PCIBIOS_SUCCESSFUL;
>  }
> +
> +int ath79_register_pci(void)
> +{
> +       int ret;
> +
> +       if (soc_is_ar724x())
> +               ret = ath724x_pcibios_init();
> +       else
> +               ret = -ENODEV;
> +
> +       return ret;
> +}
> diff --git a/arch/mips/ath79/pci.h b/arch/mips/ath79/pci.h
> index 454885f..4653ca8 100644
> --- a/arch/mips/ath79/pci.h
> +++ b/arch/mips/ath79/pci.h
> @@ -18,4 +18,10 @@ struct ath724x_pci_data {
>
>  void ath724x_pci_add_data(struct ath724x_pci_data *data, int size);
>
> +#ifdef CONFIG_PCI
> +int ath79_register_pci(void);
> +#else
> +static inline int ath79_register_pci(void) {};
> +#endif
> +
>  #endif /* __ASM_MACH_ATH79_PCI_ATH724X_H */
> diff --git a/arch/mips/pci/pci-ath724x.c b/arch/mips/pci/pci-ath724x.c
> index be01b7f..ebefc16 100644
> --- a/arch/mips/pci/pci-ath724x.c
> +++ b/arch/mips/pci/pci-ath724x.c
> @@ -137,5 +137,3 @@ int __init ath724x_pcibios_init(void)
>
>        return PCIBIOS_SUCCESSFUL;
>  }
> -
> -arch_initcall(ath724x_pcibios_init);
> --
> 1.7.2.1
>
>

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

* Re: [PATCH 4/7] MIPS: ath79: add a common PCI registration function
  2011-11-18 18:32   ` René Bolldorf
@ 2011-11-18 18:41     ` Gabor Juhos
       [not found]       ` <CAEWqx5_kuqeoHz=iNq5vDUX92zboBVksZ4JsyyEwk4tTaND77A@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Gabor Juhos @ 2011-11-18 18:41 UTC (permalink / raw)
  To: René Bolldorf; +Cc: Ralf Baechle, linux-mips

2011.11.18. 19:32 keltezéssel, René Bolldorf írta:
> On Fri, Nov 18, 2011 at 4:21 PM, Gabor Juhos <juhosg@openwrt.org> wrote:
>> The current code unconditionally registers the AR724X
>> specific PCI controller, even if the kernel is running
>> on a different SoC.
>>
> This is not true, take a look in the ath79 Kconfig file...

Well, it is true. If you have the Ubiquiti board selected, that will allow you
to select the PCI code to be built. If you select the PCI code as well, then
pci-ath724x.c will be compiled into the kernel. Due to the nature of the
'arch_initcall' macro the PCI controller always gets registered. If you have
another board selected along with the Ubiquiti, and you are trying to run the
kernel on the other board, the PCI controller will be registered on that as well.

-Gabor

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

* Re: [PATCH 4/7] MIPS: ath79: add a common PCI registration function
       [not found]         ` <4EC6AA03.2010805@openwrt.org>
@ 2011-11-18 18:58           ` René Bolldorf
  0 siblings, 0 replies; 11+ messages in thread
From: René Bolldorf @ 2011-11-18 18:58 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: Ralf Baechle, linux-mips

2011/11/18 Gabor Juhos <juhosg@openwrt.org>:
> 2011.11.18. 19:44 keltezéssel, René Bolldorf írta:
>> 2011/11/18 Gabor Juhos <juhosg@openwrt.org>:
>>> 2011.11.18. 19:32 keltezéssel, René Bolldorf írta:
>>>> On Fri, Nov 18, 2011 at 4:21 PM, Gabor Juhos <juhosg@openwrt.org> wrote:
>>>>> The current code unconditionally registers the AR724X
>>>>> specific PCI controller, even if the kernel is running
>>>>> on a different SoC.
>>>>>
>>>> This is not true, take a look in the ath79 Kconfig file...
>>>
>>> Well, it is true. If you have the Ubiquiti board selected, that will allow you
>>> to select the PCI code to be built. If you select the PCI code as well, then
>>> pci-ath724x.c will be compiled into the kernel. Due to the nature of the
>>> 'arch_initcall' macro the PCI controller always gets registered. If you have
>>> another board selected along with the Ubiquiti, and you are trying to run the
>>> kernel on the other board, the PCI controller will be registered on that as well.
>>>
>>> -Gabor
>>>
>>
>> Apologies again, got a thinko :)
>
> No problem. BTW, you forgot to reply to all again. ;)
>
> -Gabor
>

Well, I should change my settings....

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

end of thread, other threads:[~2011-11-18 18:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-18 15:21 [PATCH 1/7] MIPS: ath79: separate common PCI code Gabor Juhos
2011-11-18 15:21 ` [PATCH 2/7] MIPS: ath79: rename pci-ath724x.h Gabor Juhos
2011-11-18 15:21 ` [PATCH 3/7] MIPS: ath79: make ath724x_pcibios_init visible for external code Gabor Juhos
2011-11-18 15:21 ` [PATCH 4/7] MIPS: ath79: add a common PCI registration function Gabor Juhos
2011-11-18 18:32   ` René Bolldorf
2011-11-18 18:41     ` Gabor Juhos
     [not found]       ` <CAEWqx5_kuqeoHz=iNq5vDUX92zboBVksZ4JsyyEwk4tTaND77A@mail.gmail.com>
     [not found]         ` <4EC6AA03.2010805@openwrt.org>
2011-11-18 18:58           ` René Bolldorf
2011-11-18 15:21 ` [PATCH 5/7] MIPS: ath79: rename pci-ath724x.c to make it reflect the real SoC name Gabor Juhos
2011-11-18 15:21 ` [PATCH 6/7] MIPS: ath79: replace ath724x to ar724x Gabor Juhos
2011-11-18 15:22 ` [PATCH 7/7] MIPS: ath79: use io-accessor macros in pci-ar724x.c Gabor Juhos
2011-11-18 17:26   ` 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.