fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE
Subsystems (3)
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.
--- include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)
include/fdtdec.h +2 -1
@@ -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 );
lib/fdtdec.c +26 -19
60 lines not on this page · raw message
Signature · 1 line
2.13.0
PATCH 2/6 db410c: use fdt passed from lk
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.
--- 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
board/qualcomm/dragonboard410c/Makefile +1 -0
@@ -5,4 +5,5 @@ # obj-y := dragonboard410c.o +obj-y += lowlevel_init.o extra-y += head.o
board/qualcomm/dragonboard410c/dragonboard410c.c +8 -0
@@ -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) {
board/qualcomm/dragonboard410c/lowlevel_init.S new file +36 -0
@@ -0,0 +1,36 @@ +/* + * (C) Copyright 2016 + * Cédric Schieli <[email protected]> + * + * 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
Signature · 1 line
2.13.0
PATCH 3/6 db410c: add reserved-memory node to dts
In reply to Rob ClarkIf 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.
--- arch/arm/dts/dragonboard410c.dts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/dts/dragonboard410c.dts +6 -1
@@ -23,11 +23,16 @@ reg = <0 0x80000000 0 0x3da00000>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + }; + chosen { stdout-path = "/soc/serial at 78b0000"; }; - soc { #address-cells = <0x1>; #size-cells = <0x1>;
Signature · 1 line
2.13.0
PATCH 4/6 db410c: on aarch64 the fdtfile is in per-vendor subdirectory
In reply to Rob Clark--- include/configs/dragonboard410c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/configs/dragonboard410c.h +1 -1
@@ -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" \
Signature · 1 line
2.13.0
PATCH 5/6 db410c: config updates
In reply to Rob Clark--- configs/dragonboard410c_defconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
configs/dragonboard410c_defconfig +11 -0
@@ -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
Signature · 1 line
2.13.0
PATCH 6/6 db410c: enable r8152 usb eth
In reply to Rob Clark--- include/configs/dragonboard410c.h | 1 + 1 file changed, 1 insertion(+)
include/configs/dragonboard410c.h +1 -0
@@ -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 */
Signature · 1 line
2.13.0
PATCH 1/6 fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE
In reply to Rob ClarkHi Rob,
Quoted 7 lines · Rob Clark
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?
Quoted 87 lines
Signed-off-by Rob Clark <[email protected]>--- include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)include/fdtdec.h +2
-1@@ -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 );lib/fdtdec.c +26
-20@@ -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 definedCONFIG_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()) { --
Quoted 2 lines
2.13.0
Regards,
Simon
PATCH 1/6 fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE
Quoted 6 lines · Simon Glass
Hi Rob,
Quoted 3 lines · Rob Clark
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.
Quoted 7 lines
Quoted 4 lines
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_BOARDto 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
Quoted 92 lines
Quoted 87 lines
Signed-off-by Rob Clark <[email protected]>--- include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)include/fdtdec.h +2
-1@@ -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 );lib/fdtdec.c +26
-20@@ -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 definedCONFIG_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()) { --Quoted 2 lines
2.13.0
Regards,
Simon
PATCH 1/6 fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE
In reply to Rob ClarkQuoted 83 lines · Rob Clark
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 <[email protected]>--- include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)include/fdtdec.h +2
-1@@ -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 );lib/fdtdec.c +19
-19@@ -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 definedCONFIG_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 definedCONFIG_FIT_EMBED - gd->fdt_blob =locate_dtb_in_fit (&_end); +#elif definedCONFIG_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 +
lib/fdtdec.c int fdtdec_setup_memory_banksize(void) · line 1243
Quoted 10 lines
lib/fdtdec.c +7
-0+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()) {
Simon, what do you think? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170807/46610465/attachment.sig>
PATCH 1/6 fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE
Hi,
Quoted 98 lines · Tom Rini
Quoted 83 lines · Rob Clark
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 <[email protected]>--- include/fdtdec.h | 3 ++- lib/fdtdec.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-)include/fdtdec.h +2
-1@@ -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 );lib/fdtdec.c +19
-19@@ -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 definedCONFIG_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 definedCONFIG_FIT_EMBED - gd->fdt_blob =locate_dtb_in_fit (&_end); +#elif definedCONFIG_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 +lib/fdtdec.c int fdtdec_setup_memory_banksize(void) · line 1243
Quoted 10 lines
lib/fdtdec.c +7
-0+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 <[email protected]>
Quoted 1 line
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