[PATCH v1 2/2] pwm: Update the REPEAT_COUNT value

From: vishakha . joshi
Date: Mon Jan 03 2022 - 03:17:53 EST


From: Vishakha Joshi <vishakha.joshi@xxxxxxxxx>

Update the count value in the PWM_LEADIN register.

Signed-off-by: Vishakha Joshi <vishakha.joshi@xxxxxxxxx>
---
drivers/pwm/pwm-keembay.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-keembay.c b/drivers/pwm/pwm-keembay.c
index 733811b05721..4494e54e23b8 100644
--- a/drivers/pwm/pwm-keembay.c
+++ b/drivers/pwm/pwm-keembay.c
@@ -128,11 +128,14 @@ static int keembay_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
if (state->polarity != PWM_POLARITY_NORMAL)
return -EINVAL;

+ if (state->count > KMB_PWM_COUNT_MAX)
+ return -EINVAL;
+
/*
- * Configure the pwm repeat count as infinite at (15:0) and leadin
- * low time as 0 at (30:16), which is in terms of clock cycles.
+ * Configure the PWM repeat count at (15:0) and LEADIN low time as 0 at
+ * (30:16), which is in terms of clock cycles.
*/
- keembay_pwm_update_bits(priv, KMB_PWM_LEADIN_MASK, 0,
+ keembay_pwm_update_bits(priv, KMB_PWM_LEADIN_MASK, state->count,
KMB_PWM_LEADIN_OFFSET(pwm->hwpwm));

keembay_pwm_get_state(chip, pwm, &current_state);
--
2.17.1