All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vikas Manocha <vikas.manocha@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 12/18] stm32f7: stm32f746-disco: read memory info from device tree
Date: Tue, 4 Apr 2017 14:45:14 -0700	[thread overview]
Message-ID: <1491342324-5820-13-git-send-email-vikas.manocha@st.com> (raw)
In-Reply-To: <1491342324-5820-1-git-send-email-vikas.manocha@st.com>

Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
cc: Christophe KERELLO <christophe.kerello@st.com>
---
Changed in v2: None

 board/st/stm32f746-disco/stm32f746-disco.c | 42 +++++++++++++++++++++---------
 drivers/ram/stm32_sdram.c                  |  1 -
 include/configs/stm32f746-disco.h          |  6 +----
 3 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/board/st/stm32f746-disco/stm32f746-disco.c b/board/st/stm32f746-disco/stm32f746-disco.c
index 52c1900..4b0c7f0 100644
--- a/board/st/stm32f746-disco/stm32f746-disco.c
+++ b/board/st/stm32f746-disco/stm32f746-disco.c
@@ -21,32 +21,49 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+int get_memory_base_size(fdt_addr_t *mr_base, fdt_addr_t *mr_size)
+{
+	int mr_node;
+
+	mr_node = fdt_path_offset(gd->fdt_blob, "/memory");
+	if (mr_node < 0)
+		return mr_node;
+	*mr_base = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, mr_node,
+						      "reg", 0, mr_size, false);
+	debug("mr_base = %lx, mr_size= %lx\n", *mr_base, *mr_size);
+
+	return 0;
+}
 int dram_init(void)
 {
 	struct udevice *dev;
-	struct ram_info ram;
 	int rv;
+	fdt_addr_t mr_base, mr_size;
 
 	rv = uclass_get_device(UCLASS_RAM, 0, &dev);
 	if (rv) {
 		debug("DRAM init failed: %d\n", rv);
 		return rv;
 	}
-	rv = ram_get_info(dev, &ram);
-	if (rv) {
-		debug("Cannot get DRAM size: %d\n", rv);
+
+	rv = get_memory_base_size(&mr_base, &mr_size);
+	if (rv)
 		return rv;
-	}
-	debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
-	gd->ram_size = ram.size;
+	gd->ram_size = mr_size;
+	gd->ram_top = mr_base;
 
+	return rv;
+}
+
+void dram_init_banksize(void)
+{
+	fdt_addr_t mr_base, mr_size;
+	get_memory_base_size(&mr_base, &mr_size);
 	/*
 	 * Fill in global info with description of SRAM configuration
 	 */
-	gd->bd->bi_dram[0].start = CONFIG_SYS_RAM_BASE;
-	gd->bd->bi_dram[0].size  = ram.size;
-
-	return rv;
+	gd->bd->bi_dram[0].start = mr_base;
+	gd->bd->bi_dram[0].size  = mr_size;
 }
 
 #ifdef CONFIG_ETH_DESIGNWARE
@@ -111,7 +128,6 @@ int board_late_init(void)
 
 int board_init(void)
 {
-	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
-
+	gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
 	return 0;
 }
diff --git a/drivers/ram/stm32_sdram.c b/drivers/ram/stm32_sdram.c
index eb1ab94..5e09f35 100644
--- a/drivers/ram/stm32_sdram.c
+++ b/drivers/ram/stm32_sdram.c
@@ -179,7 +179,6 @@ static int stm32_fmc_probe(struct udevice *dev)
 
 static int stm32_fmc_get_info(struct udevice *dev, struct ram_info *info)
 {
-	info->size = CONFIG_SYS_RAM_SIZE;
 	return 0;
 }
 
diff --git a/include/configs/stm32f746-disco.h b/include/configs/stm32f746-disco.h
index f5f9f0b..3bea513 100644
--- a/include/configs/stm32f746-disco.h
+++ b/include/configs/stm32f746-disco.h
@@ -21,11 +21,7 @@
  * Configuration of the external SDRAM memory
  */
 #define CONFIG_NR_DRAM_BANKS		1
-#define CONFIG_SYS_RAM_SIZE		(8 * 1024 * 1024)
-#define CONFIG_SYS_RAM_CS		1
-#define CONFIG_SYS_RAM_FREQ_DIV		2
-#define CONFIG_SYS_RAM_BASE		0xC0000000
-#define CONFIG_SYS_SDRAM_BASE		CONFIG_SYS_RAM_BASE
+#define CONFIG_SYS_RAM_FREQ_DIV         2
 #define CONFIG_SYS_LOAD_ADDR		0xC0400000
 #define CONFIG_LOADADDR			0xC0400000
 
-- 
1.9.1

  parent reply	other threads:[~2017-04-04 21:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 21:45 [U-Boot] [PATCH v2 00/18] stm32f7: add sdram & gpio drivers Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 01/18] stm32f7: use clock driver to enable qspi controller clock Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 02/18] stm32f7: sdram: move sdram driver code to ram drivers area Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 03/18] stm32f7: dm: add driver model support for sdram Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 04/18] ARM: DT: stm32f7: add sdram pin contol node Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 05/18] stm32f7: use driver model for sdram initialization Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 06/18] stm32f7: use clock driver to enable sdram controller clock Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 07/18] stm32f7: sdram: use sdram device tree node to configure sdram controller Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 08/18] dm: gpio: Add driver for stm32f7 gpio controller Vikas Manocha
2017-04-09 19:27   ` Simon Glass
2017-04-10 16:25     ` Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 09/18] ARM: DT: stm32f7: add gpio device tree nodes Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 10/18] stm32f7: use stm32f7 gpio driver supporting driver model Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 11/18] stm32f746: to switch on user LED1 & read user button Vikas Manocha
2017-04-04 21:45 ` Vikas Manocha [this message]
2017-04-04 21:45 ` [U-Boot] [PATCH v2 13/18] stm32f7: enable board info read from device tree Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 14/18] stm32f7: sdram: correct sdram configuration as per micron sdram Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 15/18] stm32f7: increase the max no of pin configuration to 70 Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 16/18] stm32f7: move board specific pin muxing to dts Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 17/18] stm32f7: add support for stm32f769 disco board Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 18/18] stm32f7: remove not needed configuration from board config Vikas Manocha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491342324-5820-13-git-send-email-vikas.manocha@st.com \
    --to=vikas.manocha@st.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.