Lines Matching +full:low +full:- +full:g
1 // SPDX-License-Identifier: GPL-2.0
7 * Vineetha G. Jaya Kumaran <vineetha.g.jaya.kumaran@intel.com>
10 * - Upon disabling a channel, the currently running
69 * for all valid masks (e.g. KMB_PWM_LEADIN_MASK) that they are ok.
74 u32 buff = readl(priv->base + offset); in keembay_pwm_update_bits()
77 writel(buff, priv->base + offset); in keembay_pwm_update_bits()
96 unsigned long long high, low; in keembay_pwm_get_state() local
100 clk_rate = clk_get_rate(priv->clk); in keembay_pwm_get_state()
103 highlow = readl(priv->base + KMB_PWM_LEADIN_OFFSET(pwm->hwpwm)); in keembay_pwm_get_state()
105 state->enabled = true; in keembay_pwm_get_state()
107 state->enabled = false; in keembay_pwm_get_state()
110 highlow = readl(priv->base + KMB_PWM_HIGHLOW_OFFSET(pwm->hwpwm)); in keembay_pwm_get_state()
111 low = FIELD_GET(KMB_PWM_LOW_MASK, highlow) * NSEC_PER_SEC; in keembay_pwm_get_state()
113 state->duty_cycle = DIV_ROUND_UP_ULL(high, clk_rate); in keembay_pwm_get_state()
114 state->period = DIV_ROUND_UP_ULL(high + low, clk_rate); in keembay_pwm_get_state()
115 state->polarity = PWM_POLARITY_NORMAL; in keembay_pwm_get_state()
126 u16 high, low; in keembay_pwm_apply() local
128 if (state->polarity != PWM_POLARITY_NORMAL) in keembay_pwm_apply()
129 return -EINVAL; in keembay_pwm_apply()
133 * low time as 0 at (30:16), which is in terms of clock cycles. in keembay_pwm_apply()
136 KMB_PWM_LEADIN_OFFSET(pwm->hwpwm)); in keembay_pwm_apply()
140 if (!state->enabled) { in keembay_pwm_apply()
142 keembay_pwm_disable(priv, pwm->hwpwm); in keembay_pwm_apply()
148 * register contain the high time and low time of waveform accordingly. in keembay_pwm_apply()
152 clk_rate = clk_get_rate(priv->clk); in keembay_pwm_apply()
153 div = clk_rate * state->duty_cycle; in keembay_pwm_apply()
156 return -ERANGE; in keembay_pwm_apply()
159 div = clk_rate * state->period; in keembay_pwm_apply()
161 div = div - high; in keembay_pwm_apply()
163 return -ERANGE; in keembay_pwm_apply()
165 low = div; in keembay_pwm_apply()
168 FIELD_PREP(KMB_PWM_LOW_MASK, low); in keembay_pwm_apply()
170 writel(pwm_count, priv->base + KMB_PWM_HIGHLOW_OFFSET(pwm->hwpwm)); in keembay_pwm_apply()
172 if (state->enabled && !current_state.enabled) in keembay_pwm_apply()
173 keembay_pwm_enable(priv, pwm->hwpwm); in keembay_pwm_apply()
186 struct device *dev = &pdev->dev; in keembay_pwm_probe()
192 return -ENOMEM; in keembay_pwm_probe()
194 priv->clk = devm_clk_get(dev, NULL); in keembay_pwm_probe()
195 if (IS_ERR(priv->clk)) in keembay_pwm_probe()
196 return dev_err_probe(dev, PTR_ERR(priv->clk), "Failed to get clock\n"); in keembay_pwm_probe()
198 priv->base = devm_platform_ioremap_resource(pdev, 0); in keembay_pwm_probe()
199 if (IS_ERR(priv->base)) in keembay_pwm_probe()
200 return PTR_ERR(priv->base); in keembay_pwm_probe()
202 ret = keembay_clk_enable(dev, priv->clk); in keembay_pwm_probe()
206 priv->chip.dev = dev; in keembay_pwm_probe()
207 priv->chip.ops = &keembay_pwm_ops; in keembay_pwm_probe()
208 priv->chip.npwm = KMB_TOTAL_PWM_CHANNELS; in keembay_pwm_probe()
210 ret = devm_pwmchip_add(dev, &priv->chip); in keembay_pwm_probe()
218 { .compatible = "intel,keembay-pwm" },
226 .name = "pwm-keembay",
232 MODULE_ALIAS("platform:pwm-keembay");