From 906cea2b56ed9480ec6d8d849f76ec031c011dbf Mon Sep 17 00:00:00 2001 From: David Wu Date: Tue, 13 Mar 2018 20:16:39 +0800 Subject: [PATCH] pwm: rockchip: Disable irq for pwm config Add irq disabled protection at the PWM configuration, which can speed up the PWM configuration and reduce the possibility of interrupting the configuration. Change-Id: I8ca3c4b9790b747c12804fa82b51456a0de7fb92 Signed-off-by: David Wu --- drivers/pwm/pwm-rockchip.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index 55800cffae5b..6539a89985e7 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c @@ -108,6 +108,7 @@ static void rockchip_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, { struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); unsigned long period, duty; + unsigned long flags; u64 clk_rate, div; u32 ctrl; @@ -125,6 +126,7 @@ static void rockchip_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, div = clk_rate * state->duty_cycle; duty = DIV_ROUND_CLOSEST_ULL(div, pc->data->prescaler * NSEC_PER_SEC); + local_irq_save(flags); /* * Lock the period and duty of previous configuration, then * change the duty and period, that would not be effective. @@ -136,6 +138,7 @@ static void rockchip_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, else ctrl &= ~PWM_ENABLE; } + if (pc->data->supports_lock) { ctrl |= PWM_LOCK_EN; writel_relaxed(ctrl, pc->base + pc->data->regs.ctrl); @@ -161,6 +164,7 @@ static void rockchip_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ctrl &= ~PWM_LOCK_EN; writel(ctrl, pc->base + pc->data->regs.ctrl); + local_irq_restore(flags); } static int rockchip_pwm_enable(struct pwm_chip *chip,