Skip to contentSkip to conversation

dt-bindings: pwm: Add generic "pwm-channels" property

PATCH New Andre Przywara 2 participants 2 messages Feb 28, 2018 – Mar 5, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dt-bindings: pwm: Add generic "pwm-channels" property

Many PWM drivers seem to hardcode the number of PWM channels (brcm,iproc-pwm, brcm,kona-pwm.txt). If this is only one device supported by the binding, that's probably OK, but for instance for sun4i-pwm I see one or two channels, depending on the particular SoC. amlogic,meson-gxbb-pwm seems to deduce the number of channels from the number of input clocks, and pwm-st has a vendor-specific property for that (st,pwm-num-chan).
To cover all those cases more elegantly in (future) bindings, add a new generic property to specify the number of PWM channels a particular controller implements.
For instance the sun4i-pwm driver could be extended to support this for future SoCs as well.

---
Hi,

while looking at the bindings for PWM drivers, I was wondering if we should have a generic property to note the number of implemented channels? We have something for instance for DMA controllers (dma-channels), so adding this to PWM controller bindings sounds natural.
In particular the new sun8i-pwm IP seems to be scalable to a number of channels, judging from the register and bit layout and from the bit assignment in the manual. I have the gut feeling we will meet this fella again in another Allwinner SoC with a different number of channels.

Thanks!
Andre.

 Documentation/devicetree/bindings/pwm/pwm.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/pwm/pwm.txt +6 -0
index 8556263b8502..770f3aee17af 100644
@@ -60,10 +60,16 @@ Example with optional PWM specifier for inverse polarity
 PWM controller nodes must specify the number of cells used for the
 specifier using the '#pwm-cells' property.
 
+A specific controller binding might specify the implemented number of
+PWM channels using this generic property:
+	pwm-channels = <8>;
+This property holds a single 32 bit integer.
+
 An example PWM controller might look like this:
 
 	pwm: pwm at 7000a000 {
 		compatible = "nvidia,tegra20-pwm";
 		reg = <0x7000a000 0x100>;
 		#pwm-cells = <2>;
+		pwm-channels = <4>;
 	};
Signature · 1 line
2.14.1
maintainer
#1 lore raw

PATCH 1/1 dt-bindings: pwm: Add generic "pwm-channels" property

Quoted 18 lines · Andre Przywara

Many PWM drivers seem to hardcode the number of PWM channels (brcm,iproc-pwm, brcm,kona-pwm.txt). If this is only one device supported by the binding, that's probably OK, but for instance for sun4i-pwm I see one or two channels, depending on the particular SoC. amlogic,meson-gxbb-pwm seems to deduce the number of channels from the number of input clocks, and pwm-st has a vendor-specific property for that (st,pwm-num-chan).
To cover all those cases more elegantly in (future) bindings, add a new generic property to specify the number of PWM channels a particular controller implements.
For instance the sun4i-pwm driver could be extended to support this for future SoCs as well.

---
Hi,

Quoted 9 lines

while looking at the bindings for PWM drivers, I was wondering if we should have a generic property to note the number of implemented channels? We have something for instance for DMA controllers (dma-channels), so adding this to PWM controller bindings sounds natural.
In particular the new sun8i-pwm IP seems to be scalable to a number of channels, judging from the register and bit layout and from the bit assignment in the manual. I have the gut feeling we will meet this fella again in another Allwinner SoC with a different number of channels.

Often this should be implied by the compatible string. However, there are no doubt some cases that may need this. One I could think of is the PWM controller has more channels than are pinned out.

Quoted 31 lines

Thanks!
Andre.

 Documentation/devicetree/bindings/pwm/pwm.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/pwm/pwm.txt +6 -0
index 8556263b8502..770f3aee17af 100644
@@ -60,10 +60,16 @@ Example with optional PWM specifier for inverse polarity
 PWM controller nodes must specify the number of cells used for the
 specifier using the '#pwm-cells' property.
 
+A specific controller binding might specify the implemented number of
+PWM channels using this generic property:
+	pwm-channels = <8>;
+This property holds a single 32 bit integer.
+
 An example PWM controller might look like this:
 
 	pwm: pwm at 7000a000 {
 		compatible = "nvidia,tegra20-pwm";
 		reg = <0x7000a000 0x100>;
 		#pwm-cells = <2>;
+		pwm-channels = <4>;
 	};
Signature · 1 line
2.14.1