Lines Matching +full:long +full:- +full:term

1 // SPDX-License-Identifier: GPL-2.0-or-later
9 * platform device ep93xx-pwm.1 - PWMOUT1 (EGPIO14)
12 * platform device ep93xx-pwm.0 - PWMOUT
15 * platform device ep93xx-pwm.0 - PWMOUT
16 * platform device ep93xx-pwm.1 - PWMOUT1 (EGPIO14)
50 bool enabled = state->enabled; in ep93xx_pwm_apply()
51 void __iomem *base = ep93xx_pwm->base; in ep93xx_pwm_apply()
52 unsigned long long c; in ep93xx_pwm_apply()
53 unsigned long period_cycles; in ep93xx_pwm_apply()
54 unsigned long duty_cycles; in ep93xx_pwm_apply()
55 unsigned long term; in ep93xx_pwm_apply() local
57 if (state->polarity != pwm->state.polarity) { in ep93xx_pwm_apply()
59 writew(0x0, ep93xx_pwm->base + EP93XX_PWMx_ENABLE); in ep93xx_pwm_apply()
60 clk_disable_unprepare(ep93xx_pwm->clk); in ep93xx_pwm_apply()
68 ret = clk_prepare_enable(ep93xx_pwm->clk); in ep93xx_pwm_apply()
72 if (state->polarity == PWM_POLARITY_INVERSED) in ep93xx_pwm_apply()
73 writew(0x1, ep93xx_pwm->base + EP93XX_PWMx_INVERT); in ep93xx_pwm_apply()
75 writew(0x0, ep93xx_pwm->base + EP93XX_PWMx_INVERT); in ep93xx_pwm_apply()
77 clk_disable_unprepare(ep93xx_pwm->clk); in ep93xx_pwm_apply()
80 if (!state->enabled) { in ep93xx_pwm_apply()
82 writew(0x0, ep93xx_pwm->base + EP93XX_PWMx_ENABLE); in ep93xx_pwm_apply()
83 clk_disable_unprepare(ep93xx_pwm->clk); in ep93xx_pwm_apply()
94 ret = clk_prepare_enable(ep93xx_pwm->clk); in ep93xx_pwm_apply()
99 c = clk_get_rate(ep93xx_pwm->clk); in ep93xx_pwm_apply()
100 c *= state->period; in ep93xx_pwm_apply()
105 c *= state->duty_cycle; in ep93xx_pwm_apply()
106 do_div(c, state->period); in ep93xx_pwm_apply()
110 term = readw(base + EP93XX_PWMx_TERM_COUNT); in ep93xx_pwm_apply()
113 if (period_cycles > term) { in ep93xx_pwm_apply()
122 ret = -EINVAL; in ep93xx_pwm_apply()
126 clk_disable_unprepare(ep93xx_pwm->clk); in ep93xx_pwm_apply()
132 ret = clk_prepare_enable(ep93xx_pwm->clk); in ep93xx_pwm_apply()
136 writew(0x1, ep93xx_pwm->base + EP93XX_PWMx_ENABLE); in ep93xx_pwm_apply()
152 chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*ep93xx_pwm)); in ep93xx_pwm_probe()
157 ep93xx_pwm->base = devm_platform_ioremap_resource(pdev, 0); in ep93xx_pwm_probe()
158 if (IS_ERR(ep93xx_pwm->base)) in ep93xx_pwm_probe()
159 return PTR_ERR(ep93xx_pwm->base); in ep93xx_pwm_probe()
161 ep93xx_pwm->clk = devm_clk_get(&pdev->dev, "pwm_clk"); in ep93xx_pwm_probe()
162 if (IS_ERR(ep93xx_pwm->clk)) in ep93xx_pwm_probe()
163 return PTR_ERR(ep93xx_pwm->clk); in ep93xx_pwm_probe()
165 chip->ops = &ep93xx_pwm_ops; in ep93xx_pwm_probe()
167 ret = devm_pwmchip_add(&pdev->dev, chip); in ep93xx_pwm_probe()
175 { .compatible = "cirrus,ep9301-pwm" },
182 .name = "ep93xx-pwm",
192 MODULE_ALIAS("platform:ep93xx-pwm");