[U-Boot] [PATCH] Fixed ordering of MDDRC config registers to unbreak mpc5121ads patch

No errors this time
Signed-off-by: Martha M Stan mmarx@silicontkx.com --- cpu/mpc512x/fixed_sdram.c | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/cpu/mpc512x/fixed_sdram.c b/cpu/mpc512x/fixed_sdram.c index 673d61e..1f6295f 100644 --- a/cpu/mpc512x/fixed_sdram.c +++ b/cpu/mpc512x/fixed_sdram.c @@ -26,13 +26,13 @@ #include <asm/mpc512x.h>
/* - * MDDRC Config Runtime Settings in order of the 4 MDDRC cfg registers + * MDDRC Config Runtime Settings in MEMORY order of the 4 MDDRC cfg registers */ u32 default_mddrc_config[4] = { + CONFIG_SYS_MDDRC_SYS_CFG, /* sys_config */ CONFIG_SYS_MDDRC_TIME_CFG0, /* time_config0 */ CONFIG_SYS_MDDRC_TIME_CFG1, /* time_config1 */ - CONFIG_SYS_MDDRC_TIME_CFG2, /* time_config2 */ - CONFIG_SYS_MDDRC_SYS_CFG, /* sys_config */ + CONFIG_SYS_MDDRC_TIME_CFG2 /* time_config2 */ };
u32 default_init_seq[] = { @@ -79,6 +79,12 @@ long int fixed_sdram(u32 *mddrc_config, u32 *dram_init_seq, int seq_sz) volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; u32 msize = CONFIG_SYS_DDR_SIZE * 1024 * 1024; u32 msize_log2 = __ilog2(msize); + struct ddr512x_4regs { + u32 ddr_sys_config; + u32 ddr_time_config0; + u32 ddr_time_config1; + u32 ddr_time_config2; + } *mddrc_4regs; u32 i;
/* take default settings and init sequence if necessary */ @@ -130,18 +136,23 @@ long int fixed_sdram(u32 *mddrc_config, u32 *dram_init_seq, int seq_sz) * put MDDRC in CMD mode and * set the max time between refreshes to 0 during init process */ - out_be32(&im->mddrc.ddr_sys_config, mddrc_config[3] | MDDRC_SYS_CFG_CMD_MASK); - out_be32(&im->mddrc.ddr_time_config0, mddrc_config[0] & MDDRC_REFRESH_ZERO_MASK); - out_be32(&im->mddrc.ddr_time_config1, mddrc_config[1]); - out_be32(&im->mddrc.ddr_time_config2, mddrc_config[2]); + + /* using mddrc's first 4 regs only */ + mddrc_4regs = (struct ddr512x_4regs *)mddrc_config; + out_be32(&im->mddrc.ddr_sys_config, mddrc_4regs->ddr_sys_config + | MDDRC_SYS_CFG_CMD_MASK); + out_be32(&im->mddrc.ddr_time_config0, mddrc_4regs->ddr_time_config0 + & MDDRC_REFRESH_ZERO_MASK); + out_be32(&im->mddrc.ddr_time_config1, mddrc_4regs->ddr_time_config1); + out_be32(&im->mddrc.ddr_time_config2, mddrc_4regs->ddr_time_config2);
/* Initialize DDR with either default or supplied init sequence */ for (i = 0; i < seq_sz; i++) out_be32(&im->mddrc.ddr_command, dram_init_seq[i]);
/* Start MDDRC */ - out_be32(&im->mddrc.ddr_time_config0, mddrc_config[0]); - out_be32(&im->mddrc.ddr_sys_config, mddrc_config[3]); + out_be32(&im->mddrc.ddr_time_config0, mddrc_4regs->ddr_time_config0); + out_be32(&im->mddrc.ddr_sys_config, mddrc_4regs->ddr_sys_config);
return msize; }

Dear Martha M Stan,
In message 1253885565511-git-send-email-mmarx@silicontkx.com you wrote:
No errors this time
Please consider these NAKed, too. Mapping an array on top of a strucxt is just calling for trouble.
Best regards,
Wolfgang Denk
participants (2)
-
Martha M Stan
-
Wolfgang Denk