Lines Matching full:pc

63 	struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip);  in rockchip_pwm_get_state()  local
64 u32 enable_conf = pc->data->enable_conf; in rockchip_pwm_get_state()
70 ret = clk_enable(pc->pclk); in rockchip_pwm_get_state()
74 ret = clk_enable(pc->clk); in rockchip_pwm_get_state()
78 clk_rate = clk_get_rate(pc->clk); in rockchip_pwm_get_state()
80 tmp = readl_relaxed(pc->base + pc->data->regs.period); in rockchip_pwm_get_state()
81 tmp *= pc->data->prescaler * NSEC_PER_SEC; in rockchip_pwm_get_state()
84 tmp = readl_relaxed(pc->base + pc->data->regs.duty); in rockchip_pwm_get_state()
85 tmp *= pc->data->prescaler * NSEC_PER_SEC; in rockchip_pwm_get_state()
88 val = readl_relaxed(pc->base + pc->data->regs.ctrl); in rockchip_pwm_get_state()
91 if (pc->data->supports_polarity && !(val & PWM_DUTY_POSITIVE)) in rockchip_pwm_get_state()
96 clk_disable(pc->clk); in rockchip_pwm_get_state()
97 clk_disable(pc->pclk); in rockchip_pwm_get_state()
105 struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); in rockchip_pwm_config() local
110 clk_rate = clk_get_rate(pc->clk); in rockchip_pwm_config()
119 pc->data->prescaler * NSEC_PER_SEC); in rockchip_pwm_config()
122 duty = DIV_ROUND_CLOSEST_ULL(div, pc->data->prescaler * NSEC_PER_SEC); in rockchip_pwm_config()
128 ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl); in rockchip_pwm_config()
129 if (pc->data->supports_lock) { in rockchip_pwm_config()
131 writel_relaxed(ctrl, pc->base + pc->data->regs.ctrl); in rockchip_pwm_config()
134 writel(period, pc->base + pc->data->regs.period); in rockchip_pwm_config()
135 writel(duty, pc->base + pc->data->regs.duty); in rockchip_pwm_config()
137 if (pc->data->supports_polarity) { in rockchip_pwm_config()
150 if (pc->data->supports_lock) in rockchip_pwm_config()
153 writel(ctrl, pc->base + pc->data->regs.ctrl); in rockchip_pwm_config()
160 struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); in rockchip_pwm_enable() local
161 u32 enable_conf = pc->data->enable_conf; in rockchip_pwm_enable()
166 ret = clk_enable(pc->clk); in rockchip_pwm_enable()
171 val = readl_relaxed(pc->base + pc->data->regs.ctrl); in rockchip_pwm_enable()
178 writel_relaxed(val, pc->base + pc->data->regs.ctrl); in rockchip_pwm_enable()
181 clk_disable(pc->clk); in rockchip_pwm_enable()
189 struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); in rockchip_pwm_apply() local
194 ret = clk_enable(pc->pclk); in rockchip_pwm_apply()
198 ret = clk_enable(pc->clk); in rockchip_pwm_apply()
206 !pc->data->supports_lock) { in rockchip_pwm_apply()
221 clk_disable(pc->clk); in rockchip_pwm_apply()
222 clk_disable(pc->pclk); in rockchip_pwm_apply()
299 struct rockchip_pwm_chip *pc; in rockchip_pwm_probe() local
304 chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*pc)); in rockchip_pwm_probe()
307 pc = to_rockchip_pwm_chip(chip); in rockchip_pwm_probe()
309 pc->base = devm_platform_ioremap_resource(pdev, 0); in rockchip_pwm_probe()
310 if (IS_ERR(pc->base)) in rockchip_pwm_probe()
311 return PTR_ERR(pc->base); in rockchip_pwm_probe()
313 pc->clk = devm_clk_get(&pdev->dev, "pwm"); in rockchip_pwm_probe()
314 if (IS_ERR(pc->clk)) { in rockchip_pwm_probe()
315 pc->clk = devm_clk_get(&pdev->dev, NULL); in rockchip_pwm_probe()
316 if (IS_ERR(pc->clk)) in rockchip_pwm_probe()
317 return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk), in rockchip_pwm_probe()
324 pc->pclk = devm_clk_get(&pdev->dev, "pclk"); in rockchip_pwm_probe()
326 pc->pclk = pc->clk; in rockchip_pwm_probe()
328 if (IS_ERR(pc->pclk)) in rockchip_pwm_probe()
329 return dev_err_probe(&pdev->dev, PTR_ERR(pc->pclk), "Can't get APB clk\n"); in rockchip_pwm_probe()
331 ret = clk_prepare_enable(pc->clk); in rockchip_pwm_probe()
335 ret = clk_prepare_enable(pc->pclk); in rockchip_pwm_probe()
343 pc->data = device_get_match_data(&pdev->dev); in rockchip_pwm_probe()
346 enable_conf = pc->data->enable_conf; in rockchip_pwm_probe()
347 ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl); in rockchip_pwm_probe()
358 clk_disable(pc->clk); in rockchip_pwm_probe()
360 clk_disable(pc->pclk); in rockchip_pwm_probe()
365 clk_disable_unprepare(pc->pclk); in rockchip_pwm_probe()
367 clk_disable_unprepare(pc->clk); in rockchip_pwm_probe()
375 struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); in rockchip_pwm_remove() local
379 clk_unprepare(pc->pclk); in rockchip_pwm_remove()
380 clk_unprepare(pc->clk); in rockchip_pwm_remove()