Lines Matching full:pc
84 static inline u32 pwm_readl(struct tegra_pwm_chip *pc, unsigned int offset) in pwm_readl() argument
86 return readl(pc->regs + (offset << 4)); in pwm_readl()
89 static inline void pwm_writel(struct tegra_pwm_chip *pc, unsigned int offset, u32 value) in pwm_writel() argument
91 writel(value, pc->regs + (offset << 4)); in pwm_writel()
97 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip); in tegra_pwm_config() local
116 if (period_ns < pc->min_period_ns) in tegra_pwm_config()
132 if (pc->soc->num_channels == 1) { in tegra_pwm_config()
147 if (required_clk_rate > clk_round_rate(pc->clk, required_clk_rate)) in tegra_pwm_config()
163 pc->clk_rate = clk_get_rate(pc->clk); in tegra_pwm_config()
167 rate = mul_u64_u64_div_u64(pc->clk_rate, period_ns, in tegra_pwm_config()
200 pwm_writel(pc, pwm->hwpwm, val); in tegra_pwm_config()
213 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip); in tegra_pwm_enable() local
221 val = pwm_readl(pc, pwm->hwpwm); in tegra_pwm_enable()
223 pwm_writel(pc, pwm->hwpwm, val); in tegra_pwm_enable()
230 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip); in tegra_pwm_disable() local
233 val = pwm_readl(pc, pwm->hwpwm); in tegra_pwm_disable()
235 pwm_writel(pc, pwm->hwpwm, val); in tegra_pwm_disable()
273 struct tegra_pwm_chip *pc; in tegra_pwm_probe() local
279 chip = devm_pwmchip_alloc(&pdev->dev, soc->num_channels, sizeof(*pc)); in tegra_pwm_probe()
282 pc = to_tegra_pwm_chip(chip); in tegra_pwm_probe()
284 pc->soc = soc; 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()
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(&pdev->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()
337 reset_control_assert(pc->rst); in tegra_pwm_probe()
353 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip); in tegra_pwm_remove() local
357 reset_control_assert(pc->rst); in tegra_pwm_remove()
365 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip); 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()
382 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip); in tegra_pwm_runtime_resume() local
389 err = clk_prepare_enable(pc->clk); in tegra_pwm_runtime_resume()