From nobody Sat Jun 27 21:21:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AEA8C433EF for ; Sun, 20 Feb 2022 17:39:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244434AbiBTRkJ (ORCPT ); Sun, 20 Feb 2022 12:40:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240625AbiBTRkD (ORCPT ); Sun, 20 Feb 2022 12:40:03 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C68684A92C; Sun, 20 Feb 2022 09:39:41 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id d10so27296705eje.10; Sun, 20 Feb 2022 09:39:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0XdH+UuoTmIJpoL0GQGXlMfGXdvLAhnJy2/X6+fBU+E=; b=I07Ksbcl8KQ5uFjT4EV/NYk5JjRe6BhMypo4Y9zOFfZxj/WZ+eFLJzUTO+RdNclElJ z792NtSF3RMaJPITTBXx4scOOj3/oaD/fUwwOiU7ovbrp3zAm+/av+IxmxSXHBrYqFTG aq0aHI0lg6+E/+La87DONZzagS9sKMTF12snPBFlDEuB0bjwUDnNM81ZUvjtUx3AEzOi xVQ2z3UOkNX/NNPKOyTocVfEuqTSF1i3B56LarHnjBxzsEpf0xM6/HYUwq791e1c6wWv rjzNLaxJi9iUZ17mvsqpMDQemxbALVhawzH3K7srpsoZBACrSf81IvJxJo2lmK5SU0Ry Y/OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0XdH+UuoTmIJpoL0GQGXlMfGXdvLAhnJy2/X6+fBU+E=; b=Lh2/KgZB6NrI3gm6Q17B2crHs6T5kuZrMX5TEyKCocH9dt2bJ9CUN/bIQ+T9sqCnnP LONuAB48FdgIuuWrzJ0LNupzzY53K9u9AroIIVE1vqhuz3Uk979ZJ/KH637zIwO+87UU 7/2d7P0V0oWemgUiCp0FJkVR3H0KLHDhxa5FTK5YRy4JZJaGEbPh/oCkN156U2MlxsSX CAhFYM8JKCEptxSNQBW0WxAgSxiAikp4nnafR0w3UhdpH31SfPhtjaslnT6kqF0Xo02q Px+ag0zIcH4ZHl7wOQ5s8BH2gnfICrIIVU20duS2sAQAVIfAjEAhxREZ4Rvkl6CHKm8y 90EA== X-Gm-Message-State: AOAM53219HagD9UH6qzmhzDKCulVeMIHvvasJd8jKAViLx3FUZDUWHnn s446ikwgJdtfIJkfyMFIvWk= X-Google-Smtp-Source: ABdhPJya5ibmpCyFDayy/wBqecm2M9yZe1IhqwI6AEh4pXXMSO5Al2QNHYNJr88scIIdJkvdtWMfDQ== X-Received: by 2002:a17:906:3905:b0:6cf:7ef5:fee0 with SMTP id f5-20020a170906390500b006cf7ef5fee0mr12949599eje.307.1645378780088; Sun, 20 Feb 2022 09:39:40 -0800 (PST) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id i5sm4416721ejo.188.2022.02.20.09.39.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 09:39:39 -0800 (PST) From: Ansuel Smith To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Ansuel Smith , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC RFT PATCH v2 1/2] dt-bindings: mtd: partitions: Document new partition-dynamic nodes Date: Sun, 20 Feb 2022 18:39:04 +0100 Message-Id: <20220220173905.14165-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220173905.14165-1-ansuelsmth@gmail.com> References: <20220220173905.14165-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Document new partition-dynamic nodes used to provide an OF node for partition registred at runtime by parsers. This is required for nvmem system to declare and detect nvmem-cells. With these special partitions, only the label is required as the parser will provide reg and offset of the mtd. NVMEM will use the data from the parser and provide the NVMEM cells declared in the DTS, "connecting" the dynamic partition with a static declaration of cells in them. Signed-off-by: Ansuel Smith --- .../mtd/partitions/partition-dynamic.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/partit= ion-dynamic.yaml diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition-dyn= amic.yaml b/Documentation/devicetree/bindings/mtd/partitions/partition-dyna= mic.yaml new file mode 100644 index 000000000000..945128e754ac --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/partitions/partition-dynamic.ya= ml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mtd/partitions/partition-dynamic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Dynamic Partition + +description: | + This binding describes a single flash partition that is dynamically allo= cated + by a dedicated parser that is not a fixed-partition parser. To declare a + partition the label is required. This can be used to give a dynamic part= ition + an OF node so that subsystems like NVMEM can work and provide NVMEM Cell= s to + the system. An example is declaring the partition label and all the NVMEM + cells in it. The parser will detect the correct reg and offset and the N= VMEM + will register the cells in it based on the data extracted by the parser. + +maintainers: + - Ansuel Smith + +properties: + label: + description: The label / name for the partition assigned by the parser= at + runtime. This is needed for sybsystem like NVMEM to define cells and + register with this OF node. + +required: + - label + +additionalProperties: true + +examples: + - | + partitions { + compatible =3D "qcom,smem-part"; + #address-cells =3D <1>; + #size-cells =3D <1>; + + art { + compatible =3D "nvmem-cells"; + #address-cells =3D <1>; + #size-cells =3D <1>; + + label =3D "0:art"; + + macaddr_art_0: macaddr@0 { + reg =3D <0x0 0x6>; + }; + + macaddr_art_6: macaddr@6 { + reg =3D <0x6 0x6>; + }; + }; + }; --=20 2.34.1 From nobody Sat Jun 27 21:21:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1062C433F5 for ; Sun, 20 Feb 2022 17:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244459AbiBTRkO (ORCPT ); Sun, 20 Feb 2022 12:40:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242485AbiBTRkE (ORCPT ); Sun, 20 Feb 2022 12:40:04 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E4F4A92D; Sun, 20 Feb 2022 09:39:42 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id m17so24762595edc.13; Sun, 20 Feb 2022 09:39:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GWlVA6bqW04iyoIdnqOqg4FogTrKkslVGuWpN+mp7C4=; b=ZXPrnn5JakCpGzz+pLKO/QmYkH5Yq5OFtJpqO6BeL+Q4kbvp/64UYovG1W52RYi4fn eDpCk4TLyfZNORnwDqQKy2G7iB9t9veUMYYzGxfVJko/3liND8EHG36bWIADM63Tg+Cr 4YjcguJ9Sq00cEQaKOZRfukTM/eMF8O0WeBxdWNvXT/zN8nRqWSQMV7u3IYCk1mzaH4e g6R4+frRdiJh9VHcL3jZrVAXCTkInUWEAupqN1nNdKrBRr+f43X3AmmXSijGYLQ7dO1b 5t6+1dYcTWN+V4bZS1RTIvqVln13kAhW2VHiGKuBVD4W+BZgc+EBGOvT0z5SFA0BqR2m PCzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GWlVA6bqW04iyoIdnqOqg4FogTrKkslVGuWpN+mp7C4=; b=rA40HjZUWF9jhQVA6BQI4sOiUJuQJegeg589URjWIGAnolFVtLjCl6F0GMOuD5XIJQ uPk1iFhTOTd7vYE6uAVS69TzpV8ktp+/f31YbIkgsDx3OCo699hlNJGaeSvvALkpTdfq EdKQJJrPM6hmkSwSamOE8rvUvY3i/0EV+s8bHrM4FTnzjQw3/R0BtXB8Ee/rPAwBmynJ uEQ6s0ItvjxERPmbmdrl7rg164HNnkx4jDdNrkRh0vxg3GH8Pi4rRL441rkO99n/IcB0 EbXT2VRDjJpWoGhpr76FrQgm9jX66Rr3f6M2CnE8AVCmQRh8Eir4HRRW0IXa0ai6Os2T S29Q== X-Gm-Message-State: AOAM531cIMJramtfbXmLkxJW1v7MABK8QxYqWGR2SBEg8A7UJBoQTuGF TKvSzJWiz617MxTkw7gWKGo= X-Google-Smtp-Source: ABdhPJzToGjW+8krUy2PN6oNNb9xwnTzztrk8RzYmAacrb6WIpKb8jN+PL3FBq9ejq7tL7A2N2dtoQ== X-Received: by 2002:a50:e187:0:b0:406:fb92:80ce with SMTP id k7-20020a50e187000000b00406fb9280cemr17539249edl.164.1645378781006; Sun, 20 Feb 2022 09:39:41 -0800 (PST) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id i5sm4416721ejo.188.2022.02.20.09.39.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 09:39:40 -0800 (PST) From: Ansuel Smith To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Ansuel Smith , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC RFT PATCH v2 2/2] mtd: core: introduce of support for dynamic partitions Date: Sun, 20 Feb 2022 18:39:05 +0100 Message-Id: <20220220173905.14165-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220173905.14165-1-ansuelsmth@gmail.com> References: <20220220173905.14165-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We have many parser that register mtd partitions at runtime. One example is the cmdlinepart or the smem-part parser where the compatible is defined in the dts and the partitions gets detected and registered by the parser. This is problematic for the NVMEM subsystem that requires an OF node to detect NVMEM cells. To fix this problem, introduce an additional logic that will try to assign an OF node to the MTD if declared. On MTD addition, it will be checked if the MTD has an OF node and if not declared will check if a partition with the same name / label is declared in DTS. If an exact match is found, the partition dynamically allocated by the parser will have a connected OF node. The NVMEM subsystem will detect the OF node and register any NVMEM cells declared statically in the DTS. Signed-off-by: Ansuel Smith Reported-by: kernel test robot --- drivers/mtd/mtdcore.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 9186268d361b..636b0a02f6cf 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -563,6 +563,50 @@ static int mtd_nvmem_add(struct mtd_info *mtd) return 0; } =20 +void mtd_check_of_node(struct mtd_info *mtd) +{ + struct device_node *partitions, *parent_dn, *mtd_dn =3D NULL; + struct mtd_info *parent; + const char *mtd_name; + bool found =3D false; + int plen; + + /* Check if MTD already has a device node */ + if (dev_of_node(&mtd->dev)) + return; + + /* Check if a partitions node exist */ + parent =3D mtd->parent; + parent_dn =3D dev_of_node(&parent->dev); + if (!parent_dn) + return; + + partitions =3D of_get_compatible_child(parent_dn, "partitions"); + if (!partitions) + goto exit_parent; + + /* Search if a partition is defined with the same name */ + for_each_child_of_node(partitions, mtd_dn) { + mtd_name =3D of_get_property(mtd_dn, "label", &plen); + if (!strncmp(mtd->name, mtd_name, plen)) { + found =3D true; + break; + } + } + + if (!found) + goto exit_partitions; + + /* Set of_node only for nvmem */ + if (of_device_is_compatible(mtd_dn, "nvmem-cells")) + mtd_set_of_node(mtd, mtd_dn); + +exit_partitions: + of_node_put(partitions); +exit_parent: + of_node_put(parent_dn); +} + /** * add_mtd_device - register an MTD device * @mtd: pointer to new MTD device info structure @@ -668,6 +712,7 @@ int add_mtd_device(struct mtd_info *mtd) mtd->dev.devt =3D MTD_DEVT(i); dev_set_name(&mtd->dev, "mtd%d", i); dev_set_drvdata(&mtd->dev, mtd); + mtd_check_of_node(mtd); of_node_get(mtd_get_of_node(mtd)); error =3D device_register(&mtd->dev); if (error) --=20 2.34.1