driver/ddr/fsl: Fix DDR4 driver
PATCH 1/2 driver/ddr/fsl: Fix DDR4 driver
When accumulated ECC is enabled, the DQ_MAP for ECC[4:7] needs to be set to 0, i.e. 0->0, 1->1, etc., required by controller logic, even these pins are not actually connected.
Also fix a bug when reading from DDR register to use proper accessor for correct endianess.
--- drivers/ddr/fsl/ctrl_regs.c | 9 +++++++-- drivers/ddr/fsl/fsl_ddr_gen4.c | 3 +-- 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/ddr/fsl/ctrl_regs.c +7 -2
@@ -1886,9 +1886,12 @@ static void set_timing_cfg_9(fsl_ddr_cfg_regs_t *ddr)debug ("FSLDDR: timing_cfg_9 = 0x%08x\n" , ddr->timing_cfg_9); } +/* This function needs to be called after set_ddr_sdram_cfg() is called */ static void set_ddr_dq_mapping (fsl_ddr_cfg_regs_t *ddr,const dimm_params_t *dimm_params) { +unsigned int acc_ecc_en = (ddr->ddr_sdram_cfg >>2 ) &0x1 ; + ddr->dq_map_0 = ((dimm_params->dq_mapping[0 ] &0x3F ) <<26 ) | ((dimm_params->dq_mapping[1 ] &0x3F ) <<20 ) | ((dimm_params->dq_mapping[2] & 0x3F) << 14) |
@@ -1907,9 +1910,11 @@ static void set_ddr_dq_mapping(fsl_ddr_cfg_regs_t *ddr, ((dimm_params->dq_mapping[15 ] &0x3F ) <<8 ) | ((dimm_params->dq_mapping[16 ] &0x3F ) <<2 ); +/* dq_map for ECC[4:7] is set to 0 if accumulated ECC is enabled */ ddr->dq_map_3 = ((dimm_params->dq_mapping[17 ] &0x3F ) <<26 ) | ((dimm_params->dq_mapping[8 ] &0x3F ) <<20 ) | - ((dimm_params->dq_mapping[9 ] &0x3F ) <<14 ) | + (acc_ecc_en ?0 : + (dimm_params->dq_mapping[9 ] &0x3F ) <<14 ) | dimm_params->dq_mapping_ors;debug ("FSLDDR: dq_map_0 = 0x%08x\n" , ddr->dq_map_0);
@@ -2276,7 +2281,7 @@ compute_fsl_memctl_config_regs(const memctl_options_t *popts,if (ip_rev >0x40400 ) unq_mrs_en =1 ; -if (ip_rev >0x40700 ) +if ((ip_rev >0x40700 ) && (popts->cswl_override !=0 )) ddr->debug[18 ] = popts->cswl_override;set_ddr_sdram_cfg_2 (ddr, popts, unq_mrs_en);
drivers/ddr/fsl/fsl_ddr_gen4.c +1 -2
@@ -216,7 +216,7 @@ step2:* For example, 2GB on 666MT/s 64-bit bus takes about 402ms * Let's wait for 800ms */ - bus_width =3 - ((ddr->sdram_cfg &SDRAM_CFG_DBW_MASK ) + bus_width =3 - ((ddr_in32 (&ddr->sdram_cfg) &SDRAM_CFG_DBW_MASK ) >>SDRAM_CFG_DBW_SHIFT ); timeout = ((total_gb_size_per_controller << (6 - bus_width)) *100 / (get_ddr_freq (0 ) >>20 )) <<2 ;
@@ -233,5 +233,4 @@ step2:if (timeout <=0 )printf ("Waiting for D_INIT timeout. Memory may not work.\n" ); - }
Signature · 1 line
1.7.9.5
PATCH 2/2 board/ls1021aqds_d4: Add DDR4 support
LS1021AQDS has a variant with DDR4 slot. This patch adds a new target for this variant and enables DDR4 support. RAW timing parameters are not added for DDR4. The board timing parameters are only tuned for single-rank 1600 and 1800MT/s with Micron DIMM 9ASF51272AZ-2G1A1 due to availability.
---
arch/arm/Kconfig | 3 +++
arch/arm/include/asm/arch-ls102xa/config.h | 5 +++++
board/freescale/ls1021aqds/Kconfig | 2 +-
board/freescale/ls1021aqds/ddr.c | 9 ++++++++-
board/freescale/ls1021aqds/ddr.h | 10 ++++++++++
...s_nor_defconfig => ls1021aqds_d4_nor_defconfig} | 1 +
include/configs/ls1021aqds.h | 4 +++-
7 files changed, 31 insertions(+), 3 deletions(-)
copy configs/{ls1021aqds_nor_defconfig => ls1021aqds_d4_nor_defconfig} (50%)arch/arm/Kconfig +3 -0
@@ -473,6 +473,9 @@ config TARGET_LS2085A_SIMU config TARGET_LS1021AQDS bool "Support ls1021aqds_nor" +config TARGET_LS1021AQDS_D4 + bool "Support ls1021aqds_nor with DDR4" + config TARGET_LS1021ATWR bool "Support ls1021atwr_nor"
arch/arm/include/asm/arch-ls102xa/config.h +5 -0
@@ -50,7 +50,11 @@#ifdef CONFIG_DDR_SPD #define CONFIG_SYS_FSL_DDR_BE #define CONFIG_VERY_BIG_RAM +#ifdef CONFIG_SYS_FSL_DDR4 +#define CONFIG_SYS_FSL_DDRC_GEN4 +#else #define CONFIG_SYS_FSL_DDRC_ARM_GEN3 +#endif #define CONFIG_SYS_FSL_DDR #define CONFIG_SYS_LS1_DDR_BLOCK1_SIZE ((phys_size_t)2 << 30)#define CONFIG_MAX_MEM_MAPPED CONFIG_SYS_LS1_DDR_BLOCK1_SIZE
@@ -71,6 +75,7 @@#define CONFIG_MAX_CPUS 2#define CONFIG_SYS_FSL_IFC_BANK_COUNT 8#define CONFIG_NUM_DDR_CONTROLLERS 1 +#define CONFIG_SYS_FSL_DDR_VER FSL_DDR_VER_5_0#else #error SoC not defined#endif
board/freescale/ls1021aqds/Kconfig +1 -1
@@ -1,4 +1,4 @@ -if TARGET_LS1021AQDS +if TARGET_LS1021AQDS || TARGET_LS1021AQDS_D4 config SYS_CPU string
board/freescale/ls1021aqds/ddr.c +8 -1
@@ -79,7 +79,6 @@ found:*/ popts->wrlvl_override =1 ; popts->wrlvl_sample =0xf ; - popts->cswl_override =DDR_CSWL_CS0 ;/* * Rtt and Rtt_WR override
@@ -89,9 +88,17 @@ found:/* Enable ZQ calibration */ popts->zq_en =1 ; +#ifdef CONFIG_SYS_FSL_DDR4 + popts->ddr_cdr1 =DDR_CDR1_DHC_EN |DDR_CDR1_ODT (DDR_CDR_ODT_80ohm); + popts->ddr_cdr2 =DDR_CDR2_ODT (DDR_CDR_ODT_80ohm) | +DDR_CDR2_VREF_OVRD (70 );/* Vref = 70% */ +#else + popts->cswl_override =DDR_CSWL_CS0 ; +/* DHC_EN =1, ODT = 75 Ohm */ popts->ddr_cdr1 =DDR_CDR1_DHC_EN |DDR_CDR1_ODT (DDR_CDR_ODT_75ohm); popts->ddr_cdr2 =DDR_CDR2_ODT (DDR_CDR_ODT_75ohm); +#endif }#ifdef CONFIG_SYS_DDR_RAW_TIMING
board/freescale/ls1021aqds/ddr.h +10 -0
@@ -30,6 +30,13 @@ static const struct board_specific_parameters udimm0[] = {* num| hi| rank| clk| wrlvl | wrlvl | wrlvl | cpo |wrdata|2T * ranks| mhz| GB |adjst| start | ctl2 | ctl3 | |delay | */ +#ifdef CONFIG_SYS_FSL_DDR4 + {2, 1666, 0, 4, 7, 0x0808090B, 0x0C0D0E0A,}, + {2, 1900, 0, 4, 6, 0x08080A0C, 0x0D0E0F0A,}, + {1, 1666, 0, 4, 8, 0x090A0B0B, 0x0C0D0E0C,}, + {1, 1900, 0, 4, 9, 0x0A0B0C0B, 0x0D0E0F0D,}, + {1, 2200, 0, 4, 10, 0x0B0C0D0C, 0x0E0F110E,}, +#elif defined(CONFIG_SYS_FSL_DDR3) {1, 833, 1, 6, 8, 0x06060607, 0x08080807, 0x1f, 2, 0}, {1, 1350, 1, 6, 8, 0x0708080A, 0x0A0B0C09, 0x1f, 2, 0}, {1, 833, 2, 6, 8, 0x06060607, 0x08080807, 0x1f, 2, 0},
@@ -39,6 +46,9 @@ static const struct board_specific_parameters udimm0[] = { {2, 1350, 0, 6, 8, 0x0708080A, 0x0A0B0C09, 0x1f, 2, 0}, {2, 1666, 4, 4, 0xa, 0x0B08090C, 0x0B0E0D0A, 0x1f, 2, 0}, {2, 1666, 0, 4, 0xa, 0x0B08090C, 0x0B0E0D0A, 0x1f, 2, 0}, +#else +#error DDR type not defined +#endif {} };
configs/ls1021aqds_d4_nor_defconfig renamed from configs/ls1021aqds_nor_defconfig +1 -0
@@ -1,2 +1,3 @@ +CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4" CONFIG_ARM=y CONFIG_TARGET_LS1021AQDS=y
include/configs/ls1021aqds.h +3 -1
@@ -49,10 +49,12 @@ unsigned long get_board_ddr_clk(void);#define CONFIG_DDR_SPD #define SPD_EEPROM_ADDRESS 0x51#define CONFIG_SYS_SPD_BUS_NUM 0 -#define CONFIG_SYS_DDR_RAW_TIMING #define CONFIG_FSL_DDR_INTERACTIVE /* Interactive debugging */ +#ifndef CONFIG_SYS_FSL_DDR4 #define CONFIG_SYS_FSL_DDR3 /* Use DDR3 memory */ +#define CONFIG_SYS_DDR_RAW_TIMING +#endif #define CONFIG_DIMM_SLOTS_PER_CTLR 1#define CONFIG_CHIP_SELECTS_PER_CTRL 4
Signature · 1 line
1.7.9.5
PATCH 2/2 board/ls1021aqds_d4: Add DDR4 support
Quoted 22 lines · York Sun
LS1021AQDS has a variant with DDR4 slot. This patch adds a new target for this variant and enables DDR4 support. RAW timing parameters are not added for DDR4. The board timing parameters are only tuned for single-rank 1600 and 1800MT/s with Micron DIMM 9ASF51272AZ-2G1A1 due to availability.
Signed-off-by York Sun <[email protected]>--- arch/arm/Kconfig | 3 +++ arch/arm/include/asm/arch-ls102xa/config.h | 5 +++++ board/freescale/ls1021aqds/Kconfig | 2 +- board/freescale/ls1021aqds/ddr.c | 9 ++++++++- board/freescale/ls1021aqds/ddr.h | 10 ++++++++++ ...s_nor_defconfig => ls1021aqds_d4_nor_defconfig} | 1 + include/configs/ls1021aqds.h | 4 +++- 7 files changed, 31 insertions(+), 3 deletions(-) copy configs/{ls1021aqds_nor_defconfig => ls1021aqds_d4_nor_defconfig} (50%)arch/arm/Kconfig +0
-0
arch/arm/Kconfig config TARGET_LS2085A_SIMU · line 477
Quoted 5 lines
arch/arm/Kconfig +2
-0@@ -473,6 +473,9 @@ config TARGET_LS2085A_SIMU config TARGET_LS1021AQDS bool "Support ls1021aqds_nor" +config TARGET_LS1021AQDS_D4 + bool "Support ls1021aqds_nor with DDR4"
Use _DDR4 for the target, easier to understand when reading later.
Quoted 32 lines
arch/arm/Kconfig +0
-0config TARGET_LS1021ATWR bool "Support ls1021atwr_nor"arch/arm/include/asm/arch-ls102xa/config.h +5
-0@@ -50,7 +50,11 @@#ifdef CONFIG_DDR_SPD #define CONFIG_SYS_FSL_DDR_BE #define CONFIG_VERY_BIG_RAM +#ifdef CONFIG_SYS_FSL_DDR4 +#define CONFIG_SYS_FSL_DDRC_GEN4 +#else #define CONFIG_SYS_FSL_DDRC_ARM_GEN3 +#endif #define CONFIG_SYS_FSL_DDR #define CONFIG_SYS_LS1_DDR_BLOCK1_SIZE ((phys_size_t)2 << 30)#define CONFIG_MAX_MEM_MAPPED CONFIG_SYS_LS1_DDR_BLOCK1_SIZE@@ -71,6 +75,7 @@#define CONFIG_MAX_CPUS 2#define CONFIG_SYS_FSL_IFC_BANK_COUNT 8#define CONFIG_NUM_DDR_CONTROLLERS 1 +#define CONFIG_SYS_FSL_DDR_VER FSL_DDR_VER_5_0#else #error SoC not defined#endif board/freescale/ls1021aqds/Kconfig +0
-0
board/freescale/ls1021aqds/Kconfig line 1
Quoted 2 lines
board/freescale/ls1021aqds/Kconfig +1
-1@@ -1,4 +1,4 @@ -if TARGET_LS1021AQDS +if TARGET_LS1021AQDS || TARGET_LS1021AQDS_D4
Same here.
Quoted 96 lines
board/freescale/ls1021aqds/Kconfig +0
-0config SYS_CPU stringboard/freescale/ls1021aqds/ddr.c +8
-1@@ -79,7 +79,6 @@ found:*/ popts->wrlvl_override =1 ; popts->wrlvl_sample =0xf ; - popts->cswl_override =DDR_CSWL_CS0 ;/* * Rtt and Rtt_WR override @@ -89,9 +88,17 @@ found:/* Enable ZQ calibration */ popts->zq_en =1 ; +#ifdef CONFIG_SYS_FSL_DDR4 + popts->ddr_cdr1 =DDR_CDR1_DHC_EN |DDR_CDR1_ODT (DDR_CDR_ODT_80ohm); + popts->ddr_cdr2 =DDR_CDR2_ODT (DDR_CDR_ODT_80ohm) | +DDR_CDR2_VREF_OVRD (70 );/* Vref = 70% */ +#else + popts->cswl_override =DDR_CSWL_CS0 ; +/* DHC_EN =1, ODT = 75 Ohm */ popts->ddr_cdr1 =DDR_CDR1_DHC_EN |DDR_CDR1_ODT (DDR_CDR_ODT_75ohm); popts->ddr_cdr2 =DDR_CDR2_ODT (DDR_CDR_ODT_75ohm); +#endif }#ifdef CONFIG_SYS_DDR_RAW_TIMING board/freescale/ls1021aqds/ddr.h +10
-0@@ -30,6 +30,13 @@ static const struct board_specific_parameters udimm0[] = {* num| hi| rank| clk| wrlvl | wrlvl | wrlvl | cpo |wrdata|2T * ranks| mhz| GB |adjst| start | ctl2 | ctl3 | |delay | */ +#ifdef CONFIG_SYS_FSL_DDR4 + {2, 1666, 0, 4, 7, 0x0808090B, 0x0C0D0E0A,}, + {2, 1900, 0, 4, 6, 0x08080A0C, 0x0D0E0F0A,}, + {1, 1666, 0, 4, 8, 0x090A0B0B, 0x0C0D0E0C,}, + {1, 1900, 0, 4, 9, 0x0A0B0C0B, 0x0D0E0F0D,}, + {1, 2200, 0, 4, 10, 0x0B0C0D0C, 0x0E0F110E,}, +#elif defined(CONFIG_SYS_FSL_DDR3) {1, 833, 1, 6, 8, 0x06060607, 0x08080807, 0x1f, 2, 0}, {1, 1350, 1, 6, 8, 0x0708080A, 0x0A0B0C09, 0x1f, 2, 0}, {1, 833, 2, 6, 8, 0x06060607, 0x08080807, 0x1f, 2, 0},@@ -39,6 +46,9 @@ static const struct board_specific_parameters udimm0[] = { {2, 1350, 0, 6, 8, 0x0708080A, 0x0A0B0C09, 0x1f, 2, 0}, {2, 1666, 4, 4, 0xa, 0x0B08090C, 0x0B0E0D0A, 0x1f, 2, 0}, {2, 1666, 0, 4, 0xa, 0x0B08090C, 0x0B0E0D0A, 0x1f, 2, 0}, +#else +#error DDR type not defined +#endif {} };configs/ls1021aqds_d4_nor_defconfig renamed from configs/ls1021aqds_nor_defconfig +1
-0@@ -1,2 +1,3 @@ +CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4" CONFIG_ARM=y CONFIG_TARGET_LS1021AQDS=yinclude/configs/ls1021aqds.h +3
-2@@ -49,10 +49,12 @@ unsigned long get_board_ddr_clk(void);#define CONFIG_DDR_SPD #define SPD_EEPROM_ADDRESS 0x51#define CONFIG_SYS_SPD_BUS_NUM 0 -#define CONFIG_SYS_DDR_RAW_TIMING #define CONFIG_FSL_DDR_INTERACTIVE /* Interactive debugging */ +#ifndef CONFIG_SYS_FSL_DDR4 #define CONFIG_SYS_FSL_DDR3 /* Use DDR3 memory */ +#define CONFIG_SYS_DDR_RAW_TIMING +#endif #define CONFIG_DIMM_SLOTS_PER_CTLR 1#define CONFIG_CHIP_SELECTS_PER_CTRL 4 --1.7.9.5
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Signature · 3 lines
Otavio Salvador O.S. Systems http://www.ossystems.com.br http://code.ossystems.com.br Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
PATCH 2/2 board/ls1021aqds_d4: Add DDR4 support
Quoted 26 lines · Otavio Salvador
Quoted 25 lines · York Sun
LS1021AQDS has a variant with DDR4 slot. This patch adds a new target for this variant and enables DDR4 support. RAW timing parameters are not added for DDR4. The board timing parameters are only tuned for single-rank 1600 and 1800MT/s with Micron DIMM 9ASF51272AZ-2G1A1 due to availability.
Signed-off-by York Sun <[email protected]>--- arch/arm/Kconfig | 3 +++ arch/arm/include/asm/arch-ls102xa/config.h | 5 +++++ board/freescale/ls1021aqds/Kconfig | 2 +- board/freescale/ls1021aqds/ddr.c | 9 ++++++++- board/freescale/ls1021aqds/ddr.h | 10 ++++++++++ ...s_nor_defconfig => ls1021aqds_d4_nor_defconfig} | 1 + include/configs/ls1021aqds.h | 4 +++- 7 files changed, 31 insertions(+), 3 deletions(-) copy configs/{ls1021aqds_nor_defconfig => ls1021aqds_d4_nor_defconfig} (50%)arch/arm/Kconfig +0
-0@@ -473,6 +473,9 @@ config TARGET_LS2085A_SIMU config TARGET_LS1021AQDS bool "Support ls1021aqds_nor"
Quoted 4 lines
arch/arm/Kconfig config TARGET_LS2085A_SIMU · line 477
Quoted 2 lines
arch/arm/Kconfig +2
-0+config TARGET_LS1021AQDS_D4 + bool "Support ls1021aqds_nor with DDR4"Use
_DDR4for the target, easier to understand when reading later.
I accept this suggestion but will wait for the final name of the board. I used _D4 following T1040QDS_D4 because that board was named so.
York