Skip to contentSkip to conversation

i.MX28: Add function to adjust memory parameters

PATCH New Marek Vasut 3 participants 11 messages May 30, 2012 – Jun 19, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

This function can be overridden at run-time and allows implementors of new boards based on the i.MX28 chip to fine-tune the memory params. It is possible to write into the dram_vals array because when the SPL runs, it is located SRAM. Therefore the location is writable. There is no possibility of these data to be read-only.

Cc Wolfgang Denk <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Fabio Estevam <[email protected]>
---
 arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c +8 -0
index 9fa5d29..e17a4d7 100644
@@ -82,10 +82,18 @@ uint32_t dram_vals[] = {
 	0x00000000, 0x00010001
 };
 
+void __mx28_adjust_memory_params(uint32_t *dram_vals)
+{
+}
+void mx28_adjust_memory_params(uint32_t *dram_vals)
+	__attribute__((weak, alias("__mx28_adjust_memory_params")));
+
 void init_m28_200mhz_ddr2(void)
 {
 	int i;
 
+	mx28_adjust_memory_params(dram_vals);
+
 	for (i = 0; i < ARRAY_SIZE(dram_vals); i++)
 		writel(dram_vals[i], MXS_DRAM_BASE + (4 * i));
 }
Signature · 1 line
1.7.10
#1 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

Hi Marek,

Quoted 5 lines · Marek Vasut

This function can be overridden at run-time and allows implementors of new boards based on the i.MX28 chip to fine-tune the memory params. It is possible to write into the dram_vals array because when the SPL runs, it is located SRAM. Therefore the location is writable. There is no possibility of these data to be read-only.

This still does not fix the mx28evk booting issue on u-boot-imx tree.

Have you tried to boot m28evk with the following commit reverted?

commit 19a2066b578f826c7bcb2b96a90434382e8ec8f3

Author: Marek Vasut <[email protected]>
Date:   Thu May 3 05:47:19 2012 +0000

M28: Scan only first 512 MB of DRAM to avoid memory wraparound

#2 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

Dear Fabio Estevam,

Quoted 9 lines

Hi Marek,

Quoted 5 lines · Marek Vasut

This function can be overridden at run-time and allows implementors of new boards based on the i.MX28 chip to fine-tune the memory params. It is possible to write into the dram_vals array because when the SPL runs, it is located SRAM. Therefore the location is writable. There is no possibility of these data to be read-only.

Quoted 3 lines

This still does not fix the mx28evk booting issue on u-boot-imx tree.

Have you tried to boot m28evk with the following commit reverted?

It's broken, that's why the following patch was applied ;-)

Call this or similar in your spl_boot.c to adjust the DRAM configuration. Actually I think even the following value should fix your problem:

void mx28_adjust_memory_params(uint32_t *dram_vals)

{
        dram_vals[0x74 >> 2] = 0x0f02010a;
}
Quoted 6 lines

commit 19a2066b578f826c7bcb2b96a90434382e8ec8f3

Author: Marek Vasut <[email protected]>
Date:   Thu May 3 05:47:19 2012 +0000

M28: Scan only first 512 MB of DRAM to avoid memory wraparound

Best regards,
Marek Vasut

#3 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

Hi Marek,

Quoted 7 lines · Marek Vasut

Call this or similar in your spl_boot.c to adjust the DRAM configuration. Actually I think even the following value should fix your problem:

void mx28_adjust_memory_params(uint32_t *dram_vals) {
? ? ? ?dram_vals[0x74 >> 2] = 0x0f02010a;
}

I finally had a chance to try this and my mx28evk can boot again with your patch + the code above.

How do we handle this? Would you send a v2 with this additional code or should I do it myself after your original patch in this thread gets applied?

Also, please explain to the mortal folks what 'dram_vals[0x74 >> 2] = 0x0f02010a;' means.

It is not something very trivial to figure out :-)

Thanks,

Fabio Estevam

#4 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

Dear Fabio Estevam,

Quoted 11 lines

Hi Marek,

