Skip to contentSkip to conversation

Introduce a Marvell EBU MBus driver

PATCH Superseded Thomas Petazzoni 5 participants 21 messages Mar 21, 2013 – Mar 30, 2013

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

Hello,

As part of the work to write a DT-powered PCIe driver for Marvell SoCs that sits in drivers/pci/host/, it appeared that including <mach/addr-map.h> from the PCIe driver to get access to address decoding windows functions was not acceptable.

In order to fix this problem, this patch set introduces a driver for the Marvell EBU MBus driver in drivers/bus/mvebu-mbus.c. It consolidates into a single driver the address decoding code that was spread in mach-{mvebu,kirkwood,orion5x,mv78xx0,dove}/addr-map.c and plat-orion/addr-map.c. The driver provides two APIs:

* A mv_mbus_dram_info() that is used by many Marvell device drivers throughout the tree to get the list of DRAM address decoding windows they have to set up. This API was previously implemented in plat-orion/addr-map.c and is kept unchanged in order to not change the drivers.

* mvebu_mbus_add_window() / mvebu_mbus_del_window() functions to add and remove address decoding windows for a given device. Those functions have to be called either from the platform code, or from device drivers.

The driver can only be probed using a legacy (non-DT) mvebu_mbus_init() function call. This allows: 1/ to migrate the five families of Marvell EBU SoCs to use this driver and 2/ to postpone the work on defining a correct DT binding for this driver.

Note that this driver is only a consolidation, and that further improvements to the address decoding handling could be done in the future (dynamically allocating the physical range using request_resource(), describing some of the static windows in DT, etc.). We intentionally do not want those improvements to be done right now, in order to keep the amount of changes reasonable. The driver as it is is sufficient to cover the existing needs, and the needs of the upcoming PCIe driver and Device Bus driver.

This patch set is based on arm-soc/mvebu/cleanup, which already includes 3 patches from previous versions of this patch set. Therefore, those 3 cleanup patches are no longer included.

Summary of the patch set:

* Patch 1 introduces the mvebu-mbus driver itself, with the support for all 5 Marvell EBU SoC families. Note that the driver is compiled through a blind option, because we don't want the driver to be compiled in unless the corresponding sub-architecture has been migrated to use it: as explained above, compiling the driver conflicts with compiling the plat-orion/addr-map.c code.

* Patch 2 to 6 moves each Marvell EBU sub-architecture to use the mvebu-mbus driver.

* Patch 7 removes the now unused plat-orion/addr-map.c code.

Changes since v2:

* Remove the DT binding, and use the mvebu_mbus_init() function call in all Marvell EBU SoC families. Requested by Arnd Bergmann.

* Fix the MV78xx0 code, after reports of issues by Gregory Clement when testing on this platform.

* Remove the 3 patches that have been merged by Arnd in arm-soc/mvebu-cleanup.

Changes since v1:

* Fix the compatible string used in armada-370.dtsi: it was incorrectly using marvell,armadaxp-mbus instead of marvell,armada370-mbus.

* Fix the reg = <...> property for Kirkwood and Dove, the address for the devices address decoding windows was not correct.

* Fix a 'git rebase -i' mistake that lead to have some code that should have been in PATCH 4 (the driver code) into PATCH 5 (switching mach-mvebu to use the driver).

* Fix the Device Tree documentation of the driver, which was giving a wrong address.

* And since I didn't want to do a v2 just to fix my stupid mistakes, I also added a big comment at the beginning of the driver's code that explains what the driver is doing.

Sebastian, Andrew, Gregory, it would be good if you could retest this new version on Dove, Kirkwood and MV78xx0 respectively. Thanks!

For easier testing, I've pushed a branch at:

https://github.com/MISL-EBU-System-SW/mainline-public/commits/marvell-mvebu-mbus-v3

Since other drivers will depend on this one, I'd appreciate if this code could be merged early in the 3.10 cycle.

Thanks for your reviews,

Thomas

#1 lore raw

PATCH v3 1/7 bus: introduce an Marvell EBU MBus driver

The Marvell EBU SoCs have a configurable physical address space
layout: the physical ranges of memory used to address PCI(e) interfaces, NOR flashes, SRAM and various other types of memory are configurable by software, through a mechanism of so-called 'address decoding windows'.

This new driver mvebu-mbus consolidates the existing code to address the configuration of these memory ranges, which is spread into mach-mvebu, mach-orion5x, mach-mv78xx0, mach-dove and mach-kirkwood.

Following patches convert each Marvell EBU SoC family to use this driver, therefore removing the old code that was configuring the address decoding windows.

It is worth mentioning that the MVEBU_MBUS Kconfig option is intentionally added as a blind option. The new driver implements and exports the mv_mbus_dram_info() function, which is used by various Marvell drivers throughout the tree to get access to window configuration parameters that they require. This function is also implemented in arch/arm/plat-orion/addr-map.c, which ultimately gets removed at the end of this patch series. So, in order to preserve bisectability, we want to ensure that *either* this new driver, *or* the legacy code in plat-orion/addr-map.c gets compiled in.

By making MVEBU_MBUS a blind option, we are sure that only a platform that does 'select MVEBU_MBUS' will get this new driver compiled in. Therefore, throughout the next patches that convert the Marvell sub-architectures one after the other to this new driver, we add the 'select MVEBU_MBUS' and also ensure to remove plat-orion/addr-map.c from the build for this specific sub-architecture. This ensures that bisectability is preserved.

Ealier versions of this driver had a DT binding, but since those were not yet agreed upon, they were removed. The driver still uses of_device_id to find the SoC specific details according to the string passed to mvebu_mbus_init(). The plan is to re-introduce a proper DT binding as a followup set of patches.

---
 drivers/bus/Kconfig      |    7 +
 drivers/bus/Makefile     |    1 +
 drivers/bus/mvebu-mbus.c |  867 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mbus.h     |   24 +-
 4 files changed, 898 insertions(+), 1 deletion(-)
 create mode 100644 drivers/bus/mvebu-mbus.c
drivers/bus/Kconfig +7 -0
index 0f51ed6..b05ecab 100644
@@ -4,6 +4,13 @@
 
 menu "Bus devices"
 
+config MVEBU_MBUS
+	bool
+	depends on PLAT_ORION
+	help
+	  Driver needed for the MBus configuration on Marvell EBU SoCs
+	  (Kirkwood, Dove, Orion5x, MV78XX0 and Armada 370/XP).
+
 config OMAP_OCP2SCP
 	tristate "OMAP OCP2SCP DRIVER"
 	depends on ARCH_OMAP2PLUS
drivers/bus/Makefile +1 -0
index 45d997c..3c7b53c 100644
@@ -2,6 +2,7 @@
 # Makefile for the bus drivers.
 #
 
+obj-$(CONFIG_MVEBU_MBUS) += mvebu-mbus.o
 obj-$(CONFIG_OMAP_OCP2SCP)	+= omap-ocp2scp.o
 
 # Interconnect bus driver for OMAP SoCs.
drivers/bus/mvebu-mbus.c new file +867 -0

867 lines not on this page · raw message

include/linux/mbus.h +23 -1
index efa1a6d..462eb97 100644
@@ -32,6 +32,17 @@ struct mbus_dram_target_info
 	} cs[4];
 };
 
+/* Flags for PCI/PCIe address decoding regions */
+#define MVEBU_MBUS_PCI_IO  0x1
+#define MVEBU_MBUS_PCI_MEM 0x2
+#define MVEBU_MBUS_PCI_WA  0x3
+
+/*
+ * Magic value that explicits that we don't need a remapping-capable
+ * address decoding window.
+ */
+#define MVEBU_MBUS_NO_REMAP (0xffffffff)
+
 /*
  * The Marvell mbus is to be found only on SOCs from the Orion family
  * at the moment.  Provide a dummy stub for other architectures.
@@ -44,4 +55,15 @@ static inline const struct mbus_dram_target_info *mv_mbus_dram_info(void)
 	return NULL;
 }
 #endif
-#endif
+
+int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base,
+				      size_t size, phys_addr_t remap,
+				      unsigned int flags);
+int mvebu_mbus_add_window(const char *devname, phys_addr_t base,
+			  size_t size);
+int mvebu_mbus_del_window(phys_addr_t base, size_t size);
+int mvebu_mbus_init(const char *soc, phys_addr_t mbus_phys_base,
+		    size_t mbus_size, phys_addr_t sdram_phys_base,
+		    size_t sdram_size);
+
+#endif /* __LINUX_MBUS_H */
Signature · 1 line
1.7.9.5
Applied
#2 lore raw

PATCH v3 1/7 bus: introduce an Marvell EBU MBus driver

Quoted 38 lines · Thomas Petazzoni

The Marvell EBU SoCs have a configurable physical address space
layout: the physical ranges of memory used to address PCI(e) interfaces, NOR flashes, SRAM and various other types of memory are configurable by software, through a mechanism of so-called 'address decoding windows'.

This new driver mvebu-mbus consolidates the existing code to address the configuration of these memory ranges, which is spread into mach-mvebu, mach-orion5x, mach-mv78xx0, mach-dove and mach-kirkwood.

Following patches convert each Marvell EBU SoC family to use this driver, therefore removing the old code that was configuring the address decoding windows.

It is worth mentioning that the MVEBU_MBUS Kconfig option is intentionally added as a blind option. The new driver implements and exports the mv_mbus_dram_info() function, which is used by various Marvell drivers throughout the tree to get access to window configuration parameters that they require. This function is also implemented in arch/arm/plat-orion/addr-map.c, which ultimately gets removed at the end of this patch series. So, in order to preserve bisectability, we want to ensure that *either* this new driver, *or* the legacy code in plat-orion/addr-map.c gets compiled in.

By making MVEBU_MBUS a blind option, we are sure that only a platform that does 'select MVEBU_MBUS' will get this new driver compiled in. Therefore, throughout the next patches that convert the Marvell sub-architectures one after the other to this new driver, we add the 'select MVEBU_MBUS' and also ensure to remove plat-orion/addr-map.c from the build for this specific sub-architecture. This ensures that bisectability is preserved.

Ealier versions of this driver had a DT binding, but since those were not yet agreed upon, they were removed. The driver still uses of_device_id to find the SoC specific details according to the string passed to mvebu_mbus_init(). The plan is to re-introduce a proper DT binding as a followup set of patches.

Quoted 8 lines
---
 drivers/bus/Kconfig      |    7 +
 drivers/bus/Makefile     |    1 +
 drivers/bus/mvebu-mbus.c |  867 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mbus.h     |   24 +-
 4 files changed, 898 insertions(+), 1 deletion(-)
 create mode 100644 drivers/bus/mvebu-mbus.c

Applied to mvebu/drivers as there is no drivers/bus maintainer

thx,

Jason.

#3 lore raw

PATCH v3 2/7 arm: mach-mvebu: convert to use mvebu-mbus driver

In reply to Thomas Petazzoni

The changes needed to migrate the mach-mvebu (Armada 370 and Armada XP) to the mvebu-mbus driver are fairly minimal, since not many devices currently supported on those SoCs use address decoding windows. The only one being the BootROM window, used to bring up secondary CPUs.

However, this BootROM window needed for SMP brings an important
requirement: the mvebu-mbus driver must be initialized at the ->early_init() time, otherwise the BootROM window cannot be setup early enough to be ready before the secondary CPUs are started.

