Lines Matching refs:pwm

95 static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,  in tegra_pwm_config()  argument
183 if (!pwm_is_enabled(pwm)) { in tegra_pwm_config()
190 pwm_writel(pc, pwm->hwpwm, val); in tegra_pwm_config()
195 if (!pwm_is_enabled(pwm)) in tegra_pwm_config()
201 static int tegra_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) in tegra_pwm_enable() argument
211 val = pwm_readl(pc, pwm->hwpwm); in tegra_pwm_enable()
213 pwm_writel(pc, pwm->hwpwm, val); in tegra_pwm_enable()
218 static void tegra_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) in tegra_pwm_disable() argument
223 val = pwm_readl(pc, pwm->hwpwm); in tegra_pwm_disable()
225 pwm_writel(pc, pwm->hwpwm, val); in tegra_pwm_disable()
239 struct tegra_pwm_chip *pwm; in tegra_pwm_probe() local
243 pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL); in tegra_pwm_probe()
244 if (!pwm) in tegra_pwm_probe()
247 pwm->soc = of_device_get_match_data(&pdev->dev); in tegra_pwm_probe()
248 pwm->dev = &pdev->dev; in tegra_pwm_probe()
251 pwm->regs = devm_ioremap_resource(&pdev->dev, r); in tegra_pwm_probe()
252 if (IS_ERR(pwm->regs)) in tegra_pwm_probe()
253 return PTR_ERR(pwm->regs); in tegra_pwm_probe()
255 platform_set_drvdata(pdev, pwm); in tegra_pwm_probe()
257 pwm->clk = devm_clk_get(&pdev->dev, NULL); in tegra_pwm_probe()
258 if (IS_ERR(pwm->clk)) in tegra_pwm_probe()
259 return PTR_ERR(pwm->clk); in tegra_pwm_probe()
262 ret = clk_set_rate(pwm->clk, pwm->soc->max_frequency); in tegra_pwm_probe()
273 pwm->clk_rate = clk_get_rate(pwm->clk); in tegra_pwm_probe()
276 pwm->min_period_ns = in tegra_pwm_probe()
277 (NSEC_PER_SEC / (pwm->soc->max_frequency >> PWM_DUTY_WIDTH)) + 1; in tegra_pwm_probe()
279 pwm->rst = devm_reset_control_get_exclusive(&pdev->dev, "pwm"); in tegra_pwm_probe()
280 if (IS_ERR(pwm->rst)) { in tegra_pwm_probe()
281 ret = PTR_ERR(pwm->rst); in tegra_pwm_probe()
286 reset_control_deassert(pwm->rst); in tegra_pwm_probe()
288 pwm->chip.dev = &pdev->dev; in tegra_pwm_probe()
289 pwm->chip.ops = &tegra_pwm_ops; in tegra_pwm_probe()
290 pwm->chip.base = -1; in tegra_pwm_probe()
291 pwm->chip.npwm = pwm->soc->num_channels; in tegra_pwm_probe()
293 ret = pwmchip_add(&pwm->chip); in tegra_pwm_probe()
296 reset_control_assert(pwm->rst); in tegra_pwm_probe()