Quoted 7 lines · Marek Vasut

Call this or similar in your spl_boot.c to adjust the DRAM configuration. Actually I think even the following value should fix your problem:

void mx28_adjust_memory_params(uint32_t *dram_vals)

{
       dram_vals[0x74 >> 2] = 0x0f02010a;
}
Quoted 6 lines

I finally had a chance to try this and my mx28evk can boot again with your patch + the code above.

How do we handle this? Would you send a v2 with this additional code or should I do it myself after your original patch in this thread gets applied?

Stefano, can you please apply this? So Fabio can apply his on top of it?

Quoted 2 lines

Also, please explain to the mortal folks what 'dram_vals[0x74 >> 2] = 0x0f02010a;' means.

Well, check that particular register (memory configuration register at +0x74 offset) in the datasheet. It's basically adjusting the number of enabled address row and columns.

Quoted 1 line

It is not something very trivial to figure out :-)

It actually is, see above ;-)

Quoted 3 lines

Thanks,

Fabio Estevam

Best regards,
Marek Vasut

#5 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

Quoted 13 lines · Marek Vasut

Dear Fabio Estevam,

Quoted 11 lines

Hi Marek,

Quoted 7 lines · Marek Vasut

Call this or similar in your spl_boot.c to adjust the DRAM configuration. Actually I think even the following value should fix your problem:

void mx28_adjust_memory_params(uint32_t *dram_vals)

{
       dram_vals[0x74 >> 2] = 0x0f02010a;
}
Quoted 8 lines
Quoted 6 lines

I finally had a chance to try this and my mx28evk can boot again with your patch + the code above.

How do we handle this? Would you send a v2 with this additional code or should I do it myself after your original patch in this thread gets applied?

Stefano, can you please apply this? So Fabio can apply his on top of it?

I do it.

Quoted 11 lines
Quoted 3 lines

Also, please explain to the mortal folks what 'dram_vals[0x74 >> 2] = 0x0f02010a;' means.

Well, check that particular register (memory configuration register at +0x74 offset) in the datasheet. It's basically adjusting the number of enabled address row and columns.

Quoted 1 line

It is not something very trivial to figure out :-)

It actually is, see above ;-)

I see, but I will never apply a patch programmed in hexadecimal instead of plain C ;-)

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
=====================================================================
#6 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

Dear Stefano Babic,

Quoted 35 lines · Marek Vasut
Quoted 16 lines

Dear Fabio Estevam,

Quoted 14 lines

Hi Marek,

Quoted 10 lines · Marek Vasut

Call this or similar in your spl_boot.c to adjust the DRAM configuration. Actually I think even the following value should fix your problem:

void mx28_adjust_memory_params(uint32_t *dram_vals) {

       dram_vals[0x74 >> 2] = 0x0f02010a;

}

Quoted 8 lines
Quoted 6 lines

I finally had a chance to try this and my mx28evk can boot again with your patch + the code above.

How do we handle this? Would you send a v2 with this additional code or should I do it myself after your original patch in this thread gets applied?

Stefano, can you please apply this? So Fabio can apply his on top of it?

I do it.

Quoted 7 lines
Quoted 2 lines

Also, please explain to the mortal folks what 'dram_vals[0x74 >> 2] = 0x0f02010a;' means.

Well, check that particular register (memory configuration register at +0x74 offset) in the datasheet. It's basically adjusting the number of enabled address row and columns.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

It is not something very trivial to figure out :-)

It actually is, see above ;-)

I see, but I will never apply a patch programmed in hexadecimal instead of plain C ;-)

So ... what do you expect me to do? The register is called HW_DRAM_CTL29 (very descriptive) ... do you want me to create a file full of HW_DRAM_CTLnn ?

Quoted 2 lines

Stefano

Best regards,
Marek Vasut

#7 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

Dear Stefano Babic,

Quoted 38 lines
Quoted 38 lines · Marek Vasut
Quoted 19 lines

Dear Fabio Estevam,

Quoted 17 lines

Hi Marek,

