Skip to contentSkip to conversation

mx23: Make DDR initialization stable

PATCH Superseded Fabio Estevam 3 participants 31 messages May 1, 2013 – May 5, 2013

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

cover mx23: Make DDR initialization stable

Prior to this series running 'memtester' utility in Linux on a mx23evk always resulted in many errors during stress testing, if the kernel is loaded via U-boot.

Running the same test and loading the kernel via FSL bootlets resulted on zero errors.

Adjust U-boot so that it can also pass the 'memtester' stress test.

After this series was applied, no more DDR errors were observed on a mx23evk.

author reviewer
#1 lore raw

PATCH 1/9 mxs: Make the names of the elements of mxs_pinctrl_regs shorter

From: Fabio Estevam <[email protected]>

Currently when accessing an element of mxs_pinctrl_regs structure we do:

&pinctrl_regs->hw_pinctrl_emi_ds_ctrl_set

The 'hw_pinctrl' prefix is a redundant information as we already know that we are accessing a pinctrl register.

---
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c    |    2 +-
 arch/arm/include/asm/arch-mxs/regs-pinctrl.h |  168 +++++++++++++-------------
 2 files changed, 85 insertions(+), 85 deletions(-)
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +1 -1
index 4950490..1c509d6 100644
@@ -294,7 +294,7 @@ static void mx28_mem_init(void)
 
 	/* Set DDR2 mode */
 	writel(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
-		&pinctrl_regs->hw_pinctrl_emi_ds_ctrl_set);
+		&pinctrl_regs->emi_ds_ctrl_set);
 
 	/*
 	 * Configure the DRAM registers
arch/arm/include/asm/arch-mxs/regs-pinctrl.h +84 -84

213 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/9 mxs: Make the names of the elements of mxs_pinctrl_regs shorter

Dear Fabio Estevam,

Quoted 10 lines

From: Fabio Estevam <[email protected]>

Currently when accessing an element of mxs_pinctrl_regs structure we do:

&pinctrl_regs->hw_pinctrl_emi_ds_ctrl_set

The 'hw_pinctrl' prefix is a redundant information as we already know that we are accessing a pinctrl register.

Now this single file is inconsistent with the rest of the register header files.

Best regards,
Marek Vasut

author reviewer
#3 lore raw

PATCH 1/9 mxs: Make the names of the elements of mxs_pinctrl_regs shorter

Quoted 6 lines · Marek Vasut

Dear Fabio Estevam,

Quoted 4 lines

From: Fabio Estevam <[email protected]>

Currently when accessing an element of mxs_pinctrl_regs structure we do:

Quoted 8 lines
Quoted 6 lines

&pinctrl_regs->hw_pinctrl_emi_ds_ctrl_set

The 'hw_pinctrl' prefix is a redundant information as we already know that we are accessing a pinctrl register.

Now this single file is inconsistent with the rest of the register header files.

I can change the other header files as well.

#4 lore raw

PATCH 1/9 mxs: Make the names of the elements of mxs_pinctrl_regs shorter

Dear Fabio Estevam,

Quoted 12 lines · Marek Vasut
Quoted 11 lines

Dear Fabio Estevam,

Quoted 9 lines

From: Fabio Estevam <[email protected]>

Currently when accessing an element of mxs_pinctrl_regs structure we do:

&pinctrl_regs->hw_pinctrl_emi_ds_ctrl_set

The 'hw_pinctrl' prefix is a redundant information as we already know that we are accessing a pinctrl register.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Now this single file is inconsistent with the rest of the register header files.

I can change the other header files as well.

Yes, but a separate patchset can do that. Let's keep it consistent please.

Best regards,
Marek Vasut

author reviewer
#5 lore raw

PATCH 2/9 mx23: regs-pinctrl.h: Add pinctrl support for mx23

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Provide a mxs_pinctrl_regs structure for mx23.

---
 arch/arm/include/asm/arch-mxs/regs-pinctrl.h |   68 ++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
arch/arm/include/asm/arch-mxs/regs-pinctrl.h +68 -0
index c3a8700..fe7e910 100644
@@ -29,6 +29,7 @@
 #include <asm/imx-common/regs-common.h>
 
 #ifndef	__ASSEMBLY__
+#if defined(CONFIG_MX28)
 struct mxs_pinctrl_regs {
 	mxs_reg_32(ctrl)		/* 0x0 */
 
