Lines Matching full:pc

79 	struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip);  in pwm_mediatek_clk_enable()  local
82 ret = clk_prepare_enable(pc->clk_top); in pwm_mediatek_clk_enable()
86 ret = clk_prepare_enable(pc->clk_main); in pwm_mediatek_clk_enable()
90 ret = clk_prepare_enable(pc->clk_pwms[pwm->hwpwm]); in pwm_mediatek_clk_enable()
97 clk_disable_unprepare(pc->clk_main); in pwm_mediatek_clk_enable()
99 clk_disable_unprepare(pc->clk_top); in pwm_mediatek_clk_enable()
107 struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); in pwm_mediatek_clk_disable() local
109 clk_disable_unprepare(pc->clk_pwms[pwm->hwpwm]); in pwm_mediatek_clk_disable()
110 clk_disable_unprepare(pc->clk_main); in pwm_mediatek_clk_disable()
111 clk_disable_unprepare(pc->clk_top); in pwm_mediatek_clk_disable()
124 struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); in pwm_mediatek_config() local
136 if (pc->soc->has_ck_26m_sel) in pwm_mediatek_config()
137 writel(0, pc->regs + PWM_CK_26M_SEL); in pwm_mediatek_config()
141 do_div(resolution, clk_get_rate(pc->clk_pwms[pwm->hwpwm])); in pwm_mediatek_config()
157 if (pc->soc->pwm45_fixup && pwm->hwpwm > 2) { in pwm_mediatek_config()
167 pwm_mediatek_writel(pc, pwm->hwpwm, PWMCON, BIT(15) | clkdiv); in pwm_mediatek_config()
168 pwm_mediatek_writel(pc, pwm->hwpwm, reg_width, cnt_period); in pwm_mediatek_config()
169 pwm_mediatek_writel(pc, pwm->hwpwm, reg_thres, cnt_duty); in pwm_mediatek_config()
178 struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); in pwm_mediatek_enable() local
186 value = readl(pc->regs); in pwm_mediatek_enable()
188 writel(value, pc->regs); in pwm_mediatek_enable()
195 struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); in pwm_mediatek_disable() local
198 value = readl(pc->regs); in pwm_mediatek_disable()
200 writel(value, pc->regs); in pwm_mediatek_disable()
237 struct pwm_mediatek_chip *pc; in pwm_mediatek_probe() local
241 pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); in pwm_mediatek_probe()
242 if (!pc) in pwm_mediatek_probe()
245 pc->soc = of_device_get_match_data(&pdev->dev); in pwm_mediatek_probe()
247 pc->regs = devm_platform_ioremap_resource(pdev, 0); in pwm_mediatek_probe()
248 if (IS_ERR(pc->regs)) in pwm_mediatek_probe()
249 return PTR_ERR(pc->regs); in pwm_mediatek_probe()
251 pc->clk_pwms = devm_kmalloc_array(&pdev->dev, pc->soc->num_pwms, in pwm_mediatek_probe()
252 sizeof(*pc->clk_pwms), GFP_KERNEL); in pwm_mediatek_probe()
253 if (!pc->clk_pwms) in pwm_mediatek_probe()
256 pc->clk_top = devm_clk_get(&pdev->dev, "top"); in pwm_mediatek_probe()
257 if (IS_ERR(pc->clk_top)) in pwm_mediatek_probe()
258 return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_top), in pwm_mediatek_probe()
261 pc->clk_main = devm_clk_get(&pdev->dev, "main"); in pwm_mediatek_probe()
262 if (IS_ERR(pc->clk_main)) in pwm_mediatek_probe()
263 return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_main), in pwm_mediatek_probe()
266 for (i = 0; i < pc->soc->num_pwms; i++) { in pwm_mediatek_probe()
271 pc->clk_pwms[i] = devm_clk_get(&pdev->dev, name); in pwm_mediatek_probe()
272 if (IS_ERR(pc->clk_pwms[i])) in pwm_mediatek_probe()
273 return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_pwms[i]), in pwm_mediatek_probe()
277 pc->chip.dev = &pdev->dev; in pwm_mediatek_probe()
278 pc->chip.ops = &pwm_mediatek_ops; in pwm_mediatek_probe()
279 pc->chip.npwm = pc->soc->num_pwms; in pwm_mediatek_probe()
281 ret = devm_pwmchip_add(&pdev->dev, &pc->chip); in pwm_mediatek_probe()