Skip to contentSkip to conversation

spi: dt-bindings: spi-peripheral-props: Document spi-cpha and spi-cpol

PATCH Superseded Fabio Estevam 4 participants 10 messages Aug 29, 2024 – Aug 31, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 spi: dt-bindings: spi-peripheral-props: Document spi-cpha and spi-cpol

The 'spi-cpha' and 'spi-cpol' are commonly used SPI peripheral properties that indicate the device clock phase and polarity.

Document these properties.

---
 .../devicetree/bindings/spi/spi-peripheral-props.yaml  | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +10 -0
index 0bb443b8decd..b2e2717f3619 100644
@@ -29,6 +29,16 @@ properties:
     description:
       Chip select used by the device.
 
+  spi-cpha:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      The device data is sampled on trailing (last) edge of the SPI clock.
+
+  spi-cpol:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      The device clock has a falling lead (first) edge.
+
   spi-cs-high:
     $ref: /schemas/types.yaml#/definitions/flag
     description:
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 dt-bindings: trivial-devices: Add a reference to spi-peripheral-props.yaml

There may be cases where a trivial-device needs to describe the SPI clock polarity and phase via spi-cpol and spi-cpha properties.

Add a reference to spi-peripheral-props.yaml to allow that.

---
 Documentation/devicetree/bindings/trivial-devices.yaml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/trivial-devices.yaml +4 -1
index 75a5fad08c44..356b89ade6a8 100644
@@ -424,6 +424,9 @@ required:
   - compatible
   - reg
 
-additionalProperties: false
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+unevaluatedProperties: false
 
 ...
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/2] dt-bindings: trivial-devices: Add a reference to spi-peripheral-props.yaml

Quoted 3 lines · Fabio Estevam

There may be cases where a trivial-device needs to describe the SPI clock polarity and phase via spi-cpol and spi-cpha properties.

Since those don't come from spi-peripheral-props, not really the correct justification (although why they don't, I'm not sure). If you still saw dtbs_check complaints after the first patch, I maybe the controller schema is missing a reference to spi-controller.yaml?
That said, I think the reference is useful for other the properties, like spi-max-frequency, so the diff here is sound.

Thanks,
Conor.

Quoted 27 lines

Add a reference to spi-peripheral-props.yaml to allow that.

---
 Documentation/devicetree/bindings/trivial-devices.yaml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/trivial-devices.yaml +4 -1
index 75a5fad08c44..356b89ade6a8 100644
@@ -424,6 +424,9 @@ required:
   - compatible
   - reg
 
-additionalProperties: false
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+unevaluatedProperties: false
 
...
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH 2/2] dt-bindings: trivial-devices: Add a reference to spi-peripheral-props.yaml

Hi Conor,

Quoted 4 lines · Conor Dooley

Since those don't come from spi-peripheral-props, not really the correct justification (although why they don't, I'm not sure). If you still saw dtbs_check complaints after the first patch, I maybe the controller schema is missing a reference to spi-controller.yaml?

I changed the first patch as suggested:

Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +4 -0
@@ -29,6 +29,10 @@ properties:
     description:
       Chip select used by the device.
 
+  spi-cpha: true
+
+  spi-cpol: true
+
   spi-cs-high:
     $ref: /schemas/types.yaml#/definitions/flag
     description:

spi-rockchip.yaml does reference spi-controller.yaml, but I still get dtbs_check complaints after the first patch.

$ make CHECK_DTBS=y rockchip/rv1108-elgin-r1.dtb -j12
  UPD     include/config/kernel.release
  SCHEMA  Documentation/devicetree/bindings/processed-schema.json
  DTC [C] arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb
/home/fabio/linux-next/arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb:
display@0: 'spi-cpha', 'spi-cpol' do not match any of the regexes:
'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/trivial-devices.yaml#

I would appreciate some suggestions on how to fix this warning.

Thanks

#4 lore raw

