From 75b8278a0e981987d67e58b91f42a379a235c50c Mon Sep 17 00:00:00 2001 From: Bai Ping Date: Tue, 17 Apr 2018 13:57:21 +0800 Subject: [PATCH] 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 Reviewed-by: Anson Huang Signed-off-by: Vipul Kumar --- drivers/pwm/pwm-tpm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-tpm.c b/drivers/pwm/pwm-tpm.c index 29284a90fb9d..054118bd5223 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 @@ -54,7 +54,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; @@ -79,6 +79,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); -- 2.17.1