Re: [PATCH] dt-bindings: convert spmi.txt to spmi.yaml

From: Mauro Carvalho Chehab
Date: Wed Aug 26 2020 - 00:16:49 EST


Em Wed, 19 Aug 2020 17:08:12 -0600
Rob Herring <robh@xxxxxxxxxx> escreveu:

> Need to also define 'reg' constraints as defined by the bus:
>
> properties:
> reg:
> minItems: 1
> maxItems: 2 #??? Not sure about this. Is it 1 SPMI_USID and 1 \
> SPMI_GSID entry at most?


Each child have just one user ID (SPMI_USID). The group ID (SPMI_GSID) is an
optional feature. From what I know, only one group ID is allowed at most.
So, maxItems: 2 makes sense.


> items:
> items:
> - minimum: 0
> maximum: 0xf
> - enum: [ 0, 1 ]

If I use both maxItems:2 and the above, the example produces the following
error:

/devel/v4l/temp/Documentation/devicetree/bindings/spmi/spmi.example.dt.yaml: spmi@0: child@7:reg: Additional items are not allowed ([3, 1] was unexpected)

(full DT file enclosed)

This seems to be some bug at the parsing logic, which seems to be refusing
to accept both "items" and "maxItems".

-

That's said, looking at the code[1], only SPMI_USID is currently supported:

err = of_property_read_u32_array(node, "reg", reg, 2);
if (err) {
dev_err(&ctrl->dev,
"node %pOF err (%d) does not have 'reg' property\n",
node, err);
continue;
}

if (reg[1] != SPMI_USID) {
dev_err(&ctrl->dev,
"node %pOF contains unsupported 'reg' entry\n",
node);
continue;
}

if (reg[0] >= SPMI_MAX_SLAVE_ID) {
dev_err(&ctrl->dev, "invalid usid on node %pOF\n", node);
continue;
}

So, for now, using SPMI_GSID will fail.

[1] drivers/spmi/spmi.c

So, I'm inclined to define reg property as:

properties:
reg:
minItems: 1
maxItems: 2
items:
- minimum: 0
maximum: 0xf
- enum: [ 0 ]
description: |
0 means user ID address. 1 is reserved for group ID address.

And drop the group ID from the example. I'll send such version as a
second version of this patch.

Thanks,
Mauro


# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/spmi/spmi.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: System Power Management Interface (SPMI) Controller

maintainers:
- Josh Cartwright <joshc@xxxxxxxxxxxxxx>

description: |
The System Power Management (SPMI) controller is a 2-wire bus defined
by the MIPI Alliance for power management control to be used on SoC designs.

SPMI controllers are modelled in device tree using a generic set of
bindings defined here, plus any bus controller specific properties, if
needed.

Each SPMI controller has zero or more child nodes (up to 16 ones), each
one representing an unique slave at the bus.

properties:
$nodename:
pattern: "spmi@.*"

reg:
maxItems: 1

"#address-cells":
const: 2

"#size-cells":
const: 0

patternProperties:
".*@([0-9]|1[0-5])$":
description: up to 16 child PMIC nodes
type: object

properties:
reg:
minItems: 1
maxItems: 2
items:
- minimum: 0
maximum: 0xf
- enum: [ 0, 1 ]

required:
- reg

required:
- reg

examples:
- |
#include <dt-bindings/spmi/spmi.h>

spmi@0 {
reg = <0 0>;

#address-cells = <2>;
#size-cells = <0>;

child@0 {
reg = <0 SPMI_USID>;
};

child@7 {
reg = <7 SPMI_USID>,
<3 SPMI_GSID>;
};
};