From patchwork Tue Jan 31 00:02:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 92921 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1691887qgi; Mon, 30 Jan 2017 16:04:40 -0800 (PST) X-Received: by 10.99.231.5 with SMTP id b5mr27131085pgi.80.1485821080715; Mon, 30 Jan 2017 16:04:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si9687456pgk.293.2017.01.30.16.04.40; Mon, 30 Jan 2017 16:04:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932277AbdAaAEi (ORCPT + 25 others); Mon, 30 Jan 2017 19:04:38 -0500 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34537 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754574AbdAaAEC (ORCPT ); Mon, 30 Jan 2017 19:04:02 -0500 Received: by mail-pf0-f171.google.com with SMTP id e4so95133361pfg.1 for ; Mon, 30 Jan 2017 16:03:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fvlQgYgs8qDLY8BrK2ElW6L5f4JpMLu0wEGpp+zmDNE=; b=exf/NsKO5Z0+PSMe2bZN03uskbztXZ855v7n4ixj8syPcDcTHpV6tPUTSXPEzNlwc+ wjUZC8VjMjkTbkRWCHeMEZ1JGLZGH8X7iO2j9gVpODRhPQp4z84EFgIoIMrDjVlUBVZj qWGWzjOz0htJCrwuxgPjsgrTDeU9P+ttCPrPc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fvlQgYgs8qDLY8BrK2ElW6L5f4JpMLu0wEGpp+zmDNE=; b=AofMt3Ndy33RF+YcKVDIsyhKeWUbaXQCShq8Cdsgk3dGTSSxPaqtKUTAbOXe2XukbD Ojjc82WWhMFbfc7xulu0beEMlalgTXr1i47zpG8Pmrs1MWt8htLRy4zYc/Nc0cthQP9F yo7LxxfpTkZvexDmMA3fUPMrsmsGlOr6LpdvGQcrtflhjBCNV6OpjTYRop88VvY3Nvss iF3eEReqd6JMOBvKqDg/kJ5Zp2B3aeXdPaie928DJdxx1nMWnaJy1mxXZDToJmnHJGZK ysghpRX6vuv9KxrPJc5tCk+u+kJ8RcuP87UCS/wOhqToVCIm0jTutQp55IBVIddaSa7f /06g== X-Gm-Message-State: AIkVDXIfGubMKl4WaUaoHs1EXHTP5dKEBrUFW+r6ZxtP5M0ETeFeX82+XykorPo+JpFPpZ/k X-Received: by 10.98.159.80 with SMTP id g77mr25901063pfe.34.1485820984192; Mon, 30 Jan 2017 16:03:04 -0800 (PST) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id e189sm35301942pfg.64.2017.01.30.16.03.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Jan 2017 16:03:03 -0800 (PST) From: Stephen Boyd To: David Gibson Cc: devicetree-compiler@vger.kernel.org, Frank Rowand , Pantelis Antoniou , Rob Herring , Mark Brown , Grant Likely , Mark Rutland , mporter@konsulko.com, Koen Kooi , Guenter Roeck , marex@denx.de, Wolfram Sang , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [RFC/PATCH 2/4] dtc: Add syntactic sugar version of overlays Date: Mon, 30 Jan 2017 16:02:57 -0800 Message-Id: <20170131000259.28576-3-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.10.0.297.gf6727b0 In-Reply-To: <20170131000259.28576-1-stephen.boyd@linaro.org> References: <20170131000259.28576-1-stephen.boyd@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Stephen Boyd --- dtc.c | 2 +- dtc.h | 3 ++- livetree.c | 40 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 6 deletions(-) -- 2.10.0.297.gf6727b0 diff --git a/dtc.c b/dtc.c index 91e4c18b891e..d52d6c77a8cd 100644 --- a/dtc.c +++ b/dtc.c @@ -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; } } diff --git a/dtc.h b/dtc.h index c4eb6421eabf..be75aac1f185 100644 --- a/dtc.h +++ b/dtc.h @@ -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); diff --git a/livetree.c b/livetree.c index dd51223d1e61..798a87ed587e 100644 --- a/livetree.c +++ b/livetree.c @@ -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);