diff mbox

[U-Boot,RFC] cmd: fdt: memory fixup

Message ID 20170131023551.mtas7csvuk4hkxtw@lenoch
State Changes Requested
Delegated to: Simon Glass
Headers show

Commit Message

Ladislav Michl Jan. 31, 2017, 2:35 a.m. UTC
To get Falcon mode working with zImage is currently non trivial as zImages
do not fit into U-Boot's image concept too well. Fortunately at least for
ARM boards it seems getting memory node right is quite sufficient.
What about changing 'fdt memory' command to update memory node according to
detected memory layout when called without parameters?

	ladis

Comments

Ladislav Michl Jan. 31, 2017, 11:12 p.m. UTC | #1
On Tue, Jan 31, 2017 at 03:35:51AM +0100, Ladislav Michl wrote:
> To get Falcon mode working with zImage is currently non trivial as zImages
> do not fit into U-Boot's image concept too well. Fortunately at least for
> ARM boards it seems getting memory node right is quite sufficient.
> What about changing 'fdt memory' command to update memory node according to
> detected memory layout when called without parameters?

Looked at other (!arm) platforms implementation... Does not seem like good
idea anymore. What about adding posibility to call ft_arch_fixup? Other
ideas?

Thank you,
	ladis
Tom Rini Feb. 5, 2017, 4:36 p.m. UTC | #2
On Tue, Jan 31, 2017 at 03:35:51AM +0100, Ladislav Michl wrote:

> To get Falcon mode working with zImage is currently non trivial as zImages
> do not fit into U-Boot's image concept too well. Fortunately at least for
> ARM boards it seems getting memory node right is quite sufficient.
> What about changing 'fdt memory' command to update memory node according to
> detected memory layout when called without parameters?

I'm not quite sure I follow this, sorry.  The 'spl' command should be
extended cover 'zImage and 'Images', which I think shouldn't be too hard
at this point given how the abstractions work today, and then the normal
mechanism to prepare the 'args' portion should work.
diff mbox

Patch

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 95dd673b95..e08296d51c 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -517,11 +517,23 @@  static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	 * memory command
 	 */
 	} else if (strncmp(argv[1], "me", 2) == 0) {
-		uint64_t addr, size;
 		int err;
-		addr = simple_strtoull(argv[2], NULL, 16);
-		size = simple_strtoull(argv[3], NULL, 16);
-		err = fdt_fixup_memory(working_fdt, addr, size);
+		if (argc < 4) {
+			int i;
+			uint64_t start[CONFIG_NR_DRAM_BANKS];
+			uint64_t size[CONFIG_NR_DRAM_BANKS];
+			bd_t *bd = gd->bd;
+			for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+				start[i] = bd->bi_dram[i].start;
+				size[i] = bd->bi_dram[i].size;
+			}
+			err = fdt_fixup_memory_banks(working_fdt, start, size,
+						CONFIG_NR_DRAM_BANKS);
+		} else {
+			uint64_t addr = simple_strtoull(argv[2], NULL, 16);
+			uint64_t size = simple_strtoull(argv[3], NULL, 16);
+			err = fdt_fixup_memory(working_fdt, addr, size);
+		}
 		if (err < 0)
 			return err;