devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] dt-bindings: nvmem: layouts: add fixed-layout
@ 2023-03-09 11:39 Rafał Miłecki
  2023-03-09 13:07 ` Michael Walle
  0 siblings, 1 reply; 3+ messages in thread
From: Rafał Miłecki @ 2023-03-09 11:39 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski
  Cc: Srinivas Kandagatla, Greg Kroah-Hartman, Miquel Raynal,
	Michael Walle, devicetree, linux-kernel, Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

With the introduction of NVMEM layouts we should prefer and support
describing all NVMEM devices content in the "nvmem-layout" node. That
inludes using it for fixed NVMEM cells (those with hardcoded offset &
size).

This seems to be cleaner design and more explicit.

Introduce a binding allowing fixed NVMEM cells as a type of layout. To
avoid code duplication put shared part in the fixed-cell.yaml.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
V2: Use fixed-cell.yaml
---
 .../bindings/nvmem/layouts/fixed-cell.yaml    | 30 ++++++++++++
 .../bindings/nvmem/layouts/fixed-layout.yaml  | 49 +++++++++++++++++++
 .../bindings/nvmem/layouts/nvmem-layout.yaml  |  1 +
 .../devicetree/bindings/nvmem/nvmem.yaml      | 18 +------
 4 files changed, 81 insertions(+), 17 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml
 create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml

diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml
new file mode 100644
index 000000000000..2c77d02052d9
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml
@@ -0,0 +1,30 @@
+# 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ł Miłecki <rafal@milecki.pl>
+
+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: false
diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml
new file mode 100644
index 000000000000..4c4a968bb302
--- /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 specific
+  NVMEM content doesn't change).
+
+  This binding allows defining such cells using NVMEM layout. It can be used on
+  top of any NVMEM device.
+
+maintainers:
+  - Rafał Miłecki <rafal@milecki.pl>
+
+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 = "fixed-layout";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        calibration@4000 {
+            reg = <0x4000 0x100>;
+        };
+    };
diff --git a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
index 8512ee538c4c..03da7848c713 100644
--- a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
+++ b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
@@ -18,6 +18,7 @@ description: |
   perform their parsing. The nvmem-layout container is here to describe these.
 
 oneOf:
+  - $ref: fixed-layout.yaml
   - $ref: kontron,sl28-vpd.yaml
   - $ref: onie,tlv-layout.yaml
 
diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
index 75bb93dda9df..732162e9d13e 100644
--- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
+++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
@@ -49,23 +49,7 @@ 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
 
 additionalProperties: true
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] dt-bindings: nvmem: layouts: add fixed-layout
  2023-03-09 11:39 [PATCH V2] dt-bindings: nvmem: layouts: add fixed-layout Rafał Miłecki
@ 2023-03-09 13:07 ` Michael Walle
  2023-03-10  6:51   ` Rafał Miłecki
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Walle @ 2023-03-09 13:07 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Rob Herring, Krzysztof Kozlowski, Srinivas Kandagatla,
	Greg Kroah-Hartman, Miquel Raynal, devicetree, linux-kernel,
	Rafał Miłecki

Am 2023-03-09 12:39, schrieb Rafał Miłecki:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> With the introduction of NVMEM layouts we should prefer and support
> describing all NVMEM devices content in the "nvmem-layout" node. That
> inludes using it for fixed NVMEM cells (those with hardcoded offset &
> size).
> 
> This seems to be cleaner design and more explicit.
> 
> Introduce a binding allowing fixed NVMEM cells as a type of layout. To
> avoid code duplication put shared part in the fixed-cell.yaml.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

I don't feel comfortable to add an acked-by or reviewed-by here
because I don't do much with dt-bindings myself, but this looks
good to me.

 From a device tree binding POV, could there be a

nvmem-layout@0 {
   reg = <0>;
   compatible = "layout1";
};

nvmem-layout@1000 {
   reg = <1000>;
   compatible = "layout2";
};

for partitioned eeproms for example?

-michael

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] dt-bindings: nvmem: layouts: add fixed-layout
  2023-03-09 13:07 ` Michael Walle
@ 2023-03-10  6:51   ` Rafał Miłecki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafał Miłecki @ 2023-03-10  6:51 UTC (permalink / raw)
  To: Michael Walle
  Cc: Rob Herring, Krzysztof Kozlowski, Srinivas Kandagatla,
	Greg Kroah-Hartman, Miquel Raynal, devicetree, linux-kernel,
	Rafał Miłecki

On 9.03.2023 14:07, Michael Walle wrote:
> Am 2023-03-09 12:39, schrieb Rafał Miłecki:
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> With the introduction of NVMEM layouts we should prefer and support
>> describing all NVMEM devices content in the "nvmem-layout" node. That
>> inludes using it for fixed NVMEM cells (those with hardcoded offset &
>> size).
>>
>> This seems to be cleaner design and more explicit.
>>
>> Introduce a binding allowing fixed NVMEM cells as a type of layout. To
>> avoid code duplication put shared part in the fixed-cell.yaml.
>>
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> 
> I don't feel comfortable to add an acked-by or reviewed-by here
> because I don't do much with dt-bindings myself, but this looks
> good to me.

Thank you!


>  From a device tree binding POV, could there be a
> 
> nvmem-layout@0 {
>    reg = <0>;
>    compatible = "layout1";
> };
> 
> nvmem-layout@1000 {
>    reg = <1000>;
>    compatible = "layout2";
> };
> 
> for partitioned eeproms for example?

Maybe. Could you send a patch adding such binding with a proper
explanation what devices need it, please? It's out of scope of this
patch.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-10  6:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-09 11:39 [PATCH V2] dt-bindings: nvmem: layouts: add fixed-layout Rafał Miłecki
2023-03-09 13:07 ` Michael Walle
2023-03-10  6:51   ` Rafał Miłecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).