public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] arm, davinci: Fix setting of the SDRAM configuration register
@ 2011-11-08  9:02 Christian Riesch
  2011-11-08 12:58 ` [U-Boot] [PATCH v2] " Christian Riesch
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Riesch @ 2011-11-08  9:02 UTC (permalink / raw)
  To: u-boot

da850_ddr_setup() expects the BOOTUNLOCK bit to be set in
#define CONFIG_SYS_DA850_DDR2_SDBCR ... in include/configs/*.h
If BOOTUNLOCK is not set in this define, several configuration
bits will not be writeable and the code will not work.

Since the BOOTUNLOCK and TIMUNLOCK bits are not configuration options
but access control bits, this patch changes the code to work
irrespective of the value of these bits in CONFIG_SYS_DA850_DDR2_SDBCR.

Signed-off-by: Christian Riesch <christian.riesch@omicron.at>
Cc: Heiko Schocher <hs@denx.de>
Cc: Paulraj Sandeep <s-paulraj@ti.com>
---

This patch applies on top of these two patches:
[PATCH v3 1/2] arm, davinci: Rename AM1808 lowlevel functions to DA850
[PATCH v3 2/2] arm, davinci: Remove the duplication of LPSC functions in da850_lowlevel.c

Best regards, Christian

 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c |   25 +++++++++++++++++-----
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c b/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
index 490ef8f..6f72491 100644
--- a/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
+++ b/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
@@ -184,18 +184,31 @@ int da850_ddr_setup(unsigned int freq)
 	clrbits_le32(&davinci_syscfg1_regs->ddr_slew,
 		(1 << DDR_SLEW_CMOSEN_BIT));
 
+	/*
+	 * SDRAM Configuration Register (SDCR):
+	 * First set the BOOTUNLOCK bit to make configuration bits
+	 * writeable.
+	 */ 
 	setbits_le32(&dv_ddr2_regs_ctrl->sdbcr, DV_DDR_BOOTUNLOCK);
 
-	writel((CONFIG_SYS_DA850_DDR2_SDBCR & ~0xf0000000) |
-		(readl(&dv_ddr2_regs_ctrl->sdbcr) & 0xf0000000), /*rsv Bytes*/
-		&dv_ddr2_regs_ctrl->sdbcr);
-	writel(CONFIG_SYS_DA850_DDR2_SDBCR2, &dv_ddr2_regs_ctrl->sdbcr2);
+	/* 
+	 * Write the new value of these bits and clear BOOTUNLOCK.
+	 * At the same time, set the TIMUNLOCK bit to allow changing 
+	 * the timing registers
+	 */
+	tmp = CONFIG_SYS_DA850_DDR2_SDBCR;
+	tmp &= ~(0x1 << DV_DDR_SDCR_BOOTUNLOCK_SHIFT);
+	tmp |= (0x1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT);
+	writel(tmp, &dv_ddr2_regs_ctrl->sdbcr);
 
+	/* write memory configuration and timing */
+	writel(CONFIG_SYS_DA850_DDR2_SDBCR2, &dv_ddr2_regs_ctrl->sdbcr2);
 	writel(CONFIG_SYS_DA850_DDR2_SDTIMR, &dv_ddr2_regs_ctrl->sdtimr);
 	writel(CONFIG_SYS_DA850_DDR2_SDTIMR2, &dv_ddr2_regs_ctrl->sdtimr2);
 
-	clrbits_le32(&dv_ddr2_regs_ctrl->sdbcr,
-		(1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT));
+	/* clear the TIMUNLOCK bit and write the value of the CL field */
+	tmp &= ~(0x1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT);
+	writel(tmp, &dv_ddr2_regs_ctrl->sdbcr);
 
 	/*
 	 * LPMODEN and MCLKSTOPEN must be set!
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2] arm, davinci: Fix setting of the SDRAM configuration register
  2011-11-08  9:02 [U-Boot] [PATCH] arm, davinci: Fix setting of the SDRAM configuration register Christian Riesch
@ 2011-11-08 12:58 ` Christian Riesch
  2011-11-08 13:23   ` [U-Boot] [PATCH v3] " Christian Riesch
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Riesch @ 2011-11-08 12:58 UTC (permalink / raw)
  To: u-boot

da850_ddr_setup() expects the BOOTUNLOCK bit to be set in
#define CONFIG_SYS_DA850_DDR2_SDBCR ... in include/configs/*.h
If BOOTUNLOCK is not set in this define, several configuration
bits will not be writeable and the code will not work.

Since the BOOTUNLOCK and TIMUNLOCK bits are not configuration options
but access control bits, this patch changes the code to work
irrespective of the value of these bits in CONFIG_SYS_DA850_DDR2_SDBCR.

Signed-off-by: Christian Riesch <christian.riesch@omicron.at>
Cc: Heiko Schocher <hs@denx.de>
Cc: Paulraj Sandeep <s-paulraj@ti.com>
---

This patch applies on top of these two patches:
[PATCH v3 1/2] arm, davinci: Rename AM1808 lowlevel functions to DA850
[PATCH v3 2/2] arm, davinci: Remove the duplication of LPSC functions in da850_lowlevel.c

Changes for v2:
- Removed trailing whitespaces

Best regards, Christian

 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c |   25 +++++++++++++++++-----
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c b/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
index 490ef8f..6f72491 100644
--- a/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
+++ b/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
@@ -184,19 +184,31 @@ int da850_ddr_setup(unsigned int freq)
 	clrbits_le32(&davinci_syscfg1_regs->ddr_slew,
 		(1 << DDR_SLEW_CMOSEN_BIT));
 
+	/*
+	 * SDRAM Configuration Register (SDCR):
+	 * First set the BOOTUNLOCK bit to make configuration bits
+	 * writeable.
+	 */
 	setbits_le32(&dv_ddr2_regs_ctrl->sdbcr, DV_DDR_BOOTUNLOCK);
 
-	writel((CONFIG_SYS_DA850_DDR2_SDBCR & ~0xf0000000) |
-		(readl(&dv_ddr2_regs_ctrl->sdbcr) & 0xf0000000), /*rsv Bytes*/
-		&dv_ddr2_regs_ctrl->sdbcr);
-	writel(CONFIG_SYS_DA850_DDR2_SDBCR2, &dv_ddr2_regs_ctrl->sdbcr2);
+	/*
+	 * Write the new value of these bits and clear BOOTUNLOCK.
+	 * At the same time, set the TIMUNLOCK bit to allow changing
+	 * the timing registers
+	 */
+	tmp = CONFIG_SYS_DA850_DDR2_SDBCR;
+	tmp &= ~(0x1 << DV_DDR_SDCR_BOOTUNLOCK_SHIFT);
+	tmp |= (0x1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT);
+	writel(tmp, &dv_ddr2_regs_ctrl->sdbcr);
 
+	/* write memory configuration and timing */
+	writel(CONFIG_SYS_DA850_DDR2_SDBCR2, &dv_ddr2_regs_ctrl->sdbcr2);
 	writel(CONFIG_SYS_DA850_DDR2_SDTIMR, &dv_ddr2_regs_ctrl->sdtimr);
 	writel(CONFIG_SYS_DA850_DDR2_SDTIMR2, &dv_ddr2_regs_ctrl->sdtimr2);
 
-	clrbits_le32(&dv_ddr2_regs_ctrl->sdbcr,
-		(1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT));
+	/* clear the TIMUNLOCK bit and write the value of the CL field */
+	tmp &= ~(0x1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT);
+	writel(tmp, &dv_ddr2_regs_ctrl->sdbcr);
 
 	/*
 	 * LPMODEN and MCLKSTOPEN must be set!
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v3] arm, davinci: Fix setting of the SDRAM configuration register
  2011-11-08 12:58 ` [U-Boot] [PATCH v2] " Christian Riesch