Re: [PATCH 2/2] dt-bindings: trivial-devices: Add a reference to spi-peripheral-props.yaml

Quoted 37 lines · Fabio Estevam

Hi Conor,

Quoted 4 lines · Conor Dooley

Since those don't come from spi-peripheral-props, not really the correct justification (although why they don't, I'm not sure). If you still saw dtbs_check complaints after the first patch, I maybe the controller schema is missing a reference to spi-controller.yaml?

I changed the first patch as suggested:

Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +4 -0
@@ -29,6 +29,10 @@ properties:
     description:
       Chip select used by the device.
 
+  spi-cpha: true
+
+  spi-cpol: true
+
   spi-cs-high:
     $ref: /schemas/types.yaml#/definitions/flag
     description:

spi-rockchip.yaml does reference spi-controller.yaml, but I still get dtbs_check complaints after the first patch.

$ make CHECK_DTBS=y rockchip/rv1108-elgin-r1.dtb -j12
  UPD     include/config/kernel.release
  SCHEMA  Documentation/devicetree/bindings/processed-schema.json
  DTC [C] arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb
/home/fabio/linux-next/arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb:
display@0: 'spi-cpha', 'spi-cpol' do not match any of the regexes:
'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/trivial-devices.yaml#
Quoted 1 line

I would appreciate some suggestions on how to fix this warning.

Ah, I think I suggested something garbage, because I misread the diff, as my quoted mail evidences. I was really trying to suggest putting
spi-cpha: true
spi-cpol: true
in trivial-devices.yaml, but I didn't notice that the patch was to spi-peripheral-props rather than trivial-devices. These properties are defined (for reasons I don't quite understand) in spi-controller.yaml and applied to children of the controller node by that binding and I wanted to avoid the redefinition.

maintainer
#5 lore raw

Re: [PATCH 2/2] dt-bindings: trivial-devices: Add a reference to spi-peripheral-props.yaml

Quoted 38 lines · Conor Dooley
Quoted 37 lines · Fabio Estevam

Hi Conor,

Quoted 4 lines · Conor Dooley

Since those don't come from spi-peripheral-props, not really the correct justification (although why they don't, I'm not sure). If you still saw dtbs_check complaints after the first patch, I maybe the controller schema is missing a reference to spi-controller.yaml?

I changed the first patch as suggested:

Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +4 -0
@@ -29,6 +29,10 @@ properties:
     description:
       Chip select used by the device.
 
+  spi-cpha: true
+
+  spi-cpol: true
+
   spi-cs-high:
     $ref: /schemas/types.yaml#/definitions/flag
     description:

spi-rockchip.yaml does reference spi-controller.yaml, but I still get dtbs_check complaints after the first patch.

$ make CHECK_DTBS=y rockchip/rv1108-elgin-r1.dtb -j12
  UPD     include/config/kernel.release
  SCHEMA  Documentation/devicetree/bindings/processed-schema.json
  DTC [C] arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb
/home/fabio/linux-next/arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb:
display@0: 'spi-cpha', 'spi-cpol' do not match any of the regexes:
'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/trivial-devices.yaml#
Quoted 11 lines
Quoted 1 line

I would appreciate some suggestions on how to fix this warning.

Ah, I think I suggested something garbage, because I misread the diff, as my quoted mail evidences. I was really trying to suggest putting
spi-cpha: true
spi-cpol: true
in trivial-devices.yaml, but I didn't notice that the patch was to spi-peripheral-props rather than trivial-devices. These properties are defined (for reasons I don't quite understand) in spi-controller.yaml and applied to children of the controller node by that binding and I wanted to avoid the redefinition.

I steered Fabio wrong...

I think we originally had these in spi-peripheral-props, but then decided they are properties of the device, not the controller. These properties should really only be needed if the device supports different modes. If what a device supports is fixed, then that can be implicit.

There's one other case I see with "dh,dhcom-board". So I guess add spi-cpha and spi-cpol directly to trivial-devices.yaml.

