[PATCH 2/2] pwm: bcm-kona: apply pwm settings on enable
From: ClÃment PÃron
Date: Wed Nov 07 2018 - 04:36:45 EST
From: Suji Velupillai <suji.velupillai@xxxxxxxxxxxx>
When pwm_bl framework calls enable, a call to pwm_is_enabled(pwm) still
return false, this prevents the backlight being turn on at boot time.
Signed-off-by: Suji Velupillai <suji.velupillai@xxxxxxxxxxxx>
Signed-off-by: ClÃment PÃron <peron.clem@xxxxxxxxx>
---
drivers/pwm/pwm-bcm-kona.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/pwm/pwm-bcm-kona.c b/drivers/pwm/pwm-bcm-kona.c
index 09a95aeb3a70..d991d53c4b38 100644
--- a/drivers/pwm/pwm-bcm-kona.c
+++ b/drivers/pwm/pwm-bcm-kona.c
@@ -108,8 +108,8 @@ static void kona_pwmc_apply_settings(struct kona_pwmc *kp, unsigned int chan)
ndelay(400);
}
-static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm,
- int duty_ns, int period_ns)
+static int __pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm,
+ int duty_ns, int period_ns, bool pwmc_enabled)
{
struct kona_pwmc *kp = to_kona_pwmc(chip);
u64 val, div, rate;
@@ -155,7 +155,7 @@ static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm,
* always calculated above to ensure the new values are
* validated immediately instead of on enable.
*/
- if (pwm_is_enabled(pwm)) {
+ if (pwm_is_enabled(pwm) || pwmc_enabled) {
kona_pwmc_prepare_for_settings(kp, chan);
value = readl(kp->base + PRESCALE_OFFSET);
@@ -173,6 +173,12 @@ static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm,
return 0;
}
+static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm,
+ int duty_ns, int period_ns)
+{
+ return __pwmc_config(chip, pwm, duty_ns, period_ns, false);
+}
+
static int kona_pwmc_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm,
enum pwm_polarity polarity)
{
@@ -216,8 +222,8 @@ static int kona_pwmc_enable(struct pwm_chip *chip, struct pwm_device *pwm)
return ret;
}
- ret = kona_pwmc_config(chip, pwm, pwm_get_duty_cycle(pwm),
- pwm_get_period(pwm));
+ ret = __pwmc_config(chip, pwm, pwm_get_duty_cycle(pwm),
+ pwm_get_period(pwm), true);
if (ret < 0) {
clk_disable_unprepare(kp->clk);
return ret;
--
2.19.1