diff options
author | Bai Ping <ping.bai@nxp.com> | 2018-04-17 13:57:21 +0800 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:31:16 +0800 |
commit | 58c984c2e4f1b8d9640c98bade896e35f84aac09 (patch) | |
tree | 9fa0bbb88e9f40891a95c07d0cdbfd937ebe1c06 /drivers/pwm | |
parent | 418a5c86324b8c328439abdb90065e14341c9676 (diff) |
MLK-18042-01 driver: pwm: fix pwm pre-scale div config
In i.MX7ULP TPM PWM module, it has a pre-scale divider,
this divider setting is missed, so fix it.
Signed-off-by: Bai Ping <ping.bai@nxp.com>
Reviewed-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/pwm-tpm.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/pwm/pwm-tpm.c b/drivers/pwm/pwm-tpm.c index f15dc616437e..98cdcceb5f11 100644 --- a/drivers/pwm/pwm-tpm.c +++ b/drivers/pwm/pwm-tpm.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 NXP. + * Copyright 2017-2018 NXP. * * The code contained herein is licensed under the GNU General Public * License. You may obtain a copy of the GNU General Public License @@ -53,7 +53,7 @@ static int tpm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, int duty_ns, int period_ns) { struct tpm_pwm_chip *tpm = to_tpm_pwm_chip(chip); - int ret, div = 0; + int ret, val, div = 0; unsigned int period_cycles, duty_cycles; unsigned long rate; u64 c; @@ -78,6 +78,12 @@ static int tpm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, return ret; } + /* set the pre-scale */ + val = readl(tpm->base + TPM_SC); + val &= ~0x7; + val |= div; + writel(val, tpm->base + TPM_SC); + period_cycles = c; c *= duty_ns; do_div(c, period_ns); |