@@ -63,7 +63,7 @@ static void resolve_overlays(struct dt_info *dti)
struct overlay *o = dti->overlays;
while (o) {
- apply_overlay(dti->dt, o);
+ apply_overlay(dti->dt, o, dti->dtsflags);
o = o->next;
}
}
@@ -216,7 +216,8 @@ void append_to_property(struct node *node,
struct overlay *build_overlay(char *target, struct node *dt);
struct overlay *chain_overlay(struct overlay *first, struct overlay *list);
-void apply_overlay(struct node *base, struct overlay *overlay);
+void apply_overlay(struct node *base, struct overlay *overlay,
+ unsigned int dtsflags);
const char *get_unitname(struct node *node);
struct property *get_property(struct node *node, const char *propname);
@@ -331,14 +331,46 @@ struct overlay *chain_overlay(struct overlay *first, struct overlay *list)
return first;
}
-void apply_overlay(struct node *base, struct overlay *overlay)
+static void add_fragment(struct node *base, struct overlay *overlay)
{
- struct node *target = get_node_by_ref(base, overlay->target);
+ static unsigned int next_fragment = 0;
+ struct node *node;
+ struct property *p;
+ struct data d = empty_data;
+ char *name;
- if (!target)
- die("Couldn't find label or path %s for overlay\n",
+ if (!overlay->dt)
+ die("Deletions not supported at runtime for %s\n",
overlay->target);
+ /* Insert a target = <&phandle> property */
+ d = data_add_marker(d, REF_PHANDLE, overlay->target);
+ d = data_append_integer(d, 0xffffffff, 32);
+
+ p = build_property("target", d);
+
+ xasprintf(&name, "fragment@%u", next_fragment++);
+ name_node(overlay->dt, "__overlay__");
+ node = build_node(p, overlay->dt);
+ name_node(node, name);
+
+ add_child(base, node);
+}
+
+void apply_overlay(struct node *base, struct overlay *overlay,
+ unsigned int dtsflags)
+{
+ struct node *target = get_node_by_ref(base, overlay->target);
+
+ if (!target) {
+ if (dtsflags & DTSF_PLUGIN) {
+ add_fragment(base, overlay);
+ return;
+ } else
+ die("Couldn't find label or path %s for overlay\n",
+ overlay->target);
+ }
+
if (!overlay->dt)
/* Deletion */
delete_node(target);
Instead of writing overlays with the target property and __overlay__ node, i.e. fragment@0 { target = <&foo>; __overlay__ { bar-property = <0x200>; }; } support the syntactic sugar version of overlays where this can be written as &foo { bar-property = <0x200>; }; and have dtc convert that into a fragment node. Based on a patch by Pantelis Antoniou. Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> --- dtc.c | 2 +- dtc.h | 3 ++- livetree.c | 40 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 6 deletions(-) -- 2.10.0.297.gf6727b0