---
 arch/arm/boot/dts/armada-370-xp.dtsi |    5 --
 arch/arm/mach-mvebu/Kconfig          |    1 +
 arch/arm/mach-mvebu/Makefile         |    2 +-
 arch/arm/mach-mvebu/addr-map.c       |  137 ----------------------------------
 arch/arm/mach-mvebu/armada-370-xp.c  |   18 +++++
 arch/arm/mach-mvebu/armada-370-xp.h  |    6 ++
 arch/arm/mach-mvebu/platsmp.c        |    2 +
 arch/arm/plat-orion/Makefile         |    1 -
 8 files changed, 28 insertions(+), 144 deletions(-)
 delete mode 100644 arch/arm/mach-mvebu/addr-map.c
arch/arm/boot/dts/armada-370-xp.dtsi +0 -5
index 6f1acc7..38aaa3f 100644
@@ -74,11 +74,6 @@
 			       clocks = <&coreclk 2>;
 		};
 
-		addr-decoding at d0020000 {
-			compatible = "marvell,armada-addr-decoding-controller";
-			reg = <0xd0020000 0x258>;
-		};
-
 		sata at d00a0000 {
 			compatible = "marvell,orion-sata";
 			reg = <0xd00a0000 0x2400>;
arch/arm/mach-mvebu/Kconfig +1 -0
index 440b13e..c3715a5 100644
@@ -13,6 +13,7 @@ config ARCH_MVEBU
 	select MVEBU_CLK_CORE
 	select MVEBU_CLK_CPU
 	select MVEBU_CLK_GATING
+	select MVEBU_MBUS
 
 if ARCH_MVEBU
 
arch/arm/mach-mvebu/Makefile +1 -1
index da93bcb..ba769e0 100644
@@ -5,6 +5,6 @@ AFLAGS_coherency_ll.o		:= -Wa,-march=armv7-a
 
 obj-y				 += system-controller.o
 obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o
-obj-$(CONFIG_ARCH_MVEBU)	 += addr-map.o coherency.o coherency_ll.o pmsu.o irq-armada-370-xp.o 
+obj-$(CONFIG_ARCH_MVEBU)	 += coherency.o coherency_ll.o pmsu.o irq-armada-370-xp.o
 obj-$(CONFIG_SMP)                += platsmp.o headsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)        += hotplug.o
arch/arm/mach-mvebu/addr-map.c deleted +0 -137

137 lines not on this page · raw message

arch/arm/mach-mvebu/armada-370-xp.c +18 -0
index a5ea616d..12d3655 100644
@@ -19,6 +19,7 @@
 #include <linux/time-armada-370-xp.h>
 #include <linux/clk/mvebu.h>
 #include <linux/dma-mapping.h>
+#include <linux/mbus.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
@@ -48,12 +49,29 @@ void __init armada_370_xp_timer_and_clk_init(void)
 
 void __init armada_370_xp_init_early(void)
 {
+	char *mbus_soc_name;
+
 	/*
 	 * Some Armada 370/XP devices allocate their coherent buffers
 	 * from atomic context. Increase size of atomic coherent pool
 	 * to make sure such the allocations won't fail.
 	 */
 	init_dma_coherent_pool_size(SZ_1M);
+
+	/*
+	 * This initialization will be replaced by a DT-based
+	 * initialization once the mvebu-mbus driver gains DT support.
+	 */
+	if (of_machine_is_compatible("marvell,armada370"))
+		mbus_soc_name = "marvell,armada370-mbus";
+	else
+		mbus_soc_name = "marvell,armadaxp-mbus";
+
+	mvebu_mbus_init(mbus_soc_name,
+			ARMADA_370_XP_MBUS_WINS_BASE,
+			ARMADA_370_XP_MBUS_WINS_SIZE,
+			ARMADA_370_XP_SDRAM_WINS_BASE,
+			ARMADA_370_XP_SDRAM_WINS_SIZE);
 }
 
 static void __init armada_370_xp_dt_init(void)
arch/arm/mach-mvebu/armada-370-xp.h +6 -0
index c6a7d74..9783087 100644
@@ -19,6 +19,12 @@
 #define ARMADA_370_XP_REGS_VIRT_BASE	IOMEM(0xfeb00000)
 #define ARMADA_370_XP_REGS_SIZE		SZ_1M
 
+/* These defines can go away once mvebu-mbus has a DT binding */
+#define ARMADA_370_XP_MBUS_WINS_BASE    (ARMADA_370_XP_REGS_PHYS_BASE + 0x20000)
+#define ARMADA_370_XP_MBUS_WINS_SIZE    0x100
+#define ARMADA_370_XP_SDRAM_WINS_BASE   (ARMADA_370_XP_REGS_PHYS_BASE + 0x20180)
+#define ARMADA_370_XP_SDRAM_WINS_SIZE   0x20
+
 #ifdef CONFIG_SMP
 #include <linux/cpumask.h>
 
arch/arm/mach-mvebu/platsmp.c +2 -0
index fe16aaf..875ea74 100644
@@ -21,6 +21,7 @@
 #include <linux/smp.h>
 #include <linux/clk.h>
 #include <linux/of.h>
+#include <linux/mbus.h>
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
 #include "common.h"
@@ -109,6 +110,7 @@ void __init armada_xp_smp_prepare_cpus(unsigned int max_cpus)
 	set_secondary_cpus_clock();
 	flush_cache_all();
 	set_cpu_coherent(cpu_logical_map(smp_processor_id()), 0);
+	mvebu_mbus_add_window("bootrom", 0xfff00000, SZ_1M);
 }
 
 struct smp_operations armada_xp_smp_ops __initdata = {
arch/arm/plat-orion/Makefile +0 -1
index ad97400..6cfc89f 100644
@@ -3,7 +3,6 @@
 #
 ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include
 
-obj-$(CONFIG_ARCH_MVEBU)          += addr-map.o
 obj-$(CONFIG_ARCH_KIRKWOOD)       += addr-map.o
 obj-$(CONFIG_ARCH_DOVE)           += addr-map.o
 obj-$(CONFIG_ARCH_ORION5X)        += addr-map.o
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v3 3/7 arm: mach-kirkwood: convert to use mvebu-mbus driver

In reply to Thomas Petazzoni

This commit migrates the mach-kirkwood platforms to use the mvebu-mbus driver and therefore removes the Kirkwood-specific addr-map code.

The kirkwood_init_early() function is now responsible for initializing the mvebu-mbus driver by calling mvebu_mbus_init().

The address decoding windows are now registered in the kirkwood_setup_wins() function. It is worth noting that the four PCIe address decoding windows will ultimately no longer have to be registered here: it will be done automatically by the PCIe driver once Kirkwood has been migrated to use the upcoming mvebu PCIe driver.

---
 arch/arm/Kconfig                               |    1 +
 arch/arm/mach-kirkwood/Makefile                |    2 +-
 arch/arm/mach-kirkwood/addr-map.c              |   91 ------------------------
 arch/arm/mach-kirkwood/board-dt.c              |    2 +-
 arch/arm/mach-kirkwood/common.c                |   38 +++++++++-
 arch/arm/mach-kirkwood/common.h                |    2 +-
 arch/arm/mach-kirkwood/include/mach/kirkwood.h |    7 +-
 arch/arm/mach-kirkwood/pcie.c                  |    1 -
 arch/arm/plat-orion/Makefile                   |    1 -
 9 files changed, 45 insertions(+), 100 deletions(-)
 delete mode 100644 arch/arm/mach-kirkwood/addr-map.c
arch/arm/Kconfig +1 -0
index 5b71469..544767b 100644
@@ -577,6 +577,7 @@ config ARCH_KIRKWOOD
 	select PINCTRL
 	select PINCTRL_KIRKWOOD
 	select PLAT_ORION_LEGACY
+	select MVEBU_MBUS
 	help
 	  Support for the following Marvell Kirkwood series SoCs:
 	  88F6180, 88F6192 and 88F6281.
arch/arm/mach-kirkwood/Makefile +1 -1
index 4cc4bee..d805f80 100644
@@ -1,4 +1,4 @@
-obj-y				+= common.o addr-map.o irq.o pcie.o mpp.o
+obj-y				+= common.o irq.o pcie.o mpp.o
 
 obj-$(CONFIG_MACH_DB88F6281_BP)		+= db88f6281-bp-setup.o
 obj-$(CONFIG_MACH_RD88F6192_NAS)	+= rd88f6192-nas-setup.o
arch/arm/mach-kirkwood/addr-map.c deleted +0 -91

91 lines not on this page · raw message

arch/arm/mach-kirkwood/board-dt.c +1 -1
index 2e73e9d..ea49476 100644
@@ -82,7 +82,7 @@ static void __init kirkwood_dt_init(void)
 	 */
 	writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
 
-	kirkwood_setup_cpu_mbus();
+	kirkwood_setup_wins();
 
 	kirkwood_l2_init();
 
arch/arm/mach-kirkwood/common.c +36 -2
index 49792a0..c2cae69 100644
@@ -33,7 +33,6 @@
 #include <linux/platform_data/usb-ehci-orion.h>
 #include <plat/common.h>
 #include <plat/time.h>
-#include <plat/addr-map.h>
 #include <linux/platform_data/dma-mv_xor.h>
 #include "common.h"
 
@@ -535,6 +534,9 @@ void __init kirkwood_init_early(void)
 	 * the allocations won't fail.
 	 */
 	init_dma_coherent_pool_size(SZ_1M);
+	mvebu_mbus_init("marvell,kirkwood-mbus",
+			BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
+			DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ);
 }
 
 int kirkwood_tclk;
@@ -650,6 +652,38 @@ char * __init kirkwood_id(void)
 	}
 }
 
