pwm: crc: Enable/disable PWM output on enable/disable
authorHans de Goede <hdegoede@redhat.com>
Thu, 3 Sep 2020 11:23:31 +0000 (13:23 +0200)
committerHans de Goede <hdegoede@redhat.com>
Sun, 6 Sep 2020 13:38:04 +0000 (15:38 +0200)
The pwm-crc code is using 2 different enable bits:
1. bit 7 of the PWM0_CLK_DIV (PWM_OUTPUT_ENABLE)
2. bit 0 of the BACKLIGHT_EN register

So far we've kept the PWM_OUTPUT_ENABLE bit set when disabling the PWM,
this commit makes crc_pwm_disable() clear it on disable and makes
crc_pwm_enable() set it again on re-enable.

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200903112337.4113-12-hdegoede@redhat.com
drivers/pwm/pwm-crc.c

index 81232da..b72008c 100644 (file)
@@ -54,7 +54,9 @@ static int crc_pwm_calc_clk_div(int period_ns)
 static int crc_pwm_enable(struct pwm_chip *c, struct pwm_device *pwm)
 {
        struct crystalcove_pwm *crc_pwm = to_crc_pwm(c);
+       int div = crc_pwm_calc_clk_div(pwm_get_period(pwm));
 
+       regmap_write(crc_pwm->regmap, PWM0_CLK_DIV, div | PWM_OUTPUT_ENABLE);
        regmap_write(crc_pwm->regmap, BACKLIGHT_EN, 1);
 
        return 0;
@@ -63,8 +65,10 @@ static int crc_pwm_enable(struct pwm_chip *c, struct pwm_device *pwm)
 static void crc_pwm_disable(struct pwm_chip *c, struct pwm_device *pwm)
 {
        struct crystalcove_pwm *crc_pwm = to_crc_pwm(c);
+       int div = crc_pwm_calc_clk_div(pwm_get_period(pwm));
 
        regmap_write(crc_pwm->regmap, BACKLIGHT_EN, 0);
+       regmap_write(crc_pwm->regmap, PWM0_CLK_DIV, div);
 }
 
 static int crc_pwm_config(struct pwm_chip *c, struct pwm_device *pwm,