9
0
Fork 0

S3C24xx: Provide a generic way to detect memory size

This patch adds code to determine the current available SDRAM size. It relies
on other routines setting up the SDRAM controller, because it only read back
their settings.

Signed-off-by: Juergen Beisert <juergen@kreuzholzen.de>
This commit is contained in:
Juergen Beisert 2009-10-27 19:57:35 +01:00 committed by Sascha Hauer
parent 16fe431ce7
commit afae995ef9
2 changed files with 48 additions and 1 deletions

View File

@ -19,7 +19,7 @@
*/
/**
* @file
* @brief Basic clock and timer handling for S3C24xx CPUs
* @brief Basic clock, sdram and timer handling for S3C24xx CPUs
*/
#include <config.h>
@ -123,6 +123,52 @@ uint32_t s3c24xx_get_uclk(void)
return s3c24xx_get_upllclk();
}
/**
* Calculate the amount of connected and available memory
* @return Memory size in bytes
*/
uint32_t s3c24x0_get_memory_size(void)
{
uint32_t reg, size;
/*
* detect the current memory size
*/
reg = readl(BANKSIZE);
switch (reg & 0x7) {
case 0:
size = 32 * 1024 * 1024;
break;
case 1:
size = 64 * 1024 * 1024;
break;
case 2:
size = 128 * 1024 * 1024;
break;
case 4:
size = 2 * 1024 * 1024;
break;
case 5:
size = 4 * 1024 * 1024;
break;
case 6:
size = 8 * 1024 * 1024;
break;
default:
size = 16 * 1024 * 1024;
break;
}
/*
* Is bank7 also configured for SDRAM usage?
*/
if ((readl(BANKCON7) & (0x3 << 15)) == (0x3 << 15))
size <<= 1; /* also count this bank */
return size;
}
/**
* Show the user the current clock settings
*/

View File

@ -30,3 +30,4 @@ uint32_t s3c24xx_get_fclk(void);
uint32_t s3c24xx_get_hclk(void);
uint32_t s3c24xx_get_pclk(void);
uint32_t s3c24xx_get_uclk(void);
uint32_t s3c24x0_get_memory_size(void);