mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user