Lines Matching +full:duty +full:- +full:cycle

1 /* SPDX-License-Identifier: GPL-2.0 */
12 * enum pwm_polarity - polarity of a PWM signal
13 * @PWM_POLARITY_NORMAL: a high signal for the duration of the duty-
14 * cycle, followed by a low signal for the remainder of the pulse
16 * @PWM_POLARITY_INVERSED: a low signal for the duration of the duty-
17 * cycle, followed by a high signal for the remainder of the pulse
26 * struct pwm_args - board-dependent PWM arguments
30 * This structure describes board-dependent arguments attached to a PWM
49 * struct pwm_state - state of a PWM channel
51 * @duty_cycle: PWM duty cycle (in nanoseconds)
68 * struct pwm_device - PWM channel object
71 * @hwpwm: per-chip relative index of the PWM device
74 * @chip_data: chip-private data associated with the PWM device
93 * pwm_get_state() - retrieve the current PWM state
105 *state = pwm->state; in pwm_get_state()
120 pwm->state.period = period; in pwm_set_period()
132 static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty) in pwm_set_duty_cycle() argument
135 pwm->state.duty_cycle = duty; in pwm_set_duty_cycle()
159 *args = pwm->args; in pwm_get_args()
163 * pwm_init_state() - prepare a new state to be applied with pwm_apply_state()
170 * and polarity fields with the reference values defined in pwm->args.
171 * Once the function returns, you can adjust the ->enabled and ->duty_cycle
174 * ->duty_cycle is initially set to zero to avoid cases where the current
175 * ->duty_cycle value exceed the pwm_args->period one, which would trigger
176 * an error if the user calls pwm_apply_state() without adjusting ->duty_cycle
190 state->period = args.period; in pwm_init_state()
191 state->polarity = args.polarity; in pwm_init_state()
192 state->duty_cycle = 0; in pwm_init_state()
193 state->usage_power = false; in pwm_init_state()
197 * pwm_get_relative_duty_cycle() - Get a relative duty cycle value
198 * @state: PWM state to extract the duty cycle from
199 * @scale: target scale of the relative duty cycle
201 * This functions converts the absolute duty cycle stored in @state (expressed
207 * duty = pwm_get_relative_duty_cycle(&state, 100);
212 if (!state->period) in pwm_get_relative_duty_cycle()
215 return DIV_ROUND_CLOSEST_ULL((u64)state->duty_cycle * scale, in pwm_get_relative_duty_cycle()
216 state->period); in pwm_get_relative_duty_cycle()
220 * pwm_set_relative_duty_cycle() - Set a relative duty cycle value
222 * @duty_cycle: relative duty cycle value
225 * This functions converts a relative into an absolute duty cycle (expressed
226 * in nanoseconds), and puts the result in state->duty_cycle.
228 * For example if you want to configure a 50% duty cycle, call:
234 * This functions returns -EINVAL if @duty_cycle and/or @scale are
242 return -EINVAL; in pwm_set_relative_duty_cycle()
244 state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)duty_cycle * in pwm_set_relative_duty_cycle()
245 state->period, in pwm_set_relative_duty_cycle()
252 * struct pwm_capture - PWM capture data
254 * @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
262 * struct pwm_ops - PWM controller operations
285 * struct pwm_chip - abstract a PWM controller
316 * pwm_config() - change a PWM device configuration
319 * @period_ns: duration (in nanoseconds) of one cycle
329 return -EINVAL; in pwm_config()
332 return -EINVAL; in pwm_config()
344 * pwm_enable() - start a PWM output toggling
354 return -EINVAL; in pwm_enable()
365 * pwm_disable() - stop a PWM output toggling
415 return -ENOTSUPP; in pwm_apply_state()
420 return -ENOTSUPP; in pwm_adjust_config()
427 return -EINVAL; in pwm_config()
433 return -EINVAL; in pwm_enable()
445 return -EINVAL; in pwm_capture()
450 return -EINVAL; in pwm_set_chip_data()
460 return -EINVAL; in pwmchip_add()
465 return -EINVAL; in pwmchip_remove()
470 return -EINVAL; in devm_pwmchip_add()
478 return ERR_PTR(-ENODEV); in pwm_request_from_chip()
485 return ERR_PTR(-ENODEV); in pwm_get()
497 return ERR_PTR(-ENODEV); in devm_pwm_get()
505 return ERR_PTR(-ENODEV); in devm_fwnode_pwm_get()
535 state.polarity = pwm->args.polarity; in pwm_apply_args()
536 state.period = pwm->args.period; in pwm_apply_args()