@ 2011-11-08 13:23   ` Christian Riesch
  2011-11-09  6:11     ` Heiko Schocher
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Riesch @ 2011-11-08 13:23 UTC (permalink / raw)
  To: u-boot

da850_ddr_setup() expects the BOOTUNLOCK bit to be set in
If BOOTUNLOCK is not set in this define, several configuration
bits will not be writeable and the code will not work.

Since the BOOTUNLOCK and TIMUNLOCK bits are not configuration options
but access control bits, this patch changes the code to work
irrespective of the value of these bits in CONFIG_SYS_DA850_DDR2_SDBCR.

Signed-off-by: Christian Riesch <christian.riesch@omicron.at>
Cc: Heiko Schocher <hs@denx.de>
Cc: Paulraj Sandeep <s-paulraj@ti.com>
---
This patch applies on top of these two patches:
[PATCH v3 1/2] arm, davinci: Rename AM1808 lowlevel functions to DA850
[PATCH v3 2/2] arm, davinci: Remove the duplication of LPSC functions in da850_lowlevel.c

Changes for v2:
- Removed trailing whitespaces

Changes for v3:
- v2 was broken and did not apply, sorry for that!

Best regards, Christian


 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c |   25 +++++++++++++++++-----
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c b/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
index 490ef8f..327ff97 100644
--- a/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
+++ b/arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
@@ -184,18 +184,31 @@ int da850_ddr_setup(unsigned int freq)
 	clrbits_le32(&davinci_syscfg1_regs->ddr_slew,
 		(1 << DDR_SLEW_CMOSEN_BIT));
 
