Add proper SPD definitions for DDR1/2/3
PATCH 1/3 Add proper SPD definitions for DDR1/2/3
From: James Yang <[email protected]>
Also added a few helper functions for DDR1 & DDR2 to print SPD info and verify the checksum.
--- common/Makefile | 1 + common/ddr_spd.c | 519 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/ddr_spd.h | 249 +++++++++++++++++++++++++ 3 files changed, 769 insertions(+), 0 deletions(-) create mode 100644 common/ddr_spd.c create mode 100644 include/ddr_spd.h
common/Makefile +1 -0
@@ -144,6 +144,7 @@ COBJS-y += cmd_mac.o COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o COBJS-$(CONFIG_MP) += cmd_mp.o COBJS-$(CONFIG_CMD_SF) += cmd_sf.o +COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o COBJS := $(COBJS-y) SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
common/ddr_spd.c new file +519 -0
519 lines not on this page · raw message
include/ddr_spd.h new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
1.5.5.1
PATCH 1/3 Add proper SPD definitions for DDR1/2/3
Quoted 7 lines · Kumar Gala
From: James Yang <[email protected]>
Also added a few helper functions for DDR1 & DDR2 to print SPD info and
verify the checksum.Signed-off-by Kumar Gala <[email protected]>
Quoted 8 lines
---
common/Makefile | 1 +common/ddr_spd.c| 519 ++++++++++++++++++++++++++++++++++++++++++++
+++++++++include/ddr_spd.h| 249 +++++++++++++++++++++++++3 files changed, 769 insertions(+), 0 deletions(-)create mode 100644
common/ddr_spd.c
create mode 100644include/ddr_spd.h
I've updated these first three patches.. once these look good I can deal with the line issues in the others.
- k
PATCH 2/3 FSL DDR: Rewrite the FSL mpc8xxx DDR controller setup code.
In reply to Kumar Gala--- cpu/mpc85xx/Makefile | 9 + cpu/mpc86xx/Makefile | 4 + cpu/mpc8xxx/Makefile | 30 + cpu/mpc8xxx/common_timing_params.h | 55 ++ cpu/mpc8xxx/ddr2_dimm_params.h | 88 +++ cpu/mpc8xxx/fsl_ddr1.c | 362 ++++++++++ cpu/mpc8xxx/fsl_ddr2.c | 363 ++++++++++ cpu/mpc8xxx/fsl_ddr_ctrl.c | 1155 ++++++++++++++++++++++++++++++++ cpu/mpc8xxx/fsl_ddr_sdram.c | 1280 ++++++++++++++++++++++++++++++++++++ cpu/mpc8xxx/fsl_ddr_sdram.h | 91 +++ cpu/mpc8xxx/fsl_memctrl.h | 45 ++ cpu/mpc8xxx/memctl_options.h | 85 +++ 12 files changed, 3567 insertions(+), 0 deletions(-) create mode 100644 cpu/mpc8xxx/Makefile create mode 100644 cpu/mpc8xxx/common_timing_params.h create mode 100644 cpu/mpc8xxx/ddr2_dimm_params.h create mode 100644 cpu/mpc8xxx/fsl_ddr1.c create mode 100644 cpu/mpc8xxx/fsl_ddr2.c create mode 100644 cpu/mpc8xxx/fsl_ddr_ctrl.c create mode 100644 cpu/mpc8xxx/fsl_ddr_sdram.c create mode 100644 cpu/mpc8xxx/fsl_ddr_sdram.h create mode 100644 cpu/mpc8xxx/fsl_memctrl.h create mode 100644 cpu/mpc8xxx/memctl_options.h
cpu/mpc85xx/Makefile +9 -0
@@ -33,6 +33,15 @@ SOBJS-$(CONFIG_MP) += release.o SOBJS = $(SOBJS-y) COBJS-$(CONFIG_MP) += mp.o COBJS-$(CONFIG_OF_LIBFDT) += fdt.o + +ifneq ($(CONFIG_FSL_DDR3),y) +ifneq ($(CONFIG_FSL_DDR2),y) +ifneq ($(CONFIG_FSL_DDR1),y) +COBJS-y += spd_sdram.o +endif +endif +endif + COBJS = traps.o cpu.o cpu_init.o speed.o interrupts.o tlb.o \ pci.o serial_scc.o commproc.o ether_fcc.o spd_sdram.o qe_io.o \ $(COBJS-y)
cpu/mpc86xx/Makefile +4 -0
@@ -40,6 +40,10 @@ COBJS-y += spd_sdram.o COBJS-$(CONFIG_OF_LIBFDT) += fdt.o +ifneq ($(CONFIG_FSL_DDR2),y) +COBJS-y += spd_sdram.o +endif + SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) START := $(addprefix $(obj),$(START))
cpu/mpc8xxx/Makefile new file +30 -0
@@ -0,0 +1,30 @@ +# +# Copyright 2008 Freescale Semiconductor, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# Version 2 as published by the Free Software Foundation. +# + +include $(TOPDIR)/config.mk + +LIB = $(obj)libmpc8xxx.a + +COBJS-$(CONFIG_FSL_DDR1) += fsl_ddr_sdram.o fsl_ddr_ctrl.o +COBJS-$(CONFIG_FSL_DDR1) += fsl_ddr1.o + +COBJS-$(CONFIG_FSL_DDR2) += fsl_ddr_sdram.o fsl_ddr_ctrl.o +COBJS-$(CONFIG_FSL_DDR2) += fsl_ddr2.o + + +SRCS := $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) +OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y)) + +all: $(obj).depend $(LIB) + +$(LIB): $(OBJS) + $(AR) $(ARFLAGS) $@ $(OBJS) + +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend
cpu/mpc8xxx/common_timing_params.h new file +55 -0
55 lines not on this page · raw message
cpu/mpc8xxx/ddr2_dimm_params.h new file +88 -0
88 lines not on this page · raw message
cpu/mpc8xxx/fsl_ddr1.c new file +362 -0
362 lines not on this page · raw message
cpu/mpc8xxx/fsl_ddr2.c new file +363 -0
363 lines not on this page · raw message
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +1155 -0
1,155 lines not on this page · raw message
cpu/mpc8xxx/fsl_ddr_sdram.c new file +1280 -0
922 lines not on this page · raw message
cpu/mpc8xxx/fsl_ddr_sdram.h new file +91 -0
91 lines not on this page · raw message
cpu/mpc8xxx/fsl_memctrl.h new file +45 -0
45 lines not on this page · raw message
cpu/mpc8xxx/memctl_options.h new file +85 -0
85 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.5.5.1
Part of the diff is not shown here. View the raw message.
PATCH 3/3 FSL DDR: Add interactive DDR config support
Provide a mechanism to allow interactive configuration of DDR params. This is useful when trying to test various DDR settings to determine optimal configuration values for a given board.
--- cpu/mpc8xxx/Makefile | 1 + cpu/mpc8xxx/fsl_ddr_interactive.c | 1272 +++++++++++++++++++++++++++++++++++++ cpu/mpc8xxx/fsl_ddr_sdram.c | 10 + cpu/mpc8xxx/fsl_ddr_sdram.h | 3 + 4 files changed, 1286 insertions(+), 0 deletions(-) create mode 100644 cpu/mpc8xxx/fsl_ddr_interactive.c
cpu/mpc8xxx/Makefile +1 -0
@@ -10,6 +10,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)libmpc8xxx.a +COBJS-$(CONFIG_FSL_DDR_INTERACTIVE) += fsl_ddr_interactive.o COBJS-$(CONFIG_FSL_DDR1) += fsl_ddr_sdram.o fsl_ddr_ctrl.o COBJS-$(CONFIG_FSL_DDR1) += fsl_ddr1.o
cpu/mpc8xxx/fsl_ddr_interactive.c new file +1272 -0
1,272 lines not on this page · raw message
cpu/mpc8xxx/fsl_ddr_sdram.c +10 -0
@@ -1218,6 +1218,16 @@ phys_size_t fsl_ddr_sdram(void)/* Compute it once normally. */ total_memory =fsl_ddr_sdram_compute (&info,STEP_GET_SPD ); +#ifdef CONFIG_FSL_DDR_INTERACTIVE +/* +* The presence of the environment variable "ddrsetup" +* causes the interactive DDR setup prompt to appear. +*/ +if (getenv ("ddrsetup" )) { + total_memory =fsl_ddr_interactive (&info); + } +#endif +/* Check for memory controller interleaving. */ memctl_interleaved =0 ;for (i =0 ; i <CONFIG_NUM_DDR_CONTROLLERS ; i++) {
cpu/mpc8xxx/fsl_ddr_sdram.h +3 -0
@@ -58,6 +58,9 @@ typedef struct {extern phys_size_t +fsl_ddr_interactive (fsl_ddr_sdram_info_t *pinfo); + +extern phys_size_t fsl_ddr_sdram_compute (fsl_ddr_sdram_info_t *pinfo,unsigned int start_step);
Signature · 1 line
1.5.5.1
PATCH 2/3 FSL DDR: Rewrite the FSL mpc8xxx DDR controller setup code.
In reply to Kumar GalaDear Kumar Gala,
Quoted 21 lines · In message <[email protected]> you…
Signed-off-by James Yang <[email protected]>Signed-off-by Jon Loeliger <[email protected]>Signed-off-by Becky Bruce <[email protected]>Signed-off-by Ed Swarthout <[email protected]>Signed-off-by Kumar Gala <[email protected]>--- cpu/mpc85xx/Makefile | 9 + cpu/mpc86xx/Makefile | 4 + cpu/mpc8xxx/Makefile | 30 + cpu/mpc8xxx/common_timing_params.h | 55 ++ cpu/mpc8xxx/ddr2_dimm_params.h | 88 +++ cpu/mpc8xxx/fsl_ddr1.c | 362 ++++++++++ cpu/mpc8xxx/fsl_ddr2.c | 363 ++++++++++ cpu/mpc8xxx/fsl_ddr_ctrl.c | 1155 ++++++++++++++++++++++++++++++++ cpu/mpc8xxx/fsl_ddr_sdram.c | 1280 ++++++++++++++++++++++++++++++++++++ cpu/mpc8xxx/fsl_ddr_sdram.h | 91 +++ cpu/mpc8xxx/fsl_memctrl.h | 45 ++ cpu/mpc8xxx/memctl_options.h | 85 +++ 12 files changed, 3567 insertions(+), 0 deletions(-) create mode 100644 cpu/mpc8xxx/Makefile create mode 100644 cpu/mpc8xxx/common_timing_params.h
Quoted 8 lines
create mode 100644 cpu/mpc8xxx/ddr2_dimm_params.h create mode 100644 cpu/mpc8xxx/fsl_ddr1.c create mode 100644 cpu/mpc8xxx/fsl_ddr2.c create mode 100644 cpu/mpc8xxx/fsl_ddr_ctrl.c create mode 100644 cpu/mpc8xxx/fsl_ddr_sdram.c create mode 100644 cpu/mpc8xxx/fsl_ddr_sdram.h create mode 100644 cpu/mpc8xxx/fsl_memctrl.h create mode 100644 cpu/mpc8xxx/memctl_options.h
Coding Style: maximum line length exceeded; some of your lines are more than 125 characters long!
-> sed -n 's/^+//p' /tmp/patch | expand | awk 'length > 80'
"for memctl=%u dimm=%u\n", i, j);
for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
dw = pinfo->dimm_params[i][j].data_width;
for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
pinfo->dimm_params[i][j].base_address = addr;
addr += (phys_addr_t)(pinfo->dimm_params[i][j].dimm_capacity >> dbw_capacity_adjust[i]);
pinfo->common_timing_params[i].base_address = (phys_addr_t)cur_memsize;
for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
pinfo->dimm_params[i][j].base_address = (phys_addr_t)cur_memsize;
cur_memsize+= pinfo->dimm_params[i][j].dimm_capacity >> dbw_capacity_adjust[i];
total_mem_per_memctl += pinfo->dimm_params[i][j].dimm_capacity >> dbw_capacity_adjust[i];
pinfo->common_timing_params[i].total_mem = total_mem_per_memctl;
debug("FSL Memory controller configuration register computation\n");
if (pinfo->common_timing_params[i].ndimms_present == 0) {
total_memory += pinfo->common_timing_params[i].total_mem;
printf("This U-Boot only supports less than 4G of DDR.\n");
printf("You could rebuild it using CONFIG_PHYS_64BIT.\n");Quoted 11 lines
cpu/mpc8xxx/fsl_ddr2.c new file +11
-0+unsigned int +ddr_compute_dimm_parameters (const ddr2_spd_eeprom_t *spd, +dimm_params_t *pdimm, +unsigned int dimm_number) +{ +unsigned int retval; + +/* +* FIXME debate: shouldn't have to dynamically determine memory type +* This ought to be determined through a config #define +*/
...
cpu/mpc8xxx/fsl_ddr2.c line 276
Quoted 4 lines
cpu/mpc8xxx/fsl_ddr2.c new file +4
-0+ { +unsigned char dimm_type = spd->dimm_type; + +/* FIXME: what about registered SO-DIMM? */
Coding style - please do not declare variables in the middle of a function.
Get rid of this extra block.
Quoted 4 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +4
-0+static int fsl_ddr_sdram_get_rtt (void ) +{ +int rtt; +
cpu/mpc8xxx/fsl_ddr_ctrl.c line 60
Quoted 10 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +10
-0+#if defined(CONFIG_FSL_DDR1 ) + rtt =0 ; +#elif defined(CONFIG_FSL_DDR2 ) + rtt =3 ; +#else +#error "Need Rtt value for DDR3" +#endif + +return rtt; +}
Make inline?
Quoted 23 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +23
-0+/* Chip Select Configuration (CSn_CONFIG) */ +static void set_csn_config (int i,fsl_memctl_config_regs_t *ddr, +const memctl_options_t *popts, +const dimm_params_t *dimm_parameters) +{ +/* CS_n_EN: Chip Select enable */ +unsigned int cs_n_en; +/* INTLV_EN: Memory controller interleave enable */ +unsigned int intlv_en; +/* INTLV_CTL: Interleaving control */ +unsigned int intlv_ctl; +/* AP_n_EN: Chip select n auto-precharge enable */ +unsigned int ap_n_en; +/* ODT_RD_CFG: ODT for reads configuration */ +unsigned int odt_rd_cfg; +/* ODT_WR_CFG: ODT for writes configuration */ +unsigned int odt_wr_cfg; +/* BA_BITS_CS_n: Number of bank bits for SDRAM on chip select n */ +unsigned int ba_bits_cs_n; +/* ROW_BITS_CS_n: Number of row bits for SDRAM on chip select n */ +unsigned int row_bits_cs_n; +/* COL_BITS_CS_n: Number of ocl bits for SDRAM on chip select n */ +unsigned int col_bits_cs_n;
cpu/mpc8xxx/fsl_ddr_ctrl.c line 94
Quoted 10 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +10
-0+ + cs_n_en =0 ; + intlv_en =0 ; + intlv_ctl =0 ; + ap_n_en =0 ; + odt_rd_cfg =0 ; + odt_wr_cfg =0 ; + ba_bits_cs_n =0 ; + row_bits_cs_n =0 ; + col_bits_cs_n =0 ;
Why don't you initialize the variables right in the declaration?
cpu/mpc8xxx/fsl_ddr_ctrl.c line 101
Quoted 6 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +6
-0+/* Compute CS_CONFIG only for existing ranks of each DIMM. */ +if ((((i&1 ) ==0 ) + && (dimm_parameters[i/2 ].n_ranks ==1 )) + || (dimm_parameters[i/2 ].n_ranks ==2 )) { + cs_n_en =1 ; +unsigned int n_banks_per_sdram_device;
Coding style: Do not declare variables in the middle of the code.
Quoted 13 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +13
-0+ ddr->cs[i].config = (0 + | ((cs_n_en &0x1 ) <<31 ) + | ((intlv_en &0x3 ) <<29 ) + | ((intlv_en &0xf ) <<24 ) + | ((ap_n_en &0x1 ) <<23 ) + +/* +* XXX: some implementation only have 1 bit +* starting at left. +*/ + | ((odt_rd_cfg &0x7 ) <<20 ) + +/*
cpu/mpc8xxx/fsl_ddr_ctrl.c line 145
Quoted 10 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +10
-0+* FIXME: Some implementation +* only have 1 bit starting at left. +*/ + | ((odt_wr_cfg & 0x7) << 16) + + | ((ba_bits_cs_n &0x3 ) <<14 ) + | ((row_bits_cs_n &0x7 ) <<8 ) + | ((col_bits_cs_n &0x7 ) <<0 ) + ); +}
Please do not interrupt the code with multiline comments!
cpu/mpc8xxx/fsl_ddr_ctrl.c line 201
Quoted 6 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +6
-0+/* +* FIXME: Are these configurable? +*/ + trwt_mclk =0 ;/* RWT: Read-to-write turnaround */ + twrt_mclk =0 ;/* WRT: Write-to-read turnaround */ +/* 7.5 ns on -3E; 0 means WL - CL + BL/2 + 1 */
Fix indentation.
Quoted 3 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +3
-0+static void set_timing_cfg_3 (fsl_memctl_config_regs_t *ddr, +const common_timing_params_t *common_dimm) +{
...
cpu/mpc8xxx/fsl_ddr_ctrl.c line 261
Quoted 3 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +3
-0+ ddr->timing_cfg_3 = (0 + | ((ext_refrec &0x7 ) <<16 )/* EXT_ACTTOPRE */ + );
Write as a single line withouut the "0 | "
cpu/mpc8xxx/fsl_ddr_ctrl.c line 658
Quoted 5 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +5
-0+#if defined(CONFIG_FSL_DDR1 ) + wr =0 ;/* Historical */ +#elif defined(CONFIG_FSL_DDR2 ) + { +const unsigned int mclk_ps
Do not declare variables in the middle of a function.
Quoted 7 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +7
-0+unsigned int +compute_fsl_memctl_config_regs (const memctl_options_t *popts, +fsl_memctl_config_regs_t *ddr, +const common_timing_params_t *common_dimm, +const dimm_params_t *dimm_parameters, +unsigned int dbw_capacity_adjust) +{
...
Quoted 20 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +20
-0+if (popts->memctl_interleaving && popts->ba_intlv_ctl) { +/* +* This works superbank 2CS +* There are 2 memory controllers configured +* identically, memory is interleaved between them, +* and each controller uses rank interleaving within +* itself. Therefore the starting and ending address +* on each controller is twice the amount present on +* each controller. +*/ + ea = (2 * + common_dimm->total_mem >> + dbw_capacity_adjust) -1 ; + } +else if (!popts->memctl_interleaving && popts->ba_intlv_ctl) { +/* +* If memory interleaving between controllers is NOT +* enabled, the starting address for each memory +* controller is distinct. However, because rank +* interleaving is enabled, the starting and ending
cpu/mpc8xxx/fsl_ddr_ctrl.c line 1067
Quoted 10 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +10
-0+* addresses of the total memory on that memory +* controller needs to be programmed into its +* respective CS0_BNDS. +*/ + sa = common_dimm->base_address; + ea = sa + + (common_dimm->total_mem >> dbw_capacity_adjust) + -1 ; + } +else if (popts->memctl_interleaving && !popts->ba_intlv_ctl) {
etc.
Coding style: make this "} else if (...) {" (on one line).
cpu/mpc8xxx/fsl_ddr_ctrl.c line 1079
Quoted 4 lines
cpu/mpc8xxx/fsl_ddr_ctrl.c new file +4
-0+if (i ==0 ) { + ea = (2 * + (dimm_parameters[0 ].rank_density >> + dbw_capacity_adjust)) -1 ;
This is very difficult to read.
Quoted 5 lines
cpu/mpc8xxx/fsl_ddr_sdram.c new file +5
-0+unsigned int +populate_memctl_options (const common_timing_params_t *pcommon_params, +memctl_options_t *popts, +unsigned int ctrl_num) +{
...
Quoted 10 lines
cpu/mpc8xxx/fsl_ddr_sdram.c new file +10
-0+/* +* CAS latency plus additive latency must be at least 3 cycles +* for ODT_RD_CFG to be enabled. +*/ +#if 0 +/* This check should be in fsl ddr regs. */ +for (i =0 ; i <CONFIG_CHIP_SELECTS_PER_CTRL ; i++) { +if (popts->cs_local_opts[i].odt_rd_cfg) { +if ((popts->cas_latency_override_value + + popts->additive_latency_override_value) <3 ) {
cpu/mpc8xxx/fsl_ddr_sdram.c line 817
Quoted 10 lines
cpu/mpc8xxx/fsl_ddr_sdram.c new file +10
-0+printf ("CHECKME: CAS latency and Additive " +" latency must be at least 3 cycles for " +"ODT_RD_CFG to be enabled " + "(chip select = %u)\n", i); + } + } + } +#endif + +#if 0
...
Please remove dead code.
Quoted 3 lines
cpu/mpc8xxx/fsl_ddr_sdram.c new file +3
-0+unsigned int +check_fsl_memctl_config_regs (const fsl_memctl_config_regs_t *ddr) +{
...
cpu/mpc8xxx/fsl_ddr_sdram.c line 1092
Quoted 3 lines
cpu/mpc8xxx/fsl_ddr_sdram.c new file +3
-0+for (i =0 ; i <CONFIG_NUM_DDR_CONTROLLERS ; i++) { + addr =0 ; +/* pinfo->common_timing_params[i].base_address = addr; */
Indendation not correct.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de You humans have that emotional need to express gratitude. "You're welcome," I believe, is the correct response. -- Spock, "Bread and Circuses", stardate 4041.2