From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/6] fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE
Date: Mon, 7 Aug 2017 09:54:20 -0400 [thread overview]
Message-ID: <20170807135420.GE29197@bill-the-cat> (raw)
In-Reply-To: <20170803164838.10845-1-robdclark@gmail.com>
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!
--
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>
next prev parent reply other threads:[~2017-08-07 13:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-03 16:48 [U-Boot] [PATCH 1/6] fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE Rob Clark
2017-08-03 16:48 ` [U-Boot] [PATCH 2/6] db410c: use fdt passed from lk Rob Clark
2017-08-03 16:48 ` [U-Boot] [PATCH 3/6] db410c: add reserved-memory node to dts Rob Clark
2017-08-03 16:48 ` [U-Boot] [PATCH 4/6] db410c: on aarch64 the fdtfile is in per-vendor subdirectory Rob Clark
2017-08-03 16:48 ` [U-Boot] [PATCH 5/6] db410c: config updates Rob Clark
2017-08-03 16:48 ` [U-Boot] [PATCH 6/6] db410c: enable r8152 usb eth Rob Clark
2017-08-06 5:16 ` [U-Boot] [PATCH 1/6] fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE Simon Glass
2017-08-06 10:34 ` Rob Clark
2017-08-07 13:54 ` Tom Rini [this message]
2017-08-13 15:59 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170807135420.GE29197@bill-the-cat \
--to=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox