]> Git Repo - linux.git/blobdiff - drivers/pwm/pwm-tegra.c
net/sched: Retire dsmark qdisc
[linux.git] / drivers / pwm / pwm-tegra.c
index b05ea2e8acccb1ef754babdc2f71c0dc6f57c862..249dc019329791b38fd2ff7fe30762cdbb4fec2e 100644 (file)
@@ -145,9 +145,20 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
                 * source clock rate as required_clk_rate, PWM controller will
                 * be able to configure the requested period.
                 */
-               required_clk_rate = DIV_ROUND_UP_ULL(NSEC_PER_SEC << PWM_DUTY_WIDTH,
+               required_clk_rate = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC << PWM_DUTY_WIDTH,
                                                     period_ns);
 
+               if (required_clk_rate > clk_round_rate(pc->clk, required_clk_rate))
+                       /*
+                        * required_clk_rate is a lower bound for the input
+                        * rate; for lower rates there is no value for PWM_SCALE
+                        * that yields a period less than or equal to the
+                        * requested period. Hence, for lower rates, double the
+                        * required_clk_rate to get a clock rate that can meet
+                        * the requested period.
+                        */
+                       required_clk_rate *= 2;
+
                err = dev_pm_opp_set_rate(pc->dev, required_clk_rate);
                if (err < 0)
                        return -EINVAL;
This page took 0.033373 seconds and 4 git commands to generate.