fsl-ddr: add the DDR3 SPD infrastructure
PATCH 2/2 fsl-ddr: add the DDR3 SPD infrastructure
- support mirrored DIMMs, not support register DIMMs
- test passed on P2020DS board with MT9JSF12872AY-1G1D1
- test passed on MPC8569MDS board with MT8JSF12864HY-1G1D1
Signed-off-by Dave Liu <[email protected]>
Signed-off-by Travis Wheatley <[email protected]>
--- common/ddr_spd.c | 53 +++++ cpu/mpc85xx/ddr-gen3.c | 6 +- cpu/mpc8xxx/ddr/Makefile | 4 + cpu/mpc8xxx/ddr/ctrl_regs.c | 380 ++++++++++++++++++++++++++++--- cpu/mpc8xxx/ddr/ddr3_dimm_params.c | 314 +++++++++++++++++++++++++ cpu/mpc8xxx/ddr/lc_common_dimm_params.c | 74 ++++++- cpu/mpc8xxx/ddr/options.c | 28 ++- include/asm-ppc/fsl_ddr_dimm_params.h | 7 + include/asm-ppc/fsl_ddr_sdram.h | 31 +++- include/ddr_spd.h | 13 +- 10 files changed, 860 insertions(+), 50 deletions(-) create mode 100644 cpu/mpc8xxx/ddr/ddr3_dimm_params.c
common/ddr_spd.c +53 -0
@@ -59,3 +59,56 @@ ddr2_spd_check(const ddr2_spd_eeprom_t *spd)return spd_check (p, spd->spd_rev, spd->cksum); } + +/* +* CRC16 compute for DDR3 SPD +* Copied from DDR3 SPD spec. +*/ +static int +crc16 (char *ptr,int count) +{ +int crc, i; + + crc =0 ; +while (--count >=0 ) { + crc = crc ^ (int )*ptr++ <<8 ; +for (i =0 ; i <8 ; ++i) +if (crc &0x8000 ) + crc = crc <<1 ^0x1021 ; +else + crc = crc <<1 ; + } +return crc &0xffff ; +} + +unsigned int +ddr3_spd_check (const ddr3_spd_eeprom_t *spd) +{ +char *p = (char *)spd; +int csum16; +int len; +char crc_lsb;/* byte 126 */ +char crc_msb;/* byte 127 */ + +/* +* SPD byte0[7] - CRC coverage +* 0 = CRC covers bytes 0~125 +* 1 = CRC covers bytes 0~116 +*/ + + len = !(spd->info_size_crc &0x80 ) ?126 :117 ; + csum16 =crc16 (p, len); + + crc_lsb = (char ) (csum16 &0xff ); + crc_msb = (char ) (csum16 >>8 ); + +if (spd->crc[0 ] == crc_lsb && spd->crc[1 ] == crc_msb) { +return 0 ; + }else { +printf ("SPD checksum unexpected.\n" +"Checksum lsb in SPD = %02X, computed SPD = %02X\n" +"Checksum msb in SPD = %02X, computed SPD = %02X\n" , + spd->crc[0 ], crc_lsb, spd->crc[1 ], crc_msb); +return 1 ; + } +}
cpu/mpc85xx/ddr-gen3.c +4 -2
@@ -98,10 +98,12 @@ void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,#endif /* -* 200 painful micro-seconds must elapse between +* 500 painful micro-seconds must elapse between * the DDR clock setup and the DDR config enable. +* DDR2 need 200 us, and DDR3 need 500 us from spec, +* we choose the max, that is 500 us for all of case. */ -udelay (200 ); +udelay (500 ); asmvolatile ("sync;isync" );/* Let the controller go */
cpu/mpc8xxx/ddr/Makefile +4 -0
@@ -18,6 +18,10 @@ COBJS-$(CONFIG_FSL_DDR2) += main.o util.o ctrl_regs.o options.o \ lc_common_dimm_params.o COBJS-$(CONFIG_FSL_DDR2) += ddr2_dimm_params.o +COBJS-$(CONFIG_FSL_DDR3) += main.o util.o ctrl_regs.o options.o \ + lc_common_dimm_params.o +COBJS-$(CONFIG_FSL_DDR3) += ddr3_dimm_params.o + SRCS := $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
cpu/mpc8xxx/ddr/ctrl_regs.c +344 -36
583 lines not on this page · raw message
cpu/mpc8xxx/ddr/ddr3_dimm_params.c new file +314 -0
314 lines not on this page · raw message
cpu/mpc8xxx/ddr/lc_common_dimm_params.c +69 -5
125 lines not on this page · raw message
cpu/mpc8xxx/ddr/options.c +23 -5
@@ -96,10 +96,8 @@ unsigned int populate_memctl_options(int all_DIMMs_registered,*/ #if defined(CONFIG_FSL_DDR1 ) popts->DQS_config =0 ; -#elif defined(CONFIG_FSL_DDR2 ) +#elif defined(CONFIG_FSL_DDR2 ) || defined(CONFIG_FSL_DDR3 ) popts->DQS_config =1 ; -#else -#error "Fix DQS for DDR3"#endif /* Choose self-refresh during sleep. */
@@ -112,7 +110,17 @@ unsigned int populate_memctl_options(int all_DIMMs_registered, popts->data_bus_width =0 ;/* Choose burst length. */ - popts->burst_length =4 ;/* has to be 4 for DDR2 */ +#if defined(CONFIG_FSL_DDR3 ) + popts->OTF_burst_chop_en =1 ;/* on-the-fly burst chop */ + popts->burst_length =DDR_OTF ;/* on-the-fly BC4 and BL8 */ +#else + popts->burst_length =DDR_BL4 ;/* has to be 4 for DDR2 */ +#endif + +/* Choose ddr controller address mirror mode */ +#if defined(CONFIG_FSL_DDR3 ) + popts->mirrored_dimm = pdimm[0 ].mirrored_dimm; +#endif /* Global Timing Parameters. */ debug ("mclk_ps = %u ps\n" ,get_memory_clk_period_ps ());
@@ -181,7 +189,17 @@ unsigned int populate_memctl_options(int all_DIMMs_registered, popts->tFAW_window_four_activates_ps =37500 ;#elif defined(CONFIG_FSL_DDR3 ) -#error "FIXME determine four activates for DDR3" + popts->tFAW_window_four_activates_ps = pdimm[0 ].tFAW_ps; +#endif + popts->zq_en =0 ; + popts->wrlvl_en =0 ; +#if defined(CONFIG_FSL_DDR3 ) +/* +* due to ddr3 dimm is fly-by topology +* we suggest to enable write leveling to +* meet the tQDSS under different loading. +*/ + popts->wrlvl_en =1 ;#endif /*
include/asm-ppc/fsl_ddr_dimm_params.h +7 -0
@@ -33,9 +33,15 @@ typedef struct dimm_params_s {/* used in computing base address of DIMMs */ unsigned long long base_address; +/* mirrored DIMMs */ +unsigned int mirrored_dimm;/* only for ddr3 */ /* DIMM timing parameters */ +unsigned int mtb_ps;/* medium timebase ps, only for ddr3 */ +unsigned int tAA_ps;/* minimum CAS latency time, only for ddr3 */ +unsigned int tFAW_ps;/* four active window delay, only for ddr3 */ +/* * SDRAM clock periods * The range for these are 1000-10000 so a short should be sufficient
@@ -67,6 +73,7 @@ typedef struct dimm_params_s {unsigned int refresh_rate_ps; +/* DDR3 doesn't need these as below */ unsigned int tIS_ps;/* byte 32, spd->ca_setup */ unsigned int tIH_ps;/* byte 33, spd->ca_hold */ unsigned int tDS_ps;/* byte 34, spd->data_setup */
include/asm-ppc/fsl_ddr_sdram.h +30 -1
@@ -19,6 +19,11 @@#define SDRAM_TYPE_LPDDR1 6#define SDRAM_TYPE_DDR3 7 +#define DDR_BL4 4/* burst length 4 */ +#define DDR_BC4 DDR_BL4/* burst chop for ddr3 */ +#define DDR_OTF 6/* on-the-fly BC4 and BL8 */ +#define DDR_BL8 8/* burst length 8 */ +#if defined(CONFIG_FSL_DDR1 )#define FSL_DDR_MIN_TCKE_PULSE_WIDTH_DDR (1)typedef ddr1_spd_eeprom_t generic_spd_eeprom_t ;
@@ -68,6 +73,18 @@ typedef ddr3_spd_eeprom_t generic_spd_eeprom_t;#define SDRAM_CFG_2T_EN 0x00008000#define SDRAM_CFG_BI 0x00000001 +#if defined(CONFIG_P4080 ) +#define RD_TO_PRE_MASK 0xf +#define RD_TO_PRE_SHIFT 13 +#define WR_DATA_DELAY_MASK 0xf +#define WR_DATA_DELAY_SHIFT 9 +#else +#define RD_TO_PRE_MASK 0x7 +#define RD_TO_PRE_SHIFT 13 +#define WR_DATA_DELAY_MASK 0x7 +#define WR_DATA_DELAY_SHIFT 10 +#endif +/* Record of register values computed */ typedef struct fsl_ddr_cfg_regs_s { struct {
@@ -145,7 +162,11 @@ typedef struct memctl_options_s {unsigned int dynamic_power;/* DYN_PWR */ /* memory data width to use (16-bit, 32-bit, 64-bit) */ unsigned int data_bus_width; -unsigned int burst_length;/* 4, 8 */ +unsigned int burst_length;/* BL4, OTF and BL8 */ +/* On-The-Fly Burst Chop enable */ +unsigned int OTF_burst_chop_en; +/* mirrior DIMMs for DDR3 */ +unsigned int mirrored_dimm;/* Global Timing Parameters */ unsigned int cas_latency_override;
@@ -164,9 +185,17 @@ typedef struct memctl_options_s {unsigned int tCKE_clock_pulse_width_ps;/* tCKE */ unsigned int tFAW_window_four_activates_ps;/* tFAW -- FOUR_ACT */ +/* Rtt impedance */ +unsigned int rtt_override;/* rtt_override enable */ +unsigned int rtt_override_value;/* that is Rtt_Nom for DDR3 */ +/* Automatic self refresh */ unsigned int auto_self_refresh_en;unsigned int sr_it; +/* ZQ calibration */ +unsigned int zq_en; +/* Write leveling */ +unsigned int wrlvl_en; } memctl_options_t;extern phys_size_t fsl_ddr_sdram (void );
include/ddr_spd.h +12 -1
@@ -184,7 +184,7 @@ typedef struct ddr3_spd_eeprom_s {unsigned char module_type;/* 3 Key Byte / Module Type */ unsigned char density_banks;/* 4 SDRAM Density and Banks */ unsigned char addressing;/* 5 SDRAM Addressing */ -unsigned char res_6;/* 6 Reserved */ +unsigned char module_vdd;/* 6 Module nominal voltage, VDD */ unsigned char organization;/* 7 Module Organization */ unsigned char bus_width;/* 8 Module Memory Bus Width */ unsigned char ftb_div;/* 9 Fine Timebase (FTB)
@@ -273,6 +273,7 @@ extern unsigned int ddr1_spd_check(const ddr1_spd_eeprom_t *spd);extern void ddr1_spd_dump (const ddr1_spd_eeprom_t *spd);extern unsigned int ddr2_spd_check (const ddr2_spd_eeprom_t *spd);extern void ddr2_spd_dump (const ddr2_spd_eeprom_t *spd); +extern unsigned int ddr3_spd_check (const ddr3_spd_eeprom_t *spd);/* * Byte 2 Fundamental Memory Types.
@@ -289,4 +290,14 @@ extern void ddr2_spd_dump(const ddr2_spd_eeprom_t *spd);#define SPD_MEMTYPE_DDR2_FBDIMM_PROBE (0x0A)#define SPD_MEMTYPE_DDR3 (0x0B) +/* +* Byte 3 Key Byte / Module Type for DDR3 SPD +*/ +#define SPD_MODULETYPE_RDIMM (0x01) +#define SPD_MODULETYPE_UDIMM (0x02) +#define SPD_MODULETYPE_SODIMM (0x03) +#define SPD_MODULETYPE_MICRODIMM (0x04) +#define SPD_MODULETYPE_MINIRDIMM (0x05) +#define SPD_MODULETYPE_MINIUDIMM (0x06) +#endif /* _DDR_SPD_H_ */
Signature · 1 line
1.5.4