mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
pwm: loongson: Reload PWM configuration through counter reset
The Loongson PWM controller latches the LOW and PERIOD registers only at
the start of each PWM period. After disabling and re-enabling the PWM,
the controller resumes from the previous counter value and completes the
current period before re-latching the updated LOW and PERIOD values.
Reset the PWM counter when disabling the PWM and release it when
enabling the PWM so that the updated LOW and PERIOD values are latched
before the PWM starts running again.
Fixes: 2b62c89448 ("pwm: Add Loongson PWM controller support")
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
Link: https://patch.msgid.link/20260715-pwm-loongson-fix-v3-2-0aab2847eaa7@gmail.com
[ukleinek: Note LOW refers to the register currently named
LOONGSON_PWM_REG_DUTY. That name is wrong, the fix is still under
discussion.]
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
This commit is contained in:
parent
bdf16a4d74
commit
0de9b836a3
|
|
@ -99,6 +99,7 @@ static void pwm_loongson_disable(struct pwm_chip *chip, struct pwm_device *pwm)
|
|||
struct pwm_loongson_ddata *ddata = to_pwm_loongson_ddata(chip);
|
||||
|
||||
val = pwm_loongson_readl(ddata, LOONGSON_PWM_REG_CTRL);
|
||||
val |= LOONGSON_PWM_CTRL_REG_RST;
|
||||
val &= ~LOONGSON_PWM_CTRL_REG_EN;
|
||||
pwm_loongson_writel(ddata, val, LOONGSON_PWM_REG_CTRL);
|
||||
}
|
||||
|
|
@ -109,6 +110,7 @@ static int pwm_loongson_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
|||
struct pwm_loongson_ddata *ddata = to_pwm_loongson_ddata(chip);
|
||||
|
||||
val = pwm_loongson_readl(ddata, LOONGSON_PWM_REG_CTRL);
|
||||
val &= ~LOONGSON_PWM_CTRL_REG_RST;
|
||||
val |= LOONGSON_PWM_CTRL_REG_EN;
|
||||
pwm_loongson_writel(ddata, val, LOONGSON_PWM_REG_CTRL);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user