+void __init kirkwood_setup_wins(void)
+{
+	/*
+	 * The PCIe windows will no longer be statically allocated
+	 * here once Kirkwood is migrated to the pci-mvebu driver.
+	 */
+	mvebu_mbus_add_window_remap_flags("pcie0.0",
+					  KIRKWOOD_PCIE_IO_PHYS_BASE,
+					  KIRKWOOD_PCIE_IO_SIZE,
+					  KIRKWOOD_PCIE_IO_BUS_BASE,
+					  MVEBU_MBUS_PCI_IO);
+	mvebu_mbus_add_window_remap_flags("pcie0.0",
+					  KIRKWOOD_PCIE_MEM_PHYS_BASE,
+					  KIRKWOOD_PCIE_MEM_SIZE,
+					  MVEBU_MBUS_NO_REMAP,
+					  MVEBU_MBUS_PCI_MEM);
+	mvebu_mbus_add_window_remap_flags("pcie1.0",
+					  KIRKWOOD_PCIE1_IO_PHYS_BASE,
+					  KIRKWOOD_PCIE1_IO_SIZE,
+					  KIRKWOOD_PCIE1_IO_BUS_BASE,
+					  MVEBU_MBUS_PCI_IO);
+	mvebu_mbus_add_window_remap_flags("pcie1.0",
+					  KIRKWOOD_PCIE1_MEM_PHYS_BASE,
+					  KIRKWOOD_PCIE1_MEM_SIZE,
+					  MVEBU_MBUS_NO_REMAP,
+					  MVEBU_MBUS_PCI_MEM);
+	mvebu_mbus_add_window("nand", KIRKWOOD_NAND_MEM_PHYS_BASE,
+			      KIRKWOOD_NAND_MEM_SIZE);
+	mvebu_mbus_add_window("sram", KIRKWOOD_SRAM_PHYS_BASE,
+			      KIRKWOOD_SRAM_SIZE);
+}
+
 void __init kirkwood_l2_init(void)
 {
 #ifdef CONFIG_CACHE_FEROCEON_L2
@@ -675,7 +709,7 @@ void __init kirkwood_init(void)
 	 */
 	writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
 
-	kirkwood_setup_cpu_mbus();
+	kirkwood_setup_wins();
 
 	kirkwood_l2_init();
 
arch/arm/mach-kirkwood/common.h +1 -1
index 5ed7056..e24f743 100644
@@ -30,7 +30,7 @@ void kirkwood_init(void);
 void kirkwood_init_early(void);
 void kirkwood_init_irq(void);
 
-void kirkwood_setup_cpu_mbus(void);
+void kirkwood_setup_wins(void);
 
 void kirkwood_enable_pcie(void);
 void kirkwood_pcie_id(u32 *dev, u32 *rev);
arch/arm/mach-kirkwood/include/mach/kirkwood.h +5 -2
index a05563a..92976ce 100644
@@ -60,8 +60,9 @@
  * Register Map
  */
 #define DDR_VIRT_BASE		(KIRKWOOD_REGS_VIRT_BASE + 0x00000)
-#define DDR_PHYS_BASE		(KIRKWOOD_REGS_PHYS_BASE + 0x00000)
-#define  DDR_WINDOW_CPU_BASE	(DDR_VIRT_BASE + 0x1500)
+#define DDR_PHYS_BASE           (KIRKWOOD_REGS_PHYS_BASE + 0x00000)
+#define  DDR_WINDOW_CPU_BASE    (DDR_PHYS_BASE + 0x1500)
+#define  DDR_WINDOW_CPU_SZ      (0x20)
 #define DDR_OPERATION_BASE	(DDR_PHYS_BASE + 0x1418)
 
 #define DEV_BUS_PHYS_BASE	(KIRKWOOD_REGS_PHYS_BASE + 0x10000)
@@ -80,6 +81,8 @@
 
 #define BRIDGE_VIRT_BASE	(KIRKWOOD_REGS_VIRT_BASE + 0x20000)
 #define BRIDGE_PHYS_BASE	(KIRKWOOD_REGS_PHYS_BASE + 0x20000)
+#define  BRIDGE_WINS_BASE       (BRIDGE_PHYS_BASE)
+#define  BRIDGE_WINS_SZ         (0x80)
 
 #define CRYPTO_PHYS_BASE	(KIRKWOOD_REGS_PHYS_BASE + 0x30000)
 
arch/arm/mach-kirkwood/pcie.c +0 -1
index d96ad4c..7f43e6c 100644
@@ -17,7 +17,6 @@
 #include <asm/mach/pci.h>
 #include <plat/pcie.h>
 #include <mach/bridge-regs.h>
-#include <plat/addr-map.h>
 #include "common.h"
 
 static void kirkwood_enable_pcie_clk(const char *port)
arch/arm/plat-orion/Makefile +0 -1
index 6cfc89f..58db16d 100644
@@ -3,7 +3,6 @@
 #
 ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include
 
-obj-$(CONFIG_ARCH_KIRKWOOD)       += addr-map.o
 obj-$(CONFIG_ARCH_DOVE)           += addr-map.o
 obj-$(CONFIG_ARCH_ORION5X)        += addr-map.o
 obj-$(CONFIG_ARCH_MV78XX0)        += addr-map.o
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v3 4/7 arm: mach-dove: convert to use mvebu-mbus driver

In reply to Thomas Petazzoni

This commit migrates the mach-dove platforms to use the mvebu-mbus driver and therefore removes the Dove-specific addr-map code.

The dove_init_early() function now initializes the mvebu-mbus driver by calling mvebu_mbus_init().

The address decoding windows are now registered in the dove_setup_cpu_wins() function. It is worth noting that the four PCIe address decoding windows will ultimately no longer have to be registered here: it will be done automatically by the PCIe driver once Dove has been migrated to use the upcoming mvebu PCIe driver.

---
 arch/arm/Kconfig                       |    1 +
 arch/arm/mach-dove/Makefile            |    2 +-
 arch/arm/mach-dove/addr-map.c          |  125 --------------------------------
 arch/arm/mach-dove/board-dt.c          |    2 +-
 arch/arm/mach-dove/common.c            |   39 +++++++++-
 arch/arm/mach-dove/common.h            |    2 +-
 arch/arm/mach-dove/include/mach/dove.h |    5 ++
 arch/arm/plat-orion/Makefile           |    1 -
 8 files changed, 47 insertions(+), 130 deletions(-)
 delete mode 100644 arch/arm/mach-dove/addr-map.c
arch/arm/Kconfig +1 -0
index 544767b..d18a141 100644
@@ -564,6 +564,7 @@ config ARCH_DOVE
 	select PINCTRL_DOVE
 	select PLAT_ORION_LEGACY
 	select USB_ARCH_HAS_EHCI
+	select MVEBU_MBUS
 	help
 	  Support for the Marvell Dove SoC 88AP510
 
arch/arm/mach-dove/Makefile +1 -1
index 3f0a858..4d9d2ff 100644
@@ -1,4 +1,4 @@
-obj-y				+= common.o addr-map.o irq.o
+obj-y				+= common.o irq.o
 obj-$(CONFIG_DOVE_LEGACY)	+= mpp.o
 obj-$(CONFIG_PCI)		+= pcie.o
 obj-$(CONFIG_MACH_DOVE_DB)	+= dove-db-setup.o
arch/arm/mach-dove/addr-map.c deleted +0 -125

125 lines not on this page · raw message

arch/arm/mach-dove/board-dt.c +1 -1
index fbde1dd..0b14280 100644
@@ -64,7 +64,7 @@ static void __init dove_dt_init(void)
 #ifdef CONFIG_CACHE_TAUROS2
 	tauros2_init(0);
 #endif
-	dove_setup_cpu_mbus();
+	dove_setup_cpu_wins();
 
 	/* Setup root of clk tree */
 	dove_of_clk_init();
arch/arm/mach-dove/common.c +38 -1
index c6b3b2b..e2b5da0 100644
@@ -224,6 +224,9 @@ void __init dove_i2c_init(void)
 void __init dove_init_early(void)
 {
 	orion_time_set_base(TIMER_VIRT_BASE);
+	mvebu_mbus_init("marvell,dove-mbus",
+			BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
+			DOVE_MC_WINS_BASE, DOVE_MC_WINS_SZ);
 }
 
 static int __init dove_find_tclk(void)
@@ -326,6 +329,40 @@ void __init dove_sdio1_init(void)
 	platform_device_register(&dove_sdio1);
 }
 