+	/*
+	 * SDRAM Configuration Register (SDCR):
+	 * First set the BOOTUNLOCK bit to make configuration bits
+	 * writeable.
+	 */
 	setbits_le32(&dv_ddr2_regs_ctrl->sdbcr, DV_DDR_BOOTUNLOCK);
 
-	writel((CONFIG_SYS_DA850_DDR2_SDBCR & ~0xf0000000) |
-		(readl(&dv_ddr2_regs_ctrl->sdbcr) & 0xf0000000), /*rsv Bytes*/
-		&dv_ddr2_regs_ctrl->sdbcr);
-	writel(CONFIG_SYS_DA850_DDR2_SDBCR2, &dv_ddr2_regs_ctrl->sdbcr2);
+	/*
+	 * Write the new value of these bits and clear BOOTUNLOCK.
+	 * At the same time, set the TIMUNLOCK bit to allow changing
+	 * the timing registers
+	 */
+	tmp = CONFIG_SYS_DA850_DDR2_SDBCR;
+	tmp &= ~(0x1 << DV_DDR_SDCR_BOOTUNLOCK_SHIFT);
+	tmp |= (0x1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT);
+	writel(tmp, &dv_ddr2_regs_ctrl->sdbcr);
 
+	/* write memory configuration and timing */
+	writel(CONFIG_SYS_DA850_DDR2_SDBCR2, &dv_ddr2_regs_ctrl->sdbcr2);
 	writel(CONFIG_SYS_DA850_DDR2_SDTIMR, &dv_ddr2_regs_ctrl->sdtimr);
 	writel(CONFIG_SYS_DA850_DDR2_SDTIMR2, &dv_ddr2_regs_ctrl->sdtimr2);
 
-	clrbits_le32(&dv_ddr2_regs_ctrl->sdbcr,
-		(1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT));
+	/* clear the TIMUNLOCK bit and write the value of the CL field */
+	tmp &= ~(0x1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT);
+	writel(tmp, &dv_ddr2_regs_ctrl->sdbcr);
 
 	/*
 	 * LPMODEN and MCLKSTOPEN must be set!
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v3] arm, davinci: Fix setting of the SDRAM configuration register
  2011-11-08 13:23   ` [U-Boot] [PATCH v3] " Christian Riesch
@ 2011-11-09  6:11     ` Heiko Schocher
  0 siblings, 0 replies; 4+ messages in thread
From: Heiko Schocher @ 2011-11-09  6:11 UTC (permalink / raw)
  To: u-boot

Hello Christian,

Christian Riesch wrote:
> da850_ddr_setup() expects the BOOTUNLOCK bit to be set in
> If BOOTUNLOCK is not set in this define, several configuration
> bits will not be writeable and the code will not work.
> 
> Since the BOOTUNLOCK and TIMUNLOCK bits are not configuration options
> but access control bits, this patch changes the code to work
> irrespective of the value of these bits in CONFIG_SYS_DA850_DDR2_SDBCR.
> 
> Signed-off-by: Christian Riesch <christian.riesch@omicron.at>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Paulraj Sandeep <s-paulraj@ti.com>
> ---
> This patch applies on top of these two patches:
> [PATCH v3 1/2] arm, davinci: Rename AM1808 lowlevel functions to DA850
> [PATCH v3 2/2] arm, davinci: Remove the duplication of LPSC functions in da850_lowlevel.c

Thanks! Tested on the enbw_cmc board, so:

Tested-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-09  6:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08  9:02 [U-Boot] [PATCH] arm, davinci: Fix setting of the SDRAM configuration register Christian Riesch
2011-11-08 12:58 ` [U-Boot] [PATCH v2] " Christian Riesch
2011-11-08 13:23   ` [U-Boot] [PATCH v3] " Christian Riesch
2011-11-09  6:11     ` Heiko Schocher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox