// SPDX-License-Identifier: GPL-2.0 /* * Intel Keem Bay PWM driver * * Copyright (C) 2020 Intel Corporation * Authors: Lai Poey Seng <poey.seng.lai@intel.com> * Vineetha G. Jaya Kumaran <vineetha.g.jaya.kumaran@intel.com> * * Limitations: * - Upon disabling a channel, the currently running * period will not be completed. However, upon * reconfiguration of the duty cycle/period, the * currently running period will be completed first.
*/
/* * With gcc 10, CONFIG_CC_OPTIMIZE_FOR_SIZE and only "inline" instead of * "__always_inline" this fails to compile because the compiler doesn't notice * for all valid masks (e.g. KMB_PWM_LEADIN_MASK) that they are ok.
*/ static __always_inline void keembay_pwm_update_bits(struct keembay_pwm *priv, u32 mask,
u32 val, u32 offset)
{
u32 buff = readl(priv->base + offset);
if (state->polarity != PWM_POLARITY_NORMAL) return -EINVAL;
/* * Configure the pwm repeat count as infinite at (15:0) and leadin * low time as 0 at (30:16), which is in terms of clock cycles.
*/
keembay_pwm_update_bits(priv, KMB_PWM_LEADIN_MASK, 0,
KMB_PWM_LEADIN_OFFSET(pwm->hwpwm));
keembay_pwm_get_state(chip, pwm, ¤t_state);
if (!state->enabled) { if (current_state.enabled)
keembay_pwm_disable(priv, pwm->hwpwm); return 0;
}
/* * The upper 16 bits and lower 16 bits of the KMB_PWM_HIGHLOW_OFFSET * register contain the high time and low time of waveform accordingly. * All the values are in terms of clock cycles.
*/
clk_rate = clk_get_rate(priv->clk);
div = clk_rate * state->duty_cycle;
div = DIV_ROUND_DOWN_ULL(div, NSEC_PER_SEC); if (div > KMB_PWM_COUNT_MAX) return -ERANGE;
high = div;
div = clk_rate * state->period;
div = DIV_ROUND_DOWN_ULL(div, NSEC_PER_SEC);
div = div - high; if (div > KMB_PWM_COUNT_MAX) return -ERANGE;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.