+void __init dove_setup_cpu_wins(void)
+{
+	/*
+	 * The PCIe windows will no longer be statically allocated
+	 * here once Dove is migrated to the pci-mvebu driver.
+	 */
+	mvebu_mbus_add_window_remap_flags("pcie0.0",
+					  DOVE_PCIE0_IO_PHYS_BASE,
+					  DOVE_PCIE0_IO_SIZE,
+					  DOVE_PCIE0_IO_BUS_BASE,
+					  MVEBU_MBUS_PCI_IO);
+	mvebu_mbus_add_window_remap_flags("pcie1.0",
+					  DOVE_PCIE1_IO_PHYS_BASE,
+					  DOVE_PCIE1_IO_SIZE,
+					  DOVE_PCIE1_IO_BUS_BASE,
+					  MVEBU_MBUS_PCI_IO);
+	mvebu_mbus_add_window_remap_flags("pcie0.0",
+					  DOVE_PCIE0_MEM_PHYS_BASE,
+					  DOVE_PCIE0_MEM_SIZE,
+					  MVEBU_MBUS_NO_REMAP,
+					  MVEBU_MBUS_PCI_MEM);
+	mvebu_mbus_add_window_remap_flags("pcie1.0",
+					  DOVE_PCIE1_MEM_PHYS_BASE,
+					  DOVE_PCIE1_MEM_SIZE,
+					  MVEBU_MBUS_NO_REMAP,
+					  MVEBU_MBUS_PCI_MEM);
+	mvebu_mbus_add_window("cesa", DOVE_CESA_PHYS_BASE,
+			      DOVE_CESA_SIZE);
+	mvebu_mbus_add_window("bootrom", DOVE_BOOTROM_PHYS_BASE,
+			      DOVE_BOOTROM_SIZE);
+	mvebu_mbus_add_window("scratchpad", DOVE_SCRATCHPAD_PHYS_BASE,
+			      DOVE_SCRATCHPAD_SIZE);
+}
+
 void __init dove_init(void)
 {
 	pr_info("Dove 88AP510 SoC, TCLK = %d MHz.\n",
@@ -334,7 +371,7 @@ void __init dove_init(void)
 #ifdef CONFIG_CACHE_TAUROS2
 	tauros2_init(0);
 #endif
-	dove_setup_cpu_mbus();
+	dove_setup_cpu_wins();
 
 	/* Setup root of clk tree */
 	dove_clk_init();
arch/arm/mach-dove/common.h +1 -1
index ee59fba..e863479 100644
@@ -23,7 +23,7 @@ void dove_map_io(void);
 void dove_init(void);
 void dove_init_early(void);
 void dove_init_irq(void);
-void dove_setup_cpu_mbus(void);
+void dove_setup_cpu_wins(void);
 void dove_ge00_init(struct mv643xx_eth_platform_data *eth_data);
 void dove_sata_init(struct mv_sata_platform_data *sata_data);
 #ifdef CONFIG_PCI
arch/arm/mach-dove/include/mach/dove.h +5 -0
index 661725e..0c4b35f 100644
@@ -77,6 +77,8 @@
 /* North-South Bridge */
 #define BRIDGE_VIRT_BASE	(DOVE_SB_REGS_VIRT_BASE + 0x20000)
 #define BRIDGE_PHYS_BASE	(DOVE_SB_REGS_PHYS_BASE + 0x20000)
+#define  BRIDGE_WINS_BASE       (BRIDGE_PHYS_BASE)
+#define  BRIDGE_WINS_SZ         (0x80)
 
 /* Cryptographic Engine */
 #define DOVE_CRYPT_PHYS_BASE	(DOVE_SB_REGS_PHYS_BASE + 0x30000)
@@ -168,6 +170,9 @@
 #define  DOVE_SSP_CLOCK_ENABLE		(1 << 1)
 #define  DOVE_SSP_BPB_CLOCK_SRC_SSP	(1 << 11)
 /* Memory Controller */
+#define DOVE_MC_PHYS_BASE       (DOVE_NB_REGS_PHYS_BASE + 0x00000)
+#define  DOVE_MC_WINS_BASE      (DOVE_MC_PHYS_BASE + 0x100)
+#define  DOVE_MC_WINS_SZ        (0x8)
 #define DOVE_MC_VIRT_BASE	(DOVE_NB_REGS_VIRT_BASE + 0x00000)
 
 /* LCD Controller */
arch/arm/plat-orion/Makefile +0 -1
index 58db16d..9fd843e 100644
@@ -3,7 +3,6 @@
 #
 ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include
 
-obj-$(CONFIG_ARCH_DOVE)           += addr-map.o
 obj-$(CONFIG_ARCH_ORION5X)        += addr-map.o
 obj-$(CONFIG_ARCH_MV78XX0)        += addr-map.o
 
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v3 5/7 arm: mach-orion5x: convert to use mvebu-mbus driver

In reply to Thomas Petazzoni

This commit migrates the mach-orion5x platforms to use the mvebu-mbus driver and therefore removes the Orion5x-specific addr-map code.

The dove_init_early() function now initializes the mvebu-mbus driver by calling mvebu_mbus_init().

We also convert a number of orion5x_setup_xyz_win() calls to the appropriate mvebu_mbus_add_window() calls, as each board was doing its own setup for the NOR window or other devices. Ultimately, those devices will be probed from the DT.

The common address decoding windows are now registered in the orion5x_setup_wins() function. It is worth noting that the four PCIe address decoding windows will ultimately no longer have to be registered here: it will be done automatically by the PCIe driver once Dove has been migrated to use the upcoming mvebu PCIe driver.

---
 arch/arm/Kconfig                               |    1 +
 arch/arm/mach-orion5x/Makefile                 |    2 +-
 arch/arm/mach-orion5x/addr-map.c               |  155 ------------------------
 arch/arm/mach-orion5x/board-dt.c               |    2 +-
 arch/arm/mach-orion5x/common.c                 |   49 +++++++-
 arch/arm/mach-orion5x/common.h                 |   13 +-
 arch/arm/mach-orion5x/d2net-setup.c            |    4 +-
 arch/arm/mach-orion5x/db88f5281-setup.c        |   13 +-
 arch/arm/mach-orion5x/dns323-setup.c           |    3 +-
 arch/arm/mach-orion5x/edmini_v2-setup.c        |    4 +-
 arch/arm/mach-orion5x/include/mach/orion5x.h   |    6 +-
 arch/arm/mach-orion5x/kurobox_pro-setup.c      |    8 +-
 arch/arm/mach-orion5x/ls-chl-setup.c           |    4 +-
 arch/arm/mach-orion5x/ls_hgl-setup.c           |    4 +-
 arch/arm/mach-orion5x/lsmini-setup.c           |    4 +-
 arch/arm/mach-orion5x/mss2-setup.c             |    3 +-
 arch/arm/mach-orion5x/mv2120-setup.c           |    3 +-
 arch/arm/mach-orion5x/net2big-setup.c          |    4 +-
 arch/arm/mach-orion5x/pci.c                    |    7 +-
 arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c   |    4 +-
 arch/arm/mach-orion5x/rd88f5181l-ge-setup.c    |    4 +-
 arch/arm/mach-orion5x/rd88f5182-setup.c        |    7 +-
 arch/arm/mach-orion5x/terastation_pro2-setup.c |    4 +-
 arch/arm/mach-orion5x/ts209-setup.c            |    4 +-
 arch/arm/mach-orion5x/ts409-setup.c            |    4 +-
 arch/arm/mach-orion5x/wnr854t-setup.c          |    4 +-
 arch/arm/mach-orion5x/wrt350n-v2-setup.c       |    4 +-
 arch/arm/plat-orion/Makefile                   |    1 -
 28 files changed, 108 insertions(+), 217 deletions(-)
 delete mode 100644 arch/arm/mach-orion5x/addr-map.c
arch/arm/Kconfig +1 -0
index d18a141..e8caf60 100644
@@ -602,6 +602,7 @@ config ARCH_ORION5X
 	select GENERIC_CLOCKEVENTS
 	select PCI
 	select PLAT_ORION_LEGACY
+	select MVEBU_MBUS
 	help
 	  Support for the following Marvell Orion 5x series SoCs:
 	  Orion-1 (5181), Orion-VoIP (5181L), Orion-NAS (5182),
arch/arm/mach-orion5x/Makefile +1 -1
index 9e809a7..45da805 100644
@@ -1,4 +1,4 @@
-obj-y				+= common.o addr-map.o pci.o irq.o mpp.o
+obj-y				+= common.o pci.o irq.o mpp.o
 obj-$(CONFIG_MACH_DB88F5281)	+= db88f5281-setup.o
 obj-$(CONFIG_MACH_RD88F5182)	+= rd88f5182-setup.o
 obj-$(CONFIG_MACH_KUROBOX_PRO)	+= kurobox_pro-setup.o
arch/arm/mach-orion5x/addr-map.c deleted +0 -155

155 lines not on this page · raw message

arch/arm/mach-orion5x/board-dt.c +1 -1
index 35a8014..6bbc878 100644
@@ -41,7 +41,7 @@ static void __init orion5x_dt_init(void)
 	/*
 	 * Setup Orion address map
 	 */
-	orion5x_setup_cpu_mbus_bridge();
+	orion5x_setup_wins();
 
 	/* Setup root of clk tree */
 	clk_init();
arch/arm/mach-orion5x/common.c +46 -3

79 lines not on this page · raw message

arch/arm/mach-orion5x/common.h +1 -12
index e603457..cdaa01f 100644
@@ -17,18 +17,7 @@ void clk_init(void);
 extern int orion5x_tclk;
 extern void orion5x_timer_init(void);
 
-/*
- * Enumerations and functions for Orion windows mapping. Used by Orion core
- * functions to map its interfaces and by the machine-setup to map its on-
- * board devices. Details in /mach-orion/addr-map.c
- */
-void orion5x_setup_cpu_mbus_bridge(void);
-void orion5x_setup_dev_boot_win(u32 base, u32 size);
-void orion5x_setup_dev0_win(u32 base, u32 size);
-void orion5x_setup_dev1_win(u32 base, u32 size);
-void orion5x_setup_dev2_win(u32 base, u32 size);
-void orion5x_setup_pcie_wa_win(u32 base, u32 size);
-void orion5x_setup_sram_win(void);
+void orion5x_setup_wins(void);
 
 void orion5x_ehci0_init(void);
 void orion5x_ehci1_init(void);
arch/arm/mach-orion5x/d2net-setup.c +2 -2
index 57d0af7..16c88bb 100644
@@ -317,8 +317,8 @@ static void __init d2net_init(void)
 	d2net_sata_power_init();
 	orion5x_sata_init(&d2net_sata_data);
 
-	orion5x_setup_dev_boot_win(D2NET_NOR_BOOT_BASE,
-				D2NET_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", D2NET_NOR_BOOT_BASE,
+			      D2NET_NOR_BOOT_SIZE);
 	platform_device_register(&d2net_nor_flash);
 
 	platform_device_register(&d2net_gpio_buttons);
arch/arm/mach-orion5x/db88f5281-setup.c +8 -5
index 7666564..4e1263d 100644
@@ -340,16 +340,19 @@ static void __init db88f5281_init(void)
 	orion5x_uart0_init();
 	orion5x_uart1_init();
 
-	orion5x_setup_dev_boot_win(DB88F5281_NOR_BOOT_BASE,
-				DB88F5281_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", DB88F5281_NOR_BOOT_BASE,
+			      DB88F5281_NOR_BOOT_SIZE);
 	platform_device_register(&db88f5281_boot_flash);
 
-	orion5x_setup_dev0_win(DB88F5281_7SEG_BASE, DB88F5281_7SEG_SIZE);
+	mvebu_mbus_add_window("devbus-cs0", DB88F5281_7SEG_BASE,
+			      DB88F5281_7SEG_SIZE);
 
-	orion5x_setup_dev1_win(DB88F5281_NOR_BASE, DB88F5281_NOR_SIZE);
+	mvebu_mbus_add_window("devbus-cs1", DB88F5281_NOR_BASE,
+			      DB88F5281_NOR_SIZE);
 	platform_device_register(&db88f5281_nor_flash);
 
-	orion5x_setup_dev2_win(DB88F5281_NAND_BASE, DB88F5281_NAND_SIZE);
+	mvebu_mbus_add_window("devbus-cs2", DB88F5281_NAND_BASE,
+			      DB88F5281_NAND_SIZE);
 	platform_device_register(&db88f5281_nand_flash);
 
 	i2c_register_board_info(0, &db88f5281_i2c_rtc, 1);
arch/arm/mach-orion5x/dns323-setup.c +2 -1
index 6eb1732..9e6baf5 100644
@@ -611,7 +611,8 @@ static void __init dns323_init(void)
 	/* setup flash mapping
 	 * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
 	 */
-	orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", DNS323_NOR_BOOT_BASE,
+			      DNS323_NOR_BOOT_SIZE);
 	platform_device_register(&dns323_nor_flash);
 
 	/* Sort out LEDs, Buttons and i2c devices */
arch/arm/mach-orion5x/edmini_v2-setup.c +2 -2
index d675e72..1476155 100644
@@ -154,8 +154,8 @@ void __init edmini_v2_init(void)
 	orion5x_ehci0_init();
 	orion5x_eth_init(&edmini_v2_eth_data);
 
-	orion5x_setup_dev_boot_win(EDMINI_V2_NOR_BOOT_BASE,
-				EDMINI_V2_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", EDMINI_V2_NOR_BOOT_BASE,
+			      EDMINI_V2_NOR_BOOT_SIZE);
 	platform_device_register(&edmini_v2_nor_flash);
 
 	pr_notice("edmini_v2: USB device port, flash write and power-off "
arch/arm/mach-orion5x/include/mach/orion5x.h +5 -1
index d265f54..b78ff32 100644
@@ -66,8 +66,10 @@
  * Orion Registers Map
  ******************************************************************************/
 
+#define ORION5X_DDR_PHYS_BASE           (ORION5X_REGS_PHYS_BASE + 0x00000)
+#define  ORION5X_DDR_WINS_BASE          (ORION5X_DDR_PHYS_BASE + 0x1500)
+#define  ORION5X_DDR_WINS_SZ            (0x10)
 #define ORION5X_DDR_VIRT_BASE		(ORION5X_REGS_VIRT_BASE + 0x00000)
-#define  ORION5X_DDR_WINDOW_CPU_BASE    (ORION5X_DDR_VIRT_BASE + 0x1500)
 #define ORION5X_DEV_BUS_PHYS_BASE	(ORION5X_REGS_PHYS_BASE + 0x10000)
 #define ORION5X_DEV_BUS_VIRT_BASE	(ORION5X_REGS_VIRT_BASE + 0x10000)
 #define ORION5X_DEV_BUS_REG(x)		(ORION5X_DEV_BUS_VIRT_BASE + (x))
@@ -81,6 +83,8 @@
 
 #define ORION5X_BRIDGE_VIRT_BASE	(ORION5X_REGS_VIRT_BASE + 0x20000)
 #define ORION5X_BRIDGE_PHYS_BASE	(ORION5X_REGS_PHYS_BASE + 0x20000)
+#define  ORION5X_BRIDGE_WINS_BASE       (ORION5X_BRIDGE_PHYS_BASE)
+#define  ORION5X_BRIDGE_WINS_SZ         (0x80)
 
 #define ORION5X_PCI_VIRT_BASE		(ORION5X_REGS_VIRT_BASE + 0x30000)
 
arch/arm/mach-orion5x/kurobox_pro-setup.c +4 -4
index b984035..aae10e4 100644
@@ -359,13 +359,13 @@ static void __init kurobox_pro_init(void)
 	orion5x_uart1_init();
 	orion5x_xor_init();
 
-	orion5x_setup_dev_boot_win(KUROBOX_PRO_NOR_BOOT_BASE,
-				   KUROBOX_PRO_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", KUROBOX_PRO_NOR_BOOT_BASE,
+			      KUROBOX_PRO_NOR_BOOT_SIZE);
 	platform_device_register(&kurobox_pro_nor_flash);
 
 	if (machine_is_kurobox_pro()) {
-		orion5x_setup_dev0_win(KUROBOX_PRO_NAND_BASE,
-				       KUROBOX_PRO_NAND_SIZE);
+		mvebu_mbus_add_window("devbus-cs0", KUROBOX_PRO_NAND_BASE,
+				      KUROBOX_PRO_NAND_SIZE);
 		platform_device_register(&kurobox_pro_nand_flash);
 	}
 
arch/arm/mach-orion5x/ls-chl-setup.c +2 -2
index 044da5b..24f4e14 100644
@@ -294,8 +294,8 @@ static void __init lschl_init(void)
 	orion5x_uart0_init();
 	orion5x_xor_init();
 
-	orion5x_setup_dev_boot_win(LSCHL_NOR_BOOT_BASE,
-				   LSCHL_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", LSCHL_NOR_BOOT_BASE,
+			      LSCHL_NOR_BOOT_SIZE);
 	platform_device_register(&lschl_nor_flash);
 
 	platform_device_register(&lschl_leds);
arch/arm/mach-orion5x/ls_hgl-setup.c +2 -2
index d49f934..fc653bb 100644
@@ -243,8 +243,8 @@ static void __init ls_hgl_init(void)
 	orion5x_uart0_init();
 	orion5x_xor_init();
 
-	orion5x_setup_dev_boot_win(LS_HGL_NOR_BOOT_BASE,
-				   LS_HGL_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", LS_HGL_NOR_BOOT_BASE,
+			      LS_HGL_NOR_BOOT_SIZE);
 	platform_device_register(&ls_hgl_nor_flash);
 
 	platform_device_register(&ls_hgl_button_device);
arch/arm/mach-orion5x/lsmini-setup.c +2 -2
index 8e3965c..18e66e6 100644
@@ -244,8 +244,8 @@ static void __init lsmini_init(void)
 	orion5x_uart0_init();
 	orion5x_xor_init();
 
-	orion5x_setup_dev_boot_win(LSMINI_NOR_BOOT_BASE,
-				   LSMINI_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", LSMINI_NOR_BOOT_BASE,
+			      LSMINI_NOR_BOOT_SIZE);
 	platform_device_register(&lsmini_nor_flash);
 
 	platform_device_register(&lsmini_button_device);
arch/arm/mach-orion5x/mss2-setup.c +2 -1
index 0ec94a1..827acba 100644
@@ -241,7 +241,8 @@ static void __init mss2_init(void)
 	orion5x_uart0_init();
 	orion5x_xor_init();
 
-	orion5x_setup_dev_boot_win(MSS2_NOR_BOOT_BASE, MSS2_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", MSS2_NOR_BOOT_BASE,
+			      MSS2_NOR_BOOT_SIZE);
 	platform_device_register(&mss2_nor_flash);
 
 	platform_device_register(&mss2_button_device);
arch/arm/mach-orion5x/mv2120-setup.c +2 -1
index 18143f2..92600ae 100644
@@ -204,7 +204,8 @@ static void __init mv2120_init(void)
 	orion5x_uart0_init();
 	orion5x_xor_init();
 
-	orion5x_setup_dev_boot_win(MV2120_NOR_BOOT_BASE, MV2120_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", MV2120_NOR_BOOT_BASE,
+			      MV2120_NOR_BOOT_SIZE);
 	platform_device_register(&mv2120_nor_flash);
 
 	platform_device_register(&mv2120_button_device);
arch/arm/mach-orion5x/net2big-setup.c +2 -2
index 282e503..dd0641a 100644
@@ -397,8 +397,8 @@ static void __init net2big_init(void)
 	net2big_sata_power_init();
 	orion5x_sata_init(&net2big_sata_data);
 
-	orion5x_setup_dev_boot_win(NET2BIG_NOR_BOOT_BASE,
-				   NET2BIG_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", NET2BIG_NOR_BOOT_BASE,
+			      NET2BIG_NOR_BOOT_SIZE);
 	platform_device_register(&net2big_nor_flash);
 
 	platform_device_register(&net2big_gpio_buttons);
arch/arm/mach-orion5x/pci.c +5 -2
index 973db98..5033680 100644
@@ -157,8 +157,11 @@ static int __init pcie_setup(struct pci_sys_data *sys)
 	if (dev == MV88F5181_DEV_ID || dev == MV88F5182_DEV_ID) {
 		printk(KERN_NOTICE "Applying Orion-1/Orion-NAS PCIe config "
 				   "read transaction workaround\n");
-		orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE,
-					  ORION5X_PCIE_WA_SIZE);
+		mvebu_mbus_add_window_remap_flags("pcie0.0",
+						  ORION5X_PCIE_WA_PHYS_BASE,
+						  ORION5X_PCIE_WA_SIZE,
+						  MVEBU_MBUS_NO_REMAP,
+						  MVEBU_MBUS_PCI_WA);
 		pcie_ops.read = pcie_rd_conf_wa;
 	}
 
arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c +2 -2
index d6e72f6..1c4498b 100644
@@ -123,8 +123,8 @@ static void __init rd88f5181l_fxo_init(void)
 	orion5x_eth_switch_init(&rd88f5181l_fxo_switch_plat_data, NO_IRQ);
 	orion5x_uart0_init();
 
-	orion5x_setup_dev_boot_win(RD88F5181L_FXO_NOR_BOOT_BASE,
-				   RD88F5181L_FXO_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", RD88F5181L_FXO_NOR_BOOT_BASE,
+			      RD88F5181L_FXO_NOR_BOOT_SIZE);
 	platform_device_register(&rd88f5181l_fxo_nor_boot_flash);
 }
 
