[PATCH 1/3] drivers: of: implement overlay support

Roland Hieber r.hieber at pengutronix.de
Mon Jun 4 04:04:00 PDT 2018


On Sat, Jun 02, 2018 at 09:17:13PM +0000, Pascal Vizeli wrote:
> diff --git a/Documentation/user/devicetree.rst b/Documentation/user/devicetree.rst
> index 17934d86e..b2220997d 100644
> --- a/Documentation/user/devicetree.rst
> +++ b/Documentation/user/devicetree.rst
> @@ -21,7 +21,7 @@ The internal devicetree
>  -----------------------
>  
>  The devicetree consulted by barebox plays a special role. It is referred to
> -as the "internal devicetree." The barebox devicetree commands work on this
> +as the "internal devicetree". The barebox devicetree commands work on this
>  devicetree. The devicetree source (DTS) files are kept in sync with the kernel DTS
>  files. As the FDT files are meant to be backward compatible, it should always be possible
>  to start a kernel with the barebox internal devicetree. However, since the barebox
> @@ -83,3 +83,102 @@ you can exchange the internal devicetree during runtime using the
>  
>     oftree -f
>     oftree -l /new/dtb
> +
> +Devicetree overlays
> +-------------------
> +
> +Since version 3.19, the Linux kernel supports applying "devicetree overlays" to
> +its loaded device tree. This can be used to inform the kernel about additional
> +non-discoverable devices after the system has booted, which is useful for modular
> +boards and FPGAs. The details of the overlay format are specified in the Linux
> +`kernel documentation <https://www.kernel.org/doc/Documentation/devicetree/overlay-notes.txt>`_
> +and an updated DTC is required to compile the overlays.
> +
> +The use cases for overlays in barebox are a bit different:
> +
> +* some of the modular devices are needed to boot Linux to userspace, but barebox
> +  can detect which module variant is connected
> +* one of several parallel or LVDS displays (which use timing data from devicetree)
> +  can be connected to the SoC and should be used for boot messages
> +* a generic Linux (distribution) kernel should be booted on a modular
> +  system and support additional hardware on modules
> +
> +barebox supports applying overlays in the internal devicetree was well using the
> +:ref:`command_oftree` command with option ``-o``:
> +
> +.. code-block:: sh

That highlighting looks weird with mixed languages. I suggest 

  .. code-block:: none

instead. (Ideally, this should also be used for all the other code
blocks on that page, IMO ☺)

 - Roland

> +
> +   $ ./barebox -d arch/sandbox/dts/sandbox.dtb -i arch/sandbox/dts/sandbox-overlay.dtbo
> +   add fd0 backed by file arch/sandbox/dts/sandbox-overlay.dtbo
> +
> +   barebox 2015.02.0 #26 Wed Mar 4 09:41:19 CET 2015
> +   ...
> +   barebox at barebox sandbox:/ of_dump
> +   ...
> +     dummy at 0 {
> +       status = "disabled";
> +       linux,phandle = <0x1>;
> +       phandle = <0x1>;
> +     };
> +     dummy at 1 {
> +       status = "disabled";
> +       linux,phandle = <0x2>;
> +       phandle = <0x2>;
> +     };
> +     __symbols__ {
> +       dummy0 = "/dummy at 0";
> +       dummy1 = "/dummy at 1";
> +     };
> +   ...
> +   barebox at barebox sandbox:/ of_dump -f /dev/fd0
> +    {
> +     fragment at 0 {
> +       target = <0xdeadbeef>;
> +       __overlay__ {
> +         status = "okay";
> +         child {
> +           compatible = "barebox,dummy";
> +         };
> +       };
> +     };
> +     fragment at 1 {
> +       target = <0xdeadbeef>;
> +       __overlay__ {
> +         status = "okay";
> +         child {
> +           compatible = "barebox,dummy";
> +         };
> +       };
> +     };
> +     __fixups__ {
> +       dummy0 = "/fragment at 0:target:0";
> +       dummy1 = "/fragment at 1:target:0";
> +     };
> +   };
> +   barebox at barebox sandbox:/ oftree -o /dev/fd0
> +   barebox at barebox sandbox:/ of_dump
> +   ...
> +     dummy at 0 {
> +       linux,phandle = <0x1>;
> +       phandle = <0x1>;
> +       status = "okay";
> +       child {
> +         compatible = "barebox,dummy";
> +       };
> +     };
> +     dummy at 1 {
> +       linux,phandle = <0x2>;
> +       phandle = <0x2>;
> +       status = "okay";
> +       child {
> +         compatible = "barebox,dummy";
> +       };
> +     };
> +     __symbols__ {
> +       dummy0 = "/dummy at 0";
> +       dummy1 = "/dummy at 1";
> +     };
> +   ...
> +
> +If you need to use a different base devicetree instead of the one compiled into
> +barebox, it needs to be replaced as described in the previous section.

[...]
-- 
Roland Hieber                     | r.hieber at pengutronix.de     |
Pengutronix e.K.                  | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list