diff options
author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2013-03-27 15:40:36 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-04-03 17:22:11 +0200 |
commit | 18196fcf5f32219f0ec40ede42aea7e142f526d3 (patch) | |
tree | 5315aad4229bad808c99625a89af1bf0913217d1 /arch/arm/boards/crystalfontz-cfa10036 | |
parent | 01cc0084d91f484dd803369d14f470dd649db475 (diff) | |
download | barebox-18196fcf5f32219f0ec40ede42aea7e142f526d3.tar.gz barebox-18196fcf5f32219f0ec40ede42aea7e142f526d3.tar.xz |
cfa10036: Retrieve the RAM size at runtime
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>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/boards/crystalfontz-cfa10036')
-rw-r--r-- | arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c index 1bc20cf21c..a37b0898eb 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; } |