[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200920095724.8251-2-ansuelsmth@gmail.com>
Date: Sun, 20 Sep 2020 11:57:19 +0200
From: Ansuel Smith <ansuelsmth@...il.com>
To: Miquel Raynal <miquel.raynal@...tlin.com>
Cc: Ansuel Smith <ansuelsmth@...il.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>,
Rob Herring <robh+dt@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Frank Rowand <frowand.list@...il.com>,
Boris Brezillon <bbrezillon@...nel.org>,
linux-mtd@...ts.infradead.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: [PATCH v3 1/4] mtd: Add nvmem support for mtd nvmem-providers
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 <ansuelsmth@...il.com>
---
drivers/mtd/mtdcore.c | 3 ++-
drivers/mtd/parsers/ofpart.c | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 7d930569a7df..ba5236db8318 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -551,6 +551,7 @@ static int mtd_nvmem_reg_read(void *priv, unsigned int offset,
static int mtd_nvmem_add(struct mtd_info *mtd)
{
+ struct device_node *mtd_node = mtd_get_of_node(mtd);
struct nvmem_config config = {};
config.id = -1;
@@ -563,7 +564,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) {
--
2.27.0
Powered by blists - more mailing lists