From patchwork Sat Sep 19 21:49:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1367734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=kewb96vM; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=KlCSprJF; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bv4CW3nX5z9sSf for ; Sun, 20 Sep 2020 07:51:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qhQn2p80SPGfziJtZ150ax+oCFKFbFbBDp0SOXqaSDE=; b=kewb96vM0sM3L7ne9yl1BzR5G DxjWI7Lpz3CzTJ8Lsph9ixZ/oWN/Lx/2WKzCrxzOxl8Ide0MoTq7ZQvWO7ybq59BHeeh+b0pxl6Ik S3YH7mleCCZAo9dlsjiw/KJ8kBVa9gxzUs7KSVv5vMuMHx9/HPoOwyyUDzSVJnksAExnRriJDXlMR 5FMoLDS1FtCSBM8Xb3dce7Y90iiWzKgCV9OaGwO6Y9sqzOCPwcDfjnzu7DdayH5S0ZPRKQsh/OB6p zzZss+pKURGvVIuNPaq9lVsUw97rCjc10ZLd8JpPnL5nBySTAaYjrGRsNR8R7DtHynEHpP3jJlXjS qvHOH4gwg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJkkH-000175-38; Sat, 19 Sep 2020 21:50:13 +0000 Received: from mail-qv1-xf41.google.com ([2607:f8b0:4864:20::f41]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJkkE-000167-BM for linux-mtd@lists.infradead.org; Sat, 19 Sep 2020 21:50:11 +0000 Received: by mail-qv1-xf41.google.com with SMTP id p15so5160983qvk.5 for ; Sat, 19 Sep 2020 14:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hyRAlrt8J6BGlNyQOPrEJ5kGgAcwiPINvnfltt15A0M=; b=KlCSprJFAYfexEQg5FWirXfcWfQ7Dssd4Z5GWMsER+Erc+tZ4xAmd3Z++pS6A7Ogjo zG7k8aef9k1RxhUgu+PWGFEHevbbzGItxaJXRnasSqPxiE2LI7Ox3iRbxChBk3i7K0nK wyC111ojbfSdw3lIshtIpzFzU4lq2cqijwLtT/HuE8wVJJaWxYIu0rZFGVNtbyS4mlK2 VRX5yidQC9OS/PuV7njjiX3TvO+n4bD3SN274PCIQS9Q4Us1yksgKqm9+tkmGg9hxfFQ tBBPMqpGRzUR4jK8Wpc+rpnOEpxhddr2Y0j+vUVTG6PjSbWFCVGSNJbV1CJ/2jfAAwIU W+YQ== 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:mime-version:content-transfer-encoding; bh=hyRAlrt8J6BGlNyQOPrEJ5kGgAcwiPINvnfltt15A0M=; b=DAIgvQcZeizvNGzbu5/MZG039DoDw4dGEfUKPyqF0os/Ql7M1QbkfVzL3AY8x+DF7z FYrOKAgbLkQeA67blOtAHAdJ3v65mbMCAj7z8UaTJiMjrN9HXSVoOu1Ri/s3KQwFUv8b gHBI4oXkKd6q9MXP0k/V5Z4n9pZG8XSAeVSSK9CUP91TNjBfnsv4+AZ6jNstmdURbEoP N2sujpD6THjY1eWblLh5Zi43qaMKpMCaQXGwJSn2khSKnasvMh5XHipbgxCjqs7z0ttG wGZgt0HSAhzVeUVTVh5kIuot1GfZaA+QaFcbjISTFixPdGNgNszgElosiuLtVxzhDylW oh2w== X-Gm-Message-State: AOAM532MfDVLY4olm1Qz6jMa+1hk6Ax0iZtuIJdN/np+CamKfqahPr8z +CeDViIhHIaHb+yyw0FH/AM= X-Google-Smtp-Source: ABdhPJzzXrVOQ6yFroXqTSfpgunJbma6nmp/ttKWAwgCKfrT4Ttp/rSZO7OEp7oKZvpP+UQUEcXFFQ== X-Received: by 2002:a05:6214:7a1:: with SMTP id v1mr40316823qvz.19.1600552208970; Sat, 19 Sep 2020 14:50:08 -0700 (PDT) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id y30sm5617173qth.7.2020.09.19.14.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 14:50:08 -0700 (PDT) From: Ansuel Smith To: Miquel Raynal Subject: [PATCH 1/4] mtd: Add nvmem support for mtd nvmem-providers Date: Sat, 19 Sep 2020 23:49:35 +0200 Message-Id: <20200919214941.8038-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200919214941.8038-1-ansuelsmth@gmail.com> References: <20200919214941.8038-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200919_175010_414247_A61B2805 X-CRM114-Status: GOOD ( 17.23 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:f41 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Vignesh Raghavendra , Boris Brezillon , Richard Weinberger , Russell King , Ansuel Smith , devicetree@vger.kernel.org, Rob Herring , linux-mtd@lists.infradead.org, netdev@vger.kernel.org, Jakub Kicinski , Frank Rowand , "David S. Miller" , linux-kernel@vger.kernel.org, Heiner Kallweit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Introduce 2 new bindings for the mtd structure. Mtd partitions can be set as 'nvmem-provider' and any subpartition defined with the tag 'nvmem-cell' are skipped by the 'fixed-partitions' parser and registred as a nvmem cell by the nvmem api. Signed-off-by: Ansuel Smith --- drivers/mtd/mtdcore.c | 2 +- drivers/mtd/parsers/ofpart.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 7d930569a7df..72502c990007 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -563,7 +563,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd) config.stride = 1; config.read_only = true; config.root_only = true; - config.no_of_node = true; + config.no_of_node = !of_property_read_bool(mtd_node, "nvmem-provider"); config.priv = mtd; mtd->nvmem = nvmem_register(&config); diff --git a/drivers/mtd/parsers/ofpart.c b/drivers/mtd/parsers/ofpart.c index daf507c123e6..442e039214bc 100644 --- a/drivers/mtd/parsers/ofpart.c +++ b/drivers/mtd/parsers/ofpart.c @@ -61,6 +61,10 @@ static int parse_fixed_partitions(struct mtd_info *master, if (!dedicated && node_has_compatible(pp)) continue; + /* skip adding if a nvmem-cell is detected */ + if (of_property_read_bool(pp, "nvmem-cell")) + continue; + nr_parts++; } @@ -80,6 +84,10 @@ static int parse_fixed_partitions(struct mtd_info *master, if (!dedicated && node_has_compatible(pp)) continue; + /* skip adding if a nvmem-cell is detected */ + if (of_property_read_bool(pp, "nvmem-cell")) + continue; + reg = of_get_property(pp, "reg", &len); if (!reg) { if (dedicated) { From patchwork Sat Sep 19 21:49:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1367732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=XXumbvgX; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=fy3PsG2b; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bv4C91Q5bz9sSC for ; Sun, 20 Sep 2020 07:51:01 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OocQAtEJsxvWGTC6kd85Cr1Gk6j8sF2EUstj+DSYEC4=; b=XXumbvgXx47yMkFqkCA9Wo9g+ G+f6JRtL2KX4jqdf9/KqcdMELKkepzO3sUqLz4g8G18b5vOYl2qMf3RW1Offh+dEaY7GgwRPMA3jE R6Gk2a8FgJJGsMvibMCiFA3g84sewLcOK2aeh4pJlhZSrCF9AvRJe3InDLKYQJcHgYQsbrFKboEbi uKLKozLySXUdYiZiJ9t+AlyCKc66eMVvB5+D2fgemgeD1hu9rX7H4JrKPytd5HjVTlAzygUZBVGg2 NgM4wdON7zsT/3HAAlNi0jIOEb7hAgBz66N9fGgICbu4/CErzWNM1O1Ca9Ks62Zof3DaZfDpOL5fx FE3GT2Gvg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJkkO-00019F-K9; Sat, 19 Sep 2020 21:50:20 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJkkM-00017x-0g for linux-mtd@lists.infradead.org; Sat, 19 Sep 2020 21:50:18 +0000 Received: by mail-qt1-x841.google.com with SMTP id g3so8743540qtq.10 for ; Sat, 19 Sep 2020 14:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=64xYu3WDX6vWiceRdxZMl2E+VlBih2IULY9GL5lmn0U=; b=fy3PsG2bT7uohMvad4KwkkOj8iV/lS4dBm65Agal/vyFJipHQfJyxHAOYdpYC/5dnF RJ5lvHF1Vdq/k67RmOI7ddD3lM2Blo9bRdqEFXd3SaKqlcMRlaVKf/g7N+qByN3KuIws zaMZvd8JkeZRa2o23W62yla6fAqqeIcdYmbrYNq5E847448d24bVe3VnJkudo1nyUlOr gbRZEJEFYqgmetLHxXt1JmvmThSdG8sPpXaLPaHjq20DSvNrpFr1rlSM9TSJkP6ZgdBg nk2/BoyyxGu+v2gkw7qa+YihGgyZWZ2gQCZdptV1dgJCtFTBuFdoQiVB2xkaRK+kHwLV FOzQ== 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:mime-version:content-transfer-encoding; bh=64xYu3WDX6vWiceRdxZMl2E+VlBih2IULY9GL5lmn0U=; b=XDAdB9yKZwO5WTYmlbg6K2uz6xPgFPrMAvzRNDpO/SS86epPBhxKzRyha1cuFtJmRS PwhmefhN3XkHI7W1sUSOWu+hjTZPXcv2wy6iUNIDWlK2hSuvZvD8I7nyjJQxO40wo15I jGNdx8HXFDnFnDOwOzcjRuchFexBsYNYtP4SOjYwvy7mlH6PxpC1azTsH/PSAvgaGSnU AGt+Y7fv0ugALLQ2GU8mGP3k82OIaToSeA+W27ZA8YouJJtb3qEM9gpVnDT8NQG3XBHo 1b06Sn3frM6yHY5DEt5Y36elmR0CwX9ati2ghFemdTSwDkbkiAXTHRWWqZFpSjtlNutf mBZg== X-Gm-Message-State: AOAM530OeYGEGr0XSNnxz8PVBBOWxziEondQNRWHPApLTo26l2ZRwsPL QFLd5s56q7M2bVXJu3qwuMs= X-Google-Smtp-Source: ABdhPJwgPfl2zBW0ecdIfpAx8GltCRo8+hWIFLCjALXeEBPL0tomHMI3q6S9Nt1+Xjv61eWvu5/sxA== X-Received: by 2002:ac8:1b92:: with SMTP id z18mr38396682qtj.265.1600552215409; Sat, 19 Sep 2020 14:50:15 -0700 (PDT) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id y30sm5617173qth.7.2020.09.19.14.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 14:50:14 -0700 (PDT) From: Ansuel Smith To: Miquel Raynal Subject: [PATCH 2/4] dt-bindings: mtd: partition: Document use of nvmem-provider Date: Sat, 19 Sep 2020 23:49:36 +0200 Message-Id: <20200919214941.8038-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200919214941.8038-1-ansuelsmth@gmail.com> References: <20200919214941.8038-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200919_175018_085701_27DD6C80 X-CRM114-Status: GOOD ( 16.79 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:841 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Vignesh Raghavendra , Boris Brezillon , Richard Weinberger , Russell King , Ansuel Smith , devicetree@vger.kernel.org, Rob Herring , linux-mtd@lists.infradead.org, netdev@vger.kernel.org, Jakub Kicinski , Frank Rowand , "David S. Miller" , linux-kernel@vger.kernel.org, Heiner Kallweit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Document the use of this 2 new bindings, nvmem-provider and nvmem-cell, used to describe the nvmem cell that the subpartition provide to the nvmem api and the system. Nvmem cell are direct subnode of the subpartition and are skipped by the 'fixed-partitions' parser if they contain the 'nvmem-cell' tag. The subpartition must have the 'nvmem-provider' tag or the subpartition will not register the cell to the nvmem api. Signed-off-by: Ansuel Smith --- .../devicetree/bindings/mtd/partition.txt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Documentation/devicetree/bindings/mtd/partition.txt b/Documentation/devicetree/bindings/mtd/partition.txt index 4a39698221a2..66d3a3f0a021 100644 --- a/Documentation/devicetree/bindings/mtd/partition.txt +++ b/Documentation/devicetree/bindings/mtd/partition.txt @@ -64,6 +64,16 @@ Optional properties: - slc-mode: This parameter, if present, allows one to emulate SLC mode on a partition attached to an MLC NAND thus making this partition immune to paired-pages corruptions +- nvmem-provider : Optionally a subpartition can be set as a nvmem-provider. This can + be very useful if some data like the mac-address is stored in a special partition + at a specific offset. Subpartition that describe nvmem-cell must have set the + 'nvmem-cell' of they will be treated as a subpartition and not skipped and registred + as nvmem cells. In this specific case '#address-cells' and '#size-cells' must be + provided. +- nvmem-cell : A direct subnode of a subpartition can be described as a nvmem-cell and + skipped by the fixed-partition parser and registred as a nvmem-cell of the registred + nvmem subpartition IF it does contain the 'nvmem-provider tag. If the subpartition + lacks of such tag the subnode will be skipped and the nvmem api won't register them. Examples: @@ -158,3 +168,52 @@ flash@3 { }; }; }; + +flash@0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0000000 0x100000>; + read-only; + }; + + art: art@1200000 { + label = "art"; + reg = <0x1200000 0x0140000>; + read-only; + nvmem-provider; + + #address-cells = <1>; + #size-cells = <1>; + + macaddr_gmac1: macaddr_gmac1@0 { + nvmem-cell; + reg = <0x0 0x6>; + }; + + macaddr_gmac2: macaddr_gmac2@6 { + nvmem-cell; + reg = <0x6 0x6>; + }; + + macaddr_wifi: macaddr_wifi@6 { + nvmem-cell; + reg = <0x6 0x6>; + }; + + pre_cal_24g: pre_cal_24g@1000 { + nvmem-cell; + reg = <0x1000 0x2f20>; + }; + + pre_cal_5g: pre_cal_5g@5000{ + nvmem-cell; + reg = <0x5000 0x2f20>; + }; + }; + }; +}; \ No newline at end of file From patchwork Sat Sep 19 21:49:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1367735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=GZbMvaBl; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=U8LI48rR; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bv4Cb0QG4z9sSf for ; Sun, 20 Sep 2020 07:51:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CduxL7fTSO4Mmj9b+rYzUmNSq8ldsFVl0cbP7T5SvEs=; b=GZbMvaBlCqFF7+8jQne4bAQhx AGA7RdLx7FGzabaLPvKNQwRg4cQj909b84hNX5zEBrzgPkCO+bL5KwvRId2BERfDdM43/R4qTnVw4 R6bYFoeahqIoAtXmUFPK+dqnYQll8cUac/dtE57HzYR3OrLdejR/r0BqCZ3nOxMY0zEGddY4A9r+r VeWwJ/DqLFc/EnIae6V+MrZjOC46yglFeoKw3DakqlWoQ2pGxGoUGF4ClQ4xjr8GKcj1Xjc6NxbHx XgTzob/4gQITYTyOCx57xr84Jg69t+lswbYUICGJgQ77k3sqdJOmKbiwcUWCQR4GYiPeWIn21GBx/ G00lArqBQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJkkU-0001Ay-C4; Sat, 19 Sep 2020 21:50:26 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJkkR-00019j-BK for linux-mtd@lists.infradead.org; Sat, 19 Sep 2020 21:50:24 +0000 Received: by mail-qt1-x842.google.com with SMTP id g3so8743674qtq.10 for ; Sat, 19 Sep 2020 14:50:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k1VC0bLlr113eP4lGbVnwgieBOJkCTeFf8AM/n1gCow=; b=U8LI48rRoQ0BNaq/0glBW062pD8MZrTYTvy/3foXyL5w6WWpdS8j36wgieP+aBXniL urWZgZH3PVZR2BShpIPxK5/ikPx0+Ej+jyU8kdAuQ72un7OSmp213kFpS8quMPAfXb08 LbkcpXe4OghpMl7cB8OrZnIWKXfawwSwK4VYoWx0Kzz491nhd93wTxsYS7lxsqPkXI5r 9fJRCzHtWOF4WsK+0bd1g8R2ry3BCupcE9ss4h2u0z5lG5SrVTEHQQI3iQNKu7CrH4FD snCSzkIBxlN5zNnlM+Jyz21zERoOf1jmXFd/fDpPiJkRI8gAlHmYQ6R1ha3EgILMa+8a q+Pw== 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:mime-version:content-transfer-encoding; bh=k1VC0bLlr113eP4lGbVnwgieBOJkCTeFf8AM/n1gCow=; b=AxyI/r3FvrGlu1P/GdPKCKWnnlFvf1422FpqKXbf0AC5QlWotJ2huvb8jw50iiYhpG RJL52vO7eaQ+Au2KcefS10Z9PwTnawzQO2CTswwowdOWdQzrNKFkgNZ5JHxcKDay5C8U +T+MkOcSpv1zIPWhjzF2Y/D1wJ4nKYdCdgnfv4yhaUcUJRg7yDDrIRREj1KARghs0Wj6 rOn+rHb3V2YMfOHMbOefqxXQnnIA/pbCa9CqVwkSyJESNF47PWWZ0Be8ab4zFpY7HQfi lSYuhIr/A1HUx4ct3cI+iMEnjIM3j702RzD5hZKBkrXjRsfiafbQwL5DioW0QR6/nhrI laJg== X-Gm-Message-State: AOAM533rt5st97cKTXJwZTBEs4dvTWE/eNBX7IY2oZcDwFZHLE0d1jbb lSOu+ttNG6KFTkbqw6rN7Pc= X-Google-Smtp-Source: ABdhPJyYjOvZzcZByFP1j9EZs5L9ROCR3emit/oZDgW1eNjXNxKNUpXLU6/l5dj2ZVgUKNJecB8YXA== X-Received: by 2002:ac8:7b95:: with SMTP id p21mr38680074qtu.139.1600552221500; Sat, 19 Sep 2020 14:50:21 -0700 (PDT) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id y30sm5617173qth.7.2020.09.19.14.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 14:50:20 -0700 (PDT) From: Ansuel Smith To: Miquel Raynal Subject: [PATCH 3/4] of_net: add mac-address-increment support Date: Sat, 19 Sep 2020 23:49:37 +0200 Message-Id: <20200919214941.8038-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200919214941.8038-1-ansuelsmth@gmail.com> References: <20200919214941.8038-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200919_175023_446785_78892DAD X-CRM114-Status: GOOD ( 22.52 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:842 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Vignesh Raghavendra , Boris Brezillon , Richard Weinberger , Russell King , Ansuel Smith , devicetree@vger.kernel.org, Rob Herring , linux-mtd@lists.infradead.org, netdev@vger.kernel.org, Jakub Kicinski , Frank Rowand , "David S. Miller" , linux-kernel@vger.kernel.org, Heiner Kallweit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Lots of embedded devices use the mac-address of other interface extracted from nvmem cells and increments it by one or two. Add two bindings to integrate this and directly use the right mac-address for the interface. Some example are some routers that use the gmac mac-address stored in the art partition and increments it by one for the wifi. mac-address-increment-byte bindings is used to tell what byte of the mac-address has to be increased (if not defined the last byte is increased) and mac-address-increment tells how much the byte decided early has to be increased. Signed-off-by: Ansuel Smith --- drivers/of/of_net.c | 53 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c index 6e411821583e..171f5ea6f371 100644 --- a/drivers/of/of_net.c +++ b/drivers/of/of_net.c @@ -45,7 +45,7 @@ int of_get_phy_mode(struct device_node *np, phy_interface_t *interface) } EXPORT_SYMBOL_GPL(of_get_phy_mode); -static const void *of_get_mac_addr(struct device_node *np, const char *name) +static void *of_get_mac_addr(struct device_node *np, const char *name) { struct property *pp = of_find_property(np, name, NULL); @@ -54,26 +54,31 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name) return NULL; } -static const void *of_get_mac_addr_nvmem(struct device_node *np) +static void *of_get_mac_addr_nvmem(struct device_node *np, int *err) { int ret; const void *mac; u8 nvmem_mac[ETH_ALEN]; struct platform_device *pdev = of_find_device_by_node(np); - if (!pdev) - return ERR_PTR(-ENODEV); + if (!pdev) { + *err = -ENODEV; + return NULL; + } ret = nvmem_get_mac_address(&pdev->dev, &nvmem_mac); if (ret) { put_device(&pdev->dev); - return ERR_PTR(ret); + *err = ret; + return NULL; } mac = devm_kmemdup(&pdev->dev, nvmem_mac, ETH_ALEN, GFP_KERNEL); put_device(&pdev->dev); - if (!mac) - return ERR_PTR(-ENOMEM); + if (!mac) { + *err = -ENOMEM; + return NULL; + } return mac; } @@ -98,24 +103,48 @@ static const void *of_get_mac_addr_nvmem(struct device_node *np) * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists * but is all zeros. * + * DT can tell the system to increment the mac-address after is extracted by + * using: + * - mac-address-increment-byte to decide what byte to increase + * (if not defined is increased the last byte) + * - mac-address-increment to decide how much to increase + * * Return: Will be a valid pointer on success and ERR_PTR in case of error. */ const void *of_get_mac_address(struct device_node *np) { - const void *addr; + u32 inc_idx, mac_inc; + int ret = 0; + u8 *addr; + + /* Check first if the increment byte is present and valid. + * If not set assume to increment the last byte if found. + */ + if (of_property_read_u32(np, "mac-address-increment-byte", &inc_idx)) + inc_idx = 5; + if (inc_idx > 5) + return ERR_PTR(-EINVAL); addr = of_get_mac_addr(np, "mac-address"); if (addr) - return addr; + goto found; addr = of_get_mac_addr(np, "local-mac-address"); if (addr) - return addr; + goto found; addr = of_get_mac_addr(np, "address"); if (addr) - return addr; + goto found; + + addr = of_get_mac_addr_nvmem(np, &ret); + if (ret) + return ERR_PTR(ret); + +found: + if (!of_property_read_u32(np, "mac-address-increment", &mac_inc)) + addr[inc_idx] += mac_inc; - return of_get_mac_addr_nvmem(np); + return addr; } EXPORT_SYMBOL(of_get_mac_address); From patchwork Sat Sep 19 21:49:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1367733 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=mQw7zqzi; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=a1U4iKqh; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bv4CH5Bt4z9sSC for ; Sun, 20 Sep 2020 07:51:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LDaVBP/aqGK5Zs8ksYniIL5nmiiqmQKNqm6Uo+Q7CX4=; b=mQw7zqzieR7v6kzFx3VqB0VPq HYLomUi2QbSBxUj4dzG8bMWDwRrfh9wr+S67ZH5riVlRS8FtHrjQg+qWlp7F95CdxOz10KtOmxXNu QyeJMK0Mn2Jw25yq/AtY08b2Q5MKZJ7V2i+zNsV6qZn0wL8dpK2kaOZyGj6ugLdSxI6IFYICII9/w w6FL2LSyCxymPY3N1XbLk2MfzTCNpvje1frK4nUsk+lOZ5meV/Oe1KRs/M96VaWYwLtODzOkjwANh wWdjxJYWNPPHldG9lmRf++gtQzoqQQUsbKSMVfkXAaKSaAPK/stlA77bPwKE9MIlVJME8DYtYTtsY QLcd3y2QQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJkka-0001Cj-3g; Sat, 19 Sep 2020 21:50:32 +0000 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJkkX-0001BZ-HE for linux-mtd@lists.infradead.org; Sat, 19 Sep 2020 21:50:30 +0000 Received: by mail-qt1-x82c.google.com with SMTP id c18so8773684qtw.5 for ; Sat, 19 Sep 2020 14:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FuUvgB8iMkHgcxvxhIPaKesqPeUDTnfXOpNMPbDpmVY=; b=a1U4iKqhfo4da2k6ZMM0pR3UEwpnjniDmb2MM9Ml7eYFtKSG4Ku8nDDx02mS0ysf2A zF/Qo8LRemksaeTJtLkCO/1e4oaYQkSd/Mq96dFWTLkuHfeZomuha1g9UvL00j+KtoiC 4+1mLqqxrZQ0iIHLNOek3O/spp6usolVcdXfQiiF7AgnDINl43oRQkvU0zOn+qfLV26v Cy1O5i5hjsOxWwUU3B2y4YyWmkwtnpmBZLCj2p4XMorJOR+FLW87mes8h6mmchPMvkRW y20p00TJNqCjG6hF0BEoTGUnoAC67gPkqPQ7qavyHjQGWvTp40Vf3WIl9VE2L1aeFCGg KRdQ== 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:mime-version:content-transfer-encoding; bh=FuUvgB8iMkHgcxvxhIPaKesqPeUDTnfXOpNMPbDpmVY=; b=pM0/f1mUn0ot/T4FAjJ5gAhIAbnEBb0LEBwOURgUz+z3DjDzYEW2tTom7XQc2rNhMC JuwPplUvGWdFh86UlyPGKdzT26xDFM0NcNnE818dx4LnN0YKdmM6Q1atkER7nY7CGJnn 1fpLwyppKDkU0TR/9KPPZukDCeuImcsVnZ09sL3Y4qXFmfObXEg4XC1yUUv0Aa0wG00n eAny8Rq58m89TWPcSTmr/RW49vq9U+zH+CO33ZB3VHw6FAdk2gv/Z3C8ZfEiUO4cX5+Z 8jcZZInYMTRfYX9rNtLshxGNsXzeVmmOccIeamXSrzkXJUh1/Ax5QKJr0UMQDFABwLDA RBlQ== X-Gm-Message-State: AOAM530FHUvUx+ICMK24PPh1OWoB+l8jwaSIN9Gz3ndsTH76D3QPK+XJ VepOsOv0Jzeqew5K5sMSPMc= X-Google-Smtp-Source: ABdhPJzma4TX4Rjz79pVVDKKfg+gBUBcVH8tV+LWgy9AVIm0GMUcqLSOQvPA8LlC72BFBXfESKGGTg== X-Received: by 2002:ac8:409e:: with SMTP id p30mr37958612qtl.208.1600552227678; Sat, 19 Sep 2020 14:50:27 -0700 (PDT) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id y30sm5617173qth.7.2020.09.19.14.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 14:50:27 -0700 (PDT) From: Ansuel Smith To: Miquel Raynal Subject: [PATCH 4/4] dt-bindings: net: Document use of mac-address-increment Date: Sat, 19 Sep 2020 23:49:38 +0200 Message-Id: <20200919214941.8038-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200919214941.8038-1-ansuelsmth@gmail.com> References: <20200919214941.8038-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200919_175029_659414_103C66EC X-CRM114-Status: GOOD ( 17.38 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:82c listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Vignesh Raghavendra , Boris Brezillon , Richard Weinberger , Russell King , Ansuel Smith , devicetree@vger.kernel.org, Rob Herring , linux-mtd@lists.infradead.org, netdev@vger.kernel.org, Jakub Kicinski , Frank Rowand , "David S. Miller" , linux-kernel@vger.kernel.org, Heiner Kallweit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Two new bindings are now supported by the of_net driver to increase (or decrease) a mac-address. This can be very useful in case where the system extract the mac-address for the device from a dedicated partition and have a generic mac-address that needs to be incremented based on the device number. - mac-address-increment-byte is used to tell what byte must be incremented (if not set the last byte is increased) - mac-address-increment is used to tell how much to increment of the extracted mac-address decided byte. Signed-off-by: Ansuel Smith --- .../bindings/net/ethernet-controller.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml index fa2baca8c726..43f2f21faf41 100644 --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml @@ -32,6 +32,25 @@ properties: - minItems: 6 maxItems: 6 + mac-address-increment: + description: + The MAC address can optionally be increased (or decreased using + negative values) from the original value readed (from a nvmem cell + for example). This can be used if the mac is readed from a dedicated + partition and must be increased based on the number of device + present in the system. + minimum: -255 + maximum: 255 + + mac-address-increment-byte: + description: + If 'mac-address-increment' is defined, this will tell what byte of + the mac-address will be increased. If 'mac-address-increment' is + not defined, this option will do nothing. + default: 5 + minimum: 0 + maximum: 5 + max-frame-size: $ref: /schemas/types.yaml#definitions/uint32 description: