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
89 * pwm_get_state() - retrieve the current PWM state
101 *state = pwm->state; in pwm_get_state()
143 *args = pwm->args; in pwm_get_args()
147 * pwm_init_state() - prepare a new state to be applied with pwm_apply_might_sleep()
154 * and polarity fields with the reference values defined in pwm->args.
155 * Once the function returns, you can adjust the ->enabled and ->duty_cycle
158 * ->duty_cycle is initially set to zero to avoid cases where the current
159 * ->duty_cycle value exceed the pwm_args->period one, which would trigger
160 * an error if the user calls pwm_apply_might_sleep() without adjusting ->duty_cycle
174 state->period = args.period; in pwm_init_state()
175 state->polarity = args.polarity; in pwm_init_state()
176 state->duty_cycle = 0; in pwm_init_state()
177 state->usage_power = false; in pwm_init_state()
181 * pwm_get_relative_duty_cycle() - Get a relative duty cycle value
182 * @state: PWM state to extract the duty cycle from
183 * @scale: target scale of the relative duty cycle
185 * This functions converts the absolute duty cycle stored in @state (expressed
191 * duty = pwm_get_relative_duty_cycle(&state, 100);
196 if (!state->period) in pwm_get_relative_duty_cycle()
199 return DIV_ROUND_CLOSEST_ULL((u64)state->duty_cycle * scale, in pwm_get_relative_duty_cycle()
200 state->period); in pwm_get_relative_duty_cycle()
204 * pwm_set_relative_duty_cycle() - Set a relative duty cycle value
206 * @duty_cycle: relative duty cycle value
209 * This functions converts a relative into an absolute duty cycle (expressed
210 * in nanoseconds), and puts the result in state->duty_cycle.
212 * For example if you want to configure a 50% duty cycle, call:
218 * This functions returns -EINVAL if @duty_cycle and/or @scale are
226 return -EINVAL; in pwm_set_relative_duty_cycle()
228 state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)duty_cycle * in pwm_set_relative_duty_cycle()
229 state->period, in pwm_set_relative_duty_cycle()
236 * struct pwm_capture - PWM capture data
238 * @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
246 * struct pwm_ops - PWM controller operations
267 * struct pwm_chip - abstract a PWM controller
275 * @atomic: can the driver's ->apply() be called in atomic context
301 * pwm_config() - change a PWM device configuration
304 * @period_ns: duration (in nanoseconds) of one cycle
314 return -EINVAL; in pwm_config()
317 return -EINVAL; in pwm_config()
329 * pwm_enable() - start a PWM output toggling
339 return -EINVAL; in pwm_enable()
350 * pwm_disable() - stop a PWM output toggling
369 * pwm_might_sleep() - is pwm_apply_atomic() supported?
376 return !pwm->chip->atomic; in pwm_might_sleep()
416 return -EOPNOTSUPP; in pwm_apply_might_sleep()
422 return -EOPNOTSUPP; in pwm_apply_atomic()
427 return -EOPNOTSUPP; in pwm_adjust_config()
434 return -EINVAL; in pwm_config()
440 return -EINVAL; in pwm_enable()
452 return -EINVAL; in pwm_capture()
457 return -EINVAL; in pwmchip_add()
462 return -EINVAL; in pwmchip_remove()
467 return -EINVAL; in devm_pwmchip_add()
475 return ERR_PTR(-ENODEV); in pwm_request_from_chip()
482 return ERR_PTR(-ENODEV); in pwm_get()
494 return ERR_PTR(-ENODEV); in devm_pwm_get()
502 return ERR_PTR(-ENODEV); in devm_fwnode_pwm_get()
532 state.polarity = pwm->args.polarity; in pwm_apply_args()
533 state.period = pwm->args.period; in pwm_apply_args()
539 /* only for backwards-compatibility, new code should not use this */