9
0
Fork 0

at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add autodetect sdram size

if 0 is passed to at91_add_device_sdram autodetect the sdram size

The amount of available ram is determined by the SDRAMC_CR register.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Jean-Christophe PLAGNIOL-VILLARD 2012-08-03 08:52:39 +02:00 committed by Sascha Hauer
parent 1e1c4dcd8c
commit 46a11f99ff
4 changed files with 40 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include <mach/board.h>
#include <mach/at91_pmc.h>
#include <mach/at91sam9260_matrix.h>
#include <mach/at91sam9_sdramc.h>
#include <mach/gpio.h>
#include <mach/io.h>
#include <mach/cpu.h>
@ -24,6 +25,9 @@
void at91_add_device_sdram(u32 size)
{
if (!size)
size = at91_get_sdram_size();
arm_add_mem_device("ram0", AT91_CHIPSELECT_1, size);
if (cpu_is_at91sam9g20()) {
add_mem_device("sram0", AT91SAM9G20_SRAM_BASE,

View File

@ -15,6 +15,7 @@
#include <asm/hardware.h>
#include <mach/at91_pmc.h>
#include <mach/at91sam9261_matrix.h>
#include <mach/at91sam9_sdramc.h>
#include <mach/board.h>
#include <mach/gpio.h>
#include <mach/io.h>
@ -24,6 +25,9 @@
void at91_add_device_sdram(u32 size)
{
if (!size)
size = at91_get_sdram_size();
arm_add_mem_device("ram0", AT91_CHIPSELECT_1, size);
if (cpu_is_at91sam9g10())
add_mem_device("sram0", AT91SAM9G10_SRAM_BASE,

View File

@ -15,6 +15,7 @@
#include <asm/hardware.h>
#include <mach/at91_pmc.h>
#include <mach/at91sam9263_matrix.h>
#include <mach/at91sam9_sdramc.h>
#include <mach/board.h>
#include <mach/gpio.h>
#include <mach/io.h>
@ -23,6 +24,9 @@
void at91_add_device_sdram(u32 size)
{
if (!size)
size = at91_get_sdram_size();
arm_add_mem_device("ram0", AT91_CHIPSELECT_1, size);
add_mem_device("sram0", AT91SAM9263_SRAM0_BASE,
AT91SAM9263_SRAM0_SIZE, IORESOURCE_MEM_WRITEABLE);

View File

@ -83,5 +83,33 @@
#define AT91_SDRAMC_MD_SDRAM 0
#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1
#ifndef __ASSEMBLY__
#include <mach/io.h>
static inline u32 at91_get_sdram_size(void)
{
u32 val;
u32 size;
val = at91_sys_read(AT91_SDRAMC_CR);
/* Formula:
* size = bank << (col + row + 1);
* if (bandwidth == 32 bits)
* size <<= 1;
*/
size = 1;
/* COL */
size += (val & AT91_SDRAMC_NC) + 8;
/* ROW */
size += ((val & AT91_SDRAMC_NR) >> 2) + 11;
/* BANK */
size = ((val & AT91_SDRAMC_NB) ? 4 : 2) << size;
/* bandwidth */
if (!(val & AT91_SDRAMC_DBW))
size <<= 1;
return size;
}
#endif
#endif