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
242 pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL); in tegra_pwm_probe()
243 if (!pwm) in tegra_pwm_probe()
246 pwm->soc = of_device_get_match_data(&pdev->dev); in tegra_pwm_probe()
247 pwm->dev = &pdev->dev; in tegra_pwm_probe()
249 pwm->regs = devm_platform_ioremap_resource(pdev, 0); in tegra_pwm_probe()
250 if (IS_ERR(pwm->regs)) in tegra_pwm_probe()
251 return PTR_ERR(pwm->regs); in tegra_pwm_probe()
253 platform_set_drvdata(pdev, pwm); in tegra_pwm_probe()
255 pwm->clk = devm_clk_get(&pdev->dev, NULL); in tegra_pwm_probe()
256 if (IS_ERR(pwm->clk)) in tegra_pwm_probe()
257 return PTR_ERR(pwm->clk); in tegra_pwm_probe()
260 ret = clk_set_rate(pwm->clk, pwm->soc->max_frequency); in tegra_pwm_probe()
271 pwm->clk_rate = clk_get_rate(pwm->clk); in tegra_pwm_probe()
274 pwm->min_period_ns = in tegra_pwm_probe()
275 (NSEC_PER_SEC / (pwm->soc->max_frequency >> PWM_DUTY_WIDTH)) + 1; in tegra_pwm_probe()
277 pwm->rst = devm_reset_control_get_exclusive(&pdev->dev, "pwm"); in tegra_pwm_probe()
278 if (IS_ERR(pwm->rst)) { in tegra_pwm_probe()
279 ret = PTR_ERR(pwm->rst); in tegra_pwm_probe()
284 reset_control_deassert(pwm->rst); in tegra_pwm_probe()
286 pwm->chip.dev = &pdev->dev; in tegra_pwm_probe()
287 pwm->chip.ops = &tegra_pwm_ops; in tegra_pwm_probe()
288 pwm->chip.npwm = pwm->soc->num_channels; in tegra_pwm_probe()
290 ret = pwmchip_add(&pwm->chip); in tegra_pwm_probe()
293 reset_control_assert(pwm->rst); in tegra_pwm_probe()