diff options
author | Martin Blumenstingl <martin.blumenstingl@googlemail.com> | 2019-04-01 14:18:16 -0400 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2019-05-09 10:50:04 -0400 |
commit | 51496e4446875726d50a5617a6e0e0dabbc2e6da (patch) | |
tree | 66b7594064d9a6d2fddd070a0d19b2c581c85bf3 /drivers/pwm/pwm-meson.c | |
parent | 9ff06679e109a216fc4a0cf5b4069a5305df141c (diff) |
pwm: meson: Consider 128 a valid pre-divider
The pre-divider allows configuring longer PWM periods compared to using
the input clock directly. The pre-divider is 7 bit wide, meaning it's
maximum value is 128 (the register value is off-by-one: 0x7f or 127).
Change the loop to also allow for the maximum possible value to be
considered valid.
Fixes: 211ed630753d2f ("pwm: Add support for Meson PWM Controller")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-meson.c')
-rw-r--r-- | drivers/pwm/pwm-meson.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index c1ed641b3e26..aaae48ab484e 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c | |||
@@ -184,7 +184,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, | |||
184 | do_div(fin_ps, fin_freq); | 184 | do_div(fin_ps, fin_freq); |
185 | 185 | ||
186 | /* Calc pre_div with the period */ | 186 | /* Calc pre_div with the period */ |
187 | for (pre_div = 0; pre_div < MISC_CLK_DIV_MASK; pre_div++) { | 187 | for (pre_div = 0; pre_div <= MISC_CLK_DIV_MASK; pre_div++) { |
188 | cnt = DIV_ROUND_CLOSEST_ULL((u64)period * 1000, | 188 | cnt = DIV_ROUND_CLOSEST_ULL((u64)period * 1000, |
189 | fin_ps * (pre_div + 1)); | 189 | fin_ps * (pre_div + 1)); |
190 | dev_dbg(meson->chip.dev, "fin_ps=%llu pre_div=%u cnt=%u\n", | 190 | dev_dbg(meson->chip.dev, "fin_ps=%llu pre_div=%u cnt=%u\n", |
@@ -193,7 +193,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, | |||
193 | break; | 193 | break; |
194 | } | 194 | } |
195 | 195 | ||
196 | if (pre_div == MISC_CLK_DIV_MASK) { | 196 | if (pre_div > MISC_CLK_DIV_MASK) { |
197 | dev_err(meson->chip.dev, "unable to get period pre_div\n"); | 197 | dev_err(meson->chip.dev, "unable to get period pre_div\n"); |
198 | return -EINVAL; | 198 | return -EINVAL; |
199 | } | 199 | } |