• Home
  • Raw
  • Download

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

1 /* SPDX-License-Identifier: GPL-2.0 */
15 * enum pwm_polarity - polarity of a PWM signal
16 * @PWM_POLARITY_NORMAL: a high signal for the duration of the duty-
17 * cycle, followed by a low signal for the remainder of the pulse
19 * @PWM_POLARITY_INVERSED: a low signal for the duration of the duty-
20 * cycle, followed by a high signal for the remainder of the pulse
29 * struct pwm_args - board-dependent PWM arguments
33 * This structure describes board-dependent arguments attached to a PWM
52 * struct pwm_state - state of a PWM channel
54 * @duty_cycle: PWM duty cycle (in nanoseconds)
66 * struct pwm_device - PWM channel object
69 * @hwpwm: per-chip relative index of the PWM device
72 * @chip_data: chip-private data associated with the PWM device
91 * pwm_get_state() - retrieve the current PWM state
98 *state = pwm->state; in pwm_get_state()
113 pwm->state.period = period; in pwm_set_period()
125 static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty) in pwm_set_duty_cycle() argument
128 pwm->state.duty_cycle = duty; in pwm_set_duty_cycle()
152 *args = pwm->args; in pwm_get_args()
156 * pwm_init_state() - prepare a new state to be applied with pwm_apply_state()
163 * and polarity fields with the reference values defined in pwm->args.
164 * Once the function returns, you can adjust the ->enabled and ->duty_cycle
167 * ->duty_cycle is initially set to zero to avoid cases where the current
168 * ->duty_cycle value exceed the pwm_args->period one, which would trigger
169 * an error if the user calls pwm_apply_state() without adjusting ->duty_cycle
183 state->period = args.period; in pwm_init_state()
184 state->polarity = args.polarity; in pwm_init_state()
185 state->duty_cycle = 0; in pwm_init_state()
189 * pwm_get_relative_duty_cycle() - Get a relative duty cycle value
190 * @state: PWM state to extract the duty cycle from
191 * @scale: target scale of the relative duty cycle
193 * This functions converts the absolute duty cycle stored in @state (expressed
199 * duty = pwm_get_relative_duty_cycle(&state, 100);
204 if (!state->period) in pwm_get_relative_duty_cycle()
207 return DIV_ROUND_CLOSEST_ULL((u64)state->duty_cycle * scale, in pwm_get_relative_duty_cycle()
208 state->period); in pwm_get_relative_duty_cycle()
212 * pwm_set_relative_duty_cycle() - Set a relative duty cycle value
214 * @duty_cycle: relative duty cycle value
217 * This functions converts a relative into an absolute duty cycle (expressed
218 * in nanoseconds), and puts the result in state->duty_cycle.
220 * For example if you want to configure a 50% duty cycle, call:
226 * This functions returns -EINVAL if @duty_cycle and/or @scale are
234 return -EINVAL; in pwm_set_relative_duty_cycle()
236 state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)duty_cycle * in pwm_set_relative_duty_cycle()
237 state->period, in pwm_set_relative_duty_cycle()
244 * struct pwm_ops - PWM controller operations
253 * @config: configure duty cycles and period length for this PWM
279 * struct pwm_chip - abstract a PWM controller
305 * struct pwm_capture - PWM capture data
307 * @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
322 * pwm_config() - change a PWM device configuration
325 * @period_ns: duration (in nanoseconds) of one cycle
335 return -EINVAL; in pwm_config()
338 return -EINVAL; in pwm_config()
350 * pwm_enable() - start a PWM output toggling
360 return -EINVAL; in pwm_enable()
371 * pwm_disable() - stop a PWM output toggling
421 return ERR_PTR(-ENODEV); in pwm_request()
431 return -ENOTSUPP; in pwm_apply_state()
436 return -ENOTSUPP; in pwm_adjust_config()
442 return -EINVAL; in pwm_config()
449 return -EINVAL; in pwm_capture()
454 return -EINVAL; in pwm_enable()
463 return -EINVAL; in pwm_set_chip_data()
473 return -EINVAL; in pwmchip_add()
478 return -EINVAL; in pwmchip_add_inversed()
483 return -EINVAL; in pwmchip_remove()
490 return ERR_PTR(-ENODEV); in pwm_request_from_chip()
496 return ERR_PTR(-ENODEV); in pwm_get()
503 return ERR_PTR(-ENODEV); in of_pwm_get()
513 return ERR_PTR(-ENODEV); in devm_pwm_get()
520 return ERR_PTR(-ENODEV); in devm_of_pwm_get()
527 return ERR_PTR(-ENODEV); in devm_fwnode_pwm_get()
561 state.polarity = pwm->args.polarity; in pwm_apply_args()
562 state.period = pwm->args.period; in pwm_apply_args()