From nobody Tue Feb 10 23:01:26 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 73AE3C74A5B for ; Fri, 17 Mar 2023 13:27:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbjCQN0e (ORCPT ); Fri, 17 Mar 2023 09:26:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbjCQN0a (ORCPT ); Fri, 17 Mar 2023 09:26:30 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0800020A2B; Fri, 17 Mar 2023 06:26:29 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id b10so5106070ljr.0; Fri, 17 Mar 2023 06:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679059587; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XerqNhTQ44trkSYUMxRxIaoPSVpfz3XqDhrYxWbrqsQ=; b=lrjCcYeTl+RE8SRvybZeprbvRsfQjiGUrulFeJ7cK4WF+F1Ka+zaBGMYRkxyAzosXn ImYa5pGAEh/9xNcvA7QDfeAFX5WIkMxzkHsNkmSnFe4uhCIis4tfl7a002r2TZRxwmwk 3NC2fXvnzLcqINATHTB9Wdwp22sm9nbyTjuVS0S7Y+IkvVMRN2fugFsk7DSJTTL8aRH7 L3iB8hFKwFrS93E6xYgll4/2OX9UCNSWnKj2Xa1NyaQ4xz2KCVO69UpGNGq6u4TSeoY/ tHrc+7i6RhyVfjDkuA+zt3qHSiGQ/0F7l9L+4ZOUQJBEqt8VM19HzXxGY2/kr6swgxDk tNjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679059587; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XerqNhTQ44trkSYUMxRxIaoPSVpfz3XqDhrYxWbrqsQ=; b=0UxqS45Pc1sIloYRc0q5ZHTF61YWkItrTfqdMMnZNGyCMymtYVaDqi5oFdDZKzrPsv K6CUBlso660bGoTORfxQlonVXy30a7RT7A8nhrFfSc2ET3pZ5g8miUby+qsQ06yxZ2YI mtaTJ/qUjwBI5acWlAGDKygAZGQtgmHZkmYzpRC8rPOF0Pte6RNdroJx6lqCA+WYOiG7 PFWF65ycDAEb2JoEUA0xuQ4LL9qeRy/Ug4NnxjBxIQ2fhy+4ORimWSwOJcqfVhFI2f+V GAhfvoIrhufIxC3cXHIVMKQ0MQvfl0P0VyYAUOBMD/Ld0f+D/+EJIgO8MI36S83ZJ4i7 QUKQ== X-Gm-Message-State: AO0yUKXTtcXbxQdKtsFa8fR0pdblK/33WX9sE7JsFyRywELgNjf5R46r uA6Hp+UirQ9oyZmFjZ45HPE= X-Google-Smtp-Source: AK7set+zPv5Nqo5hRmQnKgqgahIWF20pv1SHi8BohqYCo7j6tf26NBF0vauDW66Nhi2yaaHAeRA2wg== X-Received: by 2002:a05:651c:50b:b0:298:a864:8c14 with SMTP id o11-20020a05651c050b00b00298a8648c14mr4539380ljp.10.1679059587106; Fri, 17 Mar 2023 06:26:27 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id p15-20020a2e740f000000b00295b588d21dsm411083ljc.49.2023.03.17.06.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 06:26:26 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla Cc: Greg Kroah-Hartman , Miquel Raynal , Michael Walle , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH V4 1/4] dt-bindings: nvmem: layouts: add fixed-layout Date: Fri, 17 Mar 2023 14:26:17 +0100 Message-Id: <20230317132620.31142-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230317132620.31142-1-zajec5@gmail.com> References: <20230317132620.31142-1-zajec5@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 From: Rafa=C5=82 Mi=C5=82ecki With the introduction of NVMEM layouts, new NVMEM content structures should be defined as such. We should also try to convert / migrate existing NVMEM content bindings to layouts. This commit handles fixed NVMEM cells. So far they had to be defined directly - as device subnodes. With this change it's allowed to put them in the DT node named "nvmem-layout". Having NVMEM cells in separated node is prefered as it draws a nice line between NVMEM device and its content. It results in cleaner bindings. FWIW a very similiar situation has happened to MTD devices and their partitions: see commit 5d96ea42eb63 ("dt-bindings: mtd: Clarify all partition subnodes"). Signed-off-by: Rafa=C5=82 Mi=C5=82ecki --- .../bindings/nvmem/layouts/fixed-cell.yaml | 31 ++++++++++++ .../bindings/nvmem/layouts/fixed-layout.yaml | 49 +++++++++++++++++++ .../bindings/nvmem/layouts/nvmem-layout.yaml | 5 +- .../devicetree/bindings/nvmem/nvmem.yaml | 19 +------ 4 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/fixed-c= ell.yaml create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/fixed-l= ayout.yaml diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yam= l b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml new file mode 100644 index 000000000000..e698098450e1 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/layouts/fixed-cell.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Fixed offset & size NVMEM cell + +maintainers: + - Rafa=C5=82 Mi=C5=82ecki + - Srinivas Kandagatla + +properties: + reg: + maxItems: 1 + + bits: + $ref: /schemas/types.yaml#/definitions/uint32-array + items: + - minimum: 0 + maximum: 7 + description: + Offset in bit within the address range specified by reg. + - minimum: 1 + description: + Size in bit within the address range specified by reg. + +required: + - reg + +additionalProperties: true diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.y= aml b/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml new file mode 100644 index 000000000000..f7496ba28f33 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/layouts/fixed-layout.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVMEM layout for fixed NVMEM cells + +description: + Many NVMEM devices have hardcoded cells layout (offset and size of defin= ed + NVMEM content doesn't change). + + This binding allows defining such NVMEM layout with its cells. It can be= used + on top of any NVMEM device. + +maintainers: + - Rafa=C5=82 Mi=C5=82ecki + +properties: + compatible: + const: fixed-layout + + "#address-cells": + const: 1 + + "#size-cells": + const: 1 + +patternProperties: + "@[a-f0-9]+$": + type: object + $ref: fixed-cell.yaml + +required: + - compatible + +additionalProperties: false + +examples: + - | + nvmem-layout { + compatible =3D "fixed-layout"; + #address-cells =3D <1>; + #size-cells =3D <1>; + + calibration@4000 { + reg =3D <0x4000 0x100>; + }; + }; diff --git a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.y= aml b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml index 8512ee538c4c..3b40f7880774 100644 --- a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml +++ b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml @@ -18,16 +18,13 @@ description: | perform their parsing. The nvmem-layout container is here to describe th= ese. =20 oneOf: + - $ref: fixed-layout.yaml - $ref: kontron,sl28-vpd.yaml - $ref: onie,tlv-layout.yaml =20 properties: compatible: true =20 - '#address-cells': false - - '#size-cells': false - required: - compatible =20 diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documenta= tion/devicetree/bindings/nvmem/nvmem.yaml index 75bb93dda9df..b79f1bb795fb 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -49,23 +49,8 @@ properties: patternProperties: "@[0-9a-f]+(,[0-7])?$": type: object - - properties: - reg: - maxItems: 1 - description: - Offset and size in bytes within the storage device. - - bits: - $ref: /schemas/types.yaml#/definitions/uint32-array - items: - - minimum: 0 - maximum: 7 - description: - Offset in bit within the address range specified by reg. - - minimum: 1 - description: - Size in bit within the address range specified by reg. + $ref: layouts/fixed-cell.yaml + deprecated: true =20 additionalProperties: true =20 --=20 2.34.1 From nobody Tue Feb 10 23:01:26 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 B7FD0C6FD1D for ; Fri, 17 Mar 2023 13:27:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230207AbjCQN0g (ORCPT ); Fri, 17 Mar 2023 09:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjCQN0b (ORCPT ); Fri, 17 Mar 2023 09:26:31 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426A020689; Fri, 17 Mar 2023 06:26:30 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id z5so5056019ljc.8; Fri, 17 Mar 2023 06:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679059588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pnovJjydcD88B/V7T4Cq2Usmwr/ZvKcG59naHHxKAo4=; b=ERZqWXNGwld4o+URwuztNFRN0kvGEcwaZ8SNLPKcpP7I/t4aJYBq56wKDiRxbDa+ad 5ZOMIihWQFASsxkCa2bwVtieCBLs86C0D1Vr5na48kYLKJL7Q0jUcxr5bUj/NX/teYNJ AvftqwjAleb0IydwVPNM8cp6YlkUmg6taljsiWYKg40vKSqJA+Q8XPL7H89q05OobzcQ Iy5mtH1P93oJp4ar0Slw2qe+DF2uiGmoveDcHpZOLPy/ApXfCVGfkQbMGAPGWqoYD2Js CFyWpv8tKjrzRmHPMisqZgrkD5Kzqm9r9JS/9yoZ3/Oany/hRNzLrBesoJ8chwuodVlJ CUPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679059588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pnovJjydcD88B/V7T4Cq2Usmwr/ZvKcG59naHHxKAo4=; b=VLMDP+Y+t7wRGjZTv9BJaau0a+ZR9L2KbIYMRN+LXaJ++ijB6Oy2ND4V7T2nixr7/J OdvNlbJZPSF32iWVIEskesuvi4l5A21WlXgk1j9+N03v4ThFBiEhpDaHawWzw9Fi0uUp km+Gb8jGOk4X+3ouZySBPQm6a8IhBkxtxXsoLGbLlgb9G4+YO2ttmUmfxraBkaqbjUJn coHuNLRRjxRWFvLQ18b07iTwtmcPS+F2moOyJLz7HdbXCvnUaRmmz820n6j+f05Xi3bb 7iSfL3setvD4UgKopXf+BZApfekaCZay0CafGHx/L/0rQiGqHHLYJ37ZcGD9CPsGCaNr mc9A== X-Gm-Message-State: AO0yUKUNm37Ib5fo+d4JAb9e4wR5zbud+uzaZ6JeiC7HVPF78FWcITkN m+71Te7TRNc/8bzX2jkbkE8= X-Google-Smtp-Source: AK7set9KzhUQ6sINcVegUPh51rWRnl9XPmJkiNZ7yM9o/q+C5mYcrpTdB32IocsNb0lN+emb2APq8A== X-Received: by 2002:a2e:87ce:0:b0:299:a8fc:1fd4 with SMTP id v14-20020a2e87ce000000b00299a8fc1fd4mr1950127ljj.51.1679059588626; Fri, 17 Mar 2023 06:26:28 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id p15-20020a2e740f000000b00295b588d21dsm411083ljc.49.2023.03.17.06.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 06:26:28 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla Cc: Greg Kroah-Hartman , Miquel Raynal , Michael Walle , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH V4 2/4] dt-bindings: nvmem: convert base example to use NVMEM fixed cells layout Date: Fri, 17 Mar 2023 14:26:18 +0100 Message-Id: <20230317132620.31142-3-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230317132620.31142-1-zajec5@gmail.com> References: <20230317132620.31142-1-zajec5@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 From: Rafa=C5=82 Mi=C5=82ecki With support for the "fixed-layout" binding it's possible and preferred now to define fixed NVMEM cells in the layout node. Do that for the binding example binding. Signed-off-by: Rafa=C5=82 Mi=C5=82ecki --- .../devicetree/bindings/nvmem/nvmem.yaml | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documenta= tion/devicetree/bindings/nvmem/nvmem.yaml index b79f1bb795fb..980244100690 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -68,24 +68,30 @@ examples: =20 /* ... */ =20 - /* Data cells */ - tsens_calibration: calib@404 { - reg =3D <0x404 0x10>; - }; - - tsens_calibration_bckp: calib_bckp@504 { - reg =3D <0x504 0x11>; - bits =3D <6 128>; - }; - - pvs_version: pvs-version@6 { - reg =3D <0x6 0x2>; - bits =3D <7 2>; - }; - - speed_bin: speed-bin@c{ - reg =3D <0xc 0x1>; - bits =3D <2 3>; + nvmem-layout { + compatible =3D "fixed-layout"; + #address-cells =3D <1>; + #size-cells =3D <1>; + + /* Data cells */ + tsens_calibration: calib@404 { + reg =3D <0x404 0x10>; + }; + + tsens_calibration_bckp: calib_bckp@504 { + reg =3D <0x504 0x11>; + bits =3D <6 128>; + }; + + pvs_version: pvs-version@6 { + reg =3D <0x6 0x2>; + bits =3D <7 2>; + }; + + speed_bin: speed-bin@c{ + reg =3D <0xc 0x1>; + bits =3D <2 3>; + }; }; }; =20 --=20 2.34.1 From nobody Tue Feb 10 23:01:26 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 082DCC74A5B for ; Fri, 17 Mar 2023 13:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbjCQN1J (ORCPT ); Fri, 17 Mar 2023 09:27:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbjCQN0e (ORCPT ); Fri, 17 Mar 2023 09:26:34 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A4B75073D; Fri, 17 Mar 2023 06:26:32 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id x36so5068717ljq.7; Fri, 17 Mar 2023 06:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679059590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QG0u4cQmxwUjiK1WMXH1+VMGQyE9TfyJFnQDUv5VBmQ=; b=pdB5G0UmcJXPsPNybdWNYdY7OIGa5bPsOFWL7tVREULieY7xe6M6OEO0POS0itAvtv rgOUhKoFwTQ/ctyXEnD1rS1Gj6SGrRk/vj4NjZvmw1AbSpib0bq24BPW/N2Azy6aLIuD KRm84JlWCSQvB7ECwaNveUxirgekosVaOwrC83ahMKrmQF8+QRRW9QIJcbiThyZP4lHL vBNoBiFOHLJB8uZ0aGwbSStkIsFXsYmqbPycBbO4Wo/NAQtTAjuGgyycea4BW2c+lPr9 QeUQ1a7IBb969WukIBrMGpT5CONruftWREUrxtUDze9MdjsjjNEIH/R37kBhQmWCWDke piWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679059590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QG0u4cQmxwUjiK1WMXH1+VMGQyE9TfyJFnQDUv5VBmQ=; b=Uz7YsdM4bhZ6hN5LtjwJzJhTEZz/TGyEpKo9t+G6Ik5FRzErdmQNHjoKL2ncXgmvCy WS3XZOXUGG+m53ULkVxcTcX4LehAg/+n8grqnXq+0dLiObYnNcaowFlJgZP6hE9SHyHJ Y1mYZ8BXGdf6hVzlh/F+qJ+fkaYM66/REERK7AHn/7PpCt0s04EMikNOdP1AZGx8qD8s 0GZLLnkoXjRodZczaL8J8eA8Yip6cgQgfJmmPEcmAvTZY7aCidXpdayT9Jpvnie793h5 2wM++sKpGUdyG67OjBjwrfmCAq7ondJMvqOtDVBSPLL1W6pOmyfH8bzHtcThn2Naq+Ph 8uBQ== X-Gm-Message-State: AO0yUKW2/eo1SZk2HgxiAnzvbFVPlwOhXQAbBvCri6WA4b8Zg4aJv7YN 8mE+st5D44SjvvaEjBAfXM8= X-Google-Smtp-Source: AK7set/RZWG5HCeVhQh/szYUfNVQl66zginixsiPhrig40kZTsvy20emhYZQ6VluayxW3oHpXEzuGQ== X-Received: by 2002:a2e:be92:0:b0:28e:a8aa:6f95 with SMTP id a18-20020a2ebe92000000b0028ea8aa6f95mr4189453ljr.8.1679059590083; Fri, 17 Mar 2023 06:26:30 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id p15-20020a2e740f000000b00295b588d21dsm411083ljc.49.2023.03.17.06.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 06:26:29 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla Cc: Greg Kroah-Hartman , Miquel Raynal , Michael Walle , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH V4 3/4] nvmem: core: export nvmem_add_cells_from_of() Date: Fri, 17 Mar 2023 14:26:19 +0100 Message-Id: <20230317132620.31142-4-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230317132620.31142-1-zajec5@gmail.com> References: <20230317132620.31142-1-zajec5@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 From: Rafa=C5=82 Mi=C5=82ecki This symbol can be cleanly re-used by the fixed NVMEM layout driver. Allow passing DT node as argument to make it a bit more generic. Signed-off-by: Rafa=C5=82 Mi=C5=82ecki --- drivers/nvmem/core.c | 7 ++++--- include/linux/nvmem-provider.h | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 212c5ba5789f..985a42cfb0a2 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -694,7 +694,7 @@ static int nvmem_validate_keepouts(struct nvmem_device = *nvmem) return 0; } =20 -static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) +int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct device_node= *np) { struct nvmem_layout *layout =3D nvmem->layout; struct device *dev =3D &nvmem->dev; @@ -702,7 +702,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device = *nvmem) const __be32 *addr; int len, ret; =20 - for_each_child_of_node(dev->of_node, child) { + for_each_child_of_node(np, child) { struct nvmem_cell_info info =3D {0}; =20 addr =3D of_get_property(child, "reg", &len); @@ -739,6 +739,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device = *nvmem) =20 return 0; } +EXPORT_SYMBOL_GPL(nvmem_add_cells_from_of); =20 int __nvmem_layout_register(struct nvmem_layout *layout, struct module *ow= ner) { @@ -970,7 +971,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_= config *config) if (rval) goto err_remove_cells; =20 - rval =3D nvmem_add_cells_from_of(nvmem); + rval =3D nvmem_add_cells_from_of(nvmem, nvmem->dev.of_node); if (rval) goto err_remove_cells; =20 diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 3e97c8315c45..2b5410be2636 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -195,6 +195,8 @@ void nvmem_del_cell_table(struct nvmem_cell_table *tabl= e); int nvmem_add_one_cell(struct nvmem_device *nvmem, const struct nvmem_cell_info *info); =20 +int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct device_node= *np); + int __nvmem_layout_register(struct nvmem_layout *layout, struct module *ow= ner); #define nvmem_layout_register(layout) \ __nvmem_layout_register(layout, THIS_MODULE) @@ -226,6 +228,11 @@ static inline int nvmem_add_one_cell(struct nvmem_devi= ce *nvmem, return -EOPNOTSUPP; } =20 +static int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct devi= ce_node *np) +{ + return -EOPNOTSUPP; +} + static inline int nvmem_layout_register(struct nvmem_layout *layout) { return -EOPNOTSUPP; --=20 2.34.1 From nobody Tue Feb 10 23:01:26 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 28384C76196 for ; Fri, 17 Mar 2023 13:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbjCQN1M (ORCPT ); Fri, 17 Mar 2023 09:27:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbjCQN0f (ORCPT ); Fri, 17 Mar 2023 09:26:35 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 707BC212A9; Fri, 17 Mar 2023 06:26:33 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id a32so5086148ljq.1; Fri, 17 Mar 2023 06:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679059591; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bWn5xXqBj6yi7+enhvrMvqUOn19onL6aIZYPMgopTDA=; b=Oj6V2PCimtWlltVB2+AyFA1DqnZAojZU3hVO2883M9Gp4gxHeUoLkTJIcSNHxDLpnS +V2rJzbGJIXMypWrzFzx11lP5YcG3JXQkl65RP/xA5SpyyWkBNUBg8XvYTq2ZQB3PgrP Ub2UPWw5+Rh0fEBXxHgYIXaaKvW+lhF9Hjrm1SvygV+S142+xLo32OcjNbd0eLaijbrl gww3P9tPf31sti0nHRjO4cS73bpT80qIP4Yhg6ewks6JiqUg+PMzNJDdFtDogoFZwqV6 olTf0h+K9vLYDVCJvLZiWBLsC5wVdNm0NwizJSbn90QCcMQ7S+lK8wHcKJjBvvm3YHSp Je+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679059591; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bWn5xXqBj6yi7+enhvrMvqUOn19onL6aIZYPMgopTDA=; b=D1qkZKxS7/Tmn+xoJ+5nr47S7YUTu4hpyE2AHpPUg6p0Ew5F29UnIbWlsU03O284Cc yQdswzBRP8xHaU84e/qkmHzONdpqrfmz60Q97f9NMmfS9Ai4PBiIoge4RfgKXgIxa885 WpmEoh/RinMWMtK17O6I3GQdrvwtzDkK/d/h77ij/90P/pRXj09Iv+LsV53dUxl5nOmm lWVKLPjnZbY1YustyeKbvm+qaMWipVJkC/kGAyLIB3rxcAu1DRCc+SFLe23mnHkvspM1 RVvoReunxjEgwn7HXAfcBAqahUcPD932VE3jPxJqo3Xo7MoZqNMS1oN4m5qJkveL5KWb NAwg== X-Gm-Message-State: AO0yUKWFq8x5wO1oaIS2xIgVrxJ3LwDeO1JVsW4OkOfT6McYWoOcmyv2 gHtGC6458KcNgumlzy0WnBA= X-Google-Smtp-Source: AK7set/00kAGhBMpoTNzaud5U11pLUBia2K1nAvT4IMnIwPHtiX8OmDHOOjTpanu7a9MGrLSIXN/NQ== X-Received: by 2002:a2e:97da:0:b0:298:3a2d:4363 with SMTP id m26-20020a2e97da000000b002983a2d4363mr3725806ljj.5.1679059591810; Fri, 17 Mar 2023 06:26:31 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id p15-20020a2e740f000000b00295b588d21dsm411083ljc.49.2023.03.17.06.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 06:26:31 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla Cc: Greg Kroah-Hartman , Miquel Raynal , Michael Walle , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH V4 4/4] nvmem: layouts: add fixed cells layout Date: Fri, 17 Mar 2023 14:26:20 +0100 Message-Id: <20230317132620.31142-5-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230317132620.31142-1-zajec5@gmail.com> References: <20230317132620.31142-1-zajec5@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 From: Rafa=C5=82 Mi=C5=82ecki This adds a driver for the "fixed-layout" NVMEM layout binding. It allows defining NVMEM cells in a layout DT node named "nvmem-layout". Signed-off-by: Rafa=C5=82 Mi=C5=82ecki --- drivers/nvmem/layouts/Kconfig | 8 +++++++ drivers/nvmem/layouts/Makefile | 1 + drivers/nvmem/layouts/fixed.c | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 drivers/nvmem/layouts/fixed.c diff --git a/drivers/nvmem/layouts/Kconfig b/drivers/nvmem/layouts/Kconfig index 7ff1ee1c1f05..2ebbde7b15b2 100644 --- a/drivers/nvmem/layouts/Kconfig +++ b/drivers/nvmem/layouts/Kconfig @@ -2,6 +2,14 @@ =20 menu "Layout Types" =20 +config NVMEM_LAYOUT_FIXED + tristate "Fixed cells layout support" + help + Say Y here if you want to support layout with fixed cells (hardcoded + offsets and sizes). + + If unsure, say N. + config NVMEM_LAYOUT_SL28_VPD tristate "Kontron sl28 VPD layout support" select CRC8 diff --git a/drivers/nvmem/layouts/Makefile b/drivers/nvmem/layouts/Makefile index 2974bd7d33ed..449dd893f968 100644 --- a/drivers/nvmem/layouts/Makefile +++ b/drivers/nvmem/layouts/Makefile @@ -3,5 +3,6 @@ # Makefile for nvmem layouts. # =20 +obj-$(CONFIG_NVMEM_LAYOUT_FIXED) +=3D fixed.o obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) +=3D sl28vpd.o obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) +=3D onie-tlv.o diff --git a/drivers/nvmem/layouts/fixed.c b/drivers/nvmem/layouts/fixed.c new file mode 100644 index 000000000000..b8d2f141d272 --- /dev/null +++ b/drivers/nvmem/layouts/fixed.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include + +static int fixed_add_cells(struct device *dev, struct nvmem_device *nvmem, + struct nvmem_layout *layout) +{ + struct device_node *layout_np; + int err; + + layout_np =3D of_nvmem_layout_get_container(nvmem); + if (!layout_np) + return -ENOENT; + + err =3D nvmem_add_cells_from_of(nvmem, layout_np); + + of_node_put(layout_np); + + return err; +} + +static const struct of_device_id fixed_of_match_table[] =3D { + { .compatible =3D "fixed-layout" }, + {}, +}; +MODULE_DEVICE_TABLE(of, fixed_of_match_table); + +struct nvmem_layout fixed_nvmem_layout =3D { + .name =3D "fixed-layout", + .of_match_table =3D fixed_of_match_table, + .add_cells =3D fixed_add_cells, +}; + +module_nvmem_layout_driver(fixed_nvmem_layout); + +MODULE_AUTHOR("Rafa=C5=82 Mi=C5=82ecki"); +MODULE_LICENSE("GPL"); +MODULE_DEVICE_TABLE(of, fixed_of_match_table); --=20 2.34.1