arch/arm/mach-orion5x/rd88f5181l-ge-setup.c +2 -2
index c8b7913..adabe34 100644
@@ -130,8 +130,8 @@ static void __init rd88f5181l_ge_init(void)
 	orion5x_i2c_init();
 	orion5x_uart0_init();
 
-	orion5x_setup_dev_boot_win(RD88F5181L_GE_NOR_BOOT_BASE,
-				   RD88F5181L_GE_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", RD88F5181L_GE_NOR_BOOT_BASE,
+			      RD88F5181L_GE_NOR_BOOT_SIZE);
 	platform_device_register(&rd88f5181l_ge_nor_boot_flash);
 
 	i2c_register_board_info(0, &rd88f5181l_ge_i2c_rtc, 1);
arch/arm/mach-orion5x/rd88f5182-setup.c +4 -3
index f9e1567..66e77ec 100644
@@ -264,10 +264,11 @@ static void __init rd88f5182_init(void)
 	orion5x_uart0_init();
 	orion5x_xor_init();
 
-	orion5x_setup_dev_boot_win(RD88F5182_NOR_BOOT_BASE,
-				   RD88F5182_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", RD88F5182_NOR_BOOT_BASE,
+			      RD88F5182_NOR_BOOT_SIZE);
 
-	orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE);
+	mvebu_mbus_add_window("devbus-cs1", RD88F5182_NOR_BASE,
+			      RD88F5182_NOR_SIZE);
 	platform_device_register(&rd88f5182_nor_flash);
 	platform_device_register(&rd88f5182_gpio_leds);
 
arch/arm/mach-orion5x/terastation_pro2-setup.c +2 -2
index acc0877..a0bfa53 100644
@@ -329,8 +329,8 @@ static void __init tsp2_init(void)
 	/*
 	 * Configure peripherals.
 	 */
-	orion5x_setup_dev_boot_win(TSP2_NOR_BOOT_BASE,
-				   TSP2_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", TSP2_NOR_BOOT_BASE,
+			      TSP2_NOR_BOOT_SIZE);
 	platform_device_register(&tsp2_nor_flash);
 
 	orion5x_ehci0_init();
arch/arm/mach-orion5x/ts209-setup.c +2 -2
index 9c17f0c..80174f0 100644
@@ -286,8 +286,8 @@ static void __init qnap_ts209_init(void)
 	/*
 	 * Configure peripherals.
 	 */
-	orion5x_setup_dev_boot_win(QNAP_TS209_NOR_BOOT_BASE,
-				   QNAP_TS209_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", QNAP_TS209_NOR_BOOT_BASE,
+			      QNAP_TS209_NOR_BOOT_SIZE);
 	platform_device_register(&qnap_ts209_nor_flash);
 
 	orion5x_ehci0_init();
arch/arm/mach-orion5x/ts409-setup.c +2 -2
index 8cc5ab6..9259279 100644
@@ -277,8 +277,8 @@ static void __init qnap_ts409_init(void)
 	/*
 	 * Configure peripherals.
 	 */
-	orion5x_setup_dev_boot_win(QNAP_TS409_NOR_BOOT_BASE,
-				   QNAP_TS409_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", QNAP_TS409_NOR_BOOT_BASE,
+			      QNAP_TS409_NOR_BOOT_SIZE);
 	platform_device_register(&qnap_ts409_nor_flash);
 
 	orion5x_ehci0_init();
arch/arm/mach-orion5x/wnr854t-setup.c +2 -2
index 66552ca..6b84863 100644
@@ -127,8 +127,8 @@ static void __init wnr854t_init(void)
 	orion5x_eth_switch_init(&wnr854t_switch_plat_data, NO_IRQ);
 	orion5x_uart0_init();
 
-	orion5x_setup_dev_boot_win(WNR854T_NOR_BOOT_BASE,
-				   WNR854T_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", WNR854T_NOR_BOOT_BASE,
+			      WNR854T_NOR_BOOT_SIZE);
 	platform_device_register(&wnr854t_nor_flash);
 }
 
arch/arm/mach-orion5x/wrt350n-v2-setup.c +2 -2
index 2c5408e..fae684b 100644
@@ -213,8 +213,8 @@ static void __init wrt350n_v2_init(void)
 	orion5x_eth_switch_init(&wrt350n_v2_switch_plat_data, NO_IRQ);
 	orion5x_uart0_init();
 
-	orion5x_setup_dev_boot_win(WRT350N_V2_NOR_BOOT_BASE,
-				   WRT350N_V2_NOR_BOOT_SIZE);
+	mvebu_mbus_add_window("devbus-boot", WRT350N_V2_NOR_BOOT_BASE,
+			      WRT350N_V2_NOR_BOOT_SIZE);
 	platform_device_register(&wrt350n_v2_nor_flash);
 	platform_device_register(&wrt350n_v2_leds);
 	platform_device_register(&wrt350n_v2_button_device);
arch/arm/plat-orion/Makefile +0 -1
index 9fd843e..09711cd 100644
@@ -3,7 +3,6 @@
 #
 ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include
 
-obj-$(CONFIG_ARCH_ORION5X)        += addr-map.o
 obj-$(CONFIG_ARCH_MV78XX0)        += addr-map.o
 
 orion-gpio-$(CONFIG_GENERIC_GPIO) += gpio.o
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v3 6/7 arm: mach-mv78xx0: convert to use the mvebu-mbus driver

In reply to Thomas Petazzoni

This commit convers the mach-mv78xx0 sub-architecture to use the mvebu-mbus driver. We simply have to call mvebu_mbus_init() in the ->init_early() function, and modify the PCIe code so that it uses the new functions provided by mvebu-mbus to create the needed PCIe windows.