Rob

#6 lore raw

Re: [PATCH 2/2] dt-bindings: trivial-devices: Add a reference to spi-peripheral-props.yaml

Quoted 51 lines · Rob Herring
Quoted 38 lines · Conor Dooley
Quoted 37 lines · Fabio Estevam

Hi Conor,

Quoted 4 lines · Conor Dooley

Since those don't come from spi-peripheral-props, not really the correct justification (although why they don't, I'm not sure). If you still saw dtbs_check complaints after the first patch, I maybe the controller schema is missing a reference to spi-controller.yaml?

I changed the first patch as suggested:

Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +4 -0
@@ -29,6 +29,10 @@ properties:
     description:
       Chip select used by the device.
 
+  spi-cpha: true
+
+  spi-cpol: true
+
   spi-cs-high:
     $ref: /schemas/types.yaml#/definitions/flag
     description:

spi-rockchip.yaml does reference spi-controller.yaml, but I still get dtbs_check complaints after the first patch.

$ make CHECK_DTBS=y rockchip/rv1108-elgin-r1.dtb -j12
  UPD     include/config/kernel.release
  SCHEMA  Documentation/devicetree/bindings/processed-schema.json
  DTC [C] arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb
/home/fabio/linux-next/arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb:
display@0: 'spi-cpha', 'spi-cpol' do not match any of the regexes:
'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/trivial-devices.yaml#
Quoted 11 lines
Quoted 1 line

I would appreciate some suggestions on how to fix this warning.

Ah, I think I suggested something garbage, because I misread the diff, as my quoted mail evidences. I was really trying to suggest putting
spi-cpha: true
spi-cpol: true
in trivial-devices.yaml, but I didn't notice that the patch was to spi-peripheral-props rather than trivial-devices. These properties are defined (for reasons I don't quite understand) in spi-controller.yaml and applied to children of the controller node by that binding and I wanted to avoid the redefinition.

Quoted 4 lines

I steered Fabio wrong...

I think we originally had these in spi-peripheral-props, but then decided they are properties of the device, not the controller.

I don't follow, how would them being properties of the "device", make them unsuitable for spi-peripheral-props? Is the differentiation supposed to be that the things in spi-peripheral-props are actually there to do per-"device" tweaks for special controller features and the things applied by spi-controller to child nodes of SPI buses are the ones that describe requirements of the device?

Even if that is a rather WTF responsibility distribution between files (partly that's down to naming), the usage does make sense. spi-peripheral-props can be unconditionally included by all SPI devices, since the controller determines what properties are relevant, and spa-cpha etc only get permitted when explicitly set as "true".

Quoted 3 lines

These
properties should really only be needed if the device supports different modes. If what a device supports is fixed, then that can be implicit.

Right. That's very inconsistently done though, even if it makes sense. I'd wager there are very few devices that actually support both configurations but conversely very few drivers for active-high-only devices that don't rely on the spi-cs-active-high (or w/e it is) property to function correctly.

I should send a patch for pcf2123 to make it required, because that is the one I know for sure requires active high off the top of my head.

Quoted 5 lines

There's one other case I see with "dh,dhcom-board". So I guess add spi-cpha and spi-cpol directly to trivial-devices.yaml.

Rob

#7 lore raw

Re: [PATCH 2/2] dt-bindings: trivial-devices: Add a reference to spi-peripheral-props.yaml

In reply to Rob Herring
Quoted 53 lines · Rob Herring
Quoted 38 lines · Conor Dooley
Quoted 37 lines · Fabio Estevam

Hi Conor,

Quoted 4 lines · Conor Dooley

Since those don't come from spi-peripheral-props, not really the correct justification (although why they don't, I'm not sure). If you still saw dtbs_check complaints after the first patch, I maybe the controller schema is missing a reference to spi-controller.yaml?

I changed the first patch as suggested:

Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +4 -0
@@ -29,6 +29,10 @@ properties:
     description:
       Chip select used by the device.
 
+  spi-cpha: true
+
+  spi-cpol: true
+
   spi-cs-high:
     $ref: /schemas/types.yaml#/definitions/flag
     description:

spi-rockchip.yaml does reference spi-controller.yaml, but I still get dtbs_check complaints after the first patch.

$ make CHECK_DTBS=y rockchip/rv1108-elgin-r1.dtb -j12
  UPD     include/config/kernel.release
  SCHEMA  Documentation/devicetree/bindings/processed-schema.json
  DTC [C] arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb
/home/fabio/linux-next/arch/arm/boot/dts/rockchip/rv1108-elgin-r1.dtb:
display@0: 'spi-cpha', 'spi-cpol' do not match any of the regexes:
'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/trivial-devices.yaml#
Quoted 11 lines
Quoted 1 line

I would appreciate some suggestions on how to fix this warning.

Ah, I think I suggested something garbage, because I misread the diff, as my quoted mail evidences. I was really trying to suggest putting
spi-cpha: true
spi-cpol: true
in trivial-devices.yaml, but I didn't notice that the patch was to spi-peripheral-props rather than trivial-devices. These properties are defined (for reasons I don't quite understand) in spi-controller.yaml and applied to children of the controller node by that binding and I wanted to avoid the redefinition.

