summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-s3c24xx
diff options
context:
space:
mode:
authorJuergen Beisert <juergen@kreuzholzen.de>2009-10-27 19:57:35 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2009-10-28 09:44:41 +0100
commitafae995ef9acd5ef6caa6ee2ba39540cf213f90c (patch)
treeacf66d798440a934ffd262c3bc7a9880dbe87218 /arch/arm/mach-s3c24xx
parent16fe431ce75c91ec5cb6c2ed53801582c8672e2a (diff)
downloadbarebox-afae995ef9acd5ef6caa6ee2ba39540cf213f90c.tar.gz
barebox-afae995ef9acd5ef6caa6ee2ba39540cf213f90c.tar.xz
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>
Diffstat (limited to 'arch/arm/mach-s3c24xx')
-rw-r--r--arch/arm/mach-s3c24xx/generic.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/arch/arm/mach-s3c24xx/generic.c b/arch/arm/mach-s3c24xx/generic.c
index 864977d7b8..515731a5a4 100644
--- a/arch/arm/mach-s3c24xx/generic.c
+++ b/arch/arm/mach-s3c24xx/generic.c
@@ -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>
@@ -124,6 +124,52 @@ uint32_t s3c24xx_get_uclk(void)
}
/**
+ * 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
*/
int s3c24xx_dump_clocks(void)