---
 arch/arm/Kconfig                             |    1 +
 arch/arm/mach-mv78xx0/Makefile               |    2 +-
 arch/arm/mach-mv78xx0/addr-map.c             |   93 --------------------------
 arch/arm/mach-mv78xx0/common.c               |   10 ++-
 arch/arm/mach-mv78xx0/include/mach/mv78xx0.h |    9 ++-
 arch/arm/mach-mv78xx0/pcie.c                 |   21 +++---
 arch/arm/plat-orion/Makefile                 |    2 -
 include/linux/mbus.h                         |    3 +
 8 files changed, 33 insertions(+), 108 deletions(-)
 delete mode 100644 arch/arm/mach-mv78xx0/addr-map.c
arch/arm/Kconfig +1 -0
index e8caf60..882f8a8 100644
@@ -590,6 +590,7 @@ config ARCH_MV78XX0
 	select GENERIC_CLOCKEVENTS
 	select PCI
 	select PLAT_ORION_LEGACY
+	select MVEBU_MBUS
 	help
 	  Support for the following Marvell MV78xx0 series SoCs:
 	  MV781x0, MV782x0.
arch/arm/mach-mv78xx0/Makefile +1 -1
index 67a13f9..7cd0463 100644
@@ -1,4 +1,4 @@
-obj-y				+= common.o addr-map.o mpp.o irq.o pcie.o
+obj-y				+= common.o mpp.o irq.o pcie.o
 obj-$(CONFIG_MACH_DB78X00_BP)	+= db78x00-bp-setup.o
 obj-$(CONFIG_MACH_RD78X00_MASA)	+= rd78x00-masa-setup.o
 obj-$(CONFIG_MACH_TERASTATION_WXL) += buffalo-wxl-setup.o
arch/arm/mach-mv78xx0/addr-map.c deleted +0 -93

93 lines not on this page · raw message

arch/arm/mach-mv78xx0/common.c +8 -2
index 0efa144..749a7f8 100644
@@ -334,6 +334,14 @@ void __init mv78xx0_uart3_init(void)
 void __init mv78xx0_init_early(void)
 {
 	orion_time_set_base(TIMER_VIRT_BASE);
+	if (mv78xx0_core_index() == 0)
+		mvebu_mbus_init("marvell,mv78xx0-mbus",
+				BRIDGE_WINS_CPU0_BASE, BRIDGE_WINS_SZ,
+				DDR_WINDOW_CPU0_BASE, DDR_WINDOW_CPU_SZ);
+	else
+		mvebu_mbus_init("marvell,mv78xx0-mbus",
+				BRIDGE_WINS_CPU1_BASE, BRIDGE_WINS_SZ,
+				DDR_WINDOW_CPU1_BASE, DDR_WINDOW_CPU_SZ);
 }
 
 void __init_refok mv78xx0_timer_init(void)
@@ -397,8 +405,6 @@ void __init mv78xx0_init(void)
 	printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
 	printk("TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000);
 
-	mv78xx0_setup_cpu_mbus();
-
 #ifdef CONFIG_CACHE_FEROCEON_L2
 	feroceon_l2_init(is_l2_writethrough());
 #endif
arch/arm/mach-mv78xx0/include/mach/mv78xx0.h +7 -2
index 46200a1..723748d 100644
@@ -60,13 +60,18 @@
  */
 #define BRIDGE_VIRT_BASE	(MV78XX0_CORE_REGS_VIRT_BASE)
 #define BRIDGE_PHYS_BASE	(MV78XX0_CORE_REGS_PHYS_BASE)
+#define  BRIDGE_WINS_CPU0_BASE  (MV78XX0_CORE0_REGS_PHYS_BASE)
+#define  BRIDGE_WINS_CPU1_BASE  (MV78XX0_CORE1_REGS_PHYS_BASE)
+#define  BRIDGE_WINS_SZ         (0xA000)
 
 /*
  * Register Map
  */
 #define DDR_VIRT_BASE		(MV78XX0_REGS_VIRT_BASE + 0x00000)
-#define  DDR_WINDOW_CPU0_BASE	(DDR_VIRT_BASE + 0x1500)
-#define  DDR_WINDOW_CPU1_BASE	(DDR_VIRT_BASE + 0x1570)
+#define DDR_PHYS_BASE           (MV78XX0_REGS_PHYS_BASE + 0x00000)
+#define  DDR_WINDOW_CPU0_BASE	(DDR_PHYS_BASE + 0x1500)
+#define  DDR_WINDOW_CPU1_BASE	(DDR_PHYS_BASE + 0x1570)
+#define  DDR_WINDOW_CPU_SZ      (0x20)
 
 #define DEV_BUS_PHYS_BASE	(MV78XX0_REGS_PHYS_BASE + 0x10000)
 #define DEV_BUS_VIRT_BASE	(MV78XX0_REGS_VIRT_BASE + 0x10000)
arch/arm/mach-mv78xx0/pcie.c +13 -8
index ee8c0b5..dc26a65 100644
@@ -10,11 +10,11 @@
 
 #include <linux/kernel.h>
 #include <linux/pci.h>
+#include <linux/mbus.h>
 #include <video/vga.h>
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <plat/pcie.h>
-#include <plat/addr-map.h>
 #include <mach/mv78xx0.h>
 #include "common.h"
 
@@ -54,7 +54,6 @@ static void __init mv78xx0_pcie_preinit(void)
 	int i;
 	u32 size_each;
 	u32 start;
-	int win = 0;
 
 	pcie_io_space.name = "PCIe I/O Space";
 	pcie_io_space.start = MV78XX0_PCIE_IO_PHYS_BASE(0);
@@ -72,6 +71,7 @@ static void __init mv78xx0_pcie_preinit(void)
 	start = MV78XX0_PCIE_MEM_PHYS_BASE;
 	for (i = 0; i < num_pcie_ports; i++) {
 		struct pcie_port *pp = pcie_port + i;
+		char winname[MVEBU_MBUS_MAX_WINNAME_SZ];
 
 		snprintf(pp->mem_space_name, sizeof(pp->mem_space_name),
 			"PCIe %d.%d MEM", pp->maj, pp->min);
@@ -85,12 +85,17 @@ static void __init mv78xx0_pcie_preinit(void)
 		if (request_resource(&iomem_resource, &pp->res))
 			panic("can't allocate PCIe MEM sub-space");
 
-		mv78xx0_setup_pcie_mem_win(win + i + 8, pp->res.start,
-					   resource_size(&pp->res),
-					   pp->maj, pp->min);
-
-		mv78xx0_setup_pcie_io_win(win + i, i * SZ_64K, SZ_64K,
-					  pp->maj, pp->min);
+		snprintf(winname, sizeof(winname), "pcie%d.%d",
+			 pp->maj, pp->min);
+
+		mvebu_mbus_add_window_remap_flags(winname,
+						  pp->res.start,
+						  resource_size(&pp->res),
+						  MVEBU_MBUS_NO_REMAP,
+						  MVEBU_MBUS_PCI_MEM);
+		mvebu_mbus_add_window_remap_flags(winname,
+						  i * SZ_64K, SZ_64K,
+						  0, MVEBU_MBUS_PCI_IO);
 	}
 }
 
arch/arm/plat-orion/Makefile +0 -2
index 09711cd..2eca54b 100644
@@ -3,8 +3,6 @@
 #
 ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include
 
-obj-$(CONFIG_ARCH_MV78XX0)        += addr-map.o
-
 orion-gpio-$(CONFIG_GENERIC_GPIO) += gpio.o
 obj-$(CONFIG_PLAT_ORION_LEGACY)   += irq.o pcie.o time.o common.o mpp.o
 obj-$(CONFIG_PLAT_ORION_LEGACY)   += $(orion-gpio-y)
include/linux/mbus.h +3 -0
index 462eb97..dba482e 100644
@@ -43,6 +43,9 @@ struct mbus_dram_target_info
  */
 #define MVEBU_MBUS_NO_REMAP (0xffffffff)
 
+/* Maximum size of a mbus window name */
+#define MVEBU_MBUS_MAX_WINNAME_SZ 32
+
 /*
  * The Marvell mbus is to be found only on SOCs from the Orion family
  * at the moment.  Provide a dummy stub for other architectures.
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v3 7/7 arm: plat-orion: remove addr-map code

In reply to Thomas Petazzoni

Now that all Marvell EBU platforms have been converted to use the mvebu-mbus driver, we can remove the common plat-orion/addr-map.c code that isn't compiled anymore.

---
 arch/arm/plat-orion/addr-map.c |  175 ----------------------------------------
 1 file changed, 175 deletions(-)
 delete mode 100644 arch/arm/plat-orion/addr-map.c
arch/arm/plat-orion/addr-map.c deleted +0 -175
deleted file mode 100644
index febe386..0000000
@@ -1,175 +0,0 @@
-/*
- * arch/arm/plat-orion/addr-map.c
- *
- * Address map functions for Marvell Orion based SoCs
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2.  This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/mbus.h>
-#include <linux/io.h>
-#include <plat/addr-map.h>
-
-struct mbus_dram_target_info orion_mbus_dram_info;
-
-const struct mbus_dram_target_info *mv_mbus_dram_info(void)
-{
-	return &orion_mbus_dram_info;
-}
-EXPORT_SYMBOL_GPL(mv_mbus_dram_info);
-
-/*
- * DDR target is the same on all Orion platforms.
- */
-#define TARGET_DDR		0
-
-/*
- * Helpers to get DDR bank info
- */
-#define DDR_BASE_CS_OFF(n)	(0x0000 + ((n) << 3))
-#define DDR_SIZE_CS_OFF(n)	(0x0004 + ((n) << 3))
-
-/*
- * CPU Address Decode Windows registers
- */
-#define WIN_CTRL_OFF		0x0000
-#define WIN_BASE_OFF		0x0004
-#define WIN_REMAP_LO_OFF	0x0008
-#define WIN_REMAP_HI_OFF	0x000c
-
-#define ATTR_HW_COHERENCY	(0x1 << 4)
-
-/*
- * Default implementation
- */
-static void __init __iomem *
-orion_win_cfg_base(const struct orion_addr_map_cfg *cfg, int win)
-{
-	return cfg->bridge_virt_base + (win << 4);
-}
-
-/*
- * Default implementation
- */
-static int __init orion_cpu_win_can_remap(const struct orion_addr_map_cfg *cfg,
-					  const int win)
-{
-	if (win < cfg->remappable_wins)
-		return 1;
-
-	return 0;
-}
-
-void __init orion_setup_cpu_win(const struct orion_addr_map_cfg *cfg,
-				const int win, const u32 base,
-				const u32 size, const u8 target,
-				const u8 attr, const int remap)
-{
-	void __iomem *addr = cfg->win_cfg_base(cfg, win);
-	u32 ctrl, base_high, remap_addr;
-
-	if (win >= cfg->num_wins) {
-		printk(KERN_ERR "setup_cpu_win: trying to allocate window "
-		       "%d when only %d allowed\n", win, cfg->num_wins);
-	}
-
-	base_high = base & 0xffff0000;
-	ctrl = ((size - 1) & 0xffff0000) | (attr << 8) | (target << 4) | 1;
-
-	writel(base_high, addr + WIN_BASE_OFF);
-	writel(ctrl, addr + WIN_CTRL_OFF);
-	if (cfg->cpu_win_can_remap(cfg, win)) {
-		if (remap < 0)
-			remap_addr = base;
-		else
-			remap_addr = remap;
-		writel(remap_addr & 0xffff0000, addr + WIN_REMAP_LO_OFF);
-		writel(0, addr + WIN_REMAP_HI_OFF);
-	}
-}
-
-/*
- * Configure a number of windows.
- */
-static void __init orion_setup_cpu_wins(const struct orion_addr_map_cfg * cfg,
-					const struct orion_addr_map_info *info)
-{
-	while (info->win != -1) {
-		orion_setup_cpu_win(cfg, info->win, info->base, info->size,
-				    info->target, info->attr, info->remap);
-		info++;
-	}
-}
-
-static void __init orion_disable_wins(const struct orion_addr_map_cfg * cfg)
-{
-	void __iomem *addr;
-	int i;
-
-	for (i = 0; i < cfg->num_wins; i++) {
-		addr = cfg->win_cfg_base(cfg, i);
-
-		writel(0, addr + WIN_BASE_OFF);
-		writel(0, addr + WIN_CTRL_OFF);
-		if (cfg->cpu_win_can_remap(cfg, i)) {
-			writel(0, addr + WIN_REMAP_LO_OFF);
-			writel(0, addr + WIN_REMAP_HI_OFF);
-		}
-	}
-}
-
-/*
- * Disable, clear and configure windows.
- */
-void __init orion_config_wins(struct orion_addr_map_cfg * cfg,
-			      const struct orion_addr_map_info *info)
-{
-	if (!cfg->cpu_win_can_remap)
-		cfg->cpu_win_can_remap = orion_cpu_win_can_remap;
-
-	if (!cfg->win_cfg_base)
-		cfg->win_cfg_base = orion_win_cfg_base;
-
-	orion_disable_wins(cfg);
-
-	if (info)
-		orion_setup_cpu_wins(cfg, info);
-}
-
-/*
- * Setup MBUS dram target info.
- */
-void __init orion_setup_cpu_mbus_target(const struct orion_addr_map_cfg *cfg,
-					const void __iomem *ddr_window_cpu_base)
-{
-	int i;
-	int cs;
-
-	orion_mbus_dram_info.mbus_dram_target_id = TARGET_DDR;
-
-	for (i = 0, cs = 0; i < 4; i++) {
-		u32 base = readl(ddr_window_cpu_base + DDR_BASE_CS_OFF(i));
-		u32 size = readl(ddr_window_cpu_base + DDR_SIZE_CS_OFF(i));
-
-		/*
-		 * Chip select enabled?
-		 */
-		if (size & 1) {
-			struct mbus_dram_window *w;
-
-			w = &orion_mbus_dram_info.cs[cs++];
-			w->cs_index = i;
-			w->mbus_attr = 0xf & ~(1 << i);
-			if (cfg->hw_io_coherency)
-				w->mbus_attr |= ATTR_HW_COHERENCY;
-			w->base = base & 0xffff0000;
-			w->size = (size | 0x0000ffff) + 1;
-		}
-	}
-	orion_mbus_dram_info.num_cs = cs;
-}
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v3 7/7 arm: plat-orion: remove addr-map code

