mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add autodetect sdram size
@ 2012-08-03  6:52 Jean-Christophe PLAGNIOL-VILLARD
  2012-08-03  6:52 ` [PATCH 2/2] at91: Calao and Atmel reboard sam{9260/9g20/9261/9g10/9263}ek " Jean-Christophe PLAGNIOL-VILLARD
  2012-08-10 14:17 ` [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add " Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-03  6:52 UTC (permalink / raw)
  To: barebox

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>
---
 arch/arm/mach-at91/at91sam9260_devices.c          |    4 +++
 arch/arm/mach-at91/at91sam9261_devices.c          |    4 +++
 arch/arm/mach-at91/at91sam9263_devices.c          |    4 +++
 arch/arm/mach-at91/include/mach/at91sam9_sdramc.h |   28 +++++++++++++++++++++
 4 files changed, 40 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index b56ca14..9c9534e 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -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,
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index a109804..0091e2d 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -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,
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 7f916d2..e686480 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -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);
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
index 5af2b54..1ab61e9 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
@@ -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
-- 
1.7.10.4


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

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

* [PATCH 2/2] at91: Calao and Atmel reboard sam{9260/9g20/9261/9g10/9263}ek autodetect sdram size
  2012-08-03  6:52 [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add autodetect sdram size Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-03  6:52 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-10 14:17 ` [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add " Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-03  6:52 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/at91sam9260ek/init.c |    2 +-
 arch/arm/boards/at91sam9261ek/init.c |    2 +-
 arch/arm/boards/at91sam9263ek/init.c |    2 +-
 arch/arm/boards/qil-a9260/init.c     |    6 +-----
 arch/arm/boards/tny-a926x/init.c     |    2 +-
 arch/arm/boards/usb-a926x/init.c     |    6 +-----
 6 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
index daadf94..826f00e 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -234,7 +234,7 @@ static void __init ek_add_led(void)
 
 static int at91sam9260ek_mem_init(void)
 {
-	at91_add_device_sdram(64 * 1024 * 1024);
+	at91_add_device_sdram(0);
 
 	return 0;
 }
diff --git a/arch/arm/boards/at91sam9261ek/init.c b/arch/arm/boards/at91sam9261ek/init.c
index b0cab5b..5abe87c 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -236,7 +236,7 @@ static void ek_device_add_leds(void) {}
 
 static int at91sam9261ek_mem_init(void)
 {
-	at91_add_device_sdram(64 * 1024 * 1024);
+	at91_add_device_sdram(0);
 
 	return 0;
 }
diff --git a/arch/arm/boards/at91sam9263ek/init.c b/arch/arm/boards/at91sam9263ek/init.c
index 68f4bfc..573fac4 100644
--- a/arch/arm/boards/at91sam9263ek/init.c
+++ b/arch/arm/boards/at91sam9263ek/init.c
@@ -166,7 +166,7 @@ static void __init ek_add_device_buttons(void)
 
 static int at91sam9263ek_mem_init(void)
 {
-	at91_add_device_sdram(64 * 1024 * 1024);
+	at91_add_device_sdram(0);
 
 	return 0;
 }
diff --git a/arch/arm/boards/qil-a9260/init.c b/arch/arm/boards/qil-a9260/init.c
index 305d733..ee204fb 100644
--- a/arch/arm/boards/qil-a9260/init.c
+++ b/arch/arm/boards/qil-a9260/init.c
@@ -150,11 +150,7 @@ static void __init ek_add_led(void)
 
 static int qil_a9260_mem_init(void)
 {
-#ifdef CONFIG_AT91_HAVE_SRAM_128M
-	at91_add_device_sdram(128 * 1024 * 1024);
-#else
-	at91_add_device_sdram(64 * 1024 * 1024);
-#endif
+	at91_add_device_sdram(0);
 
 	return 0;
 }
diff --git a/arch/arm/boards/tny-a926x/init.c b/arch/arm/boards/tny-a926x/init.c
index 2cb7da7..d58132a 100644
--- a/arch/arm/boards/tny-a926x/init.c
+++ b/arch/arm/boards/tny-a926x/init.c
@@ -171,7 +171,7 @@ static void __init ek_add_device_udc(void)
 
 static int tny_a9260_mem_init(void)
 {
-	at91_add_device_sdram(64 * 1024 * 1024);
+	at91_add_device_sdram(0);
 
 	return 0;
 }
diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c
index 824a38a..4d5fdca 100644
--- a/arch/arm/boards/usb-a926x/init.c
+++ b/arch/arm/boards/usb-a926x/init.c
@@ -203,11 +203,7 @@ static void __init ek_add_led(void)
 
 static int usb_a9260_mem_init(void)
 {
-#ifdef CONFIG_AT91_HAVE_SRAM_128M
-	at91_add_device_sdram(128 * 1024 * 1024);
-#else
-	at91_add_device_sdram(64 * 1024 * 1024);
-#endif
+	at91_add_device_sdram(0);
 
 	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] 4+ messages in thread

* Re: [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add autodetect sdram size
  2012-08-03  6:52 [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add autodetect sdram size Jean-Christophe PLAGNIOL-VILLARD
  2012-08-03  6:52 ` [PATCH 2/2] at91: Calao and Atmel reboard sam{9260/9g20/9261/9g10/9263}ek " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-10 14:17 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-10 18:38   ` Sascha Hauer
  1 sibling, 1 reply; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-10 14:17 UTC (permalink / raw)
  To: barebox

On 08:52 Fri 03 Aug     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> 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>
ping

Best Regards,
J.

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

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

* Re: [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add autodetect sdram size
  2012-08-10 14:17 ` [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-10 18:38   ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-08-10 18:38 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Aug 10, 2012 at 04:17:33PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 08:52 Fri 03 Aug     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > 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>
> ping

Already applied.

Sascha

-- 
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] 4+ messages in thread

end of thread, other threads:[~2012-08-10 18:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-03  6:52 [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add autodetect sdram size Jean-Christophe PLAGNIOL-VILLARD
2012-08-03  6:52 ` [PATCH 2/2] at91: Calao and Atmel reboard sam{9260/9g20/9261/9g10/9263}ek " Jean-Christophe PLAGNIOL-VILLARD
2012-08-10 14:17 ` [PATCH 1/2] at91: sam9260/sam9g20/sam9261/sam9g10/sam9263 add " Jean-Christophe PLAGNIOL-VILLARD
2012-08-10 18:38   ` Sascha Hauer

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