This series adds a few related fixes to the pwm .apply and .get_state
callbacks.
The first patch was originally part of the series adding Armada 8K/7K pwm
support. I split it out to a separate series following review comments from
Uwe Kleine-König who spotted a few more issues. There is no dependency between
this and the Armada 8K/7K series.
v2:
Address Uwe Kleine-König comments.
* Improve patch 1/5 summary line
* Add more information to patch 1/5 description
* Add more information to patch 2/5 description
* Don't round period/duty_cycle up in .apply (patch 3/5)
* Expand the comment in path 5/5 based on RMK's analysis of hardware
behaviour
* Add Uwe's Reviewed-by tags
Baruch Siach (5):
gpio: mvebu: fix pwm .get_state period calculation
gpio: mvebu: improve pwm period calculation accuracy
gpio: mvebu: make pwm .get_state closer to idempotent
gpio: mvebu: don't limit pwm period/duty_cycle to UINT_MAX
gpio: mvebu: document zero pwm duty cycle limitation
drivers/gpio/gpio-mvebu.c | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
--
2.29.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
The period is the sum of on and off values. That is, calculate period as
($on + $off) / clkrate
instead of
$off / clkrate - $on / clkrate
that makes no sense.
Reported-by: Russell King <linux@armlinux.org.uk>
Fixes: 757642f9a584e ("gpio: mvebu: Add limited PWM support")
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
drivers/gpio/gpio-mvebu.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
@@ -676,20 +676,17 @@ static void mvebu_pwm_get_state(struct pwm_chip *chip,elsestate->duty_cycle=1;+val=(unsignedlonglong)u;/* on duration */regmap_read(mvpwm->regs,mvebu_pwmreg_blink_off_duration(mvpwm),&u);-val=(unsignedlonglong)u*NSEC_PER_SEC;+val+=(unsignedlonglong)u;/* period = on + off duration */+val*=NSEC_PER_SEC;do_div(val,mvpwm->clk_rate);-if(val<state->duty_cycle){+if(val>UINT_MAX)+state->period=UINT_MAX;+elseif(val)+state->period=val;+elsestate->period=1;-}else{-val-=state->duty_cycle;-if(val>UINT_MAX)-state->period=UINT_MAX;-elseif(val)-state->period=val;-else-state->period=1;-}regmap_read(mvchip->regs,GPIO_BLINK_EN_OFF+mvchip->offset,&u);if(u)
--
2.29.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Wed, Jan 13, 2021 at 11:22:41AM +0200, Baruch Siach wrote:
The period is the sum of on and off values. That is, calculate period as
($on + $off) / clkrate
instead of
$off / clkrate - $on / clkrate
that makes no sense.
Reported-by: Russell King <linux@armlinux.org.uk>
Fixes: 757642f9a584e ("gpio: mvebu: Add limited PWM support")
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Uwe Kleine-König <redacted>
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
Round up the result of division in period/duty_cycle calculation to make
the result closer to idempotent.
Reported-by: Uwe Kleine-König <redacted>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
drivers/gpio/gpio-mvebu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
PWM on/off registers are limited to UINT_MAX. However the state period
and duty_cycle fields are ns values of type u64. There is no reason to
limit them to UINT_MAX.
Reported-by: Uwe Kleine-König <redacted>
Reviewed-by: Uwe Kleine-König <redacted>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
drivers/gpio/gpio-mvebu.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
On Wed, Jan 13, 2021 at 10:23 AM Baruch Siach [off-list ref] wrote:
This series adds a few related fixes to the pwm .apply and .get_state
callbacks.
The first patch was originally part of the series adding Armada 8K/7K pwm
support. I split it out to a separate series following review comments from
Uwe Kleine-König who spotted a few more issues. There is no dependency between
this and the Armada 8K/7K series.
This version looks really good and +/- minor tweaks as indicated by
Uwe:
Reviewed-by: Linus Walleij <redacted>
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hello Linus,
On Mon, Jan 18, 2021 at 02:45:14PM +0100, Linus Walleij wrote:
On Wed, Jan 13, 2021 at 10:23 AM Baruch Siach [off-list ref] wrote:
quoted
This series adds a few related fixes to the pwm .apply and .get_state
callbacks.
The first patch was originally part of the series adding Armada 8K/7K pwm
support. I split it out to a separate series following review comments from
Uwe Kleine-König who spotted a few more issues. There is no dependency between
this and the Armada 8K/7K series.
This version looks really good and +/- minor tweaks as indicated by
Uwe:
Reviewed-by: Linus Walleij <redacted>
The most recent version of this series is v4.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |