diff options
Diffstat (limited to 'drivers/pwm/pwm-mxs.c')
-rw-r--r-- | drivers/pwm/pwm-mxs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c index f75ecb09d97d..b430811e14f5 100644 --- a/drivers/pwm/pwm-mxs.c +++ b/drivers/pwm/pwm-mxs.c | |||
@@ -35,6 +35,10 @@ | |||
35 | #define PERIOD_CDIV(div) (((div) & 0x7) << 20) | 35 | #define PERIOD_CDIV(div) (((div) & 0x7) << 20) |
36 | #define PERIOD_CDIV_MAX 8 | 36 | #define PERIOD_CDIV_MAX 8 |
37 | 37 | ||
38 | static const unsigned int cdiv[PERIOD_CDIV_MAX] = { | ||
39 | 1, 2, 4, 8, 16, 64, 256, 1024 | ||
40 | }; | ||
41 | |||
38 | struct mxs_pwm_chip { | 42 | struct mxs_pwm_chip { |
39 | struct pwm_chip chip; | 43 | struct pwm_chip chip; |
40 | struct clk *clk; | 44 | struct clk *clk; |
@@ -54,13 +58,13 @@ static int mxs_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, | |||
54 | 58 | ||
55 | rate = clk_get_rate(mxs->clk); | 59 | rate = clk_get_rate(mxs->clk); |
56 | while (1) { | 60 | while (1) { |
57 | c = rate / (1 << div); | 61 | c = rate / cdiv[div]; |
58 | c = c * period_ns; | 62 | c = c * period_ns; |
59 | do_div(c, 1000000000); | 63 | do_div(c, 1000000000); |
60 | if (c < PERIOD_PERIOD_MAX) | 64 | if (c < PERIOD_PERIOD_MAX) |
61 | break; | 65 | break; |
62 | div++; | 66 | div++; |
63 | if (div > PERIOD_CDIV_MAX) | 67 | if (div >= PERIOD_CDIV_MAX) |
64 | return -EINVAL; | 68 | return -EINVAL; |
65 | } | 69 | } |
66 | 70 | ||