Quoted 10 lines · Marek Vasut

Call this or similar in your spl_boot.c to adjust the DRAM configuration. Actually I think even the following value should fix your problem:

void mx28_adjust_memory_params(uint32_t *dram_vals) {

       dram_vals[0x74 >> 2] = 0x0f02010a;

}

I finally had a chance to try this and my mx28evk can boot again with your patch + the code above.

Quoted 6 lines
Quoted 3 lines

How do we handle this? Would you send a v2 with this additional code or should I do it myself after your original patch in this thread gets applied?

Stefano, can you please apply this? So Fabio can apply his on top of it?

I do it.

Quoted 9 lines
Quoted 2 lines

Also, please explain to the mortal folks what 'dram_vals[0x74 >> 2] = 0x0f02010a;' means.

Well, check that particular register (memory configuration register at +0x74 offset) in the datasheet. It's basically adjusting the number of enabled address row and columns.

Quoted 1 line

It is not something very trivial to figure out :-)

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

It actually is, see above ;-)

I see, but I will never apply a patch programmed in hexadecimal instead of plain C ;-)

So ... what do you expect me to do? The register is called HW_DRAM_CTL29 (very descriptive) ... do you want me to create a file full of HW_DRAM_CTLnn ?

Would adding such comment be enough to satisfy you? (In slightly more polite manner I mean ... damn I'm loosing it, 2 days until exam :'-( ). Sorry for being rough, Stefano.

Quoted 1 line
Quoted 1 line

Stefano

Best regards,
Marek Vasut

#8 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

Quoted 8 lines · Marek Vasut
Quoted 4 lines

So ... what do you expect me to do? The register is called HW_DRAM_CTL29 (very descriptive) ... do you want me to create a file full of HW_DRAM_CTLnn ?

Would adding such comment be enough to satisfy you? (In slightly more polite manner I mean ... damn I'm loosing it, 2 days until exam :'-( ). Sorry for being rough, Stefano.

Do not worry, it is normal before exam ;-)

Yes, of course comments will help !

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
=====================================================================
#9 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

Dear Stefano Babic,

Quoted 10 lines · Marek Vasut
Quoted 7 lines
Quoted 3 lines

So ... what do you expect me to do? The register is called HW_DRAM_CTL29 (very descriptive) ... do you want me to create a file full of HW_DRAM_CTLnn ?

Would adding such comment be enough to satisfy you? (In slightly more polite manner I mean ... damn I'm loosing it, 2 days until exam :'-( ). Sorry for being rough, Stefano.

Do not worry, it is normal before exam ;-)

This ... is not exam. This ... is HELL!!!

Quoted 1 line

Yes, of course comments will help !

Wait ... it isn't my fault, I didn't publish any code that uses the function yet, that encodes stuff in hexadecimal. So this patch can be applied as is. It's Fabio's patch that's at fault here (and I hereby dump all responsibility on Fabio, keh keh :-) ).

But anyway ... we're gonna have this used a lot and I'm not quite sure how to handle it. So if comment is enough (aka. I'm hereby adjusting HW_DRAM_CTL29 in order to set enabled rows and cols differently, refer to "14.8.27 in mx28 TRM"), let's go with it.

Later, I think we should rework the mem init part. It's there from bootlets and I think it's all shitty because of that. Well ... the whole SPL is shitty because it's from bootlets, but that's a longer run, out of scope of this discussion.

Quoted 2 lines

Best regards,
Stefano

Best regards,
Marek Vasut

#10 lore raw

PATCH 1/1 i.MX28: Add function to adjust memory parameters

In reply to Marek Vasut
Quoted 6 lines · Marek Vasut

This function can be overridden at run-time and allows implementors of new boards based on the i.MX28 chip to fine-tune the memory params. It is possible to write into the dram_vals array because when the SPL runs, it is located SRAM. Therefore the location is writable. There is no possibility of these data to be read-only.

Quoted 6 lines
Cc Wolfgang Denk <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Fabio Estevam <[email protected]>

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

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
=====================================================================