struct sti_pwm_chip {
struct device *dev;
struct clk *pwm_clk;
+ struct clk *cpt_clk;
struct regmap *regmap;
struct sti_pwm_compat_data *cdata;
struct regmap_field *prescale_low;
if (ret)
return ret;
+ ret = clk_enable(pc->cpt_clk);
+ if (ret)
+ return ret;
+
if (!period_same) {
ret = sti_pwm_get_prescale(pc, period_ns, &prescale);
if (ret)
clk_dis:
clk_disable(pc->pwm_clk);
+ clk_disable(pc->cpt_clk);
return ret;
}
if (ret)
goto out;
+ ret = clk_enable(pc->cpt_clk);
+ if (ret)
+ goto out;
+
ret = regmap_field_write(pc->pwm_out_en, 1);
if (ret) {
dev_err(dev, "failed to enable PWM device:%d\n",
regmap_field_write(pc->pwm_out_en, 0);
clk_disable(pc->pwm_clk);
+ clk_disable(pc->cpt_clk);
mutex_unlock(&pc->sti_pwm_lock);
}
return ret;
}
+ pc->cpt_clk = of_clk_get_by_name(dev->of_node, "capture");
+ if (IS_ERR(pc->cpt_clk)) {
+ dev_err(dev, "failed to get PWM capture clock\n");
+ return PTR_ERR(pc->cpt_clk);
+ }
+
+ ret = clk_prepare(pc->cpt_clk);
+ if (ret) {
+ dev_err(dev, "failed to prepare clock\n");
+ return ret;
+ }
+
pc->chip.dev = dev;
pc->chip.ops = &sti_pwm_ops;
pc->chip.base = -1;
ret = pwmchip_add(&pc->chip);
if (ret < 0) {
clk_unprepare(pc->pwm_clk);
+ clk_unprepare(pc->cpt_clk);
return ret;
}
pwm_disable(&pc->chip.pwms[i]);
clk_unprepare(pc->pwm_clk);
+ clk_unprepare(pc->cpt_clk);
return pwmchip_remove(&pc->chip);
}