drivers/pwm: Import OnePlus Changes
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
This commit is contained in:
parent
fc9dbcc3c5
commit
63269dedbb
|
@ -85,6 +85,8 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||
u64 tmp, multi, rate;
|
||||
u32 value, prescale;
|
||||
|
||||
rate = clk_get_rate(ip->clk);
|
||||
|
||||
value = readl(ip->base + IPROC_PWM_CTRL_OFFSET);
|
||||
|
||||
if (value & BIT(IPROC_PWM_CTRL_EN_SHIFT(pwm->hwpwm)))
|
||||
|
@ -97,13 +99,6 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||
else
|
||||
state->polarity = PWM_POLARITY_INVERSED;
|
||||
|
||||
rate = clk_get_rate(ip->clk);
|
||||
if (rate == 0) {
|
||||
state->period = 0;
|
||||
state->duty_cycle = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
value = readl(ip->base + IPROC_PWM_PRESCALE_OFFSET);
|
||||
prescale = value >> IPROC_PWM_PRESCALE_SHIFT(pwm->hwpwm);
|
||||
prescale &= IPROC_PWM_PRESCALE_MAX;
|
||||
|
|
|
@ -105,12 +105,10 @@ static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm,
|
|||
* The equation is:
|
||||
* base_unit = round(base_unit_range * freq / c)
|
||||
*/
|
||||
base_unit_range = BIT(lpwm->info->base_unit_bits);
|
||||
base_unit_range = BIT(lpwm->info->base_unit_bits) - 1;
|
||||
freq *= base_unit_range;
|
||||
|
||||
base_unit = DIV_ROUND_CLOSEST_ULL(freq, c);
|
||||
/* base_unit must not be 0 and we also want to avoid overflowing it */
|
||||
base_unit = clamp_val(base_unit, 1, base_unit_range - 1);
|
||||
|
||||
on_time_div = 255ULL * duty_ns;
|
||||
do_div(on_time_div, period_ns);
|
||||
|
@ -118,7 +116,8 @@ static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm,
|
|||
|
||||
orig_ctrl = ctrl = pwm_lpss_read(pwm);
|
||||
ctrl &= ~PWM_ON_TIME_DIV_MASK;
|
||||
ctrl &= ~((base_unit_range - 1) << PWM_BASE_UNIT_SHIFT);
|
||||
ctrl &= ~(base_unit_range << PWM_BASE_UNIT_SHIFT);
|
||||
base_unit &= base_unit_range;
|
||||
ctrl |= (u32) base_unit << PWM_BASE_UNIT_SHIFT;
|
||||
ctrl |= on_time_div;
|
||||
|
||||
|
|
Loading…
Reference in New Issue