Lines Matching refs:pc
64 struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); in rockchip_pwm_get_state() local
65 u32 enable_conf = pc->data->enable_conf; in rockchip_pwm_get_state()
71 ret = clk_enable(pc->pclk); in rockchip_pwm_get_state()
75 ret = clk_enable(pc->clk); in rockchip_pwm_get_state()
79 clk_rate = clk_get_rate(pc->clk); in rockchip_pwm_get_state()
81 tmp = readl_relaxed(pc->base + pc->data->regs.period); in rockchip_pwm_get_state()
82 tmp *= pc->data->prescaler * NSEC_PER_SEC; in rockchip_pwm_get_state()
85 tmp = readl_relaxed(pc->base + pc->data->regs.duty); in rockchip_pwm_get_state()
86 tmp *= pc->data->prescaler * NSEC_PER_SEC; in rockchip_pwm_get_state()
89 val = readl_relaxed(pc->base + pc->data->regs.ctrl); in rockchip_pwm_get_state()
92 if (pc->data->supports_polarity && !(val & PWM_DUTY_POSITIVE)) in rockchip_pwm_get_state()
97 clk_disable(pc->clk); in rockchip_pwm_get_state()
98 clk_disable(pc->pclk); in rockchip_pwm_get_state()
106 struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); in rockchip_pwm_config() local
111 clk_rate = clk_get_rate(pc->clk); in rockchip_pwm_config()
120 pc->data->prescaler * NSEC_PER_SEC); in rockchip_pwm_config()
123 duty = DIV_ROUND_CLOSEST_ULL(div, pc->data->prescaler * NSEC_PER_SEC); in rockchip_pwm_config()
129 ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl); in rockchip_pwm_config()
130 if (pc->data->supports_lock) { in rockchip_pwm_config()
132 writel_relaxed(ctrl, pc->base + pc->data->regs.ctrl); in rockchip_pwm_config()
135 writel(period, pc->base + pc->data->regs.period); in rockchip_pwm_config()
136 writel(duty, pc->base + pc->data->regs.duty); in rockchip_pwm_config()
138 if (pc->data->supports_polarity) { in rockchip_pwm_config()
151 if (pc->data->supports_lock) in rockchip_pwm_config()
154 writel(ctrl, pc->base + pc->data->regs.ctrl); in rockchip_pwm_config()
161 struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); in rockchip_pwm_enable() local
162 u32 enable_conf = pc->data->enable_conf; in rockchip_pwm_enable()
167 ret = clk_enable(pc->clk); in rockchip_pwm_enable()
172 val = readl_relaxed(pc->base + pc->data->regs.ctrl); in rockchip_pwm_enable()
179 writel_relaxed(val, pc->base + pc->data->regs.ctrl); in rockchip_pwm_enable()
182 clk_disable(pc->clk); in rockchip_pwm_enable()
190 struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); in rockchip_pwm_apply() local
195 ret = clk_enable(pc->pclk); in rockchip_pwm_apply()
199 ret = clk_enable(pc->clk); in rockchip_pwm_apply()
207 !pc->data->supports_lock) { in rockchip_pwm_apply()
222 clk_disable(pc->clk); in rockchip_pwm_apply()
223 clk_disable(pc->pclk); in rockchip_pwm_apply()
301 struct rockchip_pwm_chip *pc; in rockchip_pwm_probe() local
310 pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); in rockchip_pwm_probe()
311 if (!pc) in rockchip_pwm_probe()
314 pc->base = devm_platform_ioremap_resource(pdev, 0); in rockchip_pwm_probe()
315 if (IS_ERR(pc->base)) in rockchip_pwm_probe()
316 return PTR_ERR(pc->base); in rockchip_pwm_probe()
318 pc->clk = devm_clk_get(&pdev->dev, "pwm"); in rockchip_pwm_probe()
319 if (IS_ERR(pc->clk)) { in rockchip_pwm_probe()
320 pc->clk = devm_clk_get(&pdev->dev, NULL); in rockchip_pwm_probe()
321 if (IS_ERR(pc->clk)) in rockchip_pwm_probe()
322 return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk), in rockchip_pwm_probe()
329 pc->pclk = devm_clk_get(&pdev->dev, "pclk"); in rockchip_pwm_probe()
331 pc->pclk = pc->clk; in rockchip_pwm_probe()
333 if (IS_ERR(pc->pclk)) in rockchip_pwm_probe()
334 return dev_err_probe(&pdev->dev, PTR_ERR(pc->pclk), "Can't get APB clk\n"); in rockchip_pwm_probe()
336 ret = clk_prepare_enable(pc->clk); in rockchip_pwm_probe()
340 ret = clk_prepare_enable(pc->pclk); in rockchip_pwm_probe()
346 platform_set_drvdata(pdev, pc); in rockchip_pwm_probe()
348 pc->data = id->data; in rockchip_pwm_probe()
349 pc->chip.dev = &pdev->dev; in rockchip_pwm_probe()
350 pc->chip.ops = &rockchip_pwm_ops; in rockchip_pwm_probe()
351 pc->chip.npwm = 1; in rockchip_pwm_probe()
353 enable_conf = pc->data->enable_conf; in rockchip_pwm_probe()
354 ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl); in rockchip_pwm_probe()
357 ret = pwmchip_add(&pc->chip); in rockchip_pwm_probe()
365 clk_disable(pc->clk); in rockchip_pwm_probe()
367 clk_disable(pc->pclk); in rockchip_pwm_probe()
372 clk_disable_unprepare(pc->pclk); in rockchip_pwm_probe()
374 clk_disable_unprepare(pc->clk); in rockchip_pwm_probe()
381 struct rockchip_pwm_chip *pc = platform_get_drvdata(pdev); in rockchip_pwm_remove() local
383 pwmchip_remove(&pc->chip); in rockchip_pwm_remove()
385 clk_unprepare(pc->pclk); in rockchip_pwm_remove()
386 clk_unprepare(pc->clk); in rockchip_pwm_remove()