mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2] cfa10036: Retrieve the RAM size at runtime
@ 2013-03-27 14:40 Alexandre Belloni
  2013-03-29 14:21 ` Maxime Ripard
  2013-03-30 10:39 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Belloni @ 2013-03-27 14:40 UTC (permalink / raw)
  To: barebox; +Cc: Maxime Ripard, jimwall, brian

The cfa-10036 comes in two flavours, with either 128MB or 256MB of RAM
on it.

Since it's not stored anywhere, we need to runtime detect it by
introducing the cfa10036_get_ram_size function.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
---
changes since v1:
  - stripped cfa10036_get_ram_size as suggested by Sacha
  - I'm not too happy about the v5_mmu_cache_flush definition and call but that
	has to be done, else we are not reading the modified value, even on 128MB
	boards.


 arch/arm/boards/crystalfontz-cfa10036/cfa10036.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c
index 1bc20cf..a37b089 100644
--- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c
+++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c
@@ -90,9 +90,25 @@ static struct i2c_gpio_platform_data i2c_gpio_pdata = {
 	.udelay			= 5,		/* ~100 kHz */
 };
 
+void v5_mmu_cache_flush(void);
+long cfa10036_get_ram_size(void)
+{
+	volatile u32 *base = (void *)IMX_MEMORY_BASE;
+	volatile u32 *ofs = base + SZ_128M / sizeof(u32);
+
+	*base = *ofs = 0xdeadbeef;
+	*ofs = 0xbaadcafe;
+
+	v5_mmu_cache_flush();
+	if (*base == 0xbaadcafe)
+		return SZ_128M;
+	else
+		return SZ_256M;
+}
+
 static int cfa10036_mem_init(void)
 {
-	arm_add_mem_device("ram0", IMX_MEMORY_BASE, 128 * 1024 * 1024);
+	arm_add_mem_device("ram0", IMX_MEMORY_BASE, cfa10036_get_ram_size());
 
 	return 0;
 }
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2] cfa10036: Retrieve the RAM size at runtime
  2013-03-27 14:40 [PATCH v2] cfa10036: Retrieve the RAM size at runtime Alexandre Belloni
@ 2013-03-29 14:21 ` Maxime Ripard
  2013-03-30 10:39 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Ripard @ 2013-03-29 14:21 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: barebox, jimwall, brian

Hi Alexandre,

Le 27/03/2013 15:40, Alexandre Belloni a écrit :
> The cfa-10036 comes in two flavours, with either 128MB or 256MB of RAM
> on it.
> 
> Since it's not stored anywhere, we need to runtime detect it by
> introducing the cfa10036_get_ram_size function.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2] cfa10036: Retrieve the RAM size at runtime
  2013-03-27 14:40 [PATCH v2] cfa10036: Retrieve the RAM size at runtime Alexandre Belloni
  2013-03-29 14:21 ` Maxime Ripard
@ 2013-03-30 10:39 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2013-03-30 10:39 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: barebox, Maxime Ripard, jimwall, brian

On Wed, Mar 27, 2013 at 03:40:36PM +0100, Alexandre Belloni wrote:
> The cfa-10036 comes in two flavours, with either 128MB or 256MB of RAM
> on it.
> 
> Since it's not stored anywhere, we need to runtime detect it by
> introducing the cfa10036_get_ram_size function.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Applied, thanks.

> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> changes since v1:
>   - stripped cfa10036_get_ram_size as suggested by Sacha
>   - I'm not too happy about the v5_mmu_cache_flush definition and call but that
> 	has to be done, else we are not reading the modified value, even on 128MB
> 	boards.

So your data cache works. That's good news ;)

Sascha

> 
> 
>  arch/arm/boards/crystalfontz-cfa10036/cfa10036.c |   18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c
> index 1bc20cf..a37b089 100644
> --- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c
> +++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c
> @@ -90,9 +90,25 @@ static struct i2c_gpio_platform_data i2c_gpio_pdata = {
>  	.udelay			= 5,		/* ~100 kHz */
>  };
>  
> +void v5_mmu_cache_flush(void);
> +long cfa10036_get_ram_size(void)
> +{
> +	volatile u32 *base = (void *)IMX_MEMORY_BASE;
> +	volatile u32 *ofs = base + SZ_128M / sizeof(u32);
> +
> +	*base = *ofs = 0xdeadbeef;
> +	*ofs = 0xbaadcafe;
> +
> +	v5_mmu_cache_flush();
> +	if (*base == 0xbaadcafe)
> +		return SZ_128M;
> +	else
> +		return SZ_256M;
> +}
> +
>  static int cfa10036_mem_init(void)
>  {
> -	arm_add_mem_device("ram0", IMX_MEMORY_BASE, 128 * 1024 * 1024);
> +	arm_add_mem_device("ram0", IMX_MEMORY_BASE, cfa10036_get_ram_size());
>  
>  	return 0;
>  }
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-03-30 10:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-27 14:40 [PATCH v2] cfa10036: Retrieve the RAM size at runtime Alexandre Belloni
2013-03-29 14:21 ` Maxime Ripard
2013-03-30 10:39 ` Sascha Hauer

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