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

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-
18 * cycle, followed by a low signal for the remainder of the pulse
20 * @PWM_POLARITY_INVERSED: a low signal for the duration of the duty-
21 * cycle, followed by a high signal for the remainder of the pulse
30 * struct pwm_args - board-dependent PWM arguments
34 * This structure describes board-dependent arguments attached to a PWM
53 * struct pwm_waveform - description of a PWM waveform
55 * @duty_length_ns: PWM duty cycle
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
80 * @duty_cycle: PWM duty cycle (in nanoseconds)
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()
172 *args = pwm->args; in pwm_get_args()
176 * pwm_init_state() - prepare a new state to be applied with pwm_apply_might_sleep()
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
211 * @state: PWM state to extract the duty cycle from
212 * @scale: target scale of the relative duty cycle
214 * This functions converts the absolute duty cycle stored in @state (expressed
220 * duty = pwm_get_relative_duty_cycle(&state, 100);
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
235 * @duty_cycle: relative duty cycle value
238 * This functions converts a relative into an absolute duty cycle (expressed
239 * in nanoseconds), and puts the result in state->duty_cycle.
241 * For example if you want to configure a 50% duty cycle, call:
247 * This functions returns -EINVAL if @duty_cycle and/or @scale are
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()
265 * struct pwm_capture - PWM capture data
267 * @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
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
397 * @period_ns: duration (in nanoseconds) of one cycle
407 return -EINVAL; in pwm_config()
410 return -EINVAL; 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()
630 state.polarity = pwm->args.polarity; in pwm_apply_args()
631 state.period = pwm->args.period; in pwm_apply_args()