pwm: support backward compatibility of DTB extending PWM args
Subsystems (7)
v3 cover pwm: support backward compatibility of DTB extending PWM args
Please review this alternative in-house version of supporting backward compatibility of DTB files (new kernel/PWM driver and old DTS), overcoming a problem that pwms arguments of existing PWM drivers are to be extended with polarity field.
Unfortunately I've firstly created the change and only after that found that Lothar Wa?mann is working on his version, so I won't insist on formal preference, but still I like to share my variant since it technically different from Lothar's one.
Changes from v2 to v3:
- improved commit messages
- added two more patches removing of_pwm_xlate_with_flags()
Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Wa?mann.
Vladimir Zapolskiy (5):
pwm: process pwm polarity argument in of_pwm_simple_xlate()
pwm: push up dynamic printk level on errors in of_pwm_get()
pwm: set the actual number of pwms arguments defined in board dts
pwm: do not set of_pwm_xlate_with_flags() as a callback
pwm: remove of_pwm_xlate_with_flags() function
drivers/pwm/core.c | 42 ++++++++++++----------------------------- drivers/pwm/pwm-atmel-hlcdc.c | 2 -- drivers/pwm/pwm-atmel-tcb.c | 2 -- drivers/pwm/pwm-atmel.c | 6 ------ drivers/pwm/pwm-bcm-kona.c | 2 -- drivers/pwm/pwm-fsl-ftm.c | 2 -- drivers/pwm/pwm-renesas-tpu.c | 2 -- drivers/pwm/pwm-rockchip.c | 5 ----- drivers/pwm/pwm-samsung.c | 3 --- drivers/pwm/pwm-tiecap.c | 2 -- drivers/pwm/pwm-tiehrpwm.c | 2 -- drivers/pwm/pwm-vt8500.c | 2 -- include/linux/pwm.h | 3 --- 13 files changed, 12 insertions(+), 63 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v3 1/5 pwm: process pwm polarity argument in of_pwm_simple_xlate()
The third optional argument of pwms is well defined as polarity and it is already used in a number of pwm drivers, so, to minimize changes in the remaining drivers which are to be updated accordingly set polarity in default of_xlate() function.
--- drivers/pwm/core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pwm/core.c +7 -0
@@ -174,6 +174,13 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)pwm_set_period (pwm, args->args[1 ]); +if (pc->of_pwm_n_cells >2 ) { +if (args->args[2 ] &PWM_POLARITY_INVERTED ) +pwm_set_polarity (pwm,PWM_POLARITY_INVERSED ); +else +pwm_set_polarity (pwm,PWM_POLARITY_NORMAL ); + } +return pwm; }
Signature · 1 line
1.7.10.4
PATCH v3 2/5 pwm: push up dynamic printk level on errors in of_pwm_get()
The changed three user messages on fault are printed under pr_debug(), however all of them are unrecoverable and result in failed pwm device registration, report this to a user.
--- drivers/pwm/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pwm/core.c +3 -3
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id) err =of_parse_phandle_with_args (np,"pwms" ,"#pwm-cells" , index, &args);if (err) { -pr_debug ("%s(): can't parse \"pwms\" property\n" , __func__); +pr_err ("%s(): can't parse \"pwms\" property\n" , __func__);return ERR_PTR (err); } pc =of_node_to_pwmchip (args.np);if (IS_ERR (pc)) { -pr_debug ("%s(): PWM chip not found\n" , __func__); +pr_err ("%s(): PWM chip not found\n" , __func__); pwm =ERR_CAST (pc); goto put; }if (args.args_count != pc->of_pwm_n_cells) { -pr_debug ("%s: wrong #pwm-cells for %s\n" , np->full_name, +pr_err ("%s: wrong #pwm-cells for %s\n" , np->full_name, args.np->full_name); pwm =ERR_PTR (-EINVAL ); goto put;
Signature · 1 line
1.7.10.4
PATCH v3 3/5 pwm: set the actual number of pwms arguments defined in board dts
In reply to Vladimir ZapolskiyFor backward compatibility board device tree may define amount of only mandatory pwm properties, which is compared to a pwm driver specific value, by default it is 2 and may be overwritten by a driver.
Any additional arguments shall be considered as optional and they are taken into account, only if #pwm-cells is increased accordingly.
As a positive side effect specific pwm-specifier array may have variable size of #pwm-cells (but not less than amount of mandatory arguments), which allows to omit optional arguments. The parameters array of a specific PWM is updated according to the actual data taken from device tree file.
--- drivers/pwm/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pwm/core.c +2 -1
@@ -543,12 +543,13 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id) goto put; } -if (args.args_count != pc->of_pwm_n_cells) { +if (args.args_count < pc->of_pwm_n_cells) {pr_err ("%s: wrong #pwm-cells for %s\n" , np->full_name, args.np->full_name); pwm =ERR_PTR (-EINVAL ); goto put; } + pc->of_pwm_n_cells = args.args_count; pwm = pc->of_xlate (pc, &args);if (IS_ERR (pwm))
Signature · 1 line
1.7.10.4
PATCH v3 4/5 pwm: do not set of_pwm_xlate_with_flags() as a callback
In reply to Vladimir ZapolskiyThe default of_pwm_simple_xlate() function is capable to process PWM inverted signal polarity flag, there is no need to use exported of_pwm_xlate_with_flags() by the drivers.
The minimal expected by of_pwm_simple_xlate() amount of pwms arguments is changed from 3 to 2, it allows to specify less PWM arguments in the device tree omitting secondary configuration options (in this case it is signal polarity value). The change has side effects, only if
--- drivers/pwm/pwm-atmel-hlcdc.c | 2 -- drivers/pwm/pwm-atmel-tcb.c | 2 -- drivers/pwm/pwm-atmel.c | 6 ------ drivers/pwm/pwm-bcm-kona.c | 2 -- drivers/pwm/pwm-fsl-ftm.c | 2 -- drivers/pwm/pwm-renesas-tpu.c | 2 -- drivers/pwm/pwm-rockchip.c | 5 ----- drivers/pwm/pwm-samsung.c | 3 --- drivers/pwm/pwm-tiecap.c | 2 -- drivers/pwm/pwm-tiehrpwm.c | 2 -- drivers/pwm/pwm-vt8500.c | 2 -- 11 files changed, 30 deletions(-)
drivers/pwm/pwm-atmel-hlcdc.c +0 -2
@@ -209,8 +209,6 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) chip->chip.dev = dev; chip->chip.base =-1 ; chip->chip.npwm =1 ; - chip->chip.of_xlate = of_pwm_xlate_with_flags; - chip->chip.of_pwm_n_cells =3 ; chip->chip.can_sleep =1 ; ret =pwmchip_add (&chip->chip);
drivers/pwm/pwm-atmel-tcb.c +0 -2
@@ -394,8 +394,6 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) tcbpwm->chip.dev = &pdev->dev; tcbpwm->chip.ops = &atmel_tcb_pwm_ops; - tcbpwm->chip.of_xlate = of_pwm_xlate_with_flags; - tcbpwm->chip.of_pwm_n_cells =3 ; tcbpwm->chip.base =-1 ; tcbpwm->chip.npwm =NPWM ; tcbpwm->tc = tc;
drivers/pwm/pwm-atmel.c +0 -6
@@ -347,12 +347,6 @@ static int atmel_pwm_probe(struct platform_device *pdev) atmel_pwm->chip.dev = &pdev->dev; atmel_pwm->chip.ops = &atmel_pwm_ops; - -if (pdev->dev.of_node) { - atmel_pwm->chip.of_xlate = of_pwm_xlate_with_flags; - atmel_pwm->chip.of_pwm_n_cells =3 ; - } - atmel_pwm->chip.base =-1 ; atmel_pwm->chip.npwm =4 ; atmel_pwm->chip.can_sleep = true;
drivers/pwm/pwm-bcm-kona.c +0 -2
@@ -244,8 +244,6 @@ static int kona_pwmc_probe(struct platform_device *pdev) kp->chip.ops = &kona_pwm_ops; kp->chip.base =-1 ; kp->chip.npwm =6 ; - kp->chip.of_xlate = of_pwm_xlate_with_flags; - kp->chip.of_pwm_n_cells =3 ; kp->chip.can_sleep = true; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
drivers/pwm/pwm-fsl-ftm.c +0 -2
@@ -454,8 +454,6 @@ static int fsl_pwm_probe(struct platform_device *pdev)return PTR_ERR (fpc->clk[FSL_PWM_CLK_CNTEN ]); fpc->chip.ops = &fsl_pwm_ops; - fpc->chip.of_xlate = of_pwm_xlate_with_flags; - fpc->chip.of_pwm_n_cells =3 ; fpc->chip.base =-1 ; fpc->chip.npwm =8 ; fpc->chip.can_sleep = true;
drivers/pwm/pwm-renesas-tpu.c +0 -2
@@ -418,8 +418,6 @@ static int tpu_probe(struct platform_device *pdev) tpu->chip.dev = &pdev->dev; tpu->chip.ops = &tpu_pwm_ops; - tpu->chip.of_xlate = of_pwm_xlate_with_flags; - tpu->chip.of_pwm_n_cells =3 ; tpu->chip.base =-1 ; tpu->chip.npwm =TPU_CHANNEL_MAX ;
drivers/pwm/pwm-rockchip.c +0 -5
@@ -265,11 +265,6 @@ static int rockchip_pwm_probe(struct platform_device *pdev) pc->chip.base =-1 ; pc->chip.npwm =1 ; -if (pc->data->ops->set_polarity) { - pc->chip.of_xlate = of_pwm_xlate_with_flags; - pc->chip.of_pwm_n_cells =3 ; - } - ret =pwmchip_add (&pc->chip);if (ret <0 ) {clk_unprepare (pc->clk);
drivers/pwm/pwm-samsung.c +0 -3
@@ -482,9 +482,6 @@ static int pwm_samsung_probe(struct platform_device *pdev) ret =pwm_samsung_parse_dt (chip);if (ret)return ret; - - chip->chip.of_xlate = of_pwm_xlate_with_flags; - chip->chip.of_pwm_n_cells =3 ; }else {if (!pdev->dev.platform_data) {dev_err (&pdev->dev,"no platform data specified\n" );
drivers/pwm/pwm-tiecap.c +0 -2
@@ -226,8 +226,6 @@ static int ecap_pwm_probe(struct platform_device *pdev) pc->chip.dev = &pdev->dev; pc->chip.ops = &ecap_pwm_ops; - pc->chip.of_xlate = of_pwm_xlate_with_flags; - pc->chip.of_pwm_n_cells =3 ; pc->chip.base =-1 ; pc->chip.npwm =1 ;
drivers/pwm/pwm-tiehrpwm.c +0 -2
@@ -457,8 +457,6 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev) pc->chip.dev = &pdev->dev; pc->chip.ops = &ehrpwm_pwm_ops; - pc->chip.of_xlate = of_pwm_xlate_with_flags; - pc->chip.of_pwm_n_cells =3 ; pc->chip.base =-1 ; pc->chip.npwm =NUM_PWM_CHANNEL ;
drivers/pwm/pwm-vt8500.c +0 -2
@@ -216,8 +216,6 @@ static int vt8500_pwm_probe(struct platform_device *pdev) chip->chip.dev = &pdev->dev; chip->chip.ops = &vt8500_pwm_ops; - chip->chip.of_xlate = of_pwm_xlate_with_flags; - chip->chip.of_pwm_n_cells =3 ; chip->chip.base =-1 ; chip->chip.npwm =VT8500_NR_PWMS ;
Signature · 1 line
1.7.10.4
PATCH v3 5/5 pwm: remove of_pwm_xlate_with_flags() function
In reply to Vladimir ZapolskiyDefault of_pwm_simple_xlate() is good enough to replace of_pwm_xlate_with_flags() function, since the latter has no more users, remove it from the PWM framework.
--- drivers/pwm/core.c | 26 -------------------------- include/linux/pwm.h | 3 --- 2 files changed, 29 deletions(-)
drivers/pwm/core.c +0 -26
@@ -131,32 +131,6 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)return 0 ; } -struct pwm_device * -of_pwm_xlate_with_flags (struct pwm_chip *pc,const struct of_phandle_args *args) -{ -struct pwm_device *pwm; - -if (pc->of_pwm_n_cells <3 ) -return ERR_PTR (-EINVAL ); - -if (args->args[0 ] >= pc->npwm) -return ERR_PTR (-EINVAL ); - - pwm =pwm_request_from_chip (pc, args->args[0 ],NULL ); -if (IS_ERR (pwm)) -return pwm; - -pwm_set_period (pwm, args->args[1 ]); - -if (args->args[2 ] &PWM_POLARITY_INVERTED ) -pwm_set_polarity (pwm,PWM_POLARITY_INVERSED ); -else -pwm_set_polarity (pwm,PWM_POLARITY_NORMAL ); - -return pwm; -} -EXPORT_SYMBOL_GPL (of_pwm_xlate_with_flags); -static struct pwm_device *of_pwm_simple_xlate (struct pwm_chip *pc,const struct of_phandle_args *args) {
include/linux/pwm.h +0 -3
@@ -188,9 +188,6 @@ struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,unsigned int index, const char *label); -struct pwm_device *of_pwm_xlate_with_flags (struct pwm_chip *pc, -const struct of_phandle_args *args); -struct pwm_device *pwm_get (struct device *dev,const char *con_id);struct pwm_device *of_pwm_get (struct device_node *np,const char *con_id);void pwm_put (struct pwm_device *pwm);
Signature · 1 line
1.7.10.4
v3 cover pwm: support backward compatibility of DTB extending PWM args
In reply to Vladimir ZapolskiyHello Thierry,
Quoted 24 lines · Vladimir Zapolskiy
Please review this alternative in-house version of supporting backward compatibility of DTB files (new kernel/PWM driver and old DTS), overcoming a problem that pwms arguments of existing PWM drivers are to be extended with polarity field.
Unfortunately I've firstly created the change and only after that found that Lothar Wa?mann is working on his version, so I won't insist on formal preference, but still I like to share my variant since it technically different from Lothar's one.
Changes from v2 to v3:
- improved commit messages
- added two more patches removingof_pwm_xlate_with_flags()Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Wa?mann.Vladimir Zapolskiy (5):
pwm: process pwm polarity argument inof_pwm_simple_xlate()
pwm: push up dynamic printk level on errors inof_pwm_get()
pwm: set the actual number of pwms arguments defined in board dts
pwm: do not setof_pwm_xlate_with_flags()as a callback
pwm: removeof_pwm_xlate_with_flags()function
Quoted 15 lines
drivers/pwm/core.c | 42 ++++++++++++----------------------------- drivers/pwm/pwm-atmel-hlcdc.c | 2 -- drivers/pwm/pwm-atmel-tcb.c | 2 -- drivers/pwm/pwm-atmel.c | 6 ------ drivers/pwm/pwm-bcm-kona.c | 2 -- drivers/pwm/pwm-fsl-ftm.c | 2 -- drivers/pwm/pwm-renesas-tpu.c | 2 -- drivers/pwm/pwm-rockchip.c | 5 ----- drivers/pwm/pwm-samsung.c | 3 --- drivers/pwm/pwm-tiecap.c | 2 -- drivers/pwm/pwm-tiehrpwm.c | 2 -- drivers/pwm/pwm-vt8500.c | 2 -- include/linux/pwm.h | 3 --- 13 files changed, 12 insertions(+), 63 deletions(-)
could you please review this PWM DTB backward compatibility change?
Thank you in advance.
--
With best wishes,
Vladimir
v3 cover pwm: support backward compatibility of DTB extending PWM args
Hello Thierry,
Quoted 43 lines · Vladimir Zapolskiy
Hello Thierry,
Quoted 24 lines · Vladimir Zapolskiy
Please review this alternative in-house version of supporting backward compatibility of DTB files (new kernel/PWM driver and old DTS), overcoming a problem that pwms arguments of existing PWM drivers are to be extended with polarity field.
Unfortunately I've firstly created the change and only after that found that Lothar Wa?mann is working on his version, so I won't insist on formal preference, but still I like to share my variant since it technically different from Lothar's one.
Changes from v2 to v3:
- improved commit messages
- added two more patches removingof_pwm_xlate_with_flags()Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Wa?mann.Vladimir Zapolskiy (5):
pwm: process pwm polarity argument inof_pwm_simple_xlate()
pwm: push up dynamic printk level on errors inof_pwm_get()
pwm: set the actual number of pwms arguments defined in board dts
pwm: do not setof_pwm_xlate_with_flags()as a callback
pwm: removeof_pwm_xlate_with_flags()functionQuoted 15 lines
drivers/pwm/core.c | 42 ++++++++++++----------------------------- drivers/pwm/pwm-atmel-hlcdc.c | 2 -- drivers/pwm/pwm-atmel-tcb.c | 2 -- drivers/pwm/pwm-atmel.c | 6 ------ drivers/pwm/pwm-bcm-kona.c | 2 -- drivers/pwm/pwm-fsl-ftm.c | 2 -- drivers/pwm/pwm-renesas-tpu.c | 2 -- drivers/pwm/pwm-rockchip.c | 5 ----- drivers/pwm/pwm-samsung.c | 3 --- drivers/pwm/pwm-tiecap.c | 2 -- drivers/pwm/pwm-tiehrpwm.c | 2 -- drivers/pwm/pwm-vt8500.c | 2 -- include/linux/pwm.h | 3 --- 13 files changed, 12 insertions(+), 63 deletions(-)
Quoted 4 lines
could you please review this PWM DTB backward compatibility change?
Thank you in advance.
the first three patches are unmodified since October 2014, but still not reviewed...
Could you please review the changeset?
Thank you in advance.
--
With best wishes,
Vladimir