[U-Boot] [PATCH 1/6] fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE

Similar to CONFIG_OF_BOARD, but in this case the fdt is still built by u-boot build. This allows the board to patch the fdt, etc.
In the specific case of dragonboard 410c, we pass the u-boot generated fdt to the previous stage of bootloader (by embedding it in the u-boot.img that is loaded by lk/aboot), which patches the fdt and passes it back to u-boot.
Signed-off-by: Rob Clark robdclark@gmail.com --- include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h index 4a0947c626..b9acec735a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -986,7 +986,8 @@ int fdtdec_setup(void);
/** * Board-specific FDT initialization. Returns the address to a device tree blob. - * Called when CONFIG_OF_BOARD is defined. + * Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined + * and the board implements it. */ void *board_fdt_blob_setup(void);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index d2dbd0f122..07c458673c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1203,34 +1203,41 @@ int fdtdec_setup_memory_banksize(void) } #endif
-int fdtdec_setup(void) +#ifdef CONFIG_OF_SEPARATE +/* + * For CONFIG_OF_SEPARATE, the board may optionally implement this to + * provide and/or fixup the fdt. + */ +__weak void *board_fdt_blob_setup(void) { -#if CONFIG_IS_ENABLED(OF_CONTROL) -# ifdef CONFIG_OF_EMBED - /* Get a pointer to the FDT */ - gd->fdt_blob = __dtb_dt_begin; -# elif defined CONFIG_OF_SEPARATE -# ifdef CONFIG_SPL_BUILD + void *fdt_blob = NULL; +#ifdef CONFIG_SPL_BUILD /* FDT is at end of BSS unless it is in a different memory region */ if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS)) - gd->fdt_blob = (ulong *)&_image_binary_end; + fdt_blob = (ulong *)&_image_binary_end; else - gd->fdt_blob = (ulong *)&__bss_end; + fdt_blob = (ulong *)&__bss_end;
-# elif defined CONFIG_FIT_EMBED - gd->fdt_blob = locate_dtb_in_fit(&_end); +#elif defined CONFIG_FIT_EMBED + fdt_blob = locate_dtb_in_fit(&_end);
- if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) { + if (fdt_blob == NULL || fdt_blob <= ((void *)&_end)) puts("Failed to find proper dtb in embedded FIT Image\n"); - return -1; - } - -# else +#else /* FDT is at end of image */ - gd->fdt_blob = (ulong *)&_end; + fdt_blob = (ulong *)&_end; # endif -# elif defined(CONFIG_OF_BOARD) - /* Allow the board to override the fdt address. */ + return fdt_blob; +} +#endif + +int fdtdec_setup(void) +{ +#if CONFIG_IS_ENABLED(OF_CONTROL) +# ifdef CONFIG_OF_EMBED + /* Get a pointer to the FDT */ + gd->fdt_blob = __dtb_dt_begin; +# elif defined(CONFIG_OF_SEPARATE) || defined(CONFIG_OF_BOARD) gd->fdt_blob = board_fdt_blob_setup(); # elif defined(CONFIG_OF_HOSTFILE) if (sandbox_read_fdt_from_file()) {

