Skip to contentSkip to conversation

dt-bindings: pwm: binding allwinner sun8i.

PATCH Superseded hao_zhang 3 participants 4 messages Feb 25, 2018 – Mar 1, 2018

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

hao_zhang

author
#0 lore raw

PATCH v2 1/4 dt-bindings: pwm: binding allwinner sun8i.

This patch adds allwinner sun8i pwm binding documents.

---
 Documentation/devicetree/bindings/pwm/pwm-sun8i.txt | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-sun8i.txt
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +18 -0
new file mode 100644
index 0000000..e8c48be
@@ -0,0 +1,18 @@
+Allwinner sun8i R40/V40/T3 SoC PWM controller
+
+Required properties:
+  - compatible: should be one of:
+    - "allwinner,sun8i-r40-pwm"
+  - reg: physical base address and length of the controller's registers
+  - #pwm-cells: should be 3. See pwm.txt in this directory for a description of
+    the cells format.
+  - clocks: From common clock binding, handle to the parent clock.
+
+Example:
+
+pwm: pwm at 1c23400 {
+	     compatible = "allwinner,sun8i-pwm";
+	     reg = <0x01c23400 0x154>;
+	     clocks = <&osc24M>;
+	     #pwm-cells = <3>;
+};
Signature · 1 line
2.7.4
#1 lore raw

Hi,

Quoted 18 lines · hao_zhang

This patch adds allwinner sun8i pwm binding documents.

---
 Documentation/devicetree/bindings/pwm/pwm-sun8i.txt | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-sun8i.txt
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +4 -0
new file mode 100644
index 0000000..e8c48be
@@ -0,0 +1,18 @@
+Allwinner sun8i R40/V40/T3 SoC PWM controller
+
+Required properties:
+  - compatible: should be one of:

Documentation/devicetree/bindings/pwm/pwm-sun8i.txt line 14

Quoted 10 lines
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +10 -0
+    - "allwinner,sun8i-r40-pwm"
+  - reg: physical base address and length of the controller's registers
+  - #pwm-cells: should be 3. See pwm.txt in this directory for a description of
+    the cells format.
+  - clocks: From common clock binding, handle to the parent clock.
+
+Example:
+
+pwm: pwm at 1c23400 {
+	     compatible = "allwinner,sun8i-pwm";

The compatible you have here isn't the one documented.

Documentation/devicetree/bindings/pwm/pwm-sun8i.txt line 15

Quoted 1 line
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +1 -0
+	     reg = <0x01c23400 0x154>;

And the size isn't correct, even though that doesn't really make any difference here.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180226/67e22370/attachment-0001.sig>
#2 lore raw
In reply to hao_zhang

Hi,

Quoted 14 lines · hao_zhang

This patch adds allwinner sun8i pwm binding documents.

---
 Documentation/devicetree/bindings/pwm/pwm-sun8i.txt | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-sun8i.txt
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +0 -0
new file mode 100644
index 0000000..e8c48be

Documentation/devicetree/bindings/pwm/pwm-sun8i.txt line 9

Quoted 9 lines
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +9 -0
@@ -0,0 +1,18 @@
+Allwinner sun8i R40/V40/T3 SoC PWM controller
+
+Required properties:
+  - compatible: should be one of:
+    - "allwinner,sun8i-r40-pwm"
+  - reg: physical base address and length of the controller's registers
+  - #pwm-cells: should be 3. See pwm.txt in this directory for a description of
+    the cells format.
+  - clocks: From common clock binding, handle to the parent clock.

The manual tells me that there are two possible clock sources (24 MHz OSC and APB1), with actually two bits for encoding the mux source, allowing for two more potential clock sources.
So can we extend this description to provide up to four clocks, with a clock-names property telling the driver how this maps to the mux value? Either we use clock names matching the clocks mentioned in the manual:

	clocks = <&osc24M>, <&ccu CLK_APB1>;
	clock-names = "osc", "apb1";
or we encode the mux values in the clock-names:
	clock-names = "mux-0", "mux-1";

Don't know what's more widely used in those cases, the latter seems to be more future-proof.
Each channel pair can be configured to use one of the two (or four) clocks, so we can be more flexible with multiple clocks.

Also, can you please add an "interrupts" property here? You don't need to use it in the driver right now, but since there are multiple registers dealing with the interrupts we should have it in the binding. If in need, we can then add support later.

Documentation/devicetree/bindings/pwm/pwm-sun8i.txt line 14

Quoted 5 lines
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +5 -0
+
+Example:
+
+pwm: pwm at 1c23400 {
+	     compatible = "allwinner,sun8i-pwm";

That should match what you wrote above: allwinner,sun8i-r40-pwm. And I believe this is the right compatible name, since there are numerous other sun8i SoCs with the sun4i PWM IP, so just sun8i-pwm would be misleading and confusing.

Documentation/devicetree/bindings/pwm/pwm-sun8i.txt line 16

Quoted 2 lines
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +2 -0
+	     reg = <0x01c23400 0x154>;
+	     clocks = <&osc24M>;

This should then be amended to what I sketched above.

Documentation/devicetree/bindings/pwm/pwm-sun8i.txt line 17

Quoted 1 line
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +1 -0
+	     #pwm-cells = <3>;

And then here please add:

	     interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;

Cheers,
Andre

#3 lore raw

Hi,

Quoted 31 lines · Andr? Przywara
Quoted 14 lines · hao_zhang

This patch adds allwinner sun8i pwm binding documents.

---
 Documentation/devicetree/bindings/pwm/pwm-sun8i.txt | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-sun8i.txt
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +0 -0
new file mode 100644
index 0000000..e8c48be

Documentation/devicetree/bindings/pwm/pwm-sun8i.txt line 9

Quoted 9 lines
Documentation/devicetree/bindings/pwm/pwm-sun8i.txt new file +9 -0
@@ -0,0 +1,18 @@
+Allwinner sun8i R40/V40/T3 SoC PWM controller
+
+Required properties:
+  - compatible: should be one of:
+    - "allwinner,sun8i-r40-pwm"
+  - reg: physical base address and length of the controller's registers
+  - #pwm-cells: should be 3. See pwm.txt in this directory for a description of
+    the cells format.
+  - clocks: From common clock binding, handle to the parent clock.

The manual tells me that there are two possible clock sources (24 MHz OSC and APB1), with actually two bits for encoding the mux source, allowing for two more potential clock sources.
So can we extend this description to provide up to four clocks, with a clock-names property telling the driver how this maps to the mux value? Either we use clock names matching the clocks mentioned in the manual:

Quoted 4 lines
	clocks = <&osc24M>, <&ccu CLK_APB1>;
	clock-names = "osc", "apb1";
or we encode the mux values in the clock-names:
	clock-names = "mux-0", "mux-1";

I'd prefer the former.

Quoted 2 lines

Don't know what's more widely used in those cases, the latter seems to be more future-proof.

Not really, nothing prevents the next generation to have three bits, or even 32 bits to do the muxing :)

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180301/a9bccc06/attachment.sig>