• Home
  • Raw
  • Download

Lines Matching +full:am3352 +full:- +full:ecap

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ECAP PWM driver
5 * Copyright (C) 2012 Texas Instruments, Inc. - https://www.ti.com/
17 /* ECAP registers and bits definitions */
59 return -ERANGE; in ecap_pwm_config()
61 c = pc->clk_rate; in ecap_pwm_config()
70 c = pc->clk_rate; in ecap_pwm_config()
76 pm_runtime_get_sync(pc->chip.dev); in ecap_pwm_config()
78 value = readw(pc->mmio_base + ECCTL2); in ecap_pwm_config()
83 writew(value, pc->mmio_base + ECCTL2); in ecap_pwm_config()
87 writel(duty_cycles, pc->mmio_base + CAP2); in ecap_pwm_config()
88 writel(period_cycles, pc->mmio_base + CAP1); in ecap_pwm_config()
95 writel(duty_cycles, pc->mmio_base + CAP4); in ecap_pwm_config()
96 writel(period_cycles, pc->mmio_base + CAP3); in ecap_pwm_config()
100 value = readw(pc->mmio_base + ECCTL2); in ecap_pwm_config()
103 writew(value, pc->mmio_base + ECCTL2); in ecap_pwm_config()
106 pm_runtime_put_sync(pc->chip.dev); in ecap_pwm_config()
117 pm_runtime_get_sync(pc->chip.dev); in ecap_pwm_set_polarity()
119 value = readw(pc->mmio_base + ECCTL2); in ecap_pwm_set_polarity()
128 writew(value, pc->mmio_base + ECCTL2); in ecap_pwm_set_polarity()
130 pm_runtime_put_sync(pc->chip.dev); in ecap_pwm_set_polarity()
141 pm_runtime_get_sync(pc->chip.dev); in ecap_pwm_enable()
147 value = readw(pc->mmio_base + ECCTL2); in ecap_pwm_enable()
149 writew(value, pc->mmio_base + ECCTL2); in ecap_pwm_enable()
163 value = readw(pc->mmio_base + ECCTL2); in ecap_pwm_disable()
165 writew(value, pc->mmio_base + ECCTL2); in ecap_pwm_disable()
168 pm_runtime_put_sync(pc->chip.dev); in ecap_pwm_disable()
174 dev_warn(chip->dev, "Removing PWM device without disabling\n"); in ecap_pwm_free()
175 pm_runtime_put_sync(chip->dev); in ecap_pwm_free()
189 { .compatible = "ti,am3352-ecap" },
190 { .compatible = "ti,am33xx-ecap" },
197 struct device_node *np = pdev->dev.of_node; in ecap_pwm_probe()
203 pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); in ecap_pwm_probe()
205 return -ENOMEM; in ecap_pwm_probe()
207 clk = devm_clk_get(&pdev->dev, "fck"); in ecap_pwm_probe()
209 if (of_device_is_compatible(np, "ti,am33xx-ecap")) { in ecap_pwm_probe()
210 dev_warn(&pdev->dev, "Binding is obsolete.\n"); in ecap_pwm_probe()
211 clk = devm_clk_get(pdev->dev.parent, "fck"); in ecap_pwm_probe()
216 dev_err(&pdev->dev, "failed to get clock\n"); in ecap_pwm_probe()
220 pc->clk_rate = clk_get_rate(clk); in ecap_pwm_probe()
221 if (!pc->clk_rate) { in ecap_pwm_probe()
222 dev_err(&pdev->dev, "failed to get clock rate\n"); in ecap_pwm_probe()
223 return -EINVAL; in ecap_pwm_probe()
226 pc->chip.dev = &pdev->dev; in ecap_pwm_probe()
227 pc->chip.ops = &ecap_pwm_ops; in ecap_pwm_probe()
228 pc->chip.of_xlate = of_pwm_xlate_with_flags; in ecap_pwm_probe()
229 pc->chip.of_pwm_n_cells = 3; in ecap_pwm_probe()
230 pc->chip.base = -1; in ecap_pwm_probe()
231 pc->chip.npwm = 1; in ecap_pwm_probe()
234 pc->mmio_base = devm_ioremap_resource(&pdev->dev, r); in ecap_pwm_probe()
235 if (IS_ERR(pc->mmio_base)) in ecap_pwm_probe()
236 return PTR_ERR(pc->mmio_base); in ecap_pwm_probe()
238 ret = pwmchip_add(&pc->chip); in ecap_pwm_probe()
240 dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); in ecap_pwm_probe()
245 pm_runtime_enable(&pdev->dev); in ecap_pwm_probe()
254 pm_runtime_disable(&pdev->dev); in ecap_pwm_remove()
256 return pwmchip_remove(&pc->chip); in ecap_pwm_remove()
262 pm_runtime_get_sync(pc->chip.dev); in ecap_pwm_save_context()
263 pc->ctx.ecctl2 = readw(pc->mmio_base + ECCTL2); in ecap_pwm_save_context()
264 pc->ctx.cap4 = readl(pc->mmio_base + CAP4); in ecap_pwm_save_context()
265 pc->ctx.cap3 = readl(pc->mmio_base + CAP3); in ecap_pwm_save_context()
266 pm_runtime_put_sync(pc->chip.dev); in ecap_pwm_save_context()
271 writel(pc->ctx.cap3, pc->mmio_base + CAP3); in ecap_pwm_restore_context()
272 writel(pc->ctx.cap4, pc->mmio_base + CAP4); in ecap_pwm_restore_context()
273 writew(pc->ctx.ecctl2, pc->mmio_base + ECCTL2); in ecap_pwm_restore_context()
279 struct pwm_device *pwm = pc->chip.pwms; in ecap_pwm_suspend()
293 struct pwm_device *pwm = pc->chip.pwms; in ecap_pwm_resume()
308 .name = "ecap",
317 MODULE_DESCRIPTION("ECAP PWM driver");