diff mbox series

[v5,1/3] dt-bindings: mtd: partitions: Support label only partition

Message ID 20220606151417.19227-2-ansuelsmth@gmail.com
State Changes Requested
Headers show
Series Add nvmem support for dynamic partitions | expand

Commit Message

Christian Marangi June 6, 2022, 3:14 p.m. UTC
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 <ansuelsmth@gmail.com>
---
 .../bindings/mtd/partitions/partition.yaml       | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Comments

Rob Herring (Arm) June 9, 2022, 6:32 p.m. UTC | #1
On Mon, Jun 06, 2022 at 05:14:15PM +0200, Ansuel Smith wrote:
> 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 <ansuelsmth@gmail.com>
> ---
>  .../bindings/mtd/partitions/partition.yaml       | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml 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.
>  
> +  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 cells.
> +  The OF node will be assigned only if the partition label declared match the
> +  one assigned by the parser at runtime.
> +
>  maintainers:
>    - Rafał Miłecki <rafal@milecki.pl>
>  
> @@ -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.

Generally, label is never required being something for humans rather 
than the s/w to consume. I don't see any reason why we can't still use 
the node name (with 'partition-' stripped off).

If the purpose is to define what the partition contains, then 
'compatible' is the right thing for that.

>  
>    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
>  
> -required:
> -  - reg
> +if:
> +  not:
> +    required: [ reg ]
> +then:
> +  required: [ label ]
>  
>  additionalProperties: true
> -- 
> 2.36.1
> 
>
Christian Marangi June 9, 2022, 7:57 p.m. UTC | #2
On Thu, Jun 09, 2022 at 12:32:52PM -0600, Rob Herring wrote:
> On Mon, Jun 06, 2022 at 05:14:15PM +0200, Ansuel Smith wrote:
> > 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 <ansuelsmth@gmail.com>
> > ---
> >  .../bindings/mtd/partitions/partition.yaml       | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml 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.
> >  
> > +  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 cells.
> > +  The OF node will be assigned only if the partition label declared match the
> > +  one assigned by the parser at runtime.
> > +
> >  maintainers:
> >    - Rafał Miłecki <rafal@milecki.pl>
> >  
> > @@ -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.
> 
> Generally, label is never required being something for humans rather 
> than the s/w to consume. I don't see any reason why we can't still use 
> the node name (with 'partition-' stripped off).
> 

How to enforce the use of 'partition-'? Should the driver then check the
node name and reject any wrong node name (and return error)?


> If the purpose is to define what the partition contains, then 
> 'compatible' is the right thing for that.
>

Introducing a compatible means creating another scheme I think or we can
add that special compatible in the partition scheme?

> >  
> >    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
> >  
> > -required:
> > -  - reg
> > +if:
> > +  not:
> > +    required: [ reg ]
> > +then:
> > +  required: [ label ]
> >  
> >  additionalProperties: true
> > -- 
> > 2.36.1
> > 
> >
Rob Herring (Arm) June 10, 2022, 5:02 p.m. UTC | #3
On Thu, Jun 09, 2022 at 09:57:52PM +0200, Ansuel Smith wrote:
> On Thu, Jun 09, 2022 at 12:32:52PM -0600, Rob Herring wrote:
> > On Mon, Jun 06, 2022 at 05:14:15PM +0200, Ansuel Smith wrote:
> > > 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 <ansuelsmth@gmail.com>
> > > ---
> > >  .../bindings/mtd/partitions/partition.yaml       | 16 ++++++++++++++--
> > >  1 file changed, 14 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml 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.
> > >  
> > > +  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 cells.
> > > +  The OF node will be assigned only if the partition label declared match the
> > > +  one assigned by the parser at runtime.
> > > +
> > >  maintainers:
> > >    - Rafał Miłecki <rafal@milecki.pl>
> > >  
> > > @@ -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.
> > 
> > Generally, label is never required being something for humans rather 
> > than the s/w to consume. I don't see any reason why we can't still use 
> > the node name (with 'partition-' stripped off).
> > 
> 
> How to enforce the use of 'partition-'? Should the driver then check the
> node name and reject any wrong node name (and return error)?

The schema can do it either in the parent (of partition nodes) schema or 
with $nodename 'property'.

$nodename:
  oneOf:
    - pattern: '^.*@.*$'
    - pattern: '^partition-.*$'

or:

if:
  not:
    required:
      - reg
then:
  properties:
    $nodename:
      pattern: '^partition-.*$'


The latter is a bit clearer on the intent I think.

> > If the purpose is to define what the partition contains, then 
> > 'compatible' is the right thing for that.
> >
> 
> Introducing a compatible means creating another scheme I think or we can
> add that special compatible in the partition scheme?

It would be another schema. You could make 'compatible' required here 
perhaps, but maybe there's a use for an empty node?

