From nobody Tue Apr 28 05:05:45 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 3626CC43334 for ; Mon, 6 Jun 2022 15:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240382AbiFFPOv (ORCPT ); Mon, 6 Jun 2022 11:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240345AbiFFPOn (ORCPT ); Mon, 6 Jun 2022 11:14:43 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5B35DEEB1; Mon, 6 Jun 2022 08:14:42 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id y19so29580587ejq.6; Mon, 06 Jun 2022 08:14:42 -0700 (PDT) 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=wdA5SSs2A+GftYSjZhbZ3WXsisBDCmDB/JAxOYIkUdU=; b=Erz1QKme2uzu1CL53DykcnrB+qfgjJVnrpzSTvOrs+a/I69PggV9QsYYLXjzqxHebU atO+cXtLR7n5ZB6wEgQ6IdC7lYVVlOBMbGAAUyXlYZBNl1FZgYz6TyUWfIAqXNbSXL2T UG9Zo2iohTfIMSlrKX2DPboaZgVGBb57qjEyd0DhZMoYf7eWWUNrKmfleK2dDnVruHHs bK7wxDw/KOtX5hkmXJrnkVW4hhXZ9DQR3zktMyBdMGmPnvC6GGaeQLXbYSn1zNDASMZK hNDcpkbLwl71VmMIITEVDlEXBFz0CGCrQ9VkpyBbLzCgSGeilwXFVz9GQVUfu8L4dHTp 7DzQ== 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=wdA5SSs2A+GftYSjZhbZ3WXsisBDCmDB/JAxOYIkUdU=; b=evtPmtFBR/UiziSpdssWZnMGh9vRui6yLULDniENbx27wNsWuY8VH3SOGZOfYX7ZYX Kj79dUnGrLe6P+CnBhAUrksHpCFdkQmXo2uAjCfTS1XVXFET+5Fll/2n7JmlQ0XNXiyi etL/xQtVtqVn6IutL6/Bqe9pxvcL07oa5iuohZ/0GUjWvCIuoikRD0Cswg67l0nAU7vf GXkCmmzKu6QDUlUSjS+GiQzBZKUIadjlLdpfhFxZIDXN+fZZi8GKrjDX7HnmHOJHq2un NqgMEsNEsmAhMraFxSotgOmF7/KiN0qbX4K1shbRFLZXpp8o/XgLSqEI7CP2U4+VU24A gvBA== X-Gm-Message-State: AOAM533PzQkzZYKftPB1zbbAe8H9Gf/NkbmrIQI4K/xSSVm/sfXFwpQF YP1lp9YQvR/Z8CZBknsa6YM= X-Google-Smtp-Source: ABdhPJyt2liP+1F1RvMMxu7z+WgrxpjuApud9EFnbwkjgtInQOBqMpdZdFYR9tePcSfc/J8YciKCbQ== X-Received: by 2002:a17:906:8301:b0:6e4:896d:59b1 with SMTP id j1-20020a170906830100b006e4896d59b1mr21131479ejx.396.1654528481019; Mon, 06 Jun 2022 08:14:41 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id be5-20020a0564021a2500b0042e09f44f81sm7494001edb.38.2022.06.06.08.14.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:14:40 -0700 (PDT) From: Ansuel Smith To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Greg Kroah-Hartman , Jens Axboe , Ansuel Smith , =?UTF-8?q?=EF=BF=BDecki?= , Manivannan Sadhasivam , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/3] dt-bindings: mtd: partitions: Support label only partition Date: Mon, 6 Jun 2022 17:14:15 +0200 Message-Id: <20220606151417.19227-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220606151417.19227-1-ansuelsmth@gmail.com> References: <20220606151417.19227-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Document new partition nodes that declare only the label instead of the reg 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, the reg / offset is not required. The label binding is used to match the partition allocated by the parser at runtime and 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 --- .../bindings/mtd/partitions/partition.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yam= l b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml index e1ac08064425..bff6fb980e6b 100644 --- a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml +++ b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml @@ -11,6 +11,13 @@ description: | relative offset and size specified. Depending on partition function extra properties can be used. =20 + A partition may be dynamically allocated by a specific parser at runtime. + In this specific case, the label is required instead of the reg. + This is used to assign an OF node to the dynamiccally allocated partition + so that subsystem like NVMEM can provide an OF node and declare NVMEM ce= lls. + The OF node will be assigned only if the partition label declared match = the + one assigned by the parser at runtime. + maintainers: - Rafa=C5=82 Mi=C5=82ecki =20 @@ -22,6 +29,8 @@ properties: label: description: The label / name for this partition. If omitted, the label is taken from the node name (excluding the unit address). + With dynamically allocated partition the label is required and won't + fallback to the node name. =20 read-only: description: This parameter, if present, is a hint that this partition @@ -41,7 +50,10 @@ properties: immune to paired-pages corruptions type: boolean =20 -required: - - reg +if: + not: + required: [ reg ] +then: + required: [ label ] =20 additionalProperties: true --=20 2.36.1 From nobody Tue Apr 28 05:05:45 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 E902DC43334 for ; Mon, 6 Jun 2022 15:14:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240398AbiFFPO5 (ORCPT ); Mon, 6 Jun 2022 11:14:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240363AbiFFPOp (ORCPT ); Mon, 6 Jun 2022 11:14:45 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFCCABE14E; Mon, 6 Jun 2022 08:14:43 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id fd25so19277467edb.3; Mon, 06 Jun 2022 08:14:43 -0700 (PDT) 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=IvilBWGAnBlRQU+9jyrl5Is4xvOjLGN9x8U2mNdKUuA=; b=bi9r+qtN/YEFgZKvHG34WS3p/giaGxSArRaYglAT7nz4PQ/VsYlL8SUk7w1Io9htm/ muhxQTp2qWsVdZiCnQuwTWrkk7r5MnUooK67tZwH9DEJnwK27j9dgngYu6KF6db8+F31 AWLbtIXSy/7KMzNKc5Nu9j7RcfGILCbM/zwAcz1Oh9cJiGMjYUKdEZAY7N+ZRrQ7Czkm 2hjy8FFI+KoJs2mOuMWhq5h1Won/1Mhlj1cfD4W5Co5Zy4FqYglj8PPH9DdMP4KLiGn7 +zw4HLSP2WBActg5VfNCP8JfC6J3mntx3a0vTD/g2319ASx0z7a88G8Ab00tKRaHdLk4 G4Mw== 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=IvilBWGAnBlRQU+9jyrl5Is4xvOjLGN9x8U2mNdKUuA=; b=UhTSajYCXev50BV7wFkyhWFQkFB6yRhJKTE83pV1DdlTGcDjWARPGsStUlcQKhuMOU utbWQto+IdBIvAmfDlG4KJoorbYg0FMclaFcT5MC6qL11/Uq3N2uBsokf7PHRrIG3AD2 SNoRplgituQ8XMtanmdqJlIRG7WuugpxZAwo7doiPaDi0hrd1jgema4L7XCBYzedUBj2 3bAGfD8mqd0HZBzaTU9eRLhC42fUZDcNHdg0FeVvnqgDCl9Dwbyx8Y7mxjbjzZv6mxk+ 5+73g1Vj5mOpd6kizLRkHS48/kFVGJCCIjg2nIbq2vbZC+6TIc/P2H6vhbZg70j/aM3y EvYA== X-Gm-Message-State: AOAM530HI/B5YVrSEanK+hHi0GnGXVymSyiz3jb6Jh9tk/0HrUrQ58lA odqgNK3IFDgC4DKiGX/O9fI= X-Google-Smtp-Source: ABdhPJyvopiVyT4O43UNksA7O6pjAK73X83wxSdwvAO1QFgjxLTOD7mUL678+d8kzQ3Qa2X+T1FOiA== X-Received: by 2002:a50:fc0d:0:b0:42d:c1ae:28bc with SMTP id i13-20020a50fc0d000000b0042dc1ae28bcmr28023125edr.24.1654528482474; Mon, 06 Jun 2022 08:14:42 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id be5-20020a0564021a2500b0042e09f44f81sm7494001edb.38.2022.06.06.08.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:14:41 -0700 (PDT) From: Ansuel Smith To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Greg Kroah-Hartman , Jens Axboe , Ansuel Smith , =?UTF-8?q?=EF=BF=BDecki?= , Manivannan Sadhasivam , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/3] dt-bindings: mtd: partitions: add additional example for qcom,smem-part Date: Mon, 6 Jun 2022 17:14:16 +0200 Message-Id: <20220606151417.19227-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220606151417.19227-1-ansuelsmth@gmail.com> References: <20220606151417.19227-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" Add additional example for qcom,smem-part to declare a dynamic partition to provide NVMEM cells for the commonly ART partition provided by this parser. Signed-off-by: Ansuel Smith Reviewed-by: Rob Herring --- .../mtd/partitions/qcom,smem-part.yaml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-par= t.yaml b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.ya= ml index cf3f8c1e035d..dc07909af023 100644 --- a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml +++ b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml @@ -19,6 +19,10 @@ properties: compatible: const: qcom,smem-part =20 +patternProperties: + "^partition-[0-9a-z]+$": + $ref: partition.yaml# + required: - compatible =20 @@ -31,3 +35,26 @@ examples: compatible =3D "qcom,smem-part"; }; }; + + - | + /* Example declaring dynamic partition */ + flash { + partitions { + compatible =3D "qcom,smem-part"; + + partition-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.36.1 From nobody Tue Apr 28 05:05:45 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 515DFC43334 for ; Mon, 6 Jun 2022 15:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240401AbiFFPPB (ORCPT ); Mon, 6 Jun 2022 11:15:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240369AbiFFPOr (ORCPT ); Mon, 6 Jun 2022 11:14:47 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BDDF118D10; Mon, 6 Jun 2022 08:14:45 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id q21so29613464ejm.1; Mon, 06 Jun 2022 08:14:45 -0700 (PDT) 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=GYSZo6XHpAMyhvRqkjuy1lYBsylet9wRGEIDu+7oMAg=; b=Sjpbo1f3mz+MDObOhOImNTpeNo2ne+Ui6zvvn7v/z35jvASMQcDf/nUUd0HRF/t/Ea 4h8P2FFMK6drGKIuDe7GJdr4VJiUqql9Zkf5vd/qkcjzjYBEosbzEWuLOrLbtWtJTZSQ go1rdCHGLfc6Rtc6BxG+G5Motw9DHduYGE4PafmLUcSrSbFALoldaHcCiFu4vi+Mr2Sz dbKFzNplwkQu7TA9PrRtYSaK/hXBl8xLBphmb6NCeocwI6CMhlaBO8hk/x93chFTKKDY 8kzV7kkTNyDaEkCVvOKZY3q6zuxOX2mlyAq41FsA19gzg7LN43M2Vp0WkKAaaEY0ZPwO +UaQ== 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=GYSZo6XHpAMyhvRqkjuy1lYBsylet9wRGEIDu+7oMAg=; b=yqDRtZHeTcZjwWfH6L8o3LI47h6PRBG2EDksl3jt0AszMPkQl7YycHMujME8Dp6jDV YfKWAsnezjRumAoU1nrsd8Z9+7wMrUk8p5B4z+gAbML3AwrZUIVJIm3wVmZULBjCfJNc VfKnmM6I2+FQUxEwx0rAJbN466ztrMO0VWj/vw0Vs20JW5iAqEOHYOh5vqrz/qLY4zvz rgp6LOh6dl/8wLQIU816X0o8ZX8LbiD/F/wDy2t0xdYuRX0sZNNjUvIghyPs0xhD3RnM aFEPPVOk5eF9bHeEyP2R12gSRYNm93Dok/32Orr2eT6JGzxIHxZnwSnPJIU7ZFEEZO8C ocqw== X-Gm-Message-State: AOAM532BHF+q5QPses+B4Ux3awYPjfvkr+6V2fpv90DIqRn0GFFqKfba Kwsew3c1ZpOgcTHywPqAB6M= X-Google-Smtp-Source: ABdhPJyUO4QhLpj5hQB1ExfVx6GyV11SpB7T0Mr7aQNaOcyQYh/tJ5wxoOy0jfL291yecIhfv8GacA== X-Received: by 2002:a17:907:7811:b0:6ef:a896:b407 with SMTP id la17-20020a170907781100b006efa896b407mr21254860ejc.645.1654528484015; Mon, 06 Jun 2022 08:14:44 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id be5-20020a0564021a2500b0042e09f44f81sm7494001edb.38.2022.06.06.08.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:14:43 -0700 (PDT) From: Ansuel Smith To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Greg Kroah-Hartman , Jens Axboe , Ansuel Smith , =?UTF-8?q?=EF=BF=BDecki?= , Manivannan Sadhasivam , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] mtd: core: introduce of support for dynamic partitions Date: Mon, 6 Jun 2022 17:14:17 +0200 Message-Id: <20220606151417.19227-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220606151417.19227-1-ansuelsmth@gmail.com> References: <20220606151417.19227-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 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 | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 7731796024e0..807194efb580 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -546,6 +546,54 @@ static int mtd_nvmem_add(struct mtd_info *mtd) return 0; } =20 +static 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_child_by_name(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) { + /* Skip partition with no label */ + mtd_name =3D of_get_property(mtd_dn, "label", &plen); + if (!mtd_name) + continue; + + 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 @@ -651,6 +699,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.36.1