Quoted 9 lines · Thomas Petazzoni

Now that all Marvell EBU platforms have been converted to use the mvebu-mbus driver, we can remove the common plat-orion/addr-map.c code that isn't compiled anymore.

---
 arch/arm/plat-orion/addr-map.c |  175 ----------------------------------------
 1 file changed, 175 deletions(-)
 delete mode 100644 arch/arm/plat-orion/addr-map.c

Patches 2-7 of this series applied to mvebu/soc

thx,

Jason.

#10 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

In reply to Thomas Petazzoni
Quoted 11 lines · Thomas Petazzoni

Changes since v2:

* Remove the DT binding, and use the mvebu_mbus_init() function call in all Marvell EBU SoC families. Requested by Arnd Bergmann.

* Fix the MV78xx0 code, after reports of issues by Gregory Clement when testing on this platform.

* Remove the 3 patches that have been merged by Arnd in arm-soc/mvebu-cleanup.

Thanks for the update

#11 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Thomas Petazzoni

Changes since v2:

* Remove the DT binding, and use the mvebu_mbus_init() function call in all Marvell EBU SoC families. Requested by Arnd Bergmann.

* Fix the MV78xx0 code, after reports of issues by Gregory Clement when testing on this platform.

Quoted 7 lines
Quoted 3 lines

* Remove the 3 patches that have been merged by Arnd in arm-soc/mvebu-cleanup.

Thanks for the update

And thanks for turning this around so quickly Thomas, I'll pull it in tonight or tomorrow. Hopefully pcie goes smoothly as well.

thx,

Jason.

#12 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

Thomas,

This set of patches seems to break the mvsdio driver (and hence mwifiex_sdio) on the Globalscale Mirabox. I believe this is because mvsdio.c contains a function mv_conf_mbus_windows that seems to conflict with the new mbus driver. I don't understand enough about the hardware (without the datasheets anyway) to be able to understand the exact problem, but I hope that this is enough to point you (or someone else) to it!

For reference, here is the dmesg output when I try to insert the mwifiex_sdio module with this series of patches applied:

root at mirabox:~# modprobe mwifiex_sdio

[  131.500945] mwifiex_sdio mmc0:0001:1: WLAN FW is active
[  131.673630] mwifiex_sdio mmc0:0001:1: host_to_card, write iomem (1)
failed: -110
[  132.687086] mvsdio d00d4000.mvsdio: FIFO_EMPTY bit missing
[  132.697084] [sched_delayed] sched: RT throttling activated
[  132.859950] mwifiex_sdio mmc0:0001:1: host_to_card, write iomem (2)
failed: -110
[  133.876487] mvsdio d00d4000.mvsdio: FIFO_EMPTY bit missing
[  134.049343] mwifiex_sdio mmc0:0001:1: host_to_card, write iomem (3)
failed: -110
[  134.056784] mwifiex_sdio mmc0:0001:1: DNLD_CMD: host to card failed
[  167.860538] hub 1-1:1.0: cannot reset port 2 (err = -110)
[  168.870536] hub 1-1:1.0: cannot reset port 2 (err = -110)
[  169.879536] hub 1-1:1.0: cannot reset port 2 (err = -110)
[  170.889019] hub 1-1:1.0: cannot reset port 2 (err = -110)
[  171.898509] hub 1-1:1.0: cannot reset port 2 (err = -110)
[  171.903922] hub 1-1:1.0: Cannot enable port 2.  Maybe the USB cable is bad?
[  172.918005] hub 1-1:1.0: cannot disable port 2 (err = -110)
[  173.927496] hub 1-1:1.0: cannot reset port 2 (err = -110)
[  174.936997] hub 1-1:1.0: cannot reset port 2 (err = -110)

After that the USB ports fail, and I start to get some serious errors as I'm running with my root filesystem on an SD card (which is connected via USB in the Mirabox).

I hope this helps someone come up with a patch to fix it. If you need any further testing / debugging done, please let me know.

Cheers,
Neil Greatorex

Quoted 29 lines · Jason Cooper
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Thomas Petazzoni

Changes since v2:

* Remove the DT binding, and use the mvebu_mbus_init() function call in all Marvell EBU SoC families. Requested by Arnd Bergmann.

* Fix the MV78xx0 code, after reports of issues by Gregory Clement when testing on this platform.

Quoted 7 lines
Quoted 3 lines

* Remove the 3 patches that have been merged by Arnd in arm-soc/mvebu-cleanup.

Thanks for the update

And thanks for turning this around so quickly Thomas, I'll pull it in tonight or tomorrow. Hopefully pcie goes smoothly as well.

thx,

Jason.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#13 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

Hi Neil,

Quoted 9 lines · Neil Greatorex

Thomas,

This set of patches seems to break the mvsdio driver (and hence mwifiex_sdio) on the Globalscale Mirabox. I believe this is because mvsdio.c contains a function mv_conf_mbus_windows that seems to conflict with the new mbus driver. I don't understand enough about the hardware (without the datasheets anyway) to be able to understand the exact problem, but I hope that this is enough to point you (or someone else) to it!

I've been working on getting my Mirabox running with the mainline kernel. There seems to be a problem with DMA and the mvsdio driver, which causes the exact same dmesg for me. Try loading the mvsdio driver like so: "modprobe mvsdio nodma=1" and then modprobe the mwifiex_sdio driver and see if it works for you too.

Ryan

#14 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

Ryan,

Quoted 13 lines · Ryan Press

Hi Neil,

Quoted 9 lines · Neil Greatorex

Thomas,

This set of patches seems to break the mvsdio driver (and hence mwifiex_sdio) on the Globalscale Mirabox. I believe this is because mvsdio.c contains a function mv_conf_mbus_windows that seems to conflict with the new mbus driver. I don't understand enough about the hardware (without the datasheets anyway) to be able to understand the exact problem, but I hope that this is enough to point you (or someone else) to it!

Quoted 8 lines

I've been working on getting my Mirabox running with the mainline kernel. There seems to be a problem with DMA and the mvsdio driver, which causes the exact same dmesg for me. Try loading the mvsdio driver like so: "modprobe mvsdio nodma=1" and then modprobe the mwifiex_sdio driver and see if it works for you too.

Ryan

Thanks for the information. Yes that does fix the issue, because the mvsdio driver then no longer needs to use the SDRAM address windows to do DMA transfers. However, it turns out that by doing this you are masking the bug that what actually introduced in the mbus driver (see my earlier reply to Thomas). Still, this does mean that the wifi adapter actually works now as even with the mbus fix it's unreliable, so thanks.

Cheers,
Neil

#15 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

In reply to Neil Greatorex

Dear Neil Greatorex,

Quoted 7 lines · Neil Greatorex

This set of patches seems to break the mvsdio driver (and hence mwifiex_sdio) on the Globalscale Mirabox. I believe this is because mvsdio.c contains a function mv_conf_mbus_windows that seems to conflict with the new mbus driver. I don't understand enough about the hardware (without the datasheets anyway) to be able to understand the exact problem, but I hope that this is enough to point you (or someone else) to it!

Thanks for reporting this problem. As Ryan Press said in reply to your e-mail, it is well known that the mvsdio driver doesn't handle DMA properly with SDIO devices that are not SD cards, and this, regardless of whether the mvebu-mbus driver patches are applied or not.

Therefore, are you sure that this problem is really introduced by the mvebu-mbus driver, and doesn't exist without applying the patches?

The mv_conf_mbus_windows() function of the mvsdio driver doesn't conflict with the mvebu-mbus driver. What the mvsdio driver does is request the list of DRAM chip-selects using mv_mbus_dram_info(), and configure the SDIO unit with those informations in mv_conf_mbus_windows(). But yes, the list of DRAM chip-selects is provided by mv_mbus_dram_info() and this function has changed by the introduction of the mvebu-mbus driver.

I'm on the move right now, so I don't have hardware around to test this. Would it be possible for you to test the Mirabox with the following patch applied on mvsdio, and do a run with and without the patch series that introduces mvebu-mbus? The idea is that the informations listed should be identical. If not, then indeed there is potentially a problem with the mvebu-mbus driver.

