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/dynamic-resolution-notes.txt[1]
11 A Device Tree's overlay purpose is to modify the kernel's live tree, and
12 have the modification affecting the state of the kernel in a way that
13 is reflecting the changes.
14 Since the kernel mainly deals with devices, any new device node that result
15 in an active device should have it created while if the device node is either
16 disabled or removed all together, the affected device should be deregistered.
18 Lets take an example where we have a foo board with the following base tree:
20 ---- foo.dts -----------------------------------------------------------------
23 compatible = "corp,foo";
25 /* shared resources */
29 /* On chip peripherals */
31 /* peripherals that are always instantiated */
35 ---- foo.dts -----------------------------------------------------------------
37 The overlay bar.dts, when loaded (and resolved as described in [1]) should
39 ---- bar.dts -----------------------------------------------------------------
40 /plugin/; /* allow undefined label references and record them */
42 .... /* various properties for loader use; i.e. part id etc. */
48 compatible = "corp,bar";
49 ... /* various properties and child nodes */
54 ---- bar.dts -----------------------------------------------------------------
58 ---- foo+bar.dts -------------------------------------------------------------
59 /* FOO platform + bar peripheral */
61 compatible = "corp,foo";
63 /* shared resources */
67 /* On chip peripherals */
69 /* peripherals that are always instantiated */
74 compatible = "corp,bar";
75 ... /* various properties and child nodes */
79 ---- foo+bar.dts -------------------------------------------------------------
81 As a result of the overlay, a new device node (bar) has been created
82 so a bar platform device will be registered and if a matching device driver
83 is loaded the device will be created as expected.
86 --------------------------------
88 The API is quite easy to use.
90 1. Call of_overlay_create() to create and apply an overlay. The return value
91 is a cookie identifying this overlay.
93 2. Call of_overlay_destroy() to remove and cleanup the overlay previously
94 created via the call to of_overlay_create(). Removal of an overlay that
95 is stacked by another will not be permitted.
97 Finally, if you need to remove all overlays in one-go, just call
98 of_overlay_destroy_all() which will remove every single one in the correct
104 The DTS of an overlay should have the following format:
107 /* ignored properties by the overlay */
109 fragment@0 { /* first child node */
111 target=<phandle>; /* phandle target of the overlay */
113 target-path="/path"; /* target path of the overlay */
116 property-a; /* add property-a to the target */
117 node-a { /* add to an existing, or create a node-a */
122 fragment@1 { /* second child node */
125 /* more fragments follow */
128 Using the non-phandle based target method allows one to use a base DT which does
129 not contain a __symbols__ node, i.e. it was not compiled with the -@ option.
130 The __symbols__ node is only required for the target=<phandle> method, since it
131 contains the information required to map from a phandle to a tree location.