Skip to content

Commit 895fe45

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: Add upgrade path to #pwm-cells = <3> for users of of_pwm_single_xlate()
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> Link: https://lore.kernel.org/r/b33a84d3f073880e94fc303cd32ebe095eb5ce46.1738842938.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
1 parent e320a24 commit 895fe45

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/pwm/core.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,11 +1000,27 @@ of_pwm_xlate_with_flags(struct pwm_chip *chip, const struct of_phandle_args *arg
10001000
}
10011001
EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags);
10021002

1003+
/*
1004+
* This callback is used for PXA PWM chips that only have a single PWM line.
1005+
* For such chips you could argue that passing the line number (i.e. the first
1006+
* parameter in the common case) is useless as it's always zero. So compared to
1007+
* the default xlate function of_pwm_xlate_with_flags() the first parameter is
1008+
* the default period and the second are flags.
1009+
*
1010+
* Note that if #pwm-cells = <3>, the semantic is the same as for
1011+
* of_pwm_xlate_with_flags() to allow converting the affected driver to
1012+
* #pwm-cells = <3> without breaking the legacy binding.
1013+
*
1014+
* Don't use for new drivers.
1015+
*/
10031016
struct pwm_device *
10041017
of_pwm_single_xlate(struct pwm_chip *chip, const struct of_phandle_args *args)
10051018
{
10061019
struct pwm_device *pwm;
10071020

1021+
if (args->args_count >= 3)
1022+
return of_pwm_xlate_with_flags(chip, args);
1023+
10081024
pwm = pwm_request_from_chip(chip, 0, NULL);
10091025
if (IS_ERR(pwm))
10101026
return pwm;

0 commit comments

Comments
 (0)