27 #include <linux/module.h>
31 #include <linux/slab.h>
33 #define PWM_ENABLE (1 << 31)
34 #define PWM_DUTY_WIDTH 8
35 #define PWM_DUTY_SHIFT 16
36 #define PWM_SCALE_WIDTH 13
37 #define PWM_SCALE_SHIFT 0
67 int duty_ns,
int period_ns)
71 unsigned long rate, hz;
90 hz = 1000000000ul / period_ns;
116 err = clk_prepare_enable(
pc->clk);
128 clk_disable_unprepare(
pc->clk);
139 rc = clk_prepare_enable(pc->
clk);
143 val = pwm_readl(pc, pwm->
hwpwm);
145 pwm_writel(pc, pwm->
hwpwm, val);
155 val = pwm_readl(pc, pwm->
hwpwm);
157 pwm_writel(pc, pwm->
hwpwm, val);
159 clk_disable_unprepare(pc->
clk);
162 static const struct pwm_ops tegra_pwm_ops = {
163 .config = tegra_pwm_config,
164 .enable = tegra_pwm_enable,
165 .disable = tegra_pwm_disable,
177 dev_err(&pdev->
dev,
"failed to allocate memory\n");
185 dev_err(&pdev->
dev,
"no memory resources defined\n");
193 platform_set_drvdata(pdev, pwm);
196 if (IS_ERR(pwm->
clk))
197 return PTR_ERR(pwm->
clk);
200 pwm->
chip.ops = &tegra_pwm_ops;
206 dev_err(&pdev->
dev,
"pwmchip_add() failed: %d\n", ret);
221 for (i = 0; i <
NUM_PWM; i++) {
225 if (clk_prepare_enable(pc->
clk) < 0)
228 pwm_writel(pc, i, 0);
230 clk_disable_unprepare(pc->
clk);
239 { .compatible =
"nvidia,tegra30-pwm" },
251 .probe = tegra_pwm_probe,