@@ -154,6 +155,73 @@ struct mxs_pinctrl_regs {
 
 	mxs_reg_32(emi_ds_ctrl)	/* 0x1b80 */
 };
+#elif defined(CONFIG_MX23)
+struct mxs_pinctrl_regs {
+	mxs_reg_32(ctrl)		/* 0x0 */
+	int reserved1[0x3c];
+	mxs_reg_32(muxsel0)		/* 0x100 */
+	mxs_reg_32(muxsel1)		/* 0x110 */
+	mxs_reg_32(muxsel2)		/* 0x120 */
+	mxs_reg_32(muxsel3)		/* 0x130 */
+	mxs_reg_32(muxsel4)		/* 0x140 */
+	mxs_reg_32(muxsel5)		/* 0x150 */
+	mxs_reg_32(muxsel6)		/* 0x160 */
+	mxs_reg_32(muxsel7)		/* 0x170 */
+	int reserved2[0x20];
+	mxs_reg_32(drive0)		/* 0x200 */
+	mxs_reg_32(drive1)		/* 0x210 */
+	mxs_reg_32(drive2)		/* 0x220 */
+	mxs_reg_32(drive3)		/* 0x230 */
+	mxs_reg_32(drive4)		/* 0x240 */
+	mxs_reg_32(drive5)		/* 0x250 */
+	mxs_reg_32(drive6)		/* 0x260 */
+	mxs_reg_32(drive7)		/* 0x270 */
+	mxs_reg_32(drive8)		/* 0x280 */
+	mxs_reg_32(drive9)		/* 0x290 */
+	mxs_reg_32(drive10)		/* 0x2a0 */
+	mxs_reg_32(drive11)		/* 0x2b0 */
+	mxs_reg_32(drive12)		/* 0x2c0 */
+	mxs_reg_32(drive13)		/* 0x2d0 */
+	mxs_reg_32(drive14)		/* 0x2e0 */
+	int reserved3[0x44];
+	mxs_reg_32(pull0)		/* 0x400 */
+	mxs_reg_32(pull1)		/* 0x410 */
+	mxs_reg_32(pull2)		/* 0x420 */
+	mxs_reg_32(pull3)		/* 0x430 */
+	int reserved4[0x30];
+	mxs_reg_32(dout0)		/* 0x500 */
+	mxs_reg_32(dout1)		/* 0x510 */
+	mxs_reg_32(dout2)		/* 0x520 */
+	int reserved5[0x34];
+	mxs_reg_32(din0)		/* 0x600 */
+	mxs_reg_32(din1)		/* 0x610 */
+	mxs_reg_32(din2)		/* 0x620 */
+	int reserved6[0x34];
+	mxs_reg_32(doe0)		/* 0x700 */
+	mxs_reg_32(doe1)		/* 0x710 */
+	mxs_reg_32(doe2)		/* 0x720 */
+	int reserved7[0x34];
+	mxs_reg_32(pin2irq0)		/* 0x800 */
+	mxs_reg_32(pin2irq1)		/* 0x810 */
+	mxs_reg_32(pin2irq2)		/* 0x820 */
+	int reserved8[0x34];
+	mxs_reg_32(irqen0)		/* 0x900 */
+	mxs_reg_32(irqen1)		/* 0x910 */
+	mxs_reg_32(irqen2)		/* 0x920 */
+	int reserved9[0x34];
+	mxs_reg_32(irqlevel0)		/* 0xa00 */
+	mxs_reg_32(irqlevel1)		/* 0xa10 */
+	mxs_reg_32(irqlevel2)		/* 0xa20 */
+	int reserved10[0x34];
+	mxs_reg_32(irqpol0)		/* 0xb00 */
+	mxs_reg_32(irqpol1)		/* 0xb10 */
+	mxs_reg_32(irqpol2)		/* 0xb20 */
+	int reserved11[0x34];
+	mxs_reg_32(irqstat0)		/* 0xc00 */
+	mxs_reg_32(irqstat1)		/* 0xc10 */
+	mxs_reg_32(irqstat2)		/* 0xc20 */
+};
+#endif
 #endif
 
 #define	PINCTRL_CTRL_SFTRST				(1 << 31)
