* [PATCH v2 1/3] pwm: Add upgrade path to #pwm-cells = <3> for users of of_pwm_single_xlate()
2025-02-06 12:06 [PATCH v2 0/3] pwm: pxa: Use #pwm-cells = <3> Uwe Kleine-König
@ 2025-02-06 12:06 ` Uwe Kleine-König
2025-02-06 12:06 ` [PATCH v2 2/3] dt-bindings: pwm: marvell,pxa-pwm: Update to use #pwm-cells = <3> Uwe Kleine-König
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2025-02-06 12:06 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Duje Mihanović
Cc: Hervé Codina, linux-pwm, linux-arm-kernel, devicetree
The PWM chip on PXA only has a single output. Back when the device tree
binding was defined it was considered a good idea to not pass the PWM
line index as is done for all other PWM types as it would be always zero
anyhow and so doesn't add any value.
However for consistency reasons it is nice when all PWMs use the same
binding. For that reason let of_pwm_single_xlate() (i.e. the function
that implements the PXA behaviour) behave in the same way as
of_pwm_xlate_with_flags() for 3 (or more) parameters. With that in
place, the pxa-pwm binding can be updated to #pwm-cells = <3> without
breaking old device trees that stick to #pwm-cells = <1>.
Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Tested-by: Duje Mihanović <duje.mihanovic@skole.hr>
Reviewed-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
drivers/pwm/core.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index ccd54c089bab..bc05818fa370 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -1000,11 +1000,27 @@ of_pwm_xlate_with_flags(struct pwm_chip *chip, const struct of_phandle_args *arg
}
EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags);
+/*
+ * This callback is used for PXA PWM chips that only have a single PWM line.
+ * For such chips you could argue that passing the line number (i.e. the first
+ * parameter in the common case) is useless as it's always zero. So compared to
+ * the default xlate function of_pwm_xlate_with_flags() the first parameter is
+ * the default period and the second are flags.
+ *
+ * Note that if #pwm-cells = <3>, the semantic is the same as for
+ * of_pwm_xlate_with_flags() to allow converting the affected driver to
+ * #pwm-cells = <3> without breaking the legacy binding.
+ *
+ * Don't use for new drivers.
+ */
struct pwm_device *
of_pwm_single_xlate(struct pwm_chip *chip, const struct of_phandle_args *args)
{
struct pwm_device *pwm;
+ if (args->args_count >= 3)
+ return of_pwm_xlate_with_flags(chip, args);
+
pwm = pwm_request_from_chip(chip, 0, NULL);
if (IS_ERR(pwm))
return pwm;
--
2.47.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 2/3] dt-bindings: pwm: marvell,pxa-pwm: Update to use #pwm-cells = <3>
2025-02-06 12:06 [PATCH v2 0/3] pwm: pxa: Use #pwm-cells = <3> Uwe Kleine-König
2025-02-06 12:06 ` [PATCH v2 1/3] pwm: Add upgrade path to #pwm-cells = <3> for users of of_pwm_single_xlate() Uwe Kleine-König
@ 2025-02-06 12:06 ` Uwe Kleine-König
2025-02-11 16:16 ` Rob Herring
2025-02-06 12:06 ` [PATCH v2 3/3] ARM: dts: pxa: Use #pwm-cells = <3> for marvell,pxa-pwm devices Uwe Kleine-König
2025-02-10 18:31 ` [PATCH v2 0/3] pwm: pxa: Use #pwm-cells = <3> Uwe Kleine-König
3 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2025-02-06 12:06 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Duje Mihanović
Cc: Hervé Codina, linux-pwm, linux-arm-kernel, devicetree,
Conor Dooley
The PXA PWM binding is the only one that doesn't pass the PWM line index
as first parameter of the parameter cells. However this can be upgraded
to the mandatory binding for all new PWM drivers without breaking
compatibility for old device trees using #pwm-cells = <1>.
So bump #pwm-cells to 3 with the (undocumented) promise to keep the old
behaviour for #pwm-cells = <1>.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Duje Mihanović <duje.mihanovic@skole.hr>
Reviewed-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml b/Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml
index 9ee1946dc2e1..74f2d5964742 100644
--- a/Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml
+++ b/Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml
@@ -25,8 +25,7 @@ properties:
maxItems: 1
"#pwm-cells":
- # Used for specifying the period length in nanoseconds
- const: 1
+ const: 3
clocks:
maxItems: 1
@@ -45,6 +44,6 @@ examples:
pwm0: pwm@40b00000 {
compatible = "marvell,pxa250-pwm";
reg = <0x40b00000 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM0>;
};
--
2.47.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2 2/3] dt-bindings: pwm: marvell,pxa-pwm: Update to use #pwm-cells = <3>
2025-02-06 12:06 ` [PATCH v2 2/3] dt-bindings: pwm: marvell,pxa-pwm: Update to use #pwm-cells = <3> Uwe Kleine-König
@ 2025-02-11 16:16 ` Rob Herring
0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2025-02-11 16:16 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Krzysztof Kozlowski,
Conor Dooley, Duje Mihanović, Hervé Codina, linux-pwm,
linux-arm-kernel, devicetree, Conor Dooley
On Thu, Feb 06, 2025 at 01:06:26PM +0100, Uwe Kleine-König wrote:
> The PXA PWM binding is the only one that doesn't pass the PWM line index
> as first parameter of the parameter cells. However this can be upgraded
> to the mandatory binding for all new PWM drivers without breaking
> compatibility for old device trees using #pwm-cells = <1>.
>
> So bump #pwm-cells to 3 with the (undocumented) promise to keep the old
> behaviour for #pwm-cells = <1>.
Why make that undocumented?
>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> Tested-by: Duje Mihanović <duje.mihanovic@skole.hr>
> Reviewed-by: Daniel Mack <daniel@zonque.org>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
> Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml b/Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml
> index 9ee1946dc2e1..74f2d5964742 100644
> --- a/Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml
> +++ b/Documentation/devicetree/bindings/pwm/marvell,pxa-pwm.yaml
> @@ -25,8 +25,7 @@ properties:
> maxItems: 1
>
> "#pwm-cells":
> - # Used for specifying the period length in nanoseconds
> - const: 1
> + const: 3
Note that if we apply this and not the dts change, we'll add warnings.
You could instead do:
oneOf:
- const: 1
deprecated: true
- const: 3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] ARM: dts: pxa: Use #pwm-cells = <3> for marvell,pxa-pwm devices
2025-02-06 12:06 [PATCH v2 0/3] pwm: pxa: Use #pwm-cells = <3> Uwe Kleine-König
2025-02-06 12:06 ` [PATCH v2 1/3] pwm: Add upgrade path to #pwm-cells = <3> for users of of_pwm_single_xlate() Uwe Kleine-König
2025-02-06 12:06 ` [PATCH v2 2/3] dt-bindings: pwm: marvell,pxa-pwm: Update to use #pwm-cells = <3> Uwe Kleine-König
@ 2025-02-06 12:06 ` Uwe Kleine-König
2025-02-10 18:31 ` [PATCH v2 0/3] pwm: pxa: Use #pwm-cells = <3> Uwe Kleine-König
3 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2025-02-06 12:06 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Duje Mihanović
Cc: Hervé Codina, linux-pwm, linux-arm-kernel, devicetree
For consistency with most other pwm bindings, also use 3 cells for
phandles to PWM devices.
Tested-by: Duje Mihanović <duje.mihanovic@skole.hr>
Reviewed-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
arch/arm/boot/dts/intel/pxa/pxa25x.dtsi | 4 ++--
arch/arm/boot/dts/intel/pxa/pxa27x.dtsi | 8 ++++----
.../arm/boot/dts/intel/pxa/pxa300-raumfeld-controller.dts | 2 +-
arch/arm/boot/dts/intel/pxa/pxa3xx.dtsi | 8 ++++----
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/arch/arm/boot/dts/intel/pxa/pxa25x.dtsi b/arch/arm/boot/dts/intel/pxa/pxa25x.dtsi
index 5f8300e356ad..d25065caeebc 100644
--- a/arch/arm/boot/dts/intel/pxa/pxa25x.dtsi
+++ b/arch/arm/boot/dts/intel/pxa/pxa25x.dtsi
@@ -67,14 +67,14 @@ gpio: gpio@40e00000 {
pwm0: pwm@40b00000 {
compatible = "marvell,pxa250-pwm";
reg = <0x40b00000 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM0>;
};
pwm1: pwm@40b00010 {
compatible = "marvell,pxa250-pwm";
reg = <0x40b00010 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM1>;
};
diff --git a/arch/arm/boot/dts/intel/pxa/pxa27x.dtsi b/arch/arm/boot/dts/intel/pxa/pxa27x.dtsi
index a2cbfb3be609..ed07b65cc362 100644
--- a/arch/arm/boot/dts/intel/pxa/pxa27x.dtsi
+++ b/arch/arm/boot/dts/intel/pxa/pxa27x.dtsi
@@ -49,28 +49,28 @@ usb0: usb@4c000000 {
pwm0: pwm@40b00000 {
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";
reg = <0x40b00000 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM0>;
};
pwm1: pwm@40b00010 {
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";
reg = <0x40b00010 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM1>;
};
pwm2: pwm@40c00000 {
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";
reg = <0x40c00000 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM0>;
};
pwm3: pwm@40c00010 {
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";
reg = <0x40c00010 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM1>;
};
diff --git a/arch/arm/boot/dts/intel/pxa/pxa300-raumfeld-controller.dts b/arch/arm/boot/dts/intel/pxa/pxa300-raumfeld-controller.dts
index 12b15945ac6d..9094ec422577 100644
--- a/arch/arm/boot/dts/intel/pxa/pxa300-raumfeld-controller.dts
+++ b/arch/arm/boot/dts/intel/pxa/pxa300-raumfeld-controller.dts
@@ -56,7 +56,7 @@ backlight-controller-pwm {
compatible = "pwm-backlight";
pinctrl-names = "default";
pinctrl-0 = <&pwm0_pins>;
- pwms = <&pwm0 10000>;
+ pwms = <&pwm0 0 10000 0>;
power-supply = <®_vbatt>;
status = "disabled";
diff --git a/arch/arm/boot/dts/intel/pxa/pxa3xx.dtsi b/arch/arm/boot/dts/intel/pxa/pxa3xx.dtsi
index f9c216f91865..4e69b4da0ba6 100644
--- a/arch/arm/boot/dts/intel/pxa/pxa3xx.dtsi
+++ b/arch/arm/boot/dts/intel/pxa/pxa3xx.dtsi
@@ -224,7 +224,7 @@ usb0: usb@4c000000 {
pwm0: pwm@40b00000 {
compatible = "marvell,pxa270-pwm";
reg = <0x40b00000 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM0>;
status = "disabled";
};
@@ -232,7 +232,7 @@ pwm0: pwm@40b00000 {
pwm1: pwm@40b00010 {
compatible = "marvell,pxa270-pwm";
reg = <0x40b00010 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM1>;
status = "disabled";
};
@@ -240,7 +240,7 @@ pwm1: pwm@40b00010 {
pwm2: pwm@40c00000 {
compatible = "marvell,pxa270-pwm";
reg = <0x40c00000 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM0>;
status = "disabled";
};
@@ -248,7 +248,7 @@ pwm2: pwm@40c00000 {
pwm3: pwm@40c00010 {
compatible = "marvell,pxa270-pwm";
reg = <0x40c00010 0x10>;
- #pwm-cells = <1>;
+ #pwm-cells = <3>;
clocks = <&clks CLK_PWM1>;
status = "disabled";
};
--
2.47.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2 0/3] pwm: pxa: Use #pwm-cells = <3>
2025-02-06 12:06 [PATCH v2 0/3] pwm: pxa: Use #pwm-cells = <3> Uwe Kleine-König
` (2 preceding siblings ...)
2025-02-06 12:06 ` [PATCH v2 3/3] ARM: dts: pxa: Use #pwm-cells = <3> for marvell,pxa-pwm devices Uwe Kleine-König
@ 2025-02-10 18:31 ` Uwe Kleine-König
2025-02-11 16:12 ` Rob Herring
3 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2025-02-10 18:31 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Duje Mihanović
Cc: Hervé Codina, linux-pwm, linux-arm-kernel, devicetree
[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]
On Thu, Feb 06, 2025 at 01:06:24PM +0100, Uwe Kleine-König wrote:
> Hello,
>
> this series' goal is to soften the special device-tree binding of
> marvel,pxa-pwm devices. This is the only binding that doesn't pass the
> line index as first parameter.
>
> Here the #pwm-cells value is bumped from 1 to 3, keeping compatibility
> with the old binding.
>
> The motivation for this was that Hervé sent a patch introducing pwm
> nexus nodes which don't work nicely with the marvel,pxa-pwm
> particularities.
>
> Changes since (implicit) v1, available at
> https://lore.kernel.org/linux-pwm/cover.1738777221.git.u.kleine-koenig@baylibre.com:
>
> - Use #pwm-cells = <3> also in the binding example (*sigh*), pointed
> out by Rob
> - Add review, ack and test tags by Hervé Codina, Conor Dooley, Duje
> Mihanović and Daniel Mack. Thanks!
>
> I intend to take the first patch via my pwm tree. Assuming the pxa and
> device tree maintainers and bots are happy now: Dear pxa maintainers,
> please tell if I should take the whole series via pwm, or if you want to
> take patches #2 and #3. If the latter: Do you want to delay application
> or should I provide an immutable branch for patch #1?
I applied patch #1 to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
now.
I don't know yet what should happen to the two other patches, but maybe
it's a good idea to wait a bit anyhow to have 3 cells working for the
pxa driver for a kernel release or two before we switch it.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v2 0/3] pwm: pxa: Use #pwm-cells = <3>
2025-02-10 18:31 ` [PATCH v2 0/3] pwm: pxa: Use #pwm-cells = <3> Uwe Kleine-König
@ 2025-02-11 16:12 ` Rob Herring
0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2025-02-11 16:12 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Krzysztof Kozlowski,
Conor Dooley, Duje Mihanović, Hervé Codina, linux-pwm,
linux-arm-kernel, devicetree
On Mon, Feb 10, 2025 at 07:31:08PM +0100, Uwe Kleine-König wrote:
> On Thu, Feb 06, 2025 at 01:06:24PM +0100, Uwe Kleine-König wrote:
> > Hello,
> >
> > this series' goal is to soften the special device-tree binding of
> > marvel,pxa-pwm devices. This is the only binding that doesn't pass the
> > line index as first parameter.
> >
> > Here the #pwm-cells value is bumped from 1 to 3, keeping compatibility
> > with the old binding.
> >
> > The motivation for this was that Hervé sent a patch introducing pwm
> > nexus nodes which don't work nicely with the marvel,pxa-pwm
> > particularities.
> >
> > Changes since (implicit) v1, available at
> > https://lore.kernel.org/linux-pwm/cover.1738777221.git.u.kleine-koenig@baylibre.com:
> >
> > - Use #pwm-cells = <3> also in the binding example (*sigh*), pointed
> > out by Rob
> > - Add review, ack and test tags by Hervé Codina, Conor Dooley, Duje
> > Mihanović and Daniel Mack. Thanks!
> >
> > I intend to take the first patch via my pwm tree. Assuming the pxa and
> > device tree maintainers and bots are happy now: Dear pxa maintainers,
> > please tell if I should take the whole series via pwm, or if you want to
> > take patches #2 and #3. If the latter: Do you want to delay application
> > or should I provide an immutable branch for patch #1?
>
> I applied patch #1 to
> https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
> now.
>
> I don't know yet what should happen to the two other patches, but maybe
> it's a good idea to wait a bit anyhow to have 3 cells working for the
> pxa driver for a kernel release or two before we switch it.
The dts change will never work with a kernel without patch 1. You can
somewhat mitigate that by backporting patch 1 to stable. If users aren't
doing stable updates, they might not be doing dtb updates either...
Rob
^ permalink raw reply [flat|nested] 7+ messages in thread