drivers/mmc/host/mvsdio.c +2 -0
index 145cdaf..65648ee 100644
@@ -674,6 +674,8 @@ mv_conf_mbus_windows(struct mvsd_host *host,
 
        for (i = 0; i < dram->num_cs; i++) {
                const struct mbus_dram_window *cs = dram->cs + i;
+               pr_info("mvsdio: CS[%d], base = 0x%x, size = 0x%x, mbus_attr = 0x%x\n",
+                       i, cs->base, cs->size, cs->mbus_attr);
                writel(((cs->size - 1) & 0xffff0000) |
                       (cs->mbus_attr << 8) |
                       (dram->mbus_dram_target_id << 4) | 1,

Thanks a lot!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#16 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

Thomas,

Quoted 28 lines · Thomas Petazzoni

Dear Neil Greatorex,

Quoted 7 lines · Neil Greatorex

This set of patches seems to break the mvsdio driver (and hence mwifiex_sdio) on the Globalscale Mirabox. I believe this is because mvsdio.c contains a function mv_conf_mbus_windows that seems to conflict with the new mbus driver. I don't understand enough about the hardware (without the datasheets anyway) to be able to understand the exact problem, but I hope that this is enough to point you (or someone else) to it!

Thanks for reporting this problem. As Ryan Press said in reply to your e-mail, it is well known that the mvsdio driver doesn't handle DMA properly with SDIO devices that are not SD cards, and this, regardless of whether the mvebu-mbus driver patches are applied or not.

Therefore, are you sure that this problem is really introduced by the mvebu-mbus driver, and doesn't exist without applying the patches?

The mv_conf_mbus_windows() function of the mvsdio driver doesn't conflict with the mvebu-mbus driver. What the mvsdio driver does is request the list of DRAM chip-selects using mv_mbus_dram_info(), and configure the SDIO unit with those informations in mv_conf_mbus_windows(). But yes, the list of DRAM chip-selects is provided by mv_mbus_dram_info() and this function has changed by the introduction of the mvebu-mbus driver.

Quoted 7 lines

I'm on the move right now, so I don't have hardware around to test this. Would it be possible for you to test the Mirabox with the following patch applied on mvsdio, and do a run with and without the patch series that introduces mvebu-mbus? The idea is that the informations listed should be identical. If not, then indeed there is potentially a problem with the mvebu-mbus driver.

Thanks for your information. I have managed to track down the bug. It seems that two crucial lines were missed in the conversion to the mvebu-mbus driver - the lines that set the hw_io_coherency flag if a marvell,coherency-fabric compatible node is in the device tree. This leads to the differences below that I found using your printk patch:

Before mvebu-mbus patches:

[SD] root at mirabox:~# modprobe mvsdio

[  134.595899] mvsdio: CS[0], base = 0x0, size = 0x20000000, mbus_attr = 
0x1e
[  134.602821] mvsdio: CS[1], base = 0x20000000, size = 0x20000000, 
mbus_attr = 0x1d
[  134.643933] mmc0: mvsdio driver initialized, lacking card detect (fall 
back to polling)
[  134.660814] mmc0: new high speed SDIO card at address 0001

After mvebu-mbus patches:

[SD] root at mirabox:~# modprobe mvsdio

[  107.462881] mvsdio: CS[0], base = 0x0, size = 0x20000000, mbus_attr = 
0xe
[  107.469766] mvsdio: CS[1], base = 0x20000000, size = 0x20000000, 
mbus_attr = 0xd
[  107.516219] mmc0: mvsdio driver initialized, lacking card detect (fall 
back to polling)
[  107.533029] mmc0: new high speed SDIO card at address 0001

Here is a patch that restores the behaviour to how it was before the mbus patches, but it obviously needs testing on other hardware than the Mirabox. It has been based on your marvell-mvebu-mbus-v3 branch from Github:

-- >8 --
Subject: [PATCH] bus: mvebu-mbus: Restore checking for coherency fabric
hardware

The new mvebu-mbus driver was not checking the device tree for coherency fabric hardware and hence was not setting the hw_io_coherency flag in mbus_state. This prevented the mvsdio driver from operating correctly. This patch restores the check.

---
  drivers/bus/mvebu-mbus.c |    3 +++
  1 file changed, 3 insertions(+)
drivers/bus/mvebu-mbus.c +0 -0
index 586d03e..a0250c6 100644
@@ -858,6 +858,9 @@ int __init mvebu_mbus_init(const char *soc, 

phys_addr_t mbuswins_phys_base,
return -ENOMEM;
}

+ if (of_find_compatible_node(NULL, NULL,
"marvell,coherency-fabric"))
+ mbus->hw_io_coherency = 1;
+
for (win = 0; win < mbus->soc->num_wins; win++)
mvebu_mbus_disable_window(mbus, win);

Signature · 8 lines
1.7.10.4

I hope that works for you on the Mirabox and the other platforms...

<Thomas' patch snipped>

Cheers,
Neil
#17 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

Thomas,

Quoted 8 lines · Neil Greatorex

Thomas,

Quoted 4 lines · Thomas Petazzoni

Dear Neil Greatorex,

On Thu, 28 Mar 2013 01:32:11 +0000, Neil Greatorex wrote:

...

Quoted 37 lines

Thanks for your information. I have managed to track down the bug. It seems that two crucial lines were missed in the conversion to the mvebu-mbus driver - the lines that set the hw_io_coherency flag if a marvell,coherency-fabric compatible node is in the device tree. This leads to the differences below that I found using your printk patch:

Before mvebu-mbus patches:

[SD] root at mirabox:~# modprobe mvsdio

[  134.595899] mvsdio: CS[0], base = 0x0, size = 0x20000000,
mbus_attr = 0x1e
[  134.602821] mvsdio: CS[1], base = 0x20000000, size = 0x20000000,
mbus_attr = 0x1d
[  134.643933] mmc0: mvsdio driver initialized, lacking card detect
(fall back to polling)
[  134.660814] mmc0: new high speed SDIO card at address 0001

After mvebu-mbus patches:

[SD] root at mirabox:~# modprobe mvsdio

[  107.462881] mvsdio: CS[0], base = 0x0, size = 0x20000000,
mbus_attr = 0xe
[  107.469766] mvsdio: CS[1], base = 0x20000000, size = 0x20000000,
mbus_attr = 0xd
[  107.516219] mmc0: mvsdio driver initialized, lacking card detect
(fall back to polling)
[  107.533029] mmc0: new high speed SDIO card at address 0001

Here is a patch that restores the behaviour to how it was before the mbus patches, but it obviously needs testing on other hardware than the Mirabox. It has been based on your marvell-mvebu-mbus-v3 branch from Github:

-- >8 --
Subject: [PATCH] bus: mvebu-mbus: Restore checking for coherency fabric
hardware

Quoted 7 lines

The new mvebu-mbus driver was not checking the device tree for coherency fabric hardware and hence was not setting the hw_io_coherency flag in mbus_state. This prevented the mvsdio driver from operating correctly. This patch restores the check.

---
 drivers/bus/mvebu-mbus.c |    3 +++
 1 file changed, 3 insertions(+)

Thomas,

If you can give an Ack/Tested-by, I'll apply this on top of what I just pulled in.

thx,

Jason.

Quoted 26 lines
drivers/bus/mvebu-mbus.c +3 -0
index 586d03e..a0250c6 100644
@@ -858,6 +858,9 @@ int __init mvebu_mbus_init(const char *soc,
 phys_addr_t mbuswins_phys_base,
 		return -ENOMEM;
 	}
 
+	if (of_find_compatible_node(NULL, NULL,
 "marvell,coherency-fabric"))
+		mbus->hw_io_coherency = 1;
+
 	for (win = 0; win < mbus->soc->num_wins; win++)

mvebu_mbus_disable_window(mbus, win);

Signature · 8 lines
1.7.10.4

I hope that works for you on the Mirabox and the other platforms...

<Thomas' patch snipped>

Cheers,
Neil
#18 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

In reply to Neil Greatorex

On Thu, Mar 28, 2013 at 10:27:28PM +0000, Neil Greatorex wrote:
...

Quoted 8 lines

-- >8 --
Subject: [PATCH] bus: mvebu-mbus: Restore checking for coherency fabric
hardware

The new mvebu-mbus driver was not checking the device tree for coherency fabric hardware and hence was not setting the hw_io_coherency flag in mbus_state. This prevented the mvsdio driver from operating correctly. This patch restores the check.

Neil,

If I could get you to put a Signed-off-by: on this, I'll queue it up so folks can test it more easily.

thx,

Jason.

Quoted 22 lines
---
 drivers/bus/mvebu-mbus.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/bus/mvebu-mbus.c +3 -0
index 586d03e..a0250c6 100644
@@ -858,6 +858,9 @@ int __init mvebu_mbus_init(const char *soc,
 phys_addr_t mbuswins_phys_base,
 		return -ENOMEM;
 	}
 
+	if (of_find_compatible_node(NULL, NULL,
 "marvell,coherency-fabric"))
+		mbus->hw_io_coherency = 1;
+
 	for (win = 0; win < mbus->soc->num_wins; win++)

mvebu_mbus_disable_window(mbus, win);

Signature · 1 line
1.7.10.4
#19 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

Quoted 11 lines · Jason Cooper

On Thu, Mar 28, 2013 at 10:27:28PM +0000, Neil Greatorex wrote:
...

Quoted 8 lines

-- >8 --
Subject: [PATCH] bus: mvebu-mbus: Restore checking for coherency fabric
hardware

The new mvebu-mbus driver was not checking the device tree for coherency fabric hardware and hence was not setting the hw_io_coherency flag in mbus_state. This prevented the mvsdio driver from operating correctly. This patch restores the check.

Quoted 9 lines

Neil,

If I could get you to put a Signed-off-by: on this, I'll queue it up so folks can test it more easily.

thx,

Jason.

Jason,

Thanks. I've included it below.

Cheers,
Neil

Subject: [PATCH] bus: mvebu-mbus: Restore checking for coherency fabric
hardware

The new mvebu-mbus driver was not checking the device tree for coherency fabric hardware and hence was not setting the hw_io_coherency flag in mbus_state. This prevented the mvsdio driver from operating correctly. This patch restores the check.

---
  drivers/bus/mvebu-mbus.c |    3 +++
  1 file changed, 3 insertions(+)
drivers/bus/mvebu-mbus.c +0 -0
index 586d03e..a0250c6 100644
@@ -858,6 +858,9 @@ int __init mvebu_mbus_init(const char *soc, 

phys_addr_t mbuswins_phys_base,
return -ENOMEM;
}

+ if (of_find_compatible_node(NULL, NULL,
"marvell,coherency-fabric"))
+ mbus->hw_io_coherency = 1;
+
for (win = 0; win < mbus->soc->num_wins; win++)
mvebu_mbus_disable_window(mbus, win);

Signature · 1 line
1.7.10.4
Applied
#20 lore raw

PATCH v3 1/1 Introduce a Marvell EBU MBus driver

On Sat, Mar 30, 2013 at 08:41:20PM +0000, Neil Greatorex wrote:
...

Quoted 8 lines

Subject: [PATCH] bus: mvebu-mbus: Restore checking for coherency fabric
hardware

The new mvebu-mbus driver was not checking the device tree for coherency fabric hardware and hence was not setting the hw_io_coherency flag in mbus_state. This prevented the mvsdio driver from operating correctly. This patch restores the check.

Quoted 4 lines
---
 drivers/bus/mvebu-mbus.c |    3 +++
 1 file changed, 3 insertions(+)

Applied to mvebu/drivers

thx,

Jason.