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 <david.wu@rock-chips.com>
This commit is contained in:
David Wu
2018-03-13 20:16:39 +08:00
committed by Tao Huang
parent 7c831dee39
commit 2d055eb091

View File

@@ -100,6 +100,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;
@@ -117,6 +118,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.
@@ -128,6 +130,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);
@@ -153,6 +156,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,