// SPDX-License-Identifier: GPL-2.0-only /* * Analog Devices ADP5585 PWM driver * * Copyright 2022 NXP * Copyright 2024 Ideas on Board Oy * * Limitations: * - The .apply() operation executes atomically, but may not wait for the * period to complete (this is not documented and would need to be tested). * - Disabling the PWM drives the output pin to a low level immediately. * - The hardware can only generate normal polarity output.
*/
if (!state->enabled) {
regmap_clear_bits(regmap, info->pwm_cfg, ADP5585_PWM_EN); return 0;
}
if (state->polarity != PWM_POLARITY_NORMAL) return -EINVAL;
if (state->period < ADP5585_PWM_MIN_PERIOD_NS) return -EINVAL;
period = min(state->period, ADP5585_PWM_MAX_PERIOD_NS);
duty_cycle = min(state->duty_cycle, period);
/* * Compute the on and off time. As the internal oscillator frequency is * 1MHz, the calculation can be simplified without loss of precision.
*/
on = div_u64(duty_cycle, NSEC_PER_SEC / ADP5585_PWM_OSC_FREQ_HZ);
off = div_u64(period, NSEC_PER_SEC / ADP5585_PWM_OSC_FREQ_HZ) - on;
val = cpu_to_le16(off);
ret = regmap_bulk_write(regmap, info->pwm_offt_low, &val, 2); if (ret) return ret;
val = cpu_to_le16(on);
ret = regmap_bulk_write(regmap, info->pwm_ont_low, &val, 2); if (ret) return ret;
/* Enable PWM in continuous mode and no external AND'ing. */
ret = regmap_update_bits(regmap, info->pwm_cfg,
ADP5585_PWM_IN_AND | ADP5585_PWM_MODE |
ADP5585_PWM_EN, ADP5585_PWM_EN); if (ret) return ret;
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.