diff options
Diffstat (limited to 'drivers/pwm/pwm-lpss.c')
-rw-r--r-- | drivers/pwm/pwm-lpss.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c index 689d2c1cbead..8db0d40ccacd 100644 --- a/drivers/pwm/pwm-lpss.c +++ b/drivers/pwm/pwm-lpss.c | |||
@@ -57,7 +57,7 @@ static inline void pwm_lpss_write(const struct pwm_device *pwm, u32 value) | |||
57 | writel(value, lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM); | 57 | writel(value, lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM); |
58 | } | 58 | } |
59 | 59 | ||
60 | static int pwm_lpss_update(struct pwm_device *pwm) | 60 | static int pwm_lpss_wait_for_update(struct pwm_device *pwm) |
61 | { | 61 | { |
62 | struct pwm_lpss_chip *lpwm = to_lpwm(pwm->chip); | 62 | struct pwm_lpss_chip *lpwm = to_lpwm(pwm->chip); |
63 | const void __iomem *addr = lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM; | 63 | const void __iomem *addr = lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM; |
@@ -65,8 +65,6 @@ static int pwm_lpss_update(struct pwm_device *pwm) | |||
65 | u32 val; | 65 | u32 val; |
66 | int err; | 66 | int err; |
67 | 67 | ||
68 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE); | ||
69 | |||
70 | /* | 68 | /* |
71 | * PWM Configuration register has SW_UPDATE bit that is set when a new | 69 | * PWM Configuration register has SW_UPDATE bit that is set when a new |
72 | * configuration is written to the register. The bit is automatically | 70 | * configuration is written to the register. The bit is automatically |
@@ -122,6 +120,12 @@ static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm, | |||
122 | pwm_lpss_write(pwm, ctrl); | 120 | pwm_lpss_write(pwm, ctrl); |
123 | } | 121 | } |
124 | 122 | ||
123 | static inline void pwm_lpss_cond_enable(struct pwm_device *pwm, bool cond) | ||
124 | { | ||
125 | if (cond) | ||
126 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_ENABLE); | ||
127 | } | ||
128 | |||
125 | static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm, | 129 | static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm, |
126 | struct pwm_state *state) | 130 | struct pwm_state *state) |
127 | { | 131 | { |
@@ -137,18 +141,21 @@ static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm, | |||
137 | return ret; | 141 | return ret; |
138 | } | 142 | } |
139 | pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period); | 143 | pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period); |
140 | ret = pwm_lpss_update(pwm); | 144 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE); |
145 | pwm_lpss_cond_enable(pwm, lpwm->info->bypass == false); | ||
146 | ret = pwm_lpss_wait_for_update(pwm); | ||
141 | if (ret) { | 147 | if (ret) { |
142 | pm_runtime_put(chip->dev); | 148 | pm_runtime_put(chip->dev); |
143 | return ret; | 149 | return ret; |
144 | } | 150 | } |
145 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_ENABLE); | 151 | pwm_lpss_cond_enable(pwm, lpwm->info->bypass == true); |
146 | } else { | 152 | } else { |
147 | ret = pwm_lpss_is_updating(pwm); | 153 | ret = pwm_lpss_is_updating(pwm); |
148 | if (ret) | 154 | if (ret) |
149 | return ret; | 155 | return ret; |
150 | pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period); | 156 | pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period); |
151 | return pwm_lpss_update(pwm); | 157 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE); |
158 | return pwm_lpss_wait_for_update(pwm); | ||
152 | } | 159 | } |
153 | } else if (pwm_is_enabled(pwm)) { | 160 | } else if (pwm_is_enabled(pwm)) { |
154 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) & ~PWM_ENABLE); | 161 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) & ~PWM_ENABLE); |