I steered Fabio wrong...

Quoted 7 lines

I think we originally had these in spi-peripheral-props, but then decided they are properties of the device, not the controller. These properties should really only be needed if the device supports different modes. If what a device supports is fixed, then that can be implicit.

There's one other case I see with "dh,dhcom-board". So I guess add spi-cpha and spi-cpol directly to trivial-devices.yaml.

I responded to v2 before reaching here. Are you sure that's intended? It's almost equal to the patch here: all trivial devices will have it, even if they do not need it. For a device requiring CPOL/CPHA, not having it (or the reverse) is a bug in DTS and basically we would miss such check for all trivial devices.

Best regards,
Krzysztof

#8 lore raw
In reply to Fabio Estevam
Quoted 17 lines · Fabio Estevam

The 'spi-cpha' and 'spi-cpol' are commonly used SPI peripheral properties that indicate the device clock phase and polarity.

Document these properties.

---
 .../devicetree/bindings/spi/spi-peripheral-props.yaml  | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +0 -0
index 0bb443b8decd..b2e2717f3619 100644
@@ -29,6 +29,16 @@ properties:
     description:
       Chip select used by the device.

Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml properties: · line 40

Quoted 10 lines
Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +9 -0
 
+  spi-cpha:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      The device data is sampled on trailing (last) edge of the SPI clock.
+
+  spi-cpol:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      The device clock has a falling lead (first) edge.

These two should just be usable with "spi-cpha: true", they're applied by the controller schema to it's child nodes, so you don't need to redefine their type here.

Quoted 7 lines
Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +1 -0
+
   spi-cs-high:
     $ref: /schemas/types.yaml#/definitions/flag
     description:
Signature · 1 line
2.34.1
#9 lore raw
In reply to Fabio Estevam
Quoted 17 lines · Fabio Estevam

The 'spi-cpha' and 'spi-cpol' are commonly used SPI peripheral properties that indicate the device clock phase and polarity.

Document these properties.

---
 .../devicetree/bindings/spi/spi-peripheral-props.yaml  | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +0 -0
index 0bb443b8decd..b2e2717f3619 100644
@@ -29,6 +29,16 @@ properties:
     description:
       Chip select used by the device.

Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml properties: · line 40

Quoted 10 lines
Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +9 -0
 
+  spi-cpha:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      The device data is sampled on trailing (last) edge of the SPI clock.
+
+  spi-cpol:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      The device clock has a falling lead (first) edge.

That would be a revert of earlier commit without explanation why such revert is needed. :(

Best regards,
Krzysztof