Lines Matching refs:pc
87 static inline u32 pwm_readl(struct tegra_pwm_chip *pc, unsigned int offset) in pwm_readl() argument
89 return readl(pc->regs + (offset << 4)); in pwm_readl()
92 static inline void pwm_writel(struct tegra_pwm_chip *pc, unsigned int offset, u32 value) in pwm_writel() argument
94 writel(value, pc->regs + (offset << 4)); in pwm_writel()
100 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip); in tegra_pwm_config() local
119 if (period_ns < pc->min_period_ns) in tegra_pwm_config()
135 if (pc->soc->num_channels == 1) { in tegra_pwm_config()
150 if (required_clk_rate > clk_round_rate(pc->clk, required_clk_rate)) in tegra_pwm_config()
161 err = dev_pm_opp_set_rate(pc->dev, required_clk_rate); in tegra_pwm_config()
166 pc->clk_rate = clk_get_rate(pc->clk); in tegra_pwm_config()
170 rate = mul_u64_u64_div_u64(pc->clk_rate, period_ns, in tegra_pwm_config()
197 err = pm_runtime_resume_and_get(pc->dev); in tegra_pwm_config()
203 pwm_writel(pc, pwm->hwpwm, val); in tegra_pwm_config()
209 pm_runtime_put(pc->dev); in tegra_pwm_config()
216 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip); in tegra_pwm_enable() local
220 rc = pm_runtime_resume_and_get(pc->dev); in tegra_pwm_enable()
224 val = pwm_readl(pc, pwm->hwpwm); in tegra_pwm_enable()
226 pwm_writel(pc, pwm->hwpwm, val); in tegra_pwm_enable()
233 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip); in tegra_pwm_disable() local
236 val = pwm_readl(pc, pwm->hwpwm); in tegra_pwm_disable()
238 pwm_writel(pc, pwm->hwpwm, val); in tegra_pwm_disable()
240 pm_runtime_put_sync(pc->dev); in tegra_pwm_disable()
276 struct tegra_pwm_chip *pc; in tegra_pwm_probe() local
279 pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); in tegra_pwm_probe()
280 if (!pc) in tegra_pwm_probe()
283 pc->soc = of_device_get_match_data(&pdev->dev); in tegra_pwm_probe()
284 pc->dev = &pdev->dev; in tegra_pwm_probe()
286 pc->regs = devm_platform_ioremap_resource(pdev, 0); in tegra_pwm_probe()
287 if (IS_ERR(pc->regs)) in tegra_pwm_probe()
288 return PTR_ERR(pc->regs); in tegra_pwm_probe()
290 platform_set_drvdata(pdev, pc); in tegra_pwm_probe()
292 pc->clk = devm_clk_get(&pdev->dev, NULL); in tegra_pwm_probe()
293 if (IS_ERR(pc->clk)) in tegra_pwm_probe()
294 return PTR_ERR(pc->clk); in tegra_pwm_probe()
306 ret = dev_pm_opp_set_rate(pc->dev, pc->soc->max_frequency); in tegra_pwm_probe()
317 pc->clk_rate = clk_get_rate(pc->clk); in tegra_pwm_probe()
320 pc->min_period_ns = in tegra_pwm_probe()
321 (NSEC_PER_SEC / (pc->soc->max_frequency >> PWM_DUTY_WIDTH)) + 1; in tegra_pwm_probe()
323 pc->rst = devm_reset_control_get_exclusive(&pdev->dev, "pwm"); in tegra_pwm_probe()
324 if (IS_ERR(pc->rst)) { in tegra_pwm_probe()
325 ret = PTR_ERR(pc->rst); in tegra_pwm_probe()
330 reset_control_deassert(pc->rst); in tegra_pwm_probe()
332 pc->chip.dev = &pdev->dev; in tegra_pwm_probe()
333 pc->chip.ops = &tegra_pwm_ops; in tegra_pwm_probe()
334 pc->chip.npwm = pc->soc->num_channels; in tegra_pwm_probe()
336 ret = pwmchip_add(&pc->chip); in tegra_pwm_probe()
339 reset_control_assert(pc->rst); in tegra_pwm_probe()
354 struct tegra_pwm_chip *pc = platform_get_drvdata(pdev); in tegra_pwm_remove() local
356 pwmchip_remove(&pc->chip); in tegra_pwm_remove()
358 reset_control_assert(pc->rst); in tegra_pwm_remove()
365 struct tegra_pwm_chip *pc = dev_get_drvdata(dev); in tegra_pwm_runtime_suspend() local
368 clk_disable_unprepare(pc->clk); in tegra_pwm_runtime_suspend()
372 clk_prepare_enable(pc->clk); in tegra_pwm_runtime_suspend()
381 struct tegra_pwm_chip *pc = dev_get_drvdata(dev); in tegra_pwm_runtime_resume() local
388 err = clk_prepare_enable(pc->clk); in tegra_pwm_runtime_resume()