Signature · 1 line
1.7.9.5
author reviewer
#7 lore raw

PATCH 2/9 mx23: regs-pinctrl.h: Add pinctrl support for mx23

Quoted 9 lines · Marek Vasut

Dear Fabio Estevam,

Quoted 5 lines

From: Fabio Estevam <[email protected]>

Provide a mxs_pinctrl_regs structure for mx23.

So the pinctrl structure was always wrong on mx23? Otavio?

pinctrl structure was never used on mx23 in U-boot.

#8 lore raw

PATCH 2/9 mx23: regs-pinctrl.h: Add pinctrl support for mx23

Dear Fabio Estevam,

Quoted 5 lines · Marek Vasut
Quoted 4 lines

Dear Fabio Estevam,

Quoted 2 lines

From: Fabio Estevam <[email protected]>

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Provide a mxs_pinctrl_regs structure for mx23.

So the pinctrl structure was always wrong on mx23? Otavio?

pinctrl structure was never used on mx23 in U-boot.

How come? Doesn't the board/...mx23.../spl_boot.c use that? Or iomux.c in FSL's parlance.

Best regards,
Marek Vasut

author reviewer
#9 lore raw

PATCH 2/9 mx23: regs-pinctrl.h: Add pinctrl support for mx23

Quoted 2 lines · Marek Vasut

How come? Doesn't the board/...mx23.../spl_boot.c use that? Or iomux.c in FSL's parlance.

I meant mxs_pinctrl_regs structure is only referenced for mx28 currently:

#ifdef CONFIG_MX28
static void mx28_mem_init(void)