Rob
Christian Marangi June 11, 2022, 12:36 p.m. UTC | #4
On Fri, Jun 10, 2022 at 11:02:05AM -0600, Rob Herring wrote:
> On Thu, Jun 09, 2022 at 09:57:52PM +0200, Ansuel Smith wrote:
> > On Thu, Jun 09, 2022 at 12:32:52PM -0600, Rob Herring wrote:
> > > On Mon, Jun 06, 2022 at 05:14:15PM +0200, Ansuel Smith wrote:
> > > > 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 <ansuelsmth@gmail.com>
> > > > ---
> > > >  .../bindings/mtd/partitions/partition.yaml       | 16 ++++++++++++++--
> > > >  1 file changed, 14 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml 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.
> > > >  
> > > > +  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 cells.
> > > > +  The OF node will be assigned only if the partition label declared match the
> > > > +  one assigned by the parser at runtime.
> > > > +
> > > >  maintainers:
> > > >    - Rafał Miłecki <rafal@milecki.pl>
> > > >  
> > > > @@ -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.
> > > 
> > > Generally, label is never required being something for humans rather 
> > > than the s/w to consume. I don't see any reason why we can't still use 
> > > the node name (with 'partition-' stripped off).
> > > 
> > 
> > How to enforce the use of 'partition-'? Should the driver then check the
> > node name and reject any wrong node name (and return error)?
> 
> The schema can do it either in the parent (of partition nodes) schema or 
> with $nodename 'property'.
> 
> $nodename:
>   oneOf:
>     - pattern: '^.*@.*$'
>     - pattern: '^partition-.*$'
> 
> or:
> 
> if:
>   not:
>     required:
>       - reg
> then:
>   properties:
>     $nodename:
>       pattern: '^partition-.*$'
> 
> 
> The latter is a bit clearer on the intent I think.
> 
> > > If the purpose is to define what the partition contains, then 
> > > 'compatible' is the right thing for that.
> > >
> > 
> > Introducing a compatible means creating another scheme I think or we can
> > add that special compatible in the partition scheme?
> 
> It would be another schema. You could make 'compatible' required here 
> perhaps, but maybe there's a use for an empty node?
> 
> Rob

Think I will just add the $nodename properties just to now complicate
things with another scheme.
Christian Marangi June 13, 2022, 7:25 p.m. UTC | #5
On Fri, Jun 10, 2022 at 11:02:05AM -0600, Rob Herring wrote:
> On Thu, Jun 09, 2022 at 09:57:52PM +0200, Ansuel Smith wrote:
> > On Thu, Jun 09, 2022 at 12:32:52PM -0600, Rob Herring wrote:
> > > On Mon, Jun 06, 2022 at 05:14:15PM +0200, Ansuel Smith wrote:
> > > > 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 <ansuelsmth@gmail.com>
> > > > ---
> > > >  .../bindings/mtd/partitions/partition.yaml       | 16 ++++++++++++++--
> > > >  1 file changed, 14 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml 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.
> > > >  
> > > > +  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 cells.
> > > > +  The OF node will be assigned only if the partition label declared match the
> > > > +  one assigned by the parser at runtime.
> > > > +
> > > >  maintainers:
> > > >    - Rafał Miłecki <rafal@milecki.pl>
> > > >  
> > > > @@ -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.
> > > 
> > > Generally, label is never required being something for humans rather 
> > > than the s/w to consume. I don't see any reason why we can't still use 
> > > the node name (with 'partition-' stripped off).
> > > 
> > 
> > How to enforce the use of 'partition-'? Should the driver then check the
> > node name and reject any wrong node name (and return error)?
> 
> The schema can do it either in the parent (of partition nodes) schema or 
> with $nodename 'property'.
> 
> $nodename:
>   oneOf:
>     - pattern: '^.*@.*$'
>     - pattern: '^partition-.*$'
> 
> or:
> 
> if:
>   not:
>     required:
>       - reg
> then:
>   properties:
>     $nodename:
>       pattern: '^partition-.*$'
> 
> 
> The latter is a bit clearer on the intent I think.
>

Hi, I'm testing this but I'm having some difficulties.
I put your second solution in partition.yaml

But I notice that if for example qcom,smem-part.yaml have

patternProperties:
  "^partition3-[0-9a-z]+$":
    $ref: partition.yaml#

Then the $nodename is ignored (or overwtitten?). Can't find a correct
way to declare a patternProperties that ref another schema.

I'm trying and searching a way to ref the partition.yaml but I can't
find anything. Can you help with this? It does seem uselss putting a
limitation in partition.yaml if then someone can just set a different
one in the parser Documentation.

> > > If the purpose is to define what the partition contains, then 
> > > 'compatible' is the right thing for that.
> > >
> > 
> > Introducing a compatible means creating another scheme I think or we can
> > add that special compatible in the partition scheme?
> 
> It would be another schema. You could make 'compatible' required here 
> perhaps, but maybe there's a use for an empty node?
> 
> Rob
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml 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.
 
+  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 cells.
+  The OF node will be assigned only if the partition label declared match the
+  one assigned by the parser at runtime.
+
 maintainers:
   - Rafał Miłecki <rafal@milecki.pl>
 
@@ -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.
 
   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
 
-required:
-  - reg
+if:
+  not:
+    required: [ reg ]
+then:
+  required: [ label ]
 
 additionalProperties: true