* [U-Boot] [PATCH] Allow boards to initialize the DT at runtime.
[not found] <98c581b7b5c318c1e5eeac63c8a73c6e63c476cf>
@ 2017-04-02 8:25 ` Alex Deymo
2017-04-05 10:29 ` Simon Glass
2017-05-10 17:51 ` [U-Boot] " Tom Rini
0 siblings, 2 replies; 3+ messages in thread
From: Alex Deymo @ 2017-04-02 8:25 UTC (permalink / raw)
To: u-boot
In some boards like the Raspberry Pi the initial bootloader will pass
a DT to the kernel. When using U-boot as such kernel, the board code in
U-Boot should be able to provide U-boot with this, already assembled
device tree blob.
This patch introduces a new config option CONFIG_OF_BOARD to use instead
of CONFIG_OF_EMBED or CONFIG_OF_SEPARATE which will initialize the DT
from a board-specific funtion instead of bundling one with U-boot or as
a separated file. This allows boards like the Raspberry Pi to reuse the
device tree passed from the bootcode.bin and start.elf firmware
files, included the run-time selected device tree overlays.
Signed-off-by: Alex Deymo <deymo@google.com>
---
README | 8 +++++++-
board/raspberrypi/rpi/rpi.c | 10 ++++++++++
doc/README.fdt-control | 4 ++++
dts/Kconfig | 8 ++++++++
include/fdtdec.h | 6 ++++++
lib/fdtdec.c | 3 +++
6 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/README b/README
index aa907ced8a..e658f02a7e 100644
--- a/README
+++ b/README
@@ -975,7 +975,7 @@ The following options need to be configured:
tree is available in the global data as gd->fdt_blob.
U-Boot needs to get its device tree from somewhere. This can
- be done using one of the two options below:
+ be done using one of the three options below:
CONFIG_OF_EMBED
If this variable is defined, U-Boot will embed a device tree
@@ -996,6 +996,12 @@ The following options need to be configured:
still use the individual files if you need something more
exotic.
+ CONFIG_OF_BOARD
+ If this variable is defined, U-Boot will use the device tree
+ provided by the board at runtime instead of embedding one with
+ the image. Only boards defining board_fdt_blob_setup() support
+ this option (see include/fdtdec.h file).
+
- Watchdog:
CONFIG_WATCHDOG
If this variable is defined, it enables watchdog
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 2146534b36..ef04d397d6 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -516,6 +516,16 @@ int board_mmc_init(bd_t *bis)
msg_clk->get_clock_rate.body.resp.rate_hz);
}
+/*
+ * If the firmware passed a device tree use it for U-Boot.
+ */
+void *board_fdt_blob_setup(void)
+{
+ if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
+ return NULL;
+ return (void *)fw_dtb_pointer;
+}
+
int ft_board_setup(void *blob, bd_t *bd)
{
/*
diff --git a/doc/README.fdt-control b/doc/README.fdt-control
index c965629905..378b06b108 100644
--- a/doc/README.fdt-control
+++ b/doc/README.fdt-control
@@ -130,6 +130,10 @@ u-boot-dtb.bin which does the above step for you also. If you are using
CONFIG_SPL_FRAMEWORK, then u-boot.img will be built to include the device
tree binary.
+If CONFIG_OF_BOARD is defined, a board-specific routine will provide the
+device tree at runtime, for example if an earlier bootloader stage creates
+it and passes it to U-Boot.
+
If CONFIG_OF_HOSTFILE is defined, then it will be read from a file on
startup. This is only useful for sandbox. Use the -d flag to U-Boot to
specify the file to read.
diff --git a/dts/Kconfig b/dts/Kconfig
index 3f64eda619..978b2d7f3d 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -51,6 +51,14 @@ config OF_EMBED
and development only and is not recommended for production devices.
Boards in the mainline U-Boot tree should not use it.
+config OF_BOARD
+ bool "Provided by the board at runtime"
+ depends on !SANDBOX
+ help
+ If this option is enabled, the device tree will be provided by
+ the board at runtime if the board supports it, instead of being
+ bundled with the image.
+
config OF_HOSTFILE
bool "Host filed DTB for DT control"
depends on SANDBOX
diff --git a/include/fdtdec.h b/include/fdtdec.h
index d074478f14..5c54f71458 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -1015,4 +1015,10 @@ int fdtdec_setup_memory_banksize(void);
*/
int fdtdec_setup(void);
+/**
+ * Board-specific FDT initialization. Returns the address to a device tree blob.
+ * Called when CONFIG_OF_BOARD is defined.
+ */
+void *board_fdt_blob_setup(void);
+
#endif
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 81f47ef2c7..2e1beb545b 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1247,6 +1247,9 @@ int fdtdec_setup(void)
/* FDT is at end of image */
gd->fdt_blob = (ulong *)&_end;
# endif
+# elif defined(CONFIG_OF_BOARD)
+ /* Allow the board to override the fdt address. */
+ gd->fdt_blob = board_fdt_blob_setup();
# elif defined(CONFIG_OF_HOSTFILE)
if (sandbox_read_fdt_from_file()) {
puts("Failed to read control FDT\n");
--
2.12.2.564.g063fe858b8-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] Allow boards to initialize the DT at runtime.
2017-04-02 8:25 ` [U-Boot] [PATCH] Allow boards to initialize the DT at runtime Alex Deymo
@ 2017-04-05 10:29 ` Simon Glass
2017-05-10 17:51 ` [U-Boot] " Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2017-04-05 10:29 UTC (permalink / raw)
To: u-boot
Hi Alex,
On 2 April 2017 at 02:25, Alex Deymo <deymo@google.com> wrote:
> In some boards like the Raspberry Pi the initial bootloader will pass
> a DT to the kernel. When using U-boot as such kernel, the board code in
Please use 'U-Boot' consistently.
> U-Boot should be able to provide U-boot with this, already assembled
> device tree blob.
>
> This patch introduces a new config option CONFIG_OF_BOARD to use instead
> of CONFIG_OF_EMBED or CONFIG_OF_SEPARATE which will initialize the DT
> from a board-specific funtion instead of bundling one with U-boot or as
> a separated file. This allows boards like the Raspberry Pi to reuse the
> device tree passed from the bootcode.bin and start.elf firmware
> files, included the run-time selected device tree overlays.
including
>
> Signed-off-by: Alex Deymo <deymo@google.com>
> ---
> README | 8 +++++++-
> board/raspberrypi/rpi/rpi.c | 10 ++++++++++
> doc/README.fdt-control | 4 ++++
> dts/Kconfig | 8 ++++++++
> include/fdtdec.h | 6 ++++++
> lib/fdtdec.c | 3 +++
> 6 files changed, 38 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
This seems reasonable to me. My only concern is that when U-Boot is
updated the device tree may need to be updated also (e.g. to add a new
driver). But probably that happens anyway.
Where is the DT provided? Is it a separate file on the SD card?
- Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] Allow boards to initialize the DT at runtime.
2017-04-02 8:25 ` [U-Boot] [PATCH] Allow boards to initialize the DT at runtime Alex Deymo
2017-04-05 10:29 ` Simon Glass
@ 2017-05-10 17:51 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2017-05-10 17:51 UTC (permalink / raw)
To: u-boot
On Sun, Apr 02, 2017 at 01:25:20AM -0700, Alex Deymo wrote:
> In some boards like the Raspberry Pi the initial bootloader will pass
> a DT to the kernel. When using U-boot as such kernel, the board code in
> U-Boot should be able to provide U-boot with this, already assembled
> device tree blob.
>
> This patch introduces a new config option CONFIG_OF_BOARD to use instead
> of CONFIG_OF_EMBED or CONFIG_OF_SEPARATE which will initialize the DT
> from a board-specific funtion instead of bundling one with U-boot or as
> a separated file. This allows boards like the Raspberry Pi to reuse the
> device tree passed from the bootcode.bin and start.elf firmware
> files, included the run-time selected device tree overlays.
>
> Signed-off-by: Alex Deymo <deymo@google.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
After doing the rewords Simon suggested, applied to u-boot/master,
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/20170510/ce77d783/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-10 17:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <98c581b7b5c318c1e5eeac63c8a73c6e63c476cf>
2017-04-02 8:25 ` [U-Boot] [PATCH] Allow boards to initialize the DT at runtime Alex Deymo
2017-04-05 10:29 ` Simon Glass
2017-05-10 17:51 ` [U-Boot] " Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.