arm: mvebu: Add basic address decoding support for Marvell 370/XP
Subsystems (5)
PATCH v2 1/1 arm: mvebu: Add basic address decoding support for Marvell 370/XP
Andrew, Jason, Gr?gory,
Here is a small patch set that introduces basic support for address decoding on Armada 370 and Armada XP. The aim of this basic support is essentially to be able to configure a window to remap the BootROM, which is needed to startup the secondary CPUs for the SMP support.
As we had discussed already, the address decoding configuration is not described in the Device Tree, it is for now hardcoded on a per-SoC basis. We might later discuss how to extend this to the Device Tree.
This patch set has five patches:
(*) First patch reworks the addr-map code to use void __iomem * where
appropriate instead of u32, as per the suggestion of Arnd Bergmann.
(*) Second patch introducing PLAT_ORION_LEGACY, which allows the
Marvell 370/XP platforms to be part of PLAT_ORION, and therefore re-use the existing address decoding code.
(*) Third patch making a small change to an address decoding
structure so that we can define at runtime the virtual address of the configuration registers. This is needed as on Armada 370/XP the address decoding "controller" is declared in the Device Tree.
(*) Fourth patch adding the 370/XP address decoding code itself. For
now, it only maps the BootROM on Armada XP.
(*) Fifth path adding the necessary DT code to instantiate the
address decoding "controller".
Changes since v1:
* Use void __iomem * in addr-map code. Suggested by Arnd Bergmann.
* Add Acked-by on patches 2->5 from Gr?gory Cl?ment
Thanks,
Thomas Petazzoni
PATCH 1/5 arm: plat-orion: use 'void __iomem *' in addr-map code
Use 'void __iomem *' instead of u32 where appropriate in the addr-map code. It requires adding a few casts in SoC-specific addr-map.c files, but those casts will disappear once those SoC are migrated to the device tree, in which case the address will come from the DT instead of from #define values.
--- arch/arm/mach-dove/addr-map.c | 2 +- arch/arm/mach-kirkwood/addr-map.c | 5 +++-- arch/arm/mach-mv78xx0/addr-map.c | 4 ++-- arch/arm/mach-orion5x/addr-map.c | 5 +++-- arch/arm/plat-orion/addr-map.c | 11 ++++------- arch/arm/plat-orion/include/plat/addr-map.h | 4 ++-- 6 files changed, 15 insertions(+), 16 deletions(-)
arch/arm/mach-dove/addr-map.c +1 -1
@@ -47,7 +47,7 @@ static inline void __iomem *ddr_map_sc(int i)static struct __initdata orion_addr_map_cfg addr_map_cfg = { .num_wins =8 , .remappable_wins =4 , - .bridge_virt_base =BRIDGE_VIRT_BASE , + .bridge_virt_base = (void __iomem *)BRIDGE_VIRT_BASE , };static const struct __initdata orion_addr_map_info addr_map_info[] = {
arch/arm/mach-kirkwood/addr-map.c +3 -2
@@ -41,7 +41,7 @@static struct __initdata orion_addr_map_cfg addr_map_cfg = { .num_wins =8 , .remappable_wins =4 , - .bridge_virt_base =BRIDGE_VIRT_BASE , + .bridge_virt_base = (void __iomem *)BRIDGE_VIRT_BASE , };static const struct __initdata orion_addr_map_info addr_map_info[] = {
@@ -86,5 +86,6 @@ void __init kirkwood_setup_cpu_mbus(void)/* * Setup MBUS dram target info. */ -orion_setup_cpu_mbus_target (&addr_map_cfg,DDR_WINDOW_CPU_BASE ); +orion_setup_cpu_mbus_target (&addr_map_cfg, + (void __iomem *)DDR_WINDOW_CPU_BASE ); }
arch/arm/mach-mv78xx0/addr-map.c +2 -2
@@ -71,10 +71,10 @@ void __init mv78xx0_setup_cpu_mbus(void)*/ if (mv78xx0_core_index () ==0 )orion_setup_cpu_mbus_target (&addr_map_cfg, -DDR_WINDOW_CPU0_BASE ); + (void __iomem *)DDR_WINDOW_CPU0_BASE );else orion_setup_cpu_mbus_target (&addr_map_cfg, -DDR_WINDOW_CPU1_BASE ); + (void __iomem *)DDR_WINDOW_CPU1_BASE ); } void __init mv78xx0_setup_pcie_io_win(int window, u32 base, u32 size,
arch/arm/mach-orion5x/addr-map.c +3 -2
@@ -79,7 +79,7 @@ static int __init cpu_win_can_remap(const struct orion_addr_map_cfg *cfg,static struct orion_addr_map_cfg addr_map_cfg__initdata = { .num_wins =8 , .cpu_win_can_remap = cpu_win_can_remap, - .bridge_virt_base =ORION5X_BRIDGE_VIRT_BASE , + .bridge_virt_base = (void __iomem *)ORION5X_BRIDGE_VIRT_BASE , };static const struct __initdata orion_addr_map_info addr_map_info[] = {
@@ -113,7 +113,8 @@ void __init orion5x_setup_cpu_mbus_bridge(void)/* * Setup MBUS dram target info. */ -orion_setup_cpu_mbus_target (&addr_map_cfg,ORION5X_DDR_WINDOW_CPU_BASE ); +orion_setup_cpu_mbus_target (&addr_map_cfg, + (void __iomem *)ORION5X_DDR_WINDOW_CPU_BASE ); }void __init orion5x_setup_dev_boot_win (u32 base,u32 size)
arch/arm/plat-orion/addr-map.c +4 -7
@@ -48,7 +48,7 @@ EXPORT_SYMBOL_GPL(mv_mbus_dram_info);static void __init __iomem *orion_win_cfg_base (const struct orion_addr_map_cfg *cfg,int win) { -return (void __iomem *)(cfg->bridge_virt_base + (win <<4 )); +return cfg->bridge_virt_base + (win <<4 ); }/*
@@ -143,19 +143,16 @@ void __init orion_config_wins(struct orion_addr_map_cfg * cfg,* Setup MBUS dram target info. */ void __init orion_setup_cpu_mbus_target (const struct orion_addr_map_cfg *cfg, -const u32 ddr_window_cpu_base) +const void __iomem *ddr_window_cpu_base) { -void __iomem *addr;int i;int cs; orion_mbus_dram_info.mbus_dram_target_id =TARGET_DDR ; - addr = (void __iomem *)ddr_window_cpu_base; -for (i =0 , cs =0 ; i <4 ; i++) { -u32 base =readl (addr +DDR_BASE_CS_OFF (i)); -u32 size =readl (addr +DDR_SIZE_CS_OFF (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?
arch/arm/plat-orion/include/plat/addr-map.h +2 -2
@@ -16,7 +16,7 @@ extern struct mbus_dram_target_info orion_mbus_dram_info;struct orion_addr_map_cfg {const int num_wins;/* Total number of windows */ const int remappable_wins; -const u32 bridge_virt_base; +void __iomem *const bridge_virt_base;/* If NULL, the default cpu_win_can_remap will be used, using the value in remappable_wins */
@@ -49,5 +49,5 @@ void __init orion_setup_cpu_win(const struct orion_addr_map_cfg *cfg, const u8 attr, const int remap);void __init orion_setup_cpu_mbus_target (const struct orion_addr_map_cfg *cfg, -const u32 ddr_window_cpu_base); +const void __iomem *ddr_window_cpu_base);#endif
Signature · 1 line
1.7.9.5
PATCH 1/5 arm: plat-orion: use 'void __iomem *' in addr-map code
Quoted 7 lines · Thomas Petazzoni
Use 'void
__iomem*' instead of u32 where appropriate in the addr-map code. It requires adding a few casts in SoC-specificaddr-map.cfiles, but those casts will disappear once those SoC are migrated to the device tree, in which case the address will come from the DT instead of from #define values.Signed-off-by Thomas Petazzoni <[email protected]>
Thomas,
I just wanted to make sure this came to your attention. While discussing the finer points of branch management for pull requests, Olof had the following comments regarding this patch:
Quoted 5 lines
Quoted 1 line
arm: plat-orion: use 'void
__iomem*' in addr-map codeHmm, I would prefer if the actual constants were annotated instead of cast in the code here. See how we handled that on tegra with
IOMEM(). That will also help sparse catch unannotated uses of those constants.
Could you please take a look at this? I assume the rest of this series relies on this patch, so I'm holding off until it's resolved.
thx,
Jason.
Quoted 147 lines
--- arch/arm/mach-dove/addr-map.c | 2 +- arch/arm/mach-kirkwood/addr-map.c | 5 +++-- arch/arm/mach-mv78xx0/addr-map.c | 4 ++-- arch/arm/mach-orion5x/addr-map.c | 5 +++-- arch/arm/plat-orion/addr-map.c | 11 ++++------- arch/arm/plat-orion/include/plat/addr-map.h | 4 ++-- 6 files changed, 15 insertions(+), 16 deletions(-)arch/arm/mach-dove/addr-map.c +1
-1@@ -47,7 +47,7 @@ static inline void __iomem *ddr_map_sc(int i)static struct __initdata orion_addr_map_cfg addr_map_cfg = { .num_wins =8 , .remappable_wins =4 , - .bridge_virt_base =BRIDGE_VIRT_BASE , + .bridge_virt_base = (void __iomem *)BRIDGE_VIRT_BASE , };static const struct __initdata orion_addr_map_info addr_map_info[] = {arch/arm/mach-kirkwood/addr-map.c +3
-2@@ -41,7 +41,7 @@static struct __initdata orion_addr_map_cfg addr_map_cfg = { .num_wins =8 , .remappable_wins =4 , - .bridge_virt_base =BRIDGE_VIRT_BASE , + .bridge_virt_base = (void __iomem *)BRIDGE_VIRT_BASE , };static const struct __initdata orion_addr_map_info addr_map_info[] = {@@ -86,5 +86,6 @@ void __init kirkwood_setup_cpu_mbus(void)/* * Setup MBUS dram target info. */ -orion_setup_cpu_mbus_target (&addr_map_cfg,DDR_WINDOW_CPU_BASE ); +orion_setup_cpu_mbus_target (&addr_map_cfg, + (void __iomem *)DDR_WINDOW_CPU_BASE ); }arch/arm/mach-mv78xx0/addr-map.c +2
-2@@ -71,10 +71,10 @@ void __init mv78xx0_setup_cpu_mbus(void)*/ if (mv78xx0_core_index () ==0 )orion_setup_cpu_mbus_target (&addr_map_cfg, -DDR_WINDOW_CPU0_BASE ); + (void __iomem *)DDR_WINDOW_CPU0_BASE );else orion_setup_cpu_mbus_target (&addr_map_cfg, -DDR_WINDOW_CPU1_BASE ); + (void __iomem *)DDR_WINDOW_CPU1_BASE ); } void __init mv78xx0_setup_pcie_io_win(int window, u32 base, u32 size,arch/arm/mach-orion5x/addr-map.c +3
-2@@ -79,7 +79,7 @@ static int __init cpu_win_can_remap(const struct orion_addr_map_cfg *cfg,static struct orion_addr_map_cfg addr_map_cfg__initdata = { .num_wins =8 , .cpu_win_can_remap = cpu_win_can_remap, - .bridge_virt_base =ORION5X_BRIDGE_VIRT_BASE , + .bridge_virt_base = (void __iomem *)ORION5X_BRIDGE_VIRT_BASE , };static const struct __initdata orion_addr_map_info addr_map_info[] = {@@ -113,7 +113,8 @@ void __init orion5x_setup_cpu_mbus_bridge(void)/* * Setup MBUS dram target info. */ -orion_setup_cpu_mbus_target (&addr_map_cfg,ORION5X_DDR_WINDOW_CPU_BASE ); +orion_setup_cpu_mbus_target (&addr_map_cfg, + (void __iomem *)ORION5X_DDR_WINDOW_CPU_BASE ); }void __init orion5x_setup_dev_boot_win (u32 base,u32 size)arch/arm/plat-orion/addr-map.c +4
-7@@ -48,7 +48,7 @@ EXPORT_SYMBOL_GPL(mv_mbus_dram_info);static void __init __iomem *orion_win_cfg_base (const struct orion_addr_map_cfg *cfg,int win) { -return (void __iomem *)(cfg->bridge_virt_base + (win <<4 )); +return cfg->bridge_virt_base + (win <<4 ); }/* @@ -143,19 +143,16 @@ void __init orion_config_wins(struct orion_addr_map_cfg * cfg,* Setup MBUS dram target info. */ void __init orion_setup_cpu_mbus_target (const struct orion_addr_map_cfg *cfg, -const u32 ddr_window_cpu_base) +const void __iomem *ddr_window_cpu_base) { -void __iomem *addr;int i;int cs; orion_mbus_dram_info.mbus_dram_target_id =TARGET_DDR ; - addr = (void __iomem *)ddr_window_cpu_base; -for (i =0 , cs =0 ; i <4 ; i++) { -u32 base =readl (addr +DDR_BASE_CS_OFF (i)); -u32 size =readl (addr +DDR_SIZE_CS_OFF (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? arch/arm/plat-orion/include/plat/addr-map.h +2
-2@@ -16,7 +16,7 @@ extern struct mbus_dram_target_info orion_mbus_dram_info;struct orion_addr_map_cfg {const int num_wins;/* Total number of windows */ const int remappable_wins; -const u32 bridge_virt_base; +void __iomem *const bridge_virt_base;/* If NULL, the default cpu_win_can_remap will be used, using the value in remappable_wins */ @@ -49,5 +49,5 @@ void __init orion_setup_cpu_win(const struct orion_addr_map_cfg *cfg, const u8 attr, const int remap);void __init orion_setup_cpu_mbus_target (const struct orion_addr_map_cfg *cfg, -const u32 ddr_window_cpu_base); +const void __iomem *ddr_window_cpu_base);#endif Signature · 7 lines
1.7.9.5 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/5 arm: plat-orion: use 'void __iomem *' in addr-map code
Jason,
Le Sun, 9 Sep 2012 16:45:19 -0400,
Jason Cooper <[email protected]> a ?crit :
Quoted 6 lines
I just wanted to make sure this came to your attention. While discussing the finer points of branch management for pull requests, Olof had the following comments regarding this patch:
Quoted 2 lines
Quoted 1 line
arm: plat-orion: use 'void
__iomem*' in addr-map code
Quoted 7 lines
Quoted 4 lines
Hmm, I would prefer if the actual constants were annotated instead of cast in the code here. See how we handled that on tegra with
IOMEM(). That will also help sparse catch unannotated uses of those constants.Could you please take a look at this? I assume the rest of this series relies on this patch, so I'm holding off until it's resolved.
Sorry for the delay, I was busy working on the Marvell Armada 370/XP network driver. I have now posted a 17 patches series that should hopefully address Olof's comment (version 4 of this patch series).
Thanks!
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 2/5 arm: plat-orion: introduce PLAT_ORION_LEGACY hidden config option
In reply to Thomas PetazzoniUntil now, the PLAT_ORION configuration option was common to all the Marvell EBU SoCs, and selecting this option had the effect of enabling the MPP code, GPIO code, address decoding and PCIe code from plat-orion, as well as providing access to driver-specific header files from plat-orion/include.
However, the Armada 370 and XP SoCs will not use the MPP and GPIO code (instead some proper pinctrl and gpio drivers are in preparation), and generally, we want to move away from plat-orion and instead have everything in mach-mvebu.
That said, in the mean time, we want to leverage the driver-specific headers as well as the address decoding code, so we introduce PLAT_ORION_LEGACY. The older Marvell SoCs need to select PLAT_ORION_LEGACY, while the newer Marvell SoCs need to select PLAT_ORION. Of course, when PLAT_ORION_LEGACY is selected, it automatically selects PLAT_ORION.
Then, with just PLAT_ORION, you have the address decoding code plus the driver-specific headers. If you add PLAT_ORION_LEGACY to this, you gain the old MPP, GPIO and PCIe code.
Again, this is only a temporary solution until we make all Marvell EBU platforms converge into the mach-mvebu directory. This solution avoids duplicating the existing address decoding code into mach-mvebu.
--- arch/arm/Kconfig | 13 +++++++++---- arch/arm/plat-orion/Makefile | 9 ++++----- 2 files changed, 13 insertions(+), 9 deletions(-)
arch/arm/Kconfig +9 -4
@@ -573,6 +573,7 @@ config ARCH_MVEBU select GENERIC_IRQ_CHIP select IRQ_DOMAIN select COMMON_CLK + select PLAT_ORION help Support for the Marvell SoC Family with device tree support
@@ -583,7 +584,7 @@ config ARCH_DOVE select ARCH_REQUIRE_GPIOLIB select GENERIC_CLOCKEVENTS select NEED_MACH_IO_H - select PLAT_ORION + select PLAT_ORION_LEGACY help Support for the Marvell Dove SoC 88AP510
@@ -594,7 +595,7 @@ config ARCH_KIRKWOOD select ARCH_REQUIRE_GPIOLIB select GENERIC_CLOCKEVENTS select NEED_MACH_IO_H - select PLAT_ORION + select PLAT_ORION_LEGACY help Support for the following Marvell Kirkwood series SoCs: 88F6180, 88F6192 and 88F6281.
@@ -621,7 +622,7 @@ config ARCH_MV78XX0 select ARCH_REQUIRE_GPIOLIB select GENERIC_CLOCKEVENTS select NEED_MACH_IO_H - select PLAT_ORION + select PLAT_ORION_LEGACY help Support for the following Marvell MV78xx0 series SoCs: MV781x0, MV782x0.
@@ -634,7 +635,7 @@ config ARCH_ORION5X select ARCH_REQUIRE_GPIOLIB select GENERIC_CLOCKEVENTS select NEED_MACH_IO_H - select PLAT_ORION + select PLAT_ORION_LEGACY help Support for the following Marvell Orion 5x series SoCs: Orion-1 (5181), Orion-VoIP (5181L), Orion-NAS (5182),
@@ -1153,6 +1154,10 @@ config PLAT_ORION select GENERIC_IRQ_CHIP select COMMON_CLK +config PLAT_ORION_LEGACY + bool + select PLAT_ORION + config PLAT_PXA bool
arch/arm/plat-orion/Makefile +4 -5
@@ -2,9 +2,8 @@ # Makefile for the linux kernel. # -obj-y := irq.o pcie.o time.o common.o mpp.o addr-map.o -obj-m := -obj-n := -obj- := +obj-y += addr-map.o -obj-$(CONFIG_GENERIC_GPIO) += gpio.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)
Signature · 1 line
1.7.9.5
PATCH 3/5 arm: plat-orion: make bridge_virt_base non-const to support DT use case
In reply to Thomas PetazzoniFor the Armada 370 and XP SoCs where the DT is used, we need to fill at runtime the bridge_virt_base field on the orion_addr_map_cfg. Therefore, remove the 'const' qualifier on this field.
--- arch/arm/plat-orion/include/plat/addr-map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-orion/include/plat/addr-map.h +1 -1
@@ -16,7 +16,7 @@ extern struct mbus_dram_target_info orion_mbus_dram_info;struct orion_addr_map_cfg {const int num_wins;/* Total number of windows */ const int remappable_wins; -void __iomem *const bridge_virt_base; +void __iomem *bridge_virt_base;/* If NULL, the default cpu_win_can_remap will be used, using the value in remappable_wins */
Signature · 1 line
1.7.9.5
PATCH 4/5 arm: mvebu: add basic address decoding support to Armada 370/XP
In reply to Thomas PetazzoniThis commit adds basic support for address decoding configuration for the Armada 370 and Armada XP SoCs, re-using the infrastructure provided in plat-orion.
For now, only a BootROM window is configured on Armada XP, which is needed to get the non-boot CPUs started and is therefore a requirement for SMP support.
--- arch/arm/mach-mvebu/Makefile | 2 +- arch/arm/mach-mvebu/addr-map.c | 134 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-mvebu/addr-map.c
arch/arm/mach-mvebu/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-y += system-controller.o -obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o +obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o addr-map.o
arch/arm/mach-mvebu/addr-map.c new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 4/5 arm: mvebu: add basic address decoding support to Armada 370/XP
Quoted 15 lines · Thomas Petazzoni
arch/arm/mach-mvebu/addr-map.c new file +15
-0+static void __iomem * +armada_cfg_base (const struct orion_addr_map_cfg *cfg,int win) +{ +unsigned int offset; + +/* The register layout is a bit annoying and the below code +* tries to cope with it. +* - At offset 0x0, there are the registers for the first 8 +* windows, with 4 registers of 32 bits per window (ctrl, +* base, remap low, remap high) +* - Then at offset 0x80, there is a hole of 0x10 bytes for +* the internal registers base address and internal units +* sync barrier register. +* - Then at offset 0x90, there the registers for 12 +* windows, with only 2 registers of 32 bits per window
arch/arm/mach-mvebu/addr-map.c line 85
Quoted 10 lines
arch/arm/mach-mvebu/addr-map.c new file +10
-0+* (ctrl, base). +*/ +if (win <8 ) + offset = (win <<4 ); +else + offset =ARMADA_WINDOW_8_PLUS_OFFSET + (win <<3 ); + +return (void __iomem *)(cfg->bridge_virt_base + offset); +} +
This cast can go away now that the type is already correct. Other than that, the patch looks fine.
Arnd
PATCH 5/5 arm: mvebu: add address decoding controller to the DT
In reply to Thomas Petazzoni--- arch/arm/boot/dts/armada-370-xp.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/boot/dts/armada-370-xp.dtsi +5 -0
@@ -63,6 +63,11 @@ reg = <0xd0020300 0x30>; interrupts = <37>, <38>, <39>, <40>; }; + + addr-decoding at d0020000 { + compatible = "marvell,armada-addr-decoding-controller"; + reg = <0xd0020000 0x258>; + }; }; };
Signature · 1 line
1.7.9.5