mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: i.MX23: fix memory size calulcation
@ 2022-09-09 14:39 Bastian Krause
  2022-09-12  6:21 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Bastian Krause @ 2022-09-09 14:39 UTC (permalink / raw)
  To: Barebox List; +Cc: Bastian Krause, Jürgen Borleis

According to the i.MX233 Reference Manual (i.MX233RM, Rev. 4, 03 April
2009) section "14.1.1 AHB Address Ranges", the formula to calculate the
DRAM memory size is:

  dram_memory_available = 2 * 2^col * 2^row * (# dram_devices) * (# banks_per_device)

The calulcation in barebox misses the first factor, so the result is
only half as big as it should be.

On an iMX233 OLinuXino board the following errors can be observed:

  mmu: Critical Error: Can't request SDRAM region for ttb at 43fe4000
  Error: Cannot request SDRAM region for stack

The faulty calulcation leads to 32 MB being detected (as seen in the
output of `iomem`), although 64 MB should be available (as passed to
barebox_arm_entry() in lowlevel code).

Fix the memory calculation by adding the missing factor 2.

Fixes: 7158c5987e6 ("ARM: i.MX23: Add memory size detection")
Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Jürgen Borleis <jbe@pengutronix.de>
---
 arch/arm/mach-mxs/include/mach/imx23.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-mxs/include/mach/imx23.h b/arch/arm/mach-mxs/include/mach/imx23.h
index bdd3ae4407a..03eddabed0a 100644
--- a/arch/arm/mach-mxs/include/mach/imx23.h
+++ b/arch/arm/mach-mxs/include/mach/imx23.h
@@ -25,7 +25,7 @@ static inline u32 imx23_get_memsize(void)
 	cs0 = FIELD_GET(DRAM_CTL14_CS0_EN, ctl14);
 	cs1 = FIELD_GET(DRAM_CTL14_CS1_EN, ctl14);
 
-	return (1 << columns) * (1 << rows) * banks * (cs0 + cs1);
+	return 2 * (1 << columns) * (1 << rows) * banks * (cs0 + cs1);
 }
 
 #endif /* __MACH_IMX23_H */
-- 
2.30.2




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

* Re: [PATCH] ARM: i.MX23: fix memory size calulcation
  2022-09-09 14:39 [PATCH] ARM: i.MX23: fix memory size calulcation Bastian Krause
@ 2022-09-12  6:21 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-09-12  6:21 UTC (permalink / raw)
  To: Bastian Krause; +Cc: Barebox List, Jürgen Borleis

On Fri, Sep 09, 2022 at 04:39:15PM +0200, Bastian Krause wrote:
> According to the i.MX233 Reference Manual (i.MX233RM, Rev. 4, 03 April
> 2009) section "14.1.1 AHB Address Ranges", the formula to calculate the
> DRAM memory size is:
> 
>   dram_memory_available = 2 * 2^col * 2^row * (# dram_devices) * (# banks_per_device)
> 
> The calulcation in barebox misses the first factor, so the result is
> only half as big as it should be.
> 
> On an iMX233 OLinuXino board the following errors can be observed:
> 
>   mmu: Critical Error: Can't request SDRAM region for ttb at 43fe4000
>   Error: Cannot request SDRAM region for stack
> 
> The faulty calulcation leads to 32 MB being detected (as seen in the
> output of `iomem`), although 64 MB should be available (as passed to
> barebox_arm_entry() in lowlevel code).
> 
> Fix the memory calculation by adding the missing factor 2.
> 
> Fixes: 7158c5987e6 ("ARM: i.MX23: Add memory size detection")
> Signed-off-by: Bastian Krause <bst@pengutronix.de>
> Signed-off-by: Jürgen Borleis <jbe@pengutronix.de>
> ---
>  arch/arm/mach-mxs/include/mach/imx23.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master, thanks

Sascha

> 
> diff --git a/arch/arm/mach-mxs/include/mach/imx23.h b/arch/arm/mach-mxs/include/mach/imx23.h
> index bdd3ae4407a..03eddabed0a 100644
> --- a/arch/arm/mach-mxs/include/mach/imx23.h
> +++ b/arch/arm/mach-mxs/include/mach/imx23.h
> @@ -25,7 +25,7 @@ static inline u32 imx23_get_memsize(void)
>  	cs0 = FIELD_GET(DRAM_CTL14_CS0_EN, ctl14);
>  	cs1 = FIELD_GET(DRAM_CTL14_CS1_EN, ctl14);
>  
> -	return (1 << columns) * (1 << rows) * banks * (cs0 + cs1);
> +	return 2 * (1 << columns) * (1 << rows) * banks * (cs0 + cs1);
>  }
>  
>  #endif /* __MACH_IMX23_H */
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2022-09-12  6:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09 14:39 [PATCH] ARM: i.MX23: fix memory size calulcation Bastian Krause
2022-09-12  6:21 ` Sascha Hauer

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