lk patches the fdt to set some device's MAC addresses and more importantly to patch in the simple-framebuffer node that we want u-boot to see.
Signed-off-by: Rob Clark robdclark@gmail.com --- board/qualcomm/dragonboard410c/Makefile | 1 + board/qualcomm/dragonboard410c/dragonboard410c.c | 8 ++++++ board/qualcomm/dragonboard410c/lowlevel_init.S | 36 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 board/qualcomm/dragonboard410c/lowlevel_init.S
diff --git a/board/qualcomm/dragonboard410c/Makefile b/board/qualcomm/dragonboard410c/Makefile index cd678088fa..5082383be4 100644 --- a/board/qualcomm/dragonboard410c/Makefile +++ b/board/qualcomm/dragonboard410c/Makefile @@ -5,4 +5,5 @@ #
obj-y := dragonboard410c.o +obj-y += lowlevel_init.o extra-y += head.o diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c index 37d0b85e0e..1fa4dc1b15 100644 --- a/board/qualcomm/dragonboard410c/dragonboard410c.c +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c @@ -27,6 +27,14 @@ int dram_init_banksize(void) return 0; }
+extern unsigned long fw_dtb_pointer; + +void *board_fdt_blob_setup(void) +{ + if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) + return NULL; + return (void *)fw_dtb_pointer; +}
int board_prepare_usb(enum usb_init_type type) { diff --git a/board/qualcomm/dragonboard410c/lowlevel_init.S b/board/qualcomm/dragonboard410c/lowlevel_init.S new file mode 100644 index 0000000000..cdbd8e14db --- /dev/null +++ b/board/qualcomm/dragonboard410c/lowlevel_init.S @@ -0,0 +1,36 @@ +/* + * (C) Copyright 2016 + * Cédric Schieli cschieli@gmail.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <config.h> + +.align 8 +.global fw_dtb_pointer +fw_dtb_pointer: +#ifdef CONFIG_ARM64 + .dword 0x0 +#else + .word 0x0 +#endif + +/* + * Routine: save_boot_params (called after reset from start.S) + * Description: save ATAG/FDT address provided by the firmware at boot time + */ + +.global save_boot_params +save_boot_params: + + /* The firmware provided ATAG/FDT address can be found in r2/x0 */ +#ifdef CONFIG_ARM64 + adr x8, fw_dtb_pointer + str x0, [x8] +#else + str r2, fw_dtb_pointer +#endif + + /* Returns */ + b save_boot_params_ret

If lk lights up display and populates simple-framebuffer node, it will also setup a reserved-memory node (needed by simplefb on linux). But it isn't clever enough to cope when the reserved-memory node is not present.
Signed-off-by: Rob Clark robdclark@gmail.com --- arch/arm/dts/dragonboard410c.dts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/arm/dts/dragonboard410c.dts b/arch/arm/dts/dragonboard410c.dts index 0d3b7a35f4..a47b95264c 100644 --- a/arch/arm/dts/dragonboard410c.dts +++ b/arch/arm/dts/dragonboard410c.dts @@ -23,11 +23,16 @@ reg = <0 0x80000000 0 0x3da00000>; };
+ reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + }; + chosen { stdout-path = "/soc/serial@78b0000"; };
- soc { #address-cells = <0x1>; #size-cells = <0x1>;

Signed-off-by: Rob Clark robdclark@gmail.com --- include/configs/dragonboard410c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/dragonboard410c.h b/include/configs/dragonboard410c.h index d9dc639aeb..626dff8dcd 100644 --- a/include/configs/dragonboard410c.h +++ b/include/configs/dragonboard410c.h @@ -103,7 +103,7 @@ REFLASH(dragonboard/u-boot.img, 8)\ "initrd_high=0xffffffffffffffff\0" \ "linux_image=Image\0" \ "kernel_addr_r=0x81000000\0"\ - "fdtfile=apq8016-sbc.dtb\0" \ + "fdtfile=qcom/apq8016-sbc.dtb\0" \ "fdt_addr_r=0x83000000\0"\ "ramdisk_addr_r=0x84000000\0"\ "scriptaddr=0x90000000\0"\

Signed-off-by: Rob Clark robdclark@gmail.com --- configs/dragonboard410c_defconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/configs/dragonboard410c_defconfig b/configs/dragonboard410c_defconfig index c78b4a6fd5..d9cb269085 100644 --- a/configs/dragonboard410c_defconfig +++ b/configs/dragonboard410c_defconfig @@ -9,6 +9,7 @@ CONFIG_ENV_IS_NOWHERE=y CONFIG_SYS_PROMPT="dragonboard410c => " # CONFIG_CMD_IMI is not set # CONFIG_CMD_IMLS is not set +CONFIG_CMD_POWEROFF=y CONFIG_CMD_MD5SUM=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_UNZIP=y @@ -21,11 +22,14 @@ CONFIG_CMD_TIMER=y CONFIG_CLK=y CONFIG_MSM_GPIO=y CONFIG_PM8916_GPIO=y +CONFIG_DM_KEYBOARD=y CONFIG_LED=y CONFIG_LED_GPIO=y CONFIG_DM_MMC=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_MSM=y +CONFIG_DM_ETH=y +# CONFIG_NETDEVICES is not set CONFIG_DM_PMIC=y CONFIG_PMIC_PM8916=y CONFIG_MSM_SERIAL=y @@ -38,4 +42,11 @@ CONFIG_USB_EHCI_MSM=y CONFIG_USB_ULPI_VIEWPORT=y CONFIG_USB_ULPI=y CONFIG_USB_STORAGE=y +CONFIG_USB_KEYBOARD=y +CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y +CONFIG_DM_VIDEO=y +# CONFIG_VIDEO_BPP8 is not set +CONFIG_NO_FB_CLEAR=y +CONFIG_VIDEO_SIMPLE=y +CONFIG_FAT_WRITE=y CONFIG_OF_LIBFDT_OVERLAY=y

Signed-off-by: Rob Clark robdclark@gmail.com --- include/configs/dragonboard410c.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/dragonboard410c.h b/include/configs/dragonboard410c.h index 626dff8dcd..bbc9685e0e 100644 --- a/include/configs/dragonboard410c.h +++ b/include/configs/dragonboard410c.h @@ -44,6 +44,7 @@ #define CONFIG_USB_ETHER_ASIX88179 #define CONFIG_USB_ETHER_MCS7830 #define CONFIG_USB_ETHER_SMSC95XX +#define CONFIG_USB_ETHER_RTL8152
/* Extra Commands */ /* Enable that for switching of boot partitions */

Hi Rob,
On 3 August 2017 at 10:48, Rob Clark robdclark@gmail.com wrote:
Similar to CONFIG_OF_BOARD, but in this case the fdt is still built by u-boot build. This allows the board to patch the fdt, etc.
In the specific case of dragonboard 410c, we pass the u-boot generated fdt to the previous stage of bootloader (by embedding it in the u-boot.img that is loaded by lk/aboot), which patches the fdt and passes it back to u-boot.
Why do you need to create a weak function for this? Isn't there already a CONFIG_OF_BOARD to enable this feature?
Signed-off-by: Rob Clark robdclark@gmail.com
include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h index 4a0947c626..b9acec735a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -986,7 +986,8 @@ int fdtdec_setup(void);
/**
- Board-specific FDT initialization. Returns the address to a device tree blob.
- Called when CONFIG_OF_BOARD is defined.
- Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined
*/
- and the board implements it.
void *board_fdt_blob_setup(void);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index d2dbd0f122..07c458673c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1203,34 +1203,41 @@ int fdtdec_setup_memory_banksize(void) } #endif
-int fdtdec_setup(void) +#ifdef CONFIG_OF_SEPARATE +/*
- For CONFIG_OF_SEPARATE, the board may optionally implement this to
- provide and/or fixup the fdt.
- */
+__weak void *board_fdt_blob_setup(void) { -#if CONFIG_IS_ENABLED(OF_CONTROL) -# ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */
gd->fdt_blob = __dtb_dt_begin;
-# elif defined CONFIG_OF_SEPARATE -# ifdef CONFIG_SPL_BUILD
void *fdt_blob = NULL;
+#ifdef CONFIG_SPL_BUILD /* FDT is at end of BSS unless it is in a different memory region */ if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
gd->fdt_blob = (ulong *)&_image_binary_end;
fdt_blob = (ulong *)&_image_binary_end; else
gd->fdt_blob = (ulong *)&__bss_end;
fdt_blob = (ulong *)&__bss_end;
-# elif defined CONFIG_FIT_EMBED
gd->fdt_blob = locate_dtb_in_fit(&_end);
+#elif defined CONFIG_FIT_EMBED
fdt_blob = locate_dtb_in_fit(&_end);
if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) {
if (fdt_blob == NULL || fdt_blob <= ((void *)&_end)) puts("Failed to find proper dtb in embedded FIT Image\n");
return -1;
}
-# else +#else /* FDT is at end of image */
gd->fdt_blob = (ulong *)&_end;
fdt_blob = (ulong *)&_end;
# endif -# elif defined(CONFIG_OF_BOARD)
/* Allow the board to override the fdt address. */
return fdt_blob;
+} +#endif
+int fdtdec_setup(void) +{ +#if CONFIG_IS_ENABLED(OF_CONTROL) +# ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */
gd->fdt_blob = __dtb_dt_begin;
+# elif defined(CONFIG_OF_SEPARATE) || defined(CONFIG_OF_BOARD) gd->fdt_blob = board_fdt_blob_setup(); # elif defined(CONFIG_OF_HOSTFILE) if (sandbox_read_fdt_from_file()) { -- 2.13.0
Regards, Simon

On Sun, Aug 6, 2017 at 1:16 AM, Simon Glass sjg@chromium.org wrote:
Hi Rob,
On 3 August 2017 at 10:48, Rob Clark robdclark@gmail.com wrote:
Similar to CONFIG_OF_BOARD, but in this case the fdt is still built by u-boot build. This allows the board to patch the fdt, etc.
In the specific case of dragonboard 410c, we pass the u-boot generated fdt to the previous stage of bootloader (by embedding it in the u-boot.img that is loaded by lk/aboot), which patches the fdt and passes it back to u-boot.
Why do you need to create a weak function for this? Isn't there already a CONFIG_OF_BOARD to enable this feature?
See: https://lists.denx.de/pipermail/u-boot/2017-July/299021.html
My original approach was OF_BOARD but since we still need to build the dtb that required Makefile hacks for snapdragon.
Snapdragon is something kind of in-between OF_BOARD and OF_SEPARATE.
BR, -R
Signed-off-by: Rob Clark robdclark@gmail.com
include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h index 4a0947c626..b9acec735a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -986,7 +986,8 @@ int fdtdec_setup(void);
/**
- Board-specific FDT initialization. Returns the address to a device tree blob.
- Called when CONFIG_OF_BOARD is defined.
- Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined
*/
- and the board implements it.
void *board_fdt_blob_setup(void);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index d2dbd0f122..07c458673c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1203,34 +1203,41 @@ int fdtdec_setup_memory_banksize(void) } #endif
-int fdtdec_setup(void) +#ifdef CONFIG_OF_SEPARATE +/*
- For CONFIG_OF_SEPARATE, the board may optionally implement this to
- provide and/or fixup the fdt.
- */
+__weak void *board_fdt_blob_setup(void) { -#if CONFIG_IS_ENABLED(OF_CONTROL) -# ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */
gd->fdt_blob = __dtb_dt_begin;
-# elif defined CONFIG_OF_SEPARATE -# ifdef CONFIG_SPL_BUILD
void *fdt_blob = NULL;
+#ifdef CONFIG_SPL_BUILD /* FDT is at end of BSS unless it is in a different memory region */ if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
gd->fdt_blob = (ulong *)&_image_binary_end;
fdt_blob = (ulong *)&_image_binary_end; else
gd->fdt_blob = (ulong *)&__bss_end;
fdt_blob = (ulong *)&__bss_end;
-# elif defined CONFIG_FIT_EMBED
gd->fdt_blob = locate_dtb_in_fit(&_end);
+#elif defined CONFIG_FIT_EMBED
fdt_blob = locate_dtb_in_fit(&_end);
if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) {
if (fdt_blob == NULL || fdt_blob <= ((void *)&_end)) puts("Failed to find proper dtb in embedded FIT Image\n");
return -1;
}
-# else +#else /* FDT is at end of image */
gd->fdt_blob = (ulong *)&_end;
fdt_blob = (ulong *)&_end;
# endif -# elif defined(CONFIG_OF_BOARD)
/* Allow the board to override the fdt address. */
return fdt_blob;
+} +#endif
+int fdtdec_setup(void) +{ +#if CONFIG_IS_ENABLED(OF_CONTROL) +# ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */
gd->fdt_blob = __dtb_dt_begin;
+# elif defined(CONFIG_OF_SEPARATE) || defined(CONFIG_OF_BOARD) gd->fdt_blob = board_fdt_blob_setup(); # elif defined(CONFIG_OF_HOSTFILE) if (sandbox_read_fdt_from_file()) { -- 2.13.0
Regards, Simon

On Thu, Aug 03, 2017 at 12:48:30PM -0400, Rob Clark wrote:
Similar to CONFIG_OF_BOARD, but in this case the fdt is still built by u-boot build. This allows the board to patch the fdt, etc.
In the specific case of dragonboard 410c, we pass the u-boot generated fdt to the previous stage of bootloader (by embedding it in the u-boot.img that is loaded by lk/aboot), which patches the fdt and passes it back to u-boot.
Signed-off-by: Rob Clark robdclark@gmail.com
include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h index 4a0947c626..b9acec735a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -986,7 +986,8 @@ int fdtdec_setup(void);
/**
- Board-specific FDT initialization. Returns the address to a device tree blob.
- Called when CONFIG_OF_BOARD is defined.
- Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined
*/
- and the board implements it.
void *board_fdt_blob_setup(void);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index d2dbd0f122..07c458673c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1203,34 +1203,41 @@ int fdtdec_setup_memory_banksize(void) } #endif
-int fdtdec_setup(void) +#ifdef CONFIG_OF_SEPARATE +/*
- For CONFIG_OF_SEPARATE, the board may optionally implement this to
- provide and/or fixup the fdt.
- */
+__weak void *board_fdt_blob_setup(void) { -#if CONFIG_IS_ENABLED(OF_CONTROL) -# ifdef CONFIG_OF_EMBED
- /* Get a pointer to the FDT */
- gd->fdt_blob = __dtb_dt_begin;
-# elif defined CONFIG_OF_SEPARATE -# ifdef CONFIG_SPL_BUILD
- void *fdt_blob = NULL;
+#ifdef CONFIG_SPL_BUILD /* FDT is at end of BSS unless it is in a different memory region */ if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
gd->fdt_blob = (ulong *)&_image_binary_end;
elsefdt_blob = (ulong *)&_image_binary_end;
gd->fdt_blob = (ulong *)&__bss_end;
fdt_blob = (ulong *)&__bss_end;
-# elif defined CONFIG_FIT_EMBED
- gd->fdt_blob = locate_dtb_in_fit(&_end);
+#elif defined CONFIG_FIT_EMBED
- fdt_blob = locate_dtb_in_fit(&_end);
- if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) {
- if (fdt_blob == NULL || fdt_blob <= ((void *)&_end)) puts("Failed to find proper dtb in embedded FIT Image\n");
return -1;
- }
-# else +#else /* FDT is at end of image */
- gd->fdt_blob = (ulong *)&_end;
- fdt_blob = (ulong *)&_end;
# endif -# elif defined(CONFIG_OF_BOARD)
- /* Allow the board to override the fdt address. */
- return fdt_blob;
+} +#endif
+int fdtdec_setup(void) +{ +#if CONFIG_IS_ENABLED(OF_CONTROL) +# ifdef CONFIG_OF_EMBED
- /* Get a pointer to the FDT */
- gd->fdt_blob = __dtb_dt_begin;
+# elif defined(CONFIG_OF_SEPARATE) || defined(CONFIG_OF_BOARD) gd->fdt_blob = board_fdt_blob_setup(); # elif defined(CONFIG_OF_HOSTFILE) if (sandbox_read_fdt_from_file()) {
Reviewed-by: Tom Rini trini@konsulko.com
Simon, what do you think? Thanks!

Hi,
On 7 August 2017 at 07:54, Tom Rini trini@konsulko.com wrote:
On Thu, Aug 03, 2017 at 12:48:30PM -0400, Rob Clark wrote:
Similar to CONFIG_OF_BOARD, but in this case the fdt is still built by u-boot build. This allows the board to patch the fdt, etc.
In the specific case of dragonboard 410c, we pass the u-boot generated fdt to the previous stage of bootloader (by embedding it in the u-boot.img that is loaded by lk/aboot), which patches the fdt and passes it back to u-boot.
Signed-off-by: Rob Clark robdclark@gmail.com
include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h index 4a0947c626..b9acec735a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -986,7 +986,8 @@ int fdtdec_setup(void);
/**
- Board-specific FDT initialization. Returns the address to a device tree blob.
- Called when CONFIG_OF_BOARD is defined.
- Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined
*/
- and the board implements it.
void *board_fdt_blob_setup(void);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index d2dbd0f122..07c458673c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1203,34 +1203,41 @@ int fdtdec_setup_memory_banksize(void) } #endif
-int fdtdec_setup(void) +#ifdef CONFIG_OF_SEPARATE +/*
- For CONFIG_OF_SEPARATE, the board may optionally implement this to
- provide and/or fixup the fdt.
- */
+__weak void *board_fdt_blob_setup(void) { -#if CONFIG_IS_ENABLED(OF_CONTROL) -# ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */
gd->fdt_blob = __dtb_dt_begin;
-# elif defined CONFIG_OF_SEPARATE -# ifdef CONFIG_SPL_BUILD
void *fdt_blob = NULL;
+#ifdef CONFIG_SPL_BUILD /* FDT is at end of BSS unless it is in a different memory region */ if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
gd->fdt_blob = (ulong *)&_image_binary_end;
fdt_blob = (ulong *)&_image_binary_end; else
gd->fdt_blob = (ulong *)&__bss_end;
fdt_blob = (ulong *)&__bss_end;
-# elif defined CONFIG_FIT_EMBED
gd->fdt_blob = locate_dtb_in_fit(&_end);
+#elif defined CONFIG_FIT_EMBED
fdt_blob = locate_dtb_in_fit(&_end);
if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) {
if (fdt_blob == NULL || fdt_blob <= ((void *)&_end)) puts("Failed to find proper dtb in embedded FIT Image\n");
return -1;
}
-# else +#else /* FDT is at end of image */
gd->fdt_blob = (ulong *)&_end;
fdt_blob = (ulong *)&_end;
# endif -# elif defined(CONFIG_OF_BOARD)
/* Allow the board to override the fdt address. */
return fdt_blob;
+} +#endif
+int fdtdec_setup(void) +{ +#if CONFIG_IS_ENABLED(OF_CONTROL) +# ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */
gd->fdt_blob = __dtb_dt_begin;
+# elif defined(CONFIG_OF_SEPARATE) || defined(CONFIG_OF_BOARD) gd->fdt_blob = board_fdt_blob_setup(); # elif defined(CONFIG_OF_HOSTFILE) if (sandbox_read_fdt_from_file()) {
Reviewed-by: Tom Rini trini@konsulko.com
Simon, what do you think? Thanks!
OK I see. I am not very keen on this, but at least I understand the problem.
I think the CONFIG_OF_BOARD thing should in fact be a separate option from the others (i.e. it should be outside the 'choice'). Calling that function can then be enabled independently of which option is used. This will allow the fixup to be used regardless of the means of obtaining an initial DT.
Then either we use CONFIG_OF_SEPARATE with the understanding that in fact the DT might not be there, or (perhaps) create a new CONFIG_OF_NONE to indicate that we don't have a DT (until board_fdt_blob_setup() is called).
Regards, Simon
participants (3)
-
Rob Clark
-
Simon Glass
-
Tom Rini