{
	struct mxs_pinctrl_regs *pinctrl_regs =
		(struct mxs_pinctrl_regs *)MXS_PINCTRL_BASE;

	/* Set DDR2 mode */
	writel(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
		&pinctrl_regs->hw_pinctrl_emi_ds_ctrl_set);
#10 lore raw

PATCH 2/9 mx23: regs-pinctrl.h: Add pinctrl support for mx23

Dear Fabio Estevam,

Quoted 8 lines · Marek Vasut
Quoted 2 lines

How come? Doesn't the board/...mx23.../spl_boot.c use that? Or iomux.c in FSL's parlance.

I meant mxs_pinctrl_regs structure is only referenced for mx28 currently:

#ifdef CONFIG_MX28
static void mx28_mem_init(void)

Quoted 7 lines
{
	struct mxs_pinctrl_regs *pinctrl_regs =
		(struct mxs_pinctrl_regs *)MXS_PINCTRL_BASE;

	/* Set DDR2 mode */
	writel(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
		&pinctrl_regs->hw_pinctrl_emi_ds_ctrl_set);

Ah! Good point, sorry for the prodding then.

Best regards,
Marek Vasut

author reviewer
#11 lore raw

PATCH 3/9 mx23evk: Fix DDR pin iomux settings

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Registers HW_PINCTRL_DRIVE9, HW_PINCTRL_DRIVE10, HW_PINCTRL_DRIVE11, HW_PINCTRL_DRIVE12, HW_PINCTRL_DRIVE13 and HW_PINCTRL_DRIVE14 control the drive strength and the voltage selection for the DDR pins.

The reset values of the voltage selection pins are '1', which is marked as 'reserved' in the mx23 reference manual.

Clear these bits for proper operation of DDR.

Also change MUX_CONFIG_EMI, which results in better stability and match the bootlets code from Freescale.

---
 board/freescale/mx23evk/spl_boot.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
board/freescale/mx23evk/spl_boot.c +11 -1
index b6f4e7e..035a29c 100644
@@ -26,7 +26,7 @@
 #include <asm/arch/sys_proto.h>
 
 #define	MUX_CONFIG_SSP1	(MXS_PAD_3V3 | MXS_PAD_8MA | MXS_PAD_PULLUP)
-#define	MUX_CONFIG_EMI	(MXS_PAD_3V3 | MXS_PAD_16MA | MXS_PAD_PULLUP)
+#define	MUX_CONFIG_EMI	MXS_PAD_12MA
 
 const iomux_cfg_t iomux_setup[] = {
 	/* DUART */
@@ -110,5 +110,15 @@ void mxs_adjust_memory_params(uint32_t *dram_vals)
 
 void board_init_ll(void)
 {
+	struct mxs_pinctrl_regs *pinctrl =
+		(struct mxs_pinctrl_regs *)MXS_PINCTRL_BASE;
+	/* Clear the voltage bits for EMI pins as the reset value is invalid */
+	writel(0, &pinctrl->drive9);
+	writel(0, &pinctrl->drive10);
+	writel(0, &pinctrl->drive11);
+	writel(0, &pinctrl->drive12);
+	writel(0, &pinctrl->drive13);
+	writel(0, &pinctrl->drive14);
+	writel(0, &pinctrl->drive9);
 	mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
 }
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH 3/9 mx23evk: Fix DDR pin iomux settings

Dear Fabio Estevam,

Quoted 9 lines

From: Fabio Estevam <[email protected]>

Registers HW_PINCTRL_DRIVE9, HW_PINCTRL_DRIVE10, HW_PINCTRL_DRIVE11, HW_PINCTRL_DRIVE12, HW_PINCTRL_DRIVE13 and HW_PINCTRL_DRIVE14 control the drive strength and the voltage selection for the DDR pins.

The reset values of the voltage selection pins are '1', which is marked as 'reserved' in the mx23 reference manual.

Quoted 6 lines

Clear these bits for proper operation of DDR.

Also change MUX_CONFIG_EMI, which results in better stability and match the bootlets code from Freescale.

Uh, should the pinctrl/iomux stuff not set these up properly?

Quoted 23 lines
---
 board/freescale/mx23evk/spl_boot.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/board/freescale/mx23evk/spl_boot.c index b6f4e7e..035a29c 100644

board/freescale/mx23evk/spl_boot.c +3 -1
@@ -26,7 +26,7 @@
 #include <asm/arch/sys_proto.h>
 
 #define	MUX_CONFIG_SSP1	(MXS_PAD_3V3 | MXS_PAD_8MA | MXS_PAD_PULLUP)
-#define	MUX_CONFIG_EMI	(MXS_PAD_3V3 | MXS_PAD_16MA | MXS_PAD_PULLUP)
+#define	MUX_CONFIG_EMI	MXS_PAD_12MA
 
 const iomux_cfg_t iomux_setup[] = {
 	/* DUART */
@@ -110,5 +110,15 @@ void mxs_adjust_memory_params(uint32_t *dram_vals)
 
 void board_init_ll(void)
 {
+	struct mxs_pinctrl_regs *pinctrl =
+		(struct mxs_pinctrl_regs *)MXS_PINCTRL_BASE;

board/freescale/mx23evk/spl_boot.c void mxs_adjust_memory_params(uint32_t *dram_vals) · line 124

Quoted 10 lines
board/freescale/mx23evk/spl_boot.c +8 -0
+	/* Clear the voltage bits for EMI pins as the reset value is invalid */
+	writel(0, &pinctrl->drive9);
+	writel(0, &pinctrl->drive10);
+	writel(0, &pinctrl->drive11);
+	writel(0, &pinctrl->drive12);
+	writel(0, &pinctrl->drive13);
+	writel(0, &pinctrl->drive14);
+	writel(0, &pinctrl->drive9);
 	mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
 }

Best regards,
Marek Vasut

author reviewer
#13 lore raw

PATCH 3/9 mx23evk: Fix DDR pin iomux settings

Quoted 1 line · Marek Vasut

Uh, should the pinctrl/iomux stuff not set these up properly?

This is mx23 and EMI pins specific, so I think it is OK to do it in the board file.

#14 lore raw

PATCH 3/9 mx23evk: Fix DDR pin iomux settings

Dear Fabio Estevam,

Quoted 5 lines · Marek Vasut
Quoted 1 line

Uh, should the pinctrl/iomux stuff not set these up properly?

This is mx23 and EMI pins specific, so I think it is OK to do it in the board file.

Yes, but should the iomux_setup[] configure that already?

Best regards,
Marek Vasut

author reviewer
#15 lore raw

PATCH 4/9 mx23_olinuxino: Fix DDR pin iomux settings

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Registers HW_PINCTRL_DRIVE9, HW_PINCTRL_DRIVE10, HW_PINCTRL_DRIVE11, HW_PINCTRL_DRIVE12, HW_PINCTRL_DRIVE13 and HW_PINCTRL_DRIVE14 control the drive strength and the voltage selection for the DDR pins.

The reset values of the voltage selection pins are '1', which is marked as 'reserved' in the mx23 reference manual.

Clear these bits for proper operation of DDR.

Also change MUX_CONFIG_EMI, which results in better stability and match the bootlets code from Freescale.

---
 board/olimex/mx23_olinuxino/spl_boot.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
board/olimex/mx23_olinuxino/spl_boot.c +12 -1
index a96c293..5a43677 100644
@@ -30,7 +30,7 @@
 #include <asm/arch/sys_proto.h>
 
 #define	MUX_CONFIG_EMI	(MXS_PAD_3V3 | MXS_PAD_16MA | MXS_PAD_PULLUP)
-#define	MUX_CONFIG_SSP	(MXS_PAD_3V3 | MXS_PAD_8MA | MXS_PAD_PULLUP)
+#define	MUX_CONFIG_SSP	MXS_PAD_12MA
 
 const iomux_cfg_t iomux_setup[] = {
 	/* DUART */
@@ -103,5 +103,16 @@ const iomux_cfg_t iomux_setup[] = {
 
 void board_init_ll(void)
 {
+	struct mxs_pinctrl_regs *pinctrl =
+		(struct mxs_pinctrl_regs *)MXS_PINCTRL_BASE;
+
+	/* Clear the voltage bits for EMI pins as the reset value is invalid */
+	writel(0, &pinctrl->drive9);
+	writel(0, &pinctrl->drive10);
+	writel(0, &pinctrl->drive11);
+	writel(0, &pinctrl->drive12);
+	writel(0, &pinctrl->drive13);
+	writel(0, &pinctrl->drive14);
+	writel(0, &pinctrl->drive9);
 	mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
 }
Signature · 1 line
1.7.9.5
#16 lore raw

PATCH 4/9 mx23_olinuxino: Fix DDR pin iomux settings

Dear Fabio Estevam,

Quoted 9 lines

From: Fabio Estevam <[email protected]>

Registers HW_PINCTRL_DRIVE9, HW_PINCTRL_DRIVE10, HW_PINCTRL_DRIVE11, HW_PINCTRL_DRIVE12, HW_PINCTRL_DRIVE13 and HW_PINCTRL_DRIVE14 control the drive strength and the voltage selection for the DDR pins.

The reset values of the voltage selection pins are '1', which is marked as 'reserved' in the mx23 reference manual.

Quoted 6 lines

Clear these bits for proper operation of DDR.

Also change MUX_CONFIG_EMI, which results in better stability and match the bootlets code from Freescale.

Lost of duplicated code here.

Best regards,
Marek Vasut

author reviewer
#17 lore raw

PATCH 4/9 mx23_olinuxino: Fix DDR pin iomux settings

Quoted 1 line · Marek Vasut

Lost of duplicated code here.

What do you suggest?

#18 lore raw

PATCH 4/9 mx23_olinuxino: Fix DDR pin iomux settings

Dear Fabio Estevam,

Quoted 4 lines · Marek Vasut
Quoted 1 line

Lost of duplicated code here.

What do you suggest?

Stuff it into common init sequence, but only if it really is necessary to wipe those registers and iomux_setup[] table doesn't do it for some reason.

But then, if iomux_setup[] table doesn't configure them, there's a deeper problem.

Best regards,
Marek Vasut

author reviewer
#19 lore raw

PATCH 4/9 mx23_olinuxino: Fix DDR pin iomux settings

Quoted 5 lines · Marek Vasut

Stuff it into common init sequence, but only if it really is necessary to wipe those registers and iomux_setup[] table doesn't do it for some reason.

But then, if iomux_setup[] table doesn't configure them, there's a deeper problem.

Right, I managed to fix this as you suggested (via iomux_setup).

Will send it in v2.

Thanks for reviewing it.

author reviewer
#20 lore raw

PATCH 5/9 mx23evk: Disable the internal pad keepers

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Disable the internal pad keepers to match the code from FSL bootlets and provide better stability.

---
 board/freescale/mx23evk/spl_boot.c |    4 ++++
 1 file changed, 4 insertions(+)
board/freescale/mx23evk/spl_boot.c +4 -0
index 035a29c..143aaed 100644
@@ -120,5 +120,9 @@ void board_init_ll(void)
 	writel(0, &pinctrl->drive13);
 	writel(0, &pinctrl->drive14);
 	writel(0, &pinctrl->drive9);
+
+	/* Disable the internal pad keepers */
+	writel(0x3ffff, &pinctrl->pull3);
+
 	mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
 }
Signature · 1 line
1.7.9.5
author reviewer
#21 lore raw

PATCH 6/9 mx23_olinuxino: Disable the internal pad keepers

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Disable the internal pad keepers to match the code from FSL bootlets and provide better stability.

---
 board/olimex/mx23_olinuxino/spl_boot.c |    4 ++++
 1 file changed, 4 insertions(+)
board/olimex/mx23_olinuxino/spl_boot.c +4 -0
index 5a43677..65a9f41 100644
@@ -114,5 +114,9 @@ void board_init_ll(void)
 	writel(0, &pinctrl->drive13);
 	writel(0, &pinctrl->drive14);
 	writel(0, &pinctrl->drive9);
+
+	/* Disable the internal pad keepers */
+	writel(0x3ffff, &pinctrl->pull3);
+
 	mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
 }
Signature · 1 line
1.7.9.5
author reviewer
#22 lore raw

PATCH 7/9 mxs: spl_mem_init: Remove unneeded DRAM configurations

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

There is no need to write to DRAM_CTL8 register prior to nitialize_dram_values().

Fix a comment related to writing to DRAM_CTL8.

Also, DRAM_CTL18 register on mx23 does not contain DRAM init complete bit, so remove this setting as this is also not done by FSL bootlets code.

---
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c |    9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +1 -8
index 1c509d6..cde883d 100644
@@ -262,12 +262,9 @@ static void mx23_mem_init(void)
 	 * Configure the DRAM registers
 	 */
 
-	/* Clear START and SREFRESH bit from DRAM_CTL8 */
-	clrbits_le32(MXS_DRAM_BASE + 0x20, (1 << 16) | (1 << 8));
-
 	initialize_dram_values();
 
-	/* Set START bit in DRAM_CTL16 */
+	/* Set START bit in DRAM_CTL8 */
 	setbits_le32(MXS_DRAM_BASE + 0x20, 1 << 16);
 
 	clrbits_le32(MXS_DRAM_BASE + 0x40, 1 << 17);
@@ -279,10 +276,6 @@ static void mx23_mem_init(void)
 
 	setbits_le32(MXS_DRAM_BASE + 0x40, 1 << 19);
 	setbits_le32(MXS_DRAM_BASE + 0x40, 1 << 11);
-
-	/* Wait for bit 10 (DRAM init complete) in DRAM_CTL18 */
-	while (!(readl(MXS_DRAM_BASE + 0x48) & (1 << 10)))
-		;
 }
 #endif
 
Signature · 1 line
1.7.9.5
#23 lore raw

PATCH 7/9 mxs: spl_mem_init: Remove unneeded DRAM configurations

Dear Fabio Estevam,

Quoted 20 lines

From: Fabio Estevam <[email protected]>

There is no need to write to DRAM_CTL8 register prior to nitialize_dram_values().

Fix a comment related to writing to DRAM_CTL8.

Also, DRAM_CTL18 register on mx23 does not contain DRAM init complete bit, so remove this setting as this is also not done by FSL bootlets code.

---
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c |    9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c index 1c509d6..cde883d 100644

arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c static void mx23_mem_init(void) · line 267

Quoted 6 lines
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +0 -3
@@ -262,12 +262,9 @@ static void mx23_mem_init(void)
 	 * Configure the DRAM registers
 	 */
 
-	/* Clear START and SREFRESH bit from DRAM_CTL8 */
-	clrbits_le32(MXS_DRAM_BASE + 0x20, (1 << 16) | (1 << 8));
-

Do you not need to stop the DRAM if it's already running? Like after a software reset?

Quoted 8 lines
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +1 -1
 	initialize_dram_values();
 
-	/* Set START bit in DRAM_CTL16 */
+	/* Set START bit in DRAM_CTL8 */
 	setbits_le32(MXS_DRAM_BASE + 0x20, 1 << 16);
 
 	clrbits_le32(MXS_DRAM_BASE + 0x40, 1 << 17);

arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c static void mx23_mem_init(void) · line 280

Quoted 9 lines
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +0 -4
@@ -279,10 +276,6 @@ static void mx23_mem_init(void)
 
 	setbits_le32(MXS_DRAM_BASE + 0x40, 1 << 19);
 	setbits_le32(MXS_DRAM_BASE + 0x40, 1 << 11);
-
-	/* Wait for bit 10 (DRAM init complete) in DRAM_CTL18 */
-	while (!(readl(MXS_DRAM_BASE + 0x48) & (1 << 10)))
-		;
 }
 #endif

Best regards,
Marek Vasut

author reviewer
#24 lore raw

PATCH 7/9 mxs: spl_mem_init: Remove unneeded DRAM configurations

Quoted 2 lines · Marek Vasut

Do you not need to stop the DRAM if it's already running? Like after a software reset?

I don't think this is needed. FSL bootlets code does not do this.

#25 lore raw

PATCH 7/9 mxs: spl_mem_init: Remove unneeded DRAM configurations

Dear Fabio Estevam,

Quoted 5 lines · Marek Vasut
Quoted 2 lines

Do you not need to stop the DRAM if it's already running? Like after a software reset?

I don't think this is needed. FSL bootlets code does not do this.

You'll end up messing with configuration registers on already-running RAM. That doesn't really make sense and I suspect it can result in some weird behavior.

Best regards,
Marek Vasut

author reviewer
#26 lore raw

PATCH 7/9 mxs: spl_mem_init: Remove unneeded DRAM configurations

Quoted 1 line · Marek Vasut

You'll end up messing with configuration registers on already-running RAM. That

HW_DRAM_CTL08, bit 16 (START) is 0 (inactive) after a reset, so no need to turn off the RAM.

author reviewer
#27 lore raw

PATCH 8/9 mxs: spl_mem_init: Skip the initialization of some DRAM_CTL registers

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

HW_DRAM_CTL27, HW_DRAM_CTL28 and HW_DRAM_CTL35 are not initialized as per FSL bootlets code.

mx23 Reference Manual mark HW_DRAM_CTL27 and HW_DRAM_CTL28 as "reserved".

HW_DRAM_CTL8 is setup as the last element.

So skip the initialization of these DRAM_CTL registers.

---
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +6 -3
index cde883d..f500851 100644
@@ -116,9 +116,12 @@ static void initialize_dram_values(void)
 
 	mxs_adjust_memory_params(dram_vals);
 
-	for (i = 0; i < ARRAY_SIZE(dram_vals); i++)
-		writel(dram_vals[i], MXS_DRAM_BASE + (4 * i));
-
+	for (i = 0; i < ARRAY_SIZE(dram_vals); i++) {
+#ifdef CONFIG_MX23
+		if (!(i == 8 || i == 27 || i == 28 || i == 35))
+#endif
+			writel(dram_vals[i], MXS_DRAM_BASE + (4 * i));
+	}
 #ifdef CONFIG_MX23
 	/*
 	 * Enable tRAS lockout in HW_DRAM_CTL08 ; it must be the last
Signature · 1 line
1.7.9.5
#28 lore raw

PATCH 8/9 mxs: spl_mem_init: Skip the initialization of some DRAM_CTL registers

Dear Fabio Estevam,

Quoted 21 lines

From: Fabio Estevam <[email protected]>

HW_DRAM_CTL27, HW_DRAM_CTL28 and HW_DRAM_CTL35 are not initialized as per FSL bootlets code.

mx23 Reference Manual mark HW_DRAM_CTL27 and HW_DRAM_CTL28 as "reserved".

HW_DRAM_CTL8 is setup as the last element.

So skip the initialization of these DRAM_CTL registers.

---
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c index cde883d..f500851 100644

arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c static void initialize_dram_values(void) · line 121

Quoted 9 lines
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +3 -3
@@ -116,9 +116,12 @@ static void initialize_dram_values(void)
 
 	mxs_adjust_memory_params(dram_vals);
 
-	for (i = 0; i < ARRAY_SIZE(dram_vals); i++)
-		writel(dram_vals[i], MXS_DRAM_BASE + (4 * i));
-
+	for (i = 0; i < ARRAY_SIZE(dram_vals); i++) {
+#ifdef CONFIG_MX23
+		if (!(i == 8 || i == 27 || i == 28 || i == 35))

Stick a "continue" keyword here so it's contained instead of such a semi- complete "if" clause please.

arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c static void initialize_dram_values(void) · line 127

Quoted 6 lines
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +3 -0
+#endif
+			writel(dram_vals[i], MXS_DRAM_BASE + (4 * i));
+	}
 #ifdef CONFIG_MX23
 	/*
 	 * Enable tRAS lockout in HW_DRAM_CTL08 ; it must be the last

Best regards,
Marek Vasut

#29 lore raw

PATCH 8/9 mxs: spl_mem_init: Skip the initialization of some DRAM_CTL registers

In reply to Fabio Estevam
Quoted 5 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

HW_DRAM_CTL27, HW_DRAM_CTL28 and HW_DRAM_CTL35 are not initialized as per FSL bootlets code.

Quoted 8 lines

mx23 Reference Manual mark HW_DRAM_CTL27 and HW_DRAM_CTL28 as "reserved".

HW_DRAM_CTL8 is setup as the last element.

So skip the initialization of these DRAM_CTL registers.

---

Hi Fabio,

Quoted 8 lines
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +0 -0
index cde883d..f500851 100644

arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c static void initialize_dram_values(void) · line 122

Quoted 10 lines
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +4 -3
@@ -116,9 +116,12 @@ static void initialize_dram_values(void)
 
 	mxs_adjust_memory_params(dram_vals);
 
-	for (i = 0; i < ARRAY_SIZE(dram_vals); i++)
-		writel(dram_vals[i], MXS_DRAM_BASE + (4 * i));
-
+	for (i = 0; i < ARRAY_SIZE(dram_vals); i++) {
+#ifdef CONFIG_MX23
+		if (!(i == 8 || i == 27 || i == 28 || i == 35))
+#endif

I will suggest you add also a comment here telling that the registers are reserved. I know you explain this in commit message, but people look directly into the code and it will be easire to understand why you do that.

Best regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author reviewer
#30 lore raw

PATCH 9/9 mxs: spl_mem_init: Change EMI port priority

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

FSL bootlets code set the PORT_PRIORITY_ORDER field of register HW_EMI_CTRL as 0x2, which means:

PORT0231 = 0x02 Priority Order: AXI0, AHB2, AHB3, AHB1

---
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +1 -1
index f500851..68b9587 100644
@@ -274,7 +274,7 @@ static void mx23_mem_init(void)
 	early_delay(20000);
 
 	/* Adjust EMI port priority. */
-	clrsetbits_le32(0x80020000, 0x1f << 16, 0x8);
+	clrsetbits_le32(0x80020000, 0x1f << 16, 0x2);
 	early_delay(20000);
 
 	setbits_le32(MXS_DRAM_BASE + 0x40, 1 << 19);
Signature · 1 line
1.7.9.5