arm: mvebu: sdram: Enable ECC support on Armada XP
Subsystems (3)
PATCH 1/5 arm: mvebu: sdram: Enable ECC support on Armada XP
This is tested on the DB-MV784MP-GP eval board. To really enable ECC support on this board the I2C EEPROM needs to get changed. As it saves the enabling of ECC support internally. For this the following commands can be used to enable ECC support on this board:
Its recommended for first save (print) the value(s) in this EEPROM address:
=> i2c md 4e 0.1 2
0000: 05 00 ..
To enable ECC support you need to set bit 1 in the 2nd byte:
Marvell>> i2c mw 4e 1.1 02
Marvell>> i2c md 4e 0.1 2
0000: 05 02 ..
To disable ECC support again, please use this command:
Marvell>> i2c mw 4e 1.1 00
Marvell>> i2c md 4e 0.1 2
0000: 05 00 ..
On other AXP boards, simply plugging an ECC DIMM should be enough to enable ECC support.
--- drivers/ddr/marvell/axp/ddr3_axp_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/marvell/axp/ddr3_axp_config.h +1 -1
@@ -44,7 +44,7 @@* DDR3_TRAINING_DEBUG - Debug prints of internal code */ #define DDR_TARGET_FABRIC 5 -#define DRAM_ECC 0 +#define DRAM_ECC 1#ifdef MV_DDR_32BIT #define BUS_WIDTH 32
Signature · 1 line
2.4.8
PATCH 2/5 arm: mvebu: Display ECC enabled / disabled upon bootup
This patch adds "(ECC enabled)" or "(ECC disabled)" to the DRAM bootup text. Making it easier for board with SPD DIMM's to see, if ECC is enabled or not.
--- arch/arm/mach-mvebu/dram.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm/mach-mvebu/dram.c +19 -0
@@ -12,6 +12,13 @@#include <asm/arch/cpu.h> #include <asm/arch/soc.h> +#ifdef CONFIG_SYS_MVEBU_DDR_A38X +#include "../../../drivers/ddr/marvell/a38x/ddr3_init.h" +#endif +#ifdef CONFIG_SYS_MVEBU_DDR_AXP +#include "../../../drivers/ddr/marvell/axp/ddr3_init.h" +#endif +DECLARE_GLOBAL_DATA_PTR ;struct sdram_bank {
@@ -140,3 +147,15 @@ void dram_init_banksize(void) {dram_init (); } + +void board_add_ram_info (int use_default) +{ +u32 reg; + + reg =reg_read (REG_SDRAM_CONFIG_ADDR ); +if (reg & (1 <<REG_SDRAM_CONFIG_ECC_OFFS )) +printf (" (ECC" ); +else +printf (" (ECC not" ); +printf (" enabled)" ); +}
Signature · 1 line
2.4.8
PATCH 3/5 arm: mvebu: Move CONFIG_SYS_TEXT_BASE to an address < 16 MiB
In reply to Stefan RoeseThis patch moves CONFIG_SYS_TEXT_BASE to 0x00800000 for all Armada XP / 38x boards in mainline U-Boot. This is done in preparation for the ECC SDRAM scrubbing that needs to be done in the main U-Boot. The SPL (previously bin_hdr) has already scrubbed the area:
0x0000.0000 - 0x0100.0000
In this area this main U-Boot needs to get loaded. The main U-Boot then can scrub the remaining SDRAM area while running from this location.
--- include/configs/db-88f6820-gp.h | 7 ++++++- include/configs/db-mv784mp-gp.h | 7 ++++++- include/configs/maxbcm.h | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-)
include/configs/db-88f6820-gp.h +6 -1
@@ -20,7 +20,12 @@#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_DISPLAY_BOARDINFO_LATE -#define CONFIG_SYS_TEXT_BASE 0x04000000 +/* +* TEXT_BASE needs to be below 16MiB, since this area is scrubbed +* for DDR ECC byte filling in the SPL before loading the main +* U-Boot into it. +*/ +#define CONFIG_SYS_TEXT_BASE 0x00800000#define CONFIG_SYS_TCLK 250000000/* 250MHz */ /*
include/configs/db-mv784mp-gp.h +6 -1
@@ -17,7 +17,12 @@#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_DISPLAY_BOARDINFO_LATE -#define CONFIG_SYS_TEXT_BASE 0x04000000 +/* +* TEXT_BASE needs to be below 16MiB, since this area is scrubbed +* for DDR ECC byte filling in the SPL before loading the main +* U-Boot into it. +*/ +#define CONFIG_SYS_TEXT_BASE 0x00800000#define CONFIG_SYS_TCLK 250000000/* 250MHz */ /*
include/configs/maxbcm.h +6 -1
@@ -15,7 +15,12 @@#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_DISPLAY_BOARDINFO_LATE -#define CONFIG_SYS_TEXT_BASE 0x04000000 +/* +* TEXT_BASE needs to be below 16MiB, since this area is scrubbed +* for DDR ECC byte filling in the SPL before loading the main +* U-Boot into it. +*/ +#define CONFIG_SYS_TEXT_BASE 0x00800000#define CONFIG_SYS_TCLK 250000000/* 250MHz */ /*
Signature · 1 line
2.4.8
PATCH 4/5 arm: mvebu: dram.c: Rework dram_init() and dram_init_banksize()
In reply to Stefan RoeseRework these functions so that dram_init_banksize() does not call dram_init() again. It only needs to set the banksize values in the bdinfo struct.
Make sure to also clip the size of the last bank if it exceeds the maximum allowed value of 3 GiB (0xc000.0000). Otherwise other address windows (e.g. PCIe) will overlap with this memory window.
--- arch/arm/mach-mvebu/dram.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
arch/arm/mach-mvebu/dram.c +21 -9
@@ -35,6 +35,8 @@ struct sdram_addr_dec {#define REG_CPUCS_WIN_WIN0_CS (x) (((x) & 0x3) << 2)#define REG_CPUCS_WIN_SIZE (x) (((x) & 0xff) << 24) +#define SDRAM_SIZE_MAX 0xc0000000 +/* * mvebu_sdram_bar - reads SDRAM Base Address Register */
@@ -102,29 +104,26 @@ void mvebu_sdram_size_adjust(enum memory_bank bank)int dram_init (void ) { +u64 size =0 ;int i; - gd->ram_size =0 ;for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { - gd->bd->bi_dram[i].start =mvebu_sdram_bar (i); - gd->bd->bi_dram[i].size =mvebu_sdram_bs (i);/* * It is assumed that all memory banks are consecutive * and without gaps. * If the gap is found, ram_size will be reported for * consecutive memory only */ -if (gd->bd->bi_dram[i].start != gd->ram_size) +if (mvebu_sdram_bar (i) != size)break ;/* * Don't report more than 3GiB of SDRAM, otherwise there is no * address space left for the internal registers etc. */ -if ((gd->ram_size + gd->bd->bi_dram[i].size !=0 ) && - (gd->ram_size + gd->bd->bi_dram[i].size <= (3 <<30 ))) - gd->ram_size += gd->bd->bi_dram[i].size; - + size +=mvebu_sdram_bs (i); +if (size >SDRAM_SIZE_MAX ) + size =SDRAM_SIZE_MAX ; }for (; i <CONFIG_NR_DRAM_BANKS ; i++) {
@@ -136,6 +135,8 @@ int dram_init(void) gd->bd->bi_dram[i].size =0 ; } + gd->ram_size = size; +return 0 ; }
@@ -145,7 +146,18 @@ int dram_init(void)*/ void dram_init_banksize (void ) { -dram_init (); +u64 size =0 ; +int i; + +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { + gd->bd->bi_dram[i].start =mvebu_sdram_bar (i); + gd->bd->bi_dram[i].size =mvebu_sdram_bs (i); + +/* Clip the banksize to 1GiB if it exceeds the max size */ + size += gd->bd->bi_dram[i].size; +if (size >SDRAM_SIZE_MAX ) +mvebu_sdram_bs_set (i,0x40000000 ); + } }void board_add_ram_info (int use_default)
Signature · 1 line
2.4.8
PATCH 5/5 arm: mvebu: Add complete SDRAM ECC scrubbing
In reply to Stefan RoeseThis patch introduces the SDRAM scrubbing for ECC enabled board to fill/initialize the ECC bytes. This is done via the XOR engine to speed up the process. The scrubbing is a 2-stage process:
1) SPL scrubs the area 0 - 0x100.0000 (16MiB) for the main U-Boot
2) U-Boot scrubs the remaining SDRAM area(s)
--- arch/arm/mach-mvebu/Makefile | 4 ++ arch/arm/mach-mvebu/dram.c | 130 ++++++++++++++++++++++++++++++++++++++++-- drivers/ddr/marvell/axp/xor.c | 3 +- drivers/ddr/marvell/axp/xor.h | 1 + 4 files changed, 130 insertions(+), 8 deletions(-)
arch/arm/mach-mvebu/Makefile +4 -0
@@ -14,6 +14,10 @@ else obj-y = cpu.o obj-y += dram.o +ifndef CONFIG_SPL_BUILD +obj-$(CONFIG_SYS_MVEBU_DDR_A38X) += ../../../drivers/ddr/marvell/a38x/xor.o +obj-$(CONFIG_SYS_MVEBU_DDR_AXP) += ../../../drivers/ddr/marvell/axp/xor.o +endif obj-y += gpio.o obj-y += mbus.o obj-y += timer.o
arch/arm/mach-mvebu/dram.c +124 -6
162 lines not on this page · raw message
drivers/ddr/marvell/axp/xor.c +1 -2
@@ -18,7 +18,6 @@ static u32 xor_regs_ctrl_backup;static u32 xor_regs_base_backup[MAX_CS ];static u32 xor_regs_mask_backup[MAX_CS ]; -static void mv_xor_hal_init (u32 chan_num);static int mv_xor_cmd_set (u32 chan,int command);static int mv_xor_ctrl_set (u32 chan,u32 xor_ctrl);
@@ -110,7 +109,7 @@ void mv_sys_xor_finish(void)* RETURN: * MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. */ -static void mv_xor_hal_init (u32 chan_num) +void mv_xor_hal_init (u32 chan_num) {u32 i;
drivers/ddr/marvell/axp/xor.h +1 -0
@@ -60,6 +60,7 @@ struct crc_dma_desc {u32 src_addr1;/* Mode: Source Block address pointer */ } __packed; +void mv_xor_hal_init (u32 chan_num);int mv_xor_state_get (u32 chan);void mv_sys_xor_init (MV_DRAM_INFO *dram_info);void mv_sys_xor_finish (void );
Signature · 1 line
2.4.8