Skip to contentSkip to conversation

lib: fdtdec: Add new variable ram_start to global data

PATCH New Siva Durga Prasad Paladugu 5 participants 8 messages Jun 18, 2018 – Jul 13, 2018

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/4 lib: fdtdec: Add new variable ram_start to global data

Added new variable ram_start to global data structure for holding the start address of first bank of RAM, and then use this ram_start for calculating ram_top properly. This patch fixes the erroneous calculation of ram_top incase of non zero ram start address. This patch also renames fdtdec_setup_memory_size() to fdtdec_setup_mem_size_start() as this routine now takes care of memory size and start.

---
Changes from v2:
- Used new varibale ram_start
- Rename fdtdec_setup_memory_size

Changes from v1:
- None

---
 arch/arm/mach-mvebu/arm64-common.c                       |  2 +-
 board/emulation/qemu-arm/qemu-arm.c                      |  2 +-
 board/renesas/alt/alt.c                                  |  2 +-
 board/renesas/blanche/blanche.c                          |  2 +-
 board/renesas/draak/draak.c                              |  2 +-
 board/renesas/eagle/eagle.c                              |  2 +-
 board/renesas/gose/gose.c                                |  2 +-
 board/renesas/koelsch/koelsch.c                          |  2 +-
 board/renesas/lager/lager.c                              |  2 +-
 board/renesas/porter/porter.c                            |  2 +-
 board/renesas/salvator-x/salvator-x.c                    |  2 +-
 board/renesas/silk/silk.c                                |  2 +-
 board/renesas/stout/stout.c                              |  2 +-
 board/renesas/ulcb/ulcb.c                                |  2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c       |  2 +-
 board/st/stm32f429-evaluation/stm32f429-evaluation.c     |  2 +-
 board/st/stm32f469-discovery/stm32f469-discovery.c       |  2 +-
 board/st/stm32h743-disco/stm32h743-disco.c               |  2 +-
 board/st/stm32h743-eval/stm32h743-eval.c                 |  2 +-
 board/xilinx/zynq/board.c                                |  2 +-
 board/xilinx/zynqmp/zynqmp.c                             |  2 +-
 board/xilinx/zynqmp_r5/board.c                           |  2 +-
 common/board_f.c                                         |  4 ++--
 include/asm-generic/global_data.h                        |  1 +
 include/fdtdec.h                                         | 16 +++++++++-------
 lib/fdtdec.c                                             |  3 ++-
 tools/patman/func_test.py                                |  2 +-
 tools/patman/test/0000-cover-letter.patch                |  2 +-
 ...orrect-cast-for-sandbox-in-fdtdec_setup_memory_.patch |  4 ++--
 tools/patman/test/test01.txt                             |  2 +-
 30 files changed, 41 insertions(+), 37 deletions(-)
arch/arm/mach-mvebu/arm64-common.c +1 -1
index d3ea9e6..c2ab831 100644
@@ -54,7 +54,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/emulation/qemu-arm/qemu-arm.c +1 -1
index 6ec4200..926bbf2 100644
@@ -47,7 +47,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/alt/alt.c +1 -1
index 86e9d24..58838ff 100644
@@ -78,7 +78,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/blanche/blanche.c +1 -1
index 7d48d0f..1fd511c 100644
@@ -339,7 +339,7 @@ int board_eth_init(bd_t *bis)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/draak/draak.c +1 -1
index f804fae..b178131 100644
@@ -96,7 +96,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/eagle/eagle.c +1 -1
index 4bf0a20..26deca9 100644
@@ -73,7 +73,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/gose/gose.c +1 -1
index 96ac29d..1862c16 100644
@@ -83,7 +83,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/koelsch/koelsch.c +1 -1
index b6688a2..a650b8b 100644
@@ -85,7 +85,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/lager/lager.c +1 -1
index 6bfb0d1..ee66f02 100644
@@ -94,7 +94,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/porter/porter.c +1 -1
index cadff2c..b4d7f57 100644
@@ -83,7 +83,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/salvator-x/salvator-x.c +1 -1
index 651877c..c104458 100644
@@ -108,7 +108,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/silk/silk.c +1 -1
index 5fa472c..eda61ee 100644
@@ -78,7 +78,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/stout/stout.c +1 -1
index 778593b..bc62caf 100644
@@ -97,7 +97,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/ulcb/ulcb.c +1 -1
index 9e15e45..679f09d 100644
@@ -96,7 +96,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/st/stm32f429-discovery/stm32f429-discovery.c +1 -1
index b7638c0..fea3b6e 100644
@@ -29,7 +29,7 @@ int dram_init(void)
 		return rv;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		rv = -EINVAL;
 
 	return rv;
board/st/stm32f429-evaluation/stm32f429-evaluation.c +1 -1
index 2e638c6..6bf7f33 100644
@@ -23,7 +23,7 @@ int dram_init(void)
 		return rv;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		rv = -EINVAL;
 
 	return rv;
board/st/stm32f469-discovery/stm32f469-discovery.c +1 -1
index 90d7045..e2c2865 100644
@@ -23,7 +23,7 @@ int dram_init(void)
 		return rv;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		rv = -EINVAL;
 
 	return rv;
board/st/stm32h743-disco/stm32h743-disco.c +1 -1
index fa007c7..469370c 100644
@@ -20,7 +20,7 @@ int dram_init(void)
 		return ret;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		ret = -EINVAL;
 
 	return ret;
board/st/stm32h743-eval/stm32h743-eval.c +1 -1
index fa007c7..469370c 100644
@@ -20,7 +20,7 @@ int dram_init(void)
 		return ret;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		ret = -EINVAL;
 
 	return ret;
board/xilinx/zynq/board.c +1 -1
index e4f86d1..d80dd3d 100644
@@ -93,7 +93,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	zynq_ddrc_init();
board/xilinx/zynqmp/zynqmp.c +1 -1
index e41fec3..38f935c 100644
@@ -418,7 +418,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/xilinx/zynqmp_r5/board.c +1 -1
index 70fb202..954e463 100644
@@ -18,7 +18,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
common/board_f.c +2 -2
index fa667c7..ccd2a2f 100644
@@ -281,9 +281,9 @@ static int setup_dest_addr(void)
 	gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
 #endif
 #ifdef CONFIG_SYS_SDRAM_BASE
-	gd->ram_top = CONFIG_SYS_SDRAM_BASE;
+	gd->ram_start = CONFIG_SYS_SDRAM_BASE;
 #endif
-	gd->ram_top += get_effective_memsize();
+	gd->ram_top = gd->ram_start + get_effective_memsize();
 	gd->ram_top = board_get_usable_ram_top(gd->mon_len);
 	gd->relocaddr = gd->ram_top;
 	debug("Ram top: %08lX\n", (ulong)gd->ram_top);
include/asm-generic/global_data.h +1 -0
index 2d451f8..c8ee788 100644
@@ -52,6 +52,7 @@ typedef struct global_data {
 	unsigned long env_has_init;	/* Bitmask of boolean of struct env_location offsets */
 	int env_load_location;
 
+	unsigned long ram_start;	/* Start address of first bank of RAM */
 	unsigned long ram_top;		/* Top address of RAM used by U-Boot */
 	unsigned long relocaddr;	/* Start address of U-Boot in RAM */
 	phys_size_t ram_size;		/* RAM size */
include/fdtdec.h +9 -7
index c15b2a0..f5ebf52 100644
@@ -951,20 +951,22 @@ int fdtdec_decode_display_timing(const void *blob, int node, int index,
 				 struct display_timing *config);
 
 /**
- * fdtdec_setup_memory_size() - decode and setup gd->ram_size
+ * fdtdec_setup_mem_size_start() - decode and setup gd->ram_size and
+ * gd->ram_start
  *
- * Decode the /memory 'reg' property to determine the size of the first memory
- * bank, populate the global data with the size of the first bank of memory.
+ * Decode the /memory 'reg' property to determine the size and start of the
+ * first memory bank, populate the global data with the size and start of the
+ * first bank of memory.
  *
  * This function should be called from a boards dram_init(). This helper
- * function allows for boards to query the device tree for DRAM size instead of
- * hard coding the value in the case where the memory size cannot be detected
- * automatically.
+ * function allows for boards to query the device tree for DRAM size and start
+ * address instead of hard coding the value in the case where the memory size
+ * and start address cannot be detected automatically.
  *
  * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or
  * invalid
  */
-int fdtdec_setup_memory_size(void);
+int fdtdec_setup_mem_size_start(void);
 
 /**
  * fdtdec_setup_memory_banksize() - decode and populate gd->bd->bi_dram
lib/fdtdec.c +2 -1
index f4e8dbf..8c63278 100644
@@ -1154,7 +1154,7 @@ int fdtdec_decode_display_timing(const void *blob, int parent, int index,
 	return ret;
 }
 
-int fdtdec_setup_memory_size(void)
+int fdtdec_setup_mem_size_start(void)
 {
 	int ret, mem;
 	struct fdt_resource res;
@@ -1172,6 +1172,7 @@ int fdtdec_setup_memory_size(void)
 	}
 
 	gd->ram_size = (phys_size_t)(res.end - res.start + 1);
+	gd->ram_start = (unsigned long)res.start;
 	debug("%s: Initial DRAM size %llx\n", __func__,
 	      (unsigned long long)gd->ram_size);
 
tools/patman/func_test.py +1 -1
index 85372f3..a16427a 100644
@@ -209,7 +209,7 @@ Changes in v4:
 
 Simon Glass (2):
   pci: Correct cast for sandbox
-  fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+  fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 
  cmd/pci.c                   | 3 ++-
  fs/fat/fat.c                | 1 +
tools/patman/test/0000-cover-letter.patch +1 -1
index 2906201..84ba81b 100644
@@ -10,7 +10,7 @@ Content-Transfer-Encoding: 8bit
 
 Simon Glass (2):
   pci: Correct cast for sandbox
-  fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+  fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 
  cmd/pci.c                   | 3 ++-
  fs/fat/fat.c                | 1 +
tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_memory_.patch +2 -2
index e328497..827e4cc 100644
@@ -1,7 +1,7 @@
 From 5ab48490f03051875ab13d288a4bf32b507d76fd Mon Sep 17 00:00:00 2001
 From: Simon Glass <[email protected]>
 Date: Sat, 15 Apr 2017 15:39:08 -0600
-Subject: [RFC 2/2] fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+Subject: [RFC 2/2] fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
@@ -58,7 +58,7 @@ diff --git a/lib/fdtdec.c b/lib/fdtdec.c
 index c072e54..942244f 100644
 --- a/lib/fdtdec.c
 +++ b/lib/fdtdec.c
-@@ -1200,7 +1200,8 @@ int fdtdec_setup_memory_size(void)
+@@ -1200,7 +1200,8 @@ int fdtdec_setup_mem_size_start(void)
  	}
  
  	gd->ram_size = (phys_size_t)(res.end - res.start + 1);
tools/patman/test/test01.txt +1 -1
index 8ad9587..d8be23d 100644
@@ -28,7 +28,7 @@ commit 5ab48490f03051875ab13d288a4bf32b507d76fd
 Author: Simon Glass <[email protected]>
 Date:   Sat Apr 15 15:39:08 2017 -0600
 
-    fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+    fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
     
     This gives a warning with some native compilers:
     
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/4 lib: fdtdec: Add new variable ram_start to global data

Hi Simon,

Quoted 473 lines · Siva Durga Prasad Paladugu

Added new variable ram_start to global data structure for holding the start address of first bank of RAM, and then use this ram_start for calculating ram_top properly. This patch fixes the erroneous calculation of ram_top incase of non zero ram start address. This patch also renames fdtdec_setup_memory_size() to fdtdec_setup_mem_size_start() as this routine now takes care of memory size and start.

---
Changes from v2:
- Used new varibale ram_start
- Rename fdtdec_setup_memory_size

Changes from v1:
- None

---
 arch/arm/mach-mvebu/arm64-common.c                       |  2 +-
 board/emulation/qemu-arm/qemu-arm.c                      |  2 +-
 board/renesas/alt/alt.c                                  |  2 +-
 board/renesas/blanche/blanche.c                          |  2 +-
 board/renesas/draak/draak.c                              |  2 +-
 board/renesas/eagle/eagle.c                              |  2 +-
 board/renesas/gose/gose.c                                |  2 +-
 board/renesas/koelsch/koelsch.c                          |  2 +-
 board/renesas/lager/lager.c                              |  2 +-
 board/renesas/porter/porter.c                            |  2 +-
 board/renesas/salvator-x/salvator-x.c                    |  2 +-
 board/renesas/silk/silk.c                                |  2 +-
 board/renesas/stout/stout.c                              |  2 +-
 board/renesas/ulcb/ulcb.c                                |  2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c       |  2 +-
 board/st/stm32f429-evaluation/stm32f429-evaluation.c     |  2 +-
 board/st/stm32f469-discovery/stm32f469-discovery.c       |  2 +-
 board/st/stm32h743-disco/stm32h743-disco.c               |  2 +-
 board/st/stm32h743-eval/stm32h743-eval.c                 |  2 +-
 board/xilinx/zynq/board.c                                |  2 +-
 board/xilinx/zynqmp/zynqmp.c                             |  2 +-
 board/xilinx/zynqmp_r5/board.c                           |  2 +-
 common/board_f.c                                         |  4 ++--
 include/asm-generic/global_data.h                        |  1 +
 include/fdtdec.h                                         | 16 +++++++++-------
 lib/fdtdec.c                                             |  3 ++-
 tools/patman/func_test.py                                |  2 +-
 tools/patman/test/0000-cover-letter.patch                |  2 +-
 ...orrect-cast-for-sandbox-in-fdtdec_setup_memory_.patch |  4 ++--
 tools/patman/test/test01.txt                             |  2 +-
 30 files changed, 41 insertions(+), 37 deletions(-)
arch/arm/mach-mvebu/arm64-common.c +1 -1
index d3ea9e6..c2ab831 100644
@@ -54,7 +54,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/emulation/qemu-arm/qemu-arm.c +1 -1
index 6ec4200..926bbf2 100644
@@ -47,7 +47,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/alt/alt.c +1 -1
index 86e9d24..58838ff 100644
@@ -78,7 +78,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/blanche/blanche.c +1 -1
index 7d48d0f..1fd511c 100644
@@ -339,7 +339,7 @@ int board_eth_init(bd_t *bis)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/draak/draak.c +1 -1
index f804fae..b178131 100644
@@ -96,7 +96,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/eagle/eagle.c +1 -1
index 4bf0a20..26deca9 100644
@@ -73,7 +73,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/gose/gose.c +1 -1
index 96ac29d..1862c16 100644
@@ -83,7 +83,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/koelsch/koelsch.c +1 -1
index b6688a2..a650b8b 100644
@@ -85,7 +85,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/lager/lager.c +1 -1
index 6bfb0d1..ee66f02 100644
@@ -94,7 +94,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/porter/porter.c +1 -1
index cadff2c..b4d7f57 100644
@@ -83,7 +83,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/salvator-x/salvator-x.c +1 -1
index 651877c..c104458 100644
@@ -108,7 +108,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/silk/silk.c +1 -1
index 5fa472c..eda61ee 100644
@@ -78,7 +78,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/stout/stout.c +1 -1
index 778593b..bc62caf 100644
@@ -97,7 +97,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/ulcb/ulcb.c +1 -1
index 9e15e45..679f09d 100644
@@ -96,7 +96,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/st/stm32f429-discovery/stm32f429-discovery.c +1 -1
index b7638c0..fea3b6e 100644
@@ -29,7 +29,7 @@ int dram_init(void)
 		return rv;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		rv = -EINVAL;
 
 	return rv;
board/st/stm32f429-evaluation/stm32f429-evaluation.c +1 -1
index 2e638c6..6bf7f33 100644
@@ -23,7 +23,7 @@ int dram_init(void)
 		return rv;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		rv = -EINVAL;
 
 	return rv;
board/st/stm32f469-discovery/stm32f469-discovery.c +1 -1
index 90d7045..e2c2865 100644
@@ -23,7 +23,7 @@ int dram_init(void)
 		return rv;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		rv = -EINVAL;
 
 	return rv;
board/st/stm32h743-disco/stm32h743-disco.c +1 -1
index fa007c7..469370c 100644
@@ -20,7 +20,7 @@ int dram_init(void)
 		return ret;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		ret = -EINVAL;
 
 	return ret;
board/st/stm32h743-eval/stm32h743-eval.c +1 -1
index fa007c7..469370c 100644
@@ -20,7 +20,7 @@ int dram_init(void)
 		return ret;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		ret = -EINVAL;
 
 	return ret;
board/xilinx/zynq/board.c +1 -1
index e4f86d1..d80dd3d 100644
@@ -93,7 +93,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	zynq_ddrc_init();
board/xilinx/zynqmp/zynqmp.c +1 -1
index e41fec3..38f935c 100644
@@ -418,7 +418,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/xilinx/zynqmp_r5/board.c +1 -1
index 70fb202..954e463 100644
@@ -18,7 +18,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
common/board_f.c +2 -2
index fa667c7..ccd2a2f 100644
@@ -281,9 +281,9 @@ static int setup_dest_addr(void)
 	gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
 #endif
 #ifdef CONFIG_SYS_SDRAM_BASE
-	gd->ram_top = CONFIG_SYS_SDRAM_BASE;
+	gd->ram_start = CONFIG_SYS_SDRAM_BASE;
 #endif
-	gd->ram_top += get_effective_memsize();
+	gd->ram_top = gd->ram_start + get_effective_memsize();
 	gd->ram_top = board_get_usable_ram_top(gd->mon_len);
 	gd->relocaddr = gd->ram_top;
 	debug("Ram top: %08lX\n", (ulong)gd->ram_top);
include/asm-generic/global_data.h +1 -0
index 2d451f8..c8ee788 100644
@@ -52,6 +52,7 @@ typedef struct global_data {
 	unsigned long env_has_init;	/* Bitmask of boolean of struct env_location offsets */
 	int env_load_location;
 
+	unsigned long ram_start;	/* Start address of first bank of RAM */
 	unsigned long ram_top;		/* Top address of RAM used by U-Boot */
 	unsigned long relocaddr;	/* Start address of U-Boot in RAM */
 	phys_size_t ram_size;		/* RAM size */
include/fdtdec.h +9 -7
index c15b2a0..f5ebf52 100644
@@ -951,20 +951,22 @@ int fdtdec_decode_display_timing(const void *blob, int node, int index,
 				 struct display_timing *config);
 
 /**
- * fdtdec_setup_memory_size() - decode and setup gd->ram_size
+ * fdtdec_setup_mem_size_start() - decode and setup gd->ram_size and
+ * gd->ram_start
  *
- * Decode the /memory 'reg' property to determine the size of the first memory
- * bank, populate the global data with the size of the first bank of memory.
+ * Decode the /memory 'reg' property to determine the size and start of the
+ * first memory bank, populate the global data with the size and start of the
+ * first bank of memory.
  *
  * This function should be called from a boards dram_init(). This helper
- * function allows for boards to query the device tree for DRAM size instead of
- * hard coding the value in the case where the memory size cannot be detected
- * automatically.
+ * function allows for boards to query the device tree for DRAM size and start
+ * address instead of hard coding the value in the case where the memory size
+ * and start address cannot be detected automatically.
  *
  * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or
  * invalid
  */
-int fdtdec_setup_memory_size(void);
+int fdtdec_setup_mem_size_start(void);
 
 /**
  * fdtdec_setup_memory_banksize() - decode and populate gd->bd->bi_dram
lib/fdtdec.c +2 -1
index f4e8dbf..8c63278 100644
@@ -1154,7 +1154,7 @@ int fdtdec_decode_display_timing(const void *blob, int parent, int index,
 	return ret;
 }
 
-int fdtdec_setup_memory_size(void)
+int fdtdec_setup_mem_size_start(void)
 {
 	int ret, mem;
 	struct fdt_resource res;
@@ -1172,6 +1172,7 @@ int fdtdec_setup_memory_size(void)
 	}
 
 	gd->ram_size = (phys_size_t)(res.end - res.start + 1);
+	gd->ram_start = (unsigned long)res.start;
 	debug("%s: Initial DRAM size %llx\n", __func__,
 	      (unsigned long long)gd->ram_size);
 
tools/patman/func_test.py +1 -1
index 85372f3..a16427a 100644
@@ -209,7 +209,7 @@ Changes in v4:
 
 Simon Glass (2):
   pci: Correct cast for sandbox
-  fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+  fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 
  cmd/pci.c                   | 3 ++-
  fs/fat/fat.c                | 1 +
tools/patman/test/0000-cover-letter.patch +1 -1
index 2906201..84ba81b 100644
@@ -10,7 +10,7 @@ Content-Transfer-Encoding: 8bit
 
 Simon Glass (2):
   pci: Correct cast for sandbox
-  fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+  fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 
  cmd/pci.c                   | 3 ++-
  fs/fat/fat.c                | 1 +
tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_memory_.patch +2 -2
index e328497..827e4cc 100644
@@ -1,7 +1,7 @@
 From 5ab48490f03051875ab13d288a4bf32b507d76fd Mon Sep 17 00:00:00 2001
 From: Simon Glass <[email protected]>
 Date: Sat, 15 Apr 2017 15:39:08 -0600
-Subject: [RFC 2/2] fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+Subject: [RFC 2/2] fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
@@ -58,7 +58,7 @@ diff --git a/lib/fdtdec.c b/lib/fdtdec.c
 index c072e54..942244f 100644
 --- a/lib/fdtdec.c
 +++ b/lib/fdtdec.c
-@@ -1200,7 +1200,8 @@ int fdtdec_setup_memory_size(void)
+@@ -1200,7 +1200,8 @@ int fdtdec_setup_mem_size_start(void)
  	}
 
  	gd->ram_size = (phys_size_t)(res.end - res.start + 1);
tools/patman/test/test01.txt +0 -0
index 8ad9587..d8be23d 100644

tools/patman/test/test01.txt commit 5ab48490f03051875ab13d288a4bf32b507d76fd · line 34

Quoted 8 lines
tools/patman/test/test01.txt +1 -1
@@ -28,7 +28,7 @@ commit 5ab48490f03051875ab13d288a4bf32b507d76fd
 Author: Simon Glass <[email protected]>
 Date:   Sat Apr 15 15:39:08 2017 -0600
 
-    fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+    fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 
     This gives a warning with some native compilers:
 

sjg: Do you see any issue with this patch?

I can't see the reason for fixing tools/patman but I will wait for you.

Thanks,
Michal

#2 lore raw

PATCH v3 1/4 lib: fdtdec: Add new variable ram_start to global data

Hi,

Quoted 52 lines · Michal Simek

Hi Simon,

Quoted 49 lines · Siva Durga Prasad Paladugu

Added new variable ram_start to global data structure for holding the start address of first bank of RAM, and then use this ram_start for calculating ram_top properly. This patch fixes the erroneous calculation of ram_top incase of non zero ram start address. This patch also renames fdtdec_setup_memory_size() to fdtdec_setup_mem_size_start() as this routine now takes care of memory size and start.

---
Changes from v2:
- Used new varibale ram_start
- Rename fdtdec_setup_memory_size

Changes from v1:
- None

---
 arch/arm/mach-mvebu/arm64-common.c                       |  2 +-
 board/emulation/qemu-arm/qemu-arm.c                      |  2 +-
 board/renesas/alt/alt.c                                  |  2 +-
 board/renesas/blanche/blanche.c                          |  2 +-
 board/renesas/draak/draak.c                              |  2 +-
 board/renesas/eagle/eagle.c                              |  2 +-
 board/renesas/gose/gose.c                                |  2 +-
 board/renesas/koelsch/koelsch.c                          |  2 +-
 board/renesas/lager/lager.c                              |  2 +-
 board/renesas/porter/porter.c                            |  2 +-
 board/renesas/salvator-x/salvator-x.c                    |  2 +-
 board/renesas/silk/silk.c                                |  2 +-
 board/renesas/stout/stout.c                              |  2 +-
 board/renesas/ulcb/ulcb.c                                |  2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c       |  2 +-
 board/st/stm32f429-evaluation/stm32f429-evaluation.c     |  2 +-
 board/st/stm32f469-discovery/stm32f469-discovery.c       |  2 +-
 board/st/stm32h743-disco/stm32h743-disco.c               |  2 +-
 board/st/stm32h743-eval/stm32h743-eval.c                 |  2 +-
 board/xilinx/zynq/board.c                                |  2 +-
 board/xilinx/zynqmp/zynqmp.c                             |  2 +-
 board/xilinx/zynqmp_r5/board.c                           |  2 +-
 common/board_f.c                                         |  4 ++--
 include/asm-generic/global_data.h                        |  1 +
 include/fdtdec.h                                         | 16 +++++++++-------
 lib/fdtdec.c                                             |  3 ++-
 tools/patman/func_test.py                                |  2 +-
 tools/patman/test/0000-cover-letter.patch                |  2 +-
 ...orrect-cast-for-sandbox-in-fdtdec_setup_memory_.patch |  4 ++--
 tools/patman/test/test01.txt                             |  2 +-
 30 files changed, 41 insertions(+), 37 deletions(-)

[...]

Quoted 1 line

sjg: Do you see any issue with this patch?

I think it is OK. Would like to get more people to look at it though.

Quoted 2 lines

I can't see the reason for fixing tools/patman but I will wait for you.

Changing patman tests is OK with me. Keeps thing consistent.

Regards,
Simon

#3 lore raw

PATCH v3 1/4 lib: fdtdec: Add new variable ram_start to global data

Hi,

Quoted 58 lines · Simon Glass

Hi,

Quoted 52 lines · Michal Simek

Hi Simon,

Quoted 49 lines · Siva Durga Prasad Paladugu

Added new variable ram_start to global data structure for holding the start address of first bank of RAM, and then use this ram_start for calculating ram_top properly. This patch fixes the erroneous calculation of ram_top incase of non zero ram start address. This patch also renames fdtdec_setup_memory_size() to fdtdec_setup_mem_size_start() as this routine now takes care of memory size and start.

---
Changes from v2:
- Used new varibale ram_start
- Rename fdtdec_setup_memory_size

Changes from v1:
- None

---
 arch/arm/mach-mvebu/arm64-common.c                       |  2 +-
 board/emulation/qemu-arm/qemu-arm.c                      |  2 +-
 board/renesas/alt/alt.c                                  |  2 +-
 board/renesas/blanche/blanche.c                          |  2 +-
 board/renesas/draak/draak.c                              |  2 +-
 board/renesas/eagle/eagle.c                              |  2 +-
 board/renesas/gose/gose.c                                |  2 +-
 board/renesas/koelsch/koelsch.c                          |  2 +-
 board/renesas/lager/lager.c                              |  2 +-
 board/renesas/porter/porter.c                            |  2 +-
 board/renesas/salvator-x/salvator-x.c                    |  2 +-
 board/renesas/silk/silk.c                                |  2 +-
 board/renesas/stout/stout.c                              |  2 +-
 board/renesas/ulcb/ulcb.c                                |  2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c       |  2 +-
 board/st/stm32f429-evaluation/stm32f429-evaluation.c     |  2 +-
 board/st/stm32f469-discovery/stm32f469-discovery.c       |  2 +-
 board/st/stm32h743-disco/stm32h743-disco.c               |  2 +-
 board/st/stm32h743-eval/stm32h743-eval.c                 |  2 +-
 board/xilinx/zynq/board.c                                |  2 +-
 board/xilinx/zynqmp/zynqmp.c                             |  2 +-
 board/xilinx/zynqmp_r5/board.c                           |  2 +-
 common/board_f.c                                         |  4 ++--
 include/asm-generic/global_data.h                        |  1 +
 include/fdtdec.h                                         | 16 +++++++++-------
 lib/fdtdec.c                                             |  3 ++-
 tools/patman/func_test.py                                |  2 +-
 tools/patman/test/0000-cover-letter.patch                |  2 +-
 ...orrect-cast-for-sandbox-in-fdtdec_setup_memory_.patch |  4 ++--
 tools/patman/test/test01.txt                             |  2 +-
 30 files changed, 41 insertions(+), 37 deletions(-)

[...]

Quoted 8 lines
Quoted 1 line

sjg: Do you see any issue with this patch?

I think it is OK. Would like to get more people to look at it though.

Quoted 2 lines

I can't see the reason for fixing tools/patman but I will wait for you.

Changing patman tests is OK with me. Keeps thing consistent.

thanks Simon.

Tom: Do you see any issue with this change?

Marek: Can you please retest renesas boards that this patch is not breaking your boards?

Thanks,
Michal

#4 lore raw

PATCH v3 1/4 lib: fdtdec: Add new variable ram_start to global data

Quoted 66 lines · Michal Simek

Hi,

Quoted 63 lines · Simon Glass

Hi,

Quoted 52 lines · Michal Simek

Hi Simon,

Quoted 49 lines · Siva Durga Prasad Paladugu

Added new variable ram_start to global data structure for holding the start address of first bank of RAM, and then use this ram_start for calculating ram_top properly. This patch fixes the erroneous calculation of ram_top incase of non zero ram start address. This patch also renames fdtdec_setup_memory_size() to fdtdec_setup_mem_size_start() as this routine now takes care of memory size and start.

---
Changes from v2:
- Used new varibale ram_start
- Rename fdtdec_setup_memory_size

Changes from v1:
- None

---
 arch/arm/mach-mvebu/arm64-common.c                       |  2 +-
 board/emulation/qemu-arm/qemu-arm.c                      |  2 +-
 board/renesas/alt/alt.c                                  |  2 +-
 board/renesas/blanche/blanche.c                          |  2 +-
 board/renesas/draak/draak.c                              |  2 +-
 board/renesas/eagle/eagle.c                              |  2 +-
 board/renesas/gose/gose.c                                |  2 +-
 board/renesas/koelsch/koelsch.c                          |  2 +-
 board/renesas/lager/lager.c                              |  2 +-
 board/renesas/porter/porter.c                            |  2 +-
 board/renesas/salvator-x/salvator-x.c                    |  2 +-
 board/renesas/silk/silk.c                                |  2 +-
 board/renesas/stout/stout.c                              |  2 +-
 board/renesas/ulcb/ulcb.c                                |  2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c       |  2 +-
 board/st/stm32f429-evaluation/stm32f429-evaluation.c     |  2 +-
 board/st/stm32f469-discovery/stm32f469-discovery.c       |  2 +-
 board/st/stm32h743-disco/stm32h743-disco.c               |  2 +-
 board/st/stm32h743-eval/stm32h743-eval.c                 |  2 +-
 board/xilinx/zynq/board.c                                |  2 +-
 board/xilinx/zynqmp/zynqmp.c                             |  2 +-
 board/xilinx/zynqmp_r5/board.c                           |  2 +-
 common/board_f.c                                         |  4 ++--
 include/asm-generic/global_data.h                        |  1 +
 include/fdtdec.h                                         | 16 +++++++++-------
 lib/fdtdec.c                                             |  3 ++-
 tools/patman/func_test.py                                |  2 +-
 tools/patman/test/0000-cover-letter.patch                |  2 +-
 ...orrect-cast-for-sandbox-in-fdtdec_setup_memory_.patch |  4 ++--
 tools/patman/test/test01.txt                             |  2 +-
 30 files changed, 41 insertions(+), 37 deletions(-)

[...]

Quoted 1 line

sjg: Do you see any issue with this patch?

I think it is OK. Would like to get more people to look at it though.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I can't see the reason for fixing tools/patman but I will wait for you.

Changing patman tests is OK with me. Keeps thing consistent.

thanks Simon.

Tom: Do you see any issue with this change?

Yes, thanks. You can take it via your tree once Marek has had a chance to test things.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180625/9e8b77d7/attachment.sig>
#5 lore raw

PATCH v3 1/4 lib: fdtdec: Add new variable ram_start to global data

Quoted 71 lines · Tom Rini
Quoted 70 lines · Michal Simek

Hi,

Quoted 66 lines · Simon Glass

Hi,

Quoted 52 lines · Michal Simek

Hi Simon,

Quoted 49 lines · Siva Durga Prasad Paladugu

Added new variable ram_start to global data structure for holding the start address of first bank of RAM, and then use this ram_start for calculating ram_top properly. This patch fixes the erroneous calculation of ram_top incase of non zero ram start address. This patch also renames fdtdec_setup_memory_size() to fdtdec_setup_mem_size_start() as this routine now takes care of memory size and start.

---
Changes from v2:
- Used new varibale ram_start
- Rename fdtdec_setup_memory_size

Changes from v1:
- None

---
 arch/arm/mach-mvebu/arm64-common.c                       |  2 +-
 board/emulation/qemu-arm/qemu-arm.c                      |  2 +-
 board/renesas/alt/alt.c                                  |  2 +-
 board/renesas/blanche/blanche.c                          |  2 +-
 board/renesas/draak/draak.c                              |  2 +-
 board/renesas/eagle/eagle.c                              |  2 +-
 board/renesas/gose/gose.c                                |  2 +-
 board/renesas/koelsch/koelsch.c                          |  2 +-
 board/renesas/lager/lager.c                              |  2 +-
 board/renesas/porter/porter.c                            |  2 +-
 board/renesas/salvator-x/salvator-x.c                    |  2 +-
 board/renesas/silk/silk.c                                |  2 +-
 board/renesas/stout/stout.c                              |  2 +-
 board/renesas/ulcb/ulcb.c                                |  2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c       |  2 +-
 board/st/stm32f429-evaluation/stm32f429-evaluation.c     |  2 +-
 board/st/stm32f469-discovery/stm32f469-discovery.c       |  2 +-
 board/st/stm32h743-disco/stm32h743-disco.c               |  2 +-
 board/st/stm32h743-eval/stm32h743-eval.c                 |  2 +-
 board/xilinx/zynq/board.c                                |  2 +-
 board/xilinx/zynqmp/zynqmp.c                             |  2 +-
 board/xilinx/zynqmp_r5/board.c                           |  2 +-
 common/board_f.c                                         |  4 ++--
 include/asm-generic/global_data.h                        |  1 +
 include/fdtdec.h                                         | 16 +++++++++-------
 lib/fdtdec.c                                             |  3 ++-
 tools/patman/func_test.py                                |  2 +-
 tools/patman/test/0000-cover-letter.patch                |  2 +-
 ...orrect-cast-for-sandbox-in-fdtdec_setup_memory_.patch |  4 ++--
 tools/patman/test/test01.txt                             |  2 +-
 30 files changed, 41 insertions(+), 37 deletions(-)

[...]

Quoted 1 line

sjg: Do you see any issue with this patch?

I think it is OK. Would like to get more people to look at it though.

Quoted 2 lines

I can't see the reason for fixing tools/patman but I will wait for you.

Changing patman tests is OK with me. Keeps thing consistent.

Quoted 8 lines
Quoted 3 lines

thanks Simon.

Tom: Do you see any issue with this change?

Yes, thanks. You can take it via your tree once Marek has had a chance to test things.

I'd rather like the rename in a separate patch, since that makes it hard to review. I don't see how "This patch fixes the erroneous calculation of ram_top incase of non zero ram start address." thought, maybe it's hidden in this mega-patch.

Signature · 2 lines
Best regards,
Marek Vasut
#6 lore raw

PATCH v3 1/4 lib: fdtdec: Add new variable ram_start to global data

Quoted 79 lines · Marek Vasut
Quoted 78 lines · Tom Rini
Quoted 66 lines · Michal Simek

Hi,

Quoted 63 lines · Simon Glass

Hi,

Quoted 52 lines · Michal Simek

Hi Simon,

Quoted 49 lines · Siva Durga Prasad Paladugu

Added new variable ram_start to global data structure for holding the start address of first bank of RAM, and then use this ram_start for calculating ram_top properly. This patch fixes the erroneous calculation of ram_top incase of non zero ram start address. This patch also renames fdtdec_setup_memory_size() to fdtdec_setup_mem_size_start() as this routine now takes care of memory size and start.

---
Changes from v2:
- Used new varibale ram_start
- Rename fdtdec_setup_memory_size

Changes from v1:
- None

---
 arch/arm/mach-mvebu/arm64-common.c                       |  2 +-
 board/emulation/qemu-arm/qemu-arm.c                      |  2 +-
 board/renesas/alt/alt.c                                  |  2 +-
 board/renesas/blanche/blanche.c                          |  2 +-
 board/renesas/draak/draak.c                              |  2 +-
 board/renesas/eagle/eagle.c                              |  2 +-
 board/renesas/gose/gose.c                                |  2 +-
 board/renesas/koelsch/koelsch.c                          |  2 +-
 board/renesas/lager/lager.c                              |  2 +-
 board/renesas/porter/porter.c                            |  2 +-
 board/renesas/salvator-x/salvator-x.c                    |  2 +-
 board/renesas/silk/silk.c                                |  2 +-
 board/renesas/stout/stout.c                              |  2 +-
 board/renesas/ulcb/ulcb.c                                |  2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c       |  2 +-
 board/st/stm32f429-evaluation/stm32f429-evaluation.c     |  2 +-
 board/st/stm32f469-discovery/stm32f469-discovery.c       |  2 +-
 board/st/stm32h743-disco/stm32h743-disco.c               |  2 +-
 board/st/stm32h743-eval/stm32h743-eval.c                 |  2 +-
 board/xilinx/zynq/board.c                                |  2 +-
 board/xilinx/zynqmp/zynqmp.c                             |  2 +-
 board/xilinx/zynqmp_r5/board.c                           |  2 +-
 common/board_f.c                                         |  4 ++--
 include/asm-generic/global_data.h                        |  1 +
 include/fdtdec.h                                         | 16 +++++++++-------
 lib/fdtdec.c                                             |  3 ++-
 tools/patman/func_test.py                                |  2 +-
 tools/patman/test/0000-cover-letter.patch                |  2 +-
 ...orrect-cast-for-sandbox-in-fdtdec_setup_memory_.patch |  4 ++--
 tools/patman/test/test01.txt                             |  2 +-
 30 files changed, 41 insertions(+), 37 deletions(-)

[...]

Quoted 1 line

sjg: Do you see any issue with this patch?

I think it is OK. Would like to get more people to look at it though.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I can't see the reason for fixing tools/patman but I will wait for you.

Changing patman tests is OK with me. Keeps thing consistent.

thanks Simon.

Tom: Do you see any issue with this change?

Yes, thanks. You can take it via your tree once Marek has had a chance to test things.

Quoted 7 lines
Quoted 1 line

I'd rather like the rename in a separate patch, since that makes it hard to review. I don't see how "This patch fixes the erroneous calculation of ram_top incase of non zero ram start address." thought, maybe it's hidden in this mega-patch.

We have discussed this with Marek over chat that he will look how renesas is configuring sdram based.
Fix is done only in lib/fdtdec.c to fill
gd->ram_start = (unsigned long)res.start;

the rest is just renaming around.

Thanks,
Michal

#7 lore raw

PATCH v3 1/4 lib: fdtdec: Add new variable ram_start to global data

In reply to Siva Durga Prasad Paladugu
Quoted 473 lines · Siva Durga Prasad Paladugu

Added new variable ram_start to global data structure for holding the start address of first bank of RAM, and then use this ram_start for calculating ram_top properly. This patch fixes the erroneous calculation of ram_top incase of non zero ram start address. This patch also renames fdtdec_setup_memory_size() to fdtdec_setup_mem_size_start() as this routine now takes care of memory size and start.

---
Changes from v2:
- Used new varibale ram_start
- Rename fdtdec_setup_memory_size

Changes from v1:
- None

---
 arch/arm/mach-mvebu/arm64-common.c                       |  2 +-
 board/emulation/qemu-arm/qemu-arm.c                      |  2 +-
 board/renesas/alt/alt.c                                  |  2 +-
 board/renesas/blanche/blanche.c                          |  2 +-
 board/renesas/draak/draak.c                              |  2 +-
 board/renesas/eagle/eagle.c                              |  2 +-
 board/renesas/gose/gose.c                                |  2 +-
 board/renesas/koelsch/koelsch.c                          |  2 +-
 board/renesas/lager/lager.c                              |  2 +-
 board/renesas/porter/porter.c                            |  2 +-
 board/renesas/salvator-x/salvator-x.c                    |  2 +-
 board/renesas/silk/silk.c                                |  2 +-
 board/renesas/stout/stout.c                              |  2 +-
 board/renesas/ulcb/ulcb.c                                |  2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c       |  2 +-
 board/st/stm32f429-evaluation/stm32f429-evaluation.c     |  2 +-
 board/st/stm32f469-discovery/stm32f469-discovery.c       |  2 +-
 board/st/stm32h743-disco/stm32h743-disco.c               |  2 +-
 board/st/stm32h743-eval/stm32h743-eval.c                 |  2 +-
 board/xilinx/zynq/board.c                                |  2 +-
 board/xilinx/zynqmp/zynqmp.c                             |  2 +-
 board/xilinx/zynqmp_r5/board.c                           |  2 +-
 common/board_f.c                                         |  4 ++--
 include/asm-generic/global_data.h                        |  1 +
 include/fdtdec.h                                         | 16 +++++++++-------
 lib/fdtdec.c                                             |  3 ++-
 tools/patman/func_test.py                                |  2 +-
 tools/patman/test/0000-cover-letter.patch                |  2 +-
 ...orrect-cast-for-sandbox-in-fdtdec_setup_memory_.patch |  4 ++--
 tools/patman/test/test01.txt                             |  2 +-
 30 files changed, 41 insertions(+), 37 deletions(-)
arch/arm/mach-mvebu/arm64-common.c +1 -1
index d3ea9e6..c2ab831 100644
@@ -54,7 +54,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/emulation/qemu-arm/qemu-arm.c +1 -1
index 6ec4200..926bbf2 100644
@@ -47,7 +47,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/alt/alt.c +1 -1
index 86e9d24..58838ff 100644
@@ -78,7 +78,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/blanche/blanche.c +1 -1
index 7d48d0f..1fd511c 100644
@@ -339,7 +339,7 @@ int board_eth_init(bd_t *bis)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/draak/draak.c +1 -1
index f804fae..b178131 100644
@@ -96,7 +96,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/eagle/eagle.c +1 -1
index 4bf0a20..26deca9 100644
@@ -73,7 +73,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/gose/gose.c +1 -1
index 96ac29d..1862c16 100644
@@ -83,7 +83,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/koelsch/koelsch.c +1 -1
index b6688a2..a650b8b 100644
@@ -85,7 +85,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/lager/lager.c +1 -1
index 6bfb0d1..ee66f02 100644
@@ -94,7 +94,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/porter/porter.c +1 -1
index cadff2c..b4d7f57 100644
@@ -83,7 +83,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/salvator-x/salvator-x.c +1 -1
index 651877c..c104458 100644
@@ -108,7 +108,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/silk/silk.c +1 -1
index 5fa472c..eda61ee 100644
@@ -78,7 +78,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/stout/stout.c +1 -1
index 778593b..bc62caf 100644
@@ -97,7 +97,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/renesas/ulcb/ulcb.c +1 -1
index 9e15e45..679f09d 100644
@@ -96,7 +96,7 @@ int board_init(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/st/stm32f429-discovery/stm32f429-discovery.c +1 -1
index b7638c0..fea3b6e 100644
@@ -29,7 +29,7 @@ int dram_init(void)
 		return rv;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		rv = -EINVAL;
 
 	return rv;
board/st/stm32f429-evaluation/stm32f429-evaluation.c +1 -1
index 2e638c6..6bf7f33 100644
@@ -23,7 +23,7 @@ int dram_init(void)
 		return rv;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		rv = -EINVAL;
 
 	return rv;
board/st/stm32f469-discovery/stm32f469-discovery.c +1 -1
index 90d7045..e2c2865 100644
@@ -23,7 +23,7 @@ int dram_init(void)
 		return rv;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		rv = -EINVAL;
 
 	return rv;
board/st/stm32h743-disco/stm32h743-disco.c +1 -1
index fa007c7..469370c 100644
@@ -20,7 +20,7 @@ int dram_init(void)
 		return ret;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		ret = -EINVAL;
 
 	return ret;
board/st/stm32h743-eval/stm32h743-eval.c +1 -1
index fa007c7..469370c 100644
@@ -20,7 +20,7 @@ int dram_init(void)
 		return ret;
 	}
 
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		ret = -EINVAL;
 
 	return ret;
board/xilinx/zynq/board.c +1 -1
index e4f86d1..d80dd3d 100644
@@ -93,7 +93,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	zynq_ddrc_init();
board/xilinx/zynqmp/zynqmp.c +1 -1
index e41fec3..38f935c 100644
@@ -418,7 +418,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
board/xilinx/zynqmp_r5/board.c +1 -1
index 70fb202..954e463 100644
@@ -18,7 +18,7 @@ int dram_init_banksize(void)
 
 int dram_init(void)
 {
-	if (fdtdec_setup_memory_size() != 0)
+	if (fdtdec_setup_mem_size_start() != 0)
 		return -EINVAL;
 
 	return 0;
common/board_f.c +2 -2
index fa667c7..ccd2a2f 100644
@@ -281,9 +281,9 @@ static int setup_dest_addr(void)
 	gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
 #endif
 #ifdef CONFIG_SYS_SDRAM_BASE
-	gd->ram_top = CONFIG_SYS_SDRAM_BASE;
+	gd->ram_start = CONFIG_SYS_SDRAM_BASE;
 #endif
-	gd->ram_top += get_effective_memsize();
+	gd->ram_top = gd->ram_start + get_effective_memsize();
 	gd->ram_top = board_get_usable_ram_top(gd->mon_len);
 	gd->relocaddr = gd->ram_top;
 	debug("Ram top: %08lX\n", (ulong)gd->ram_top);
include/asm-generic/global_data.h +1 -0
index 2d451f8..c8ee788 100644
@@ -52,6 +52,7 @@ typedef struct global_data {
 	unsigned long env_has_init;	/* Bitmask of boolean of struct env_location offsets */
 	int env_load_location;
 
+	unsigned long ram_start;	/* Start address of first bank of RAM */
 	unsigned long ram_top;		/* Top address of RAM used by U-Boot */
 	unsigned long relocaddr;	/* Start address of U-Boot in RAM */
 	phys_size_t ram_size;		/* RAM size */
include/fdtdec.h +9 -7
index c15b2a0..f5ebf52 100644
@@ -951,20 +951,22 @@ int fdtdec_decode_display_timing(const void *blob, int node, int index,
 				 struct display_timing *config);
 
 /**
- * fdtdec_setup_memory_size() - decode and setup gd->ram_size
+ * fdtdec_setup_mem_size_start() - decode and setup gd->ram_size and
+ * gd->ram_start
  *
- * Decode the /memory 'reg' property to determine the size of the first memory
- * bank, populate the global data with the size of the first bank of memory.
+ * Decode the /memory 'reg' property to determine the size and start of the
+ * first memory bank, populate the global data with the size and start of the
+ * first bank of memory.
  *
  * This function should be called from a boards dram_init(). This helper
- * function allows for boards to query the device tree for DRAM size instead of
- * hard coding the value in the case where the memory size cannot be detected
- * automatically.
+ * function allows for boards to query the device tree for DRAM size and start
+ * address instead of hard coding the value in the case where the memory size
+ * and start address cannot be detected automatically.
  *
  * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or
  * invalid
  */
-int fdtdec_setup_memory_size(void);
+int fdtdec_setup_mem_size_start(void);
 
 /**
  * fdtdec_setup_memory_banksize() - decode and populate gd->bd->bi_dram
lib/fdtdec.c +2 -1
index f4e8dbf..8c63278 100644
@@ -1154,7 +1154,7 @@ int fdtdec_decode_display_timing(const void *blob, int parent, int index,
 	return ret;
 }
 
-int fdtdec_setup_memory_size(void)
+int fdtdec_setup_mem_size_start(void)
 {
 	int ret, mem;
 	struct fdt_resource res;
@@ -1172,6 +1172,7 @@ int fdtdec_setup_memory_size(void)
 	}
 
 	gd->ram_size = (phys_size_t)(res.end - res.start + 1);
+	gd->ram_start = (unsigned long)res.start;
 	debug("%s: Initial DRAM size %llx\n", __func__,
 	      (unsigned long long)gd->ram_size);
 
tools/patman/func_test.py +1 -1
index 85372f3..a16427a 100644
@@ -209,7 +209,7 @@ Changes in v4:
 
 Simon Glass (2):
   pci: Correct cast for sandbox
-  fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+  fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 
  cmd/pci.c                   | 3 ++-
  fs/fat/fat.c                | 1 +
tools/patman/test/0000-cover-letter.patch +1 -1
index 2906201..84ba81b 100644
@@ -10,7 +10,7 @@ Content-Transfer-Encoding: 8bit
 
 Simon Glass (2):
   pci: Correct cast for sandbox
-  fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+  fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 
  cmd/pci.c                   | 3 ++-
  fs/fat/fat.c                | 1 +
tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_memory_.patch +2 -2
index e328497..827e4cc 100644
@@ -1,7 +1,7 @@
 From 5ab48490f03051875ab13d288a4bf32b507d76fd Mon Sep 17 00:00:00 2001
 From: Simon Glass <[email protected]>
 Date: Sat, 15 Apr 2017 15:39:08 -0600
-Subject: [RFC 2/2] fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+Subject: [RFC 2/2] fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
@@ -58,7 +58,7 @@ diff --git a/lib/fdtdec.c b/lib/fdtdec.c
 index c072e54..942244f 100644
 --- a/lib/fdtdec.c
 +++ b/lib/fdtdec.c
-@@ -1200,7 +1200,8 @@ int fdtdec_setup_memory_size(void)
+@@ -1200,7 +1200,8 @@ int fdtdec_setup_mem_size_start(void)
  	}
 
  	gd->ram_size = (phys_size_t)(res.end - res.start + 1);
tools/patman/test/test01.txt +0 -0
index 8ad9587..d8be23d 100644

tools/patman/test/test01.txt commit 5ab48490f03051875ab13d288a4bf32b507d76fd · line 34

Quoted 8 lines
tools/patman/test/test01.txt +1 -1
@@ -28,7 +28,7 @@ commit 5ab48490f03051875ab13d288a4bf32b507d76fd
 Author: Simon Glass <[email protected]>
 Date:   Sat Apr 15 15:39:08 2017 -0600
 
-    fdt: Correct cast for sandbox in fdtdec_setup_memory_size()
+    fdt: Correct cast for sandbox in fdtdec_setup_mem_size_start()
 
     This gives a warning with some native compilers:
 

Siva: Can you please update this patch based on this one which was applied? There is a new ram_base added.

Thanks,
Michal

commit 90c08fa038451d6d7b7d8711bfd829b61d64c490

Author:     Michael Pratt <[email protected]>
AuthorDate: Mon Jun 11 13:07:09 2018 -0600
Commit:     Simon Glass <[email protected]>
CommitDate: Mon Jul 9 09:11:00 2018 -0600

fdt: Add device tree memory bindings

Support a default memory bank, specified in reg, as well as board-specific memory banks in subtree board-id nodes.

This allows memory information to be provided in the device tree, rather than hard-coded in, which will make it simpler to handle similar devices with different memory banks, as the board-id values or masks can be used to match devices.