Lines Matching +full:period +full:- +full:scale

1 /* SPDX-License-Identifier: GPL-2.0 */
16 * enum pwm_polarity - polarity of a PWM signal
17 * @PWM_POLARITY_NORMAL: a high signal for the duration of the duty-
19 * period
20 * @PWM_POLARITY_INVERSED: a low signal for the duration of the duty-
22 * period
30 * struct pwm_args - board-dependent PWM arguments
31 * @period: reference period
34 * This structure describes board-dependent arguments attached to a PWM
43 u64 period; member
53 * struct pwm_waveform - description of a PWM waveform
54 * @period_length_ns: PWM period
56 * @duty_offset_ns: offset of the rising edge from the period's start
61 * PWM_POLARITY_NORMAL) and period - duty_cycle (.polarity =
67 * active or inactive level, go high-z or even continue to toggle.
78 * struct pwm_state - state of a PWM channel
79 * @period: PWM period (in nanoseconds)
89 u64 period; member
97 * struct pwm_device - PWM channel object
100 * @hwpwm: per-chip relative index of the PWM device
118 * pwm_get_state() - retrieve the current PWM state
130 *state = pwm->state; in pwm_get_state()
148 return state.period; in pwm_get_period()
172 *args = pwm->args; in pwm_get_args()
176 * pwm_init_state() - prepare a new state to be applied with pwm_apply_might_sleep()
182 * that first retrieves the current PWM state and the replaces the period
183 * and polarity fields with the reference values defined in pwm->args.
184 * Once the function returns, you can adjust the ->enabled and ->duty_cycle
187 * ->duty_cycle is initially set to zero to avoid cases where the current
188 * ->duty_cycle value exceed the pwm_args->period one, which would trigger
189 * an error if the user calls pwm_apply_might_sleep() without adjusting ->duty_cycle
203 state->period = args.period; in pwm_init_state()
204 state->polarity = args.polarity; in pwm_init_state()
205 state->duty_cycle = 0; in pwm_init_state()
206 state->usage_power = false; in pwm_init_state()
210 * pwm_get_relative_duty_cycle() - Get a relative duty cycle value
212 * @scale: target scale of the relative duty cycle
215 * in nanosecond) into a value relative to the period.
223 pwm_get_relative_duty_cycle(const struct pwm_state *state, unsigned int scale) in pwm_get_relative_duty_cycle() argument
225 if (!state->period) in pwm_get_relative_duty_cycle()
228 return DIV_ROUND_CLOSEST_ULL((u64)state->duty_cycle * scale, in pwm_get_relative_duty_cycle()
229 state->period); in pwm_get_relative_duty_cycle()
233 * pwm_set_relative_duty_cycle() - Set a relative duty cycle value
236 * @scale: scale in which @duty_cycle is expressed
239 * in nanoseconds), and puts the result in state->duty_cycle.
247 * This functions returns -EINVAL if @duty_cycle and/or @scale are
248 * inconsistent (@scale == 0 or @duty_cycle > @scale).
252 unsigned int scale) in pwm_set_relative_duty_cycle() argument
254 if (!scale || duty_cycle > scale) in pwm_set_relative_duty_cycle()
255 return -EINVAL; in pwm_set_relative_duty_cycle()
257 state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)duty_cycle * in pwm_set_relative_duty_cycle()
258 state->period, in pwm_set_relative_duty_cycle()
259 scale); in pwm_set_relative_duty_cycle()
265 * struct pwm_capture - PWM capture data
266 * @period: period of the PWM signal (in nanoseconds)
270 unsigned int period; member
275 * struct pwm_ops - PWM controller operations
310 * struct pwm_chip - abstract a PWM controller
317 * @atomic: can the driver's ->apply() be called in atomic context
351 * pwmchip_supports_waveform() - checks if the given chip supports waveform callbacks
364 return chip->ops->write_waveform != NULL; in pwmchip_supports_waveform()
369 return chip->dev.parent; in pwmchip_parent()
374 return dev_get_drvdata(&chip->dev); in pwmchip_get_drvdata()
379 dev_set_drvdata(&chip->dev, data); in pwmchip_set_drvdata()
394 * pwm_config() - change a PWM device configuration
407 return -EINVAL; in pwm_config()
410 return -EINVAL; in pwm_config()
413 if (state.duty_cycle == duty_ns && state.period == period_ns) in pwm_config()
417 state.period = period_ns; in pwm_config()
422 * pwm_enable() - start a PWM output toggling
432 return -EINVAL; in pwm_enable()
443 * pwm_disable() - stop a PWM output toggling
462 * pwm_might_sleep() - is pwm_apply_atomic() supported?
469 return !pwm->chip->atomic; in pwm_might_sleep()
506 return -EOPNOTSUPP; in pwm_apply_might_sleep()
512 return -EOPNOTSUPP; in pwm_apply_atomic()
517 return -EOPNOTSUPP; in pwm_get_state_hw()
522 return -EOPNOTSUPP; in pwm_adjust_config()
529 return -EINVAL; in pwm_config()
535 return -EINVAL; in pwm_enable()
551 return ERR_PTR(-EINVAL); in pwmchip_alloc()
563 return -EINVAL; in pwmchip_add()
568 return -EINVAL; in pwmchip_remove()
573 return -EINVAL; in devm_pwmchip_add()
580 return ERR_PTR(-ENODEV); in pwm_get()
592 return ERR_PTR(-ENODEV); in devm_pwm_get()
600 return ERR_PTR(-ENODEV); in devm_fwnode_pwm_get()
610 * where the polarity and period are set according to pwm_args info. in pwm_apply_args()
621 * the PWM device and set the reference period and polarity config. in pwm_apply_args()
630 state.polarity = pwm->args.polarity; in pwm_apply_args()
631 state.period = pwm->args.period; in pwm_apply_args()
643 unsigned int period; member
655 .period = _period, \