pwm: pwm-mxs: Wait for configuration to apply before disabling PWM.
Subsystems (2)
PATCH v2 1/1 pwm: pwm-mxs: Wait for configuration to apply before disabling PWM.
We have to be sure that the last configuration has been applied. In most cases drivers will have set the duty-cycle to 0%. To prevent the PWM from locking at a 100% duty-cycle, we delay disabling the PWM for a whole period to make sure any new configuration has been latched.
Signed-off-by Robin van der Gracht <[email protected]>
--- drivers/pwm/pwm-mxs.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pwm/pwm-mxs.c +7 -0
@@ -10,6 +10,7 @@*/ #include <linux/clk.h> +#include <linux/delay.h> #include <linux/err.h> #include <linux/io.h> #include <linux/kernel.h>
@@ -113,6 +114,12 @@ static int mxs_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)static void mxs_pwm_disable (struct pwm_chip *chip,struct pwm_device *pwm) {struct mxs_pwm_chip *mxs =to_mxs_pwm_chip (chip); +unsigned int period; + +/* Ensure latest configuration applied. */ + period =pwm_get_period (pwm); + period =DIV_ROUND_UP (period,NSEC_PER_USEC ); +usleep_range (period, period +1000 );writel (1 << pwm->hwpwm, mxs->base +PWM_CTRL +CLR );
Signature · 1 line
1.7.9.5