1 Device Tree Overlay Notes
2 -------------------------
4 This document describes the implementation of the in-kernel
5 device tree overlay functionality residing in drivers/of/overlay.c and is a
6 companion document to Documentation/devicetree/dt-object-internal.txt[1] &
7 Documentation/devicetree/dynamic-resolution-notes.txt[2]
12 A Device Tree's overlay purpose is to modify the kernel's live tree, and
13 have the modification affecting the state of the kernel in a way that
14 is reflecting the changes.
15 Since the kernel mainly deals with devices, any new device node that result
16 in an active device should have it created while if the device node is either
17 disabled or removed all together, the affected device should be deregistered.
19 Lets take an example where we have a foo board with the following base tree
20 which is taken from [1].
22 ---- foo.dts -----------------------------------------------------------------
25 compatible = "corp,foo";
27 /* shared resources */
31 /* On chip peripherals */
33 /* peripherals that are always instantiated */
37 ---- foo.dts -----------------------------------------------------------------
39 The overlay bar.dts, when loaded (and resolved as described in [2]) should
41 ---- bar.dts -----------------------------------------------------------------
42 /plugin/; /* allow undefined label references and record them */
44 .... /* various properties for loader use; i.e. part id etc. */
50 compatible = "corp,bar";
51 ... /* various properties and child nodes */
56 ---- bar.dts -----------------------------------------------------------------
60 ---- foo+bar.dts -------------------------------------------------------------
61 /* FOO platform + bar peripheral */
63 compatible = "corp,foo";
65 /* shared resources */
69 /* On chip peripherals */
71 /* peripherals that are always instantiated */
76 compatible = "corp,bar";
77 ... /* various properties and child nodes */
81 ---- foo+bar.dts -------------------------------------------------------------
83 As a result of the overlay, a new device node (bar) has been created
84 so a bar platform device will be registered and if a matching device driver
85 is loaded the device will be created as expected.
88 --------------------------------
90 The API is quite easy to use.
92 1. Call of_overlay_create() to create and apply an overlay. The return value
93 is a cookie identifying this overlay.
95 2. Call of_overlay_destroy() to remove and cleanup the overlay previously
96 created via the call to of_overlay_create(). Removal of an overlay that
97 is stacked by another will not be permitted.
99 Finally, if you need to remove all overlays in one-go, just call
100 of_overlay_destroy_all() which will remove every single one in the correct
106 The DTS of an overlay should have the following format:
109 /* ignored properties by the overlay */
111 fragment@0 { /* first child node */
113 target=<phandle>; /* phandle target of the overlay */
115 target-path="/path"; /* target path of the overlay */
118 property-a; /* add property-a to the target */
119 node-a { /* add to an existing, or create a node-a */
124 fragment@1 { /* second child node */
127 /* more fragments follow */
130 Using the non-phandle based target method allows one to use a base DT which does
131 not contain a __symbols__ node, i.e. it was not compiled with the -@ option.
132 The __symbols__ node is only required for the target=<phandle> method, since it
133 contains the information required to map from a phandle to a tree location.