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_state - state of a PWM channel
55 * @duty_cycle: PWM duty cycle (in nanoseconds)
72 * struct pwm_device - PWM channel object
75 * @hwpwm: per-chip relative index of the PWM device
93 * pwm_get_state() - retrieve the current PWM state
105 *state = pwm->state; in pwm_get_state()
147 *args = pwm->args; in pwm_get_args()
151 * pwm_init_state() - prepare a new state to be applied with pwm_apply_might_sleep()
158 * and polarity fields with the reference values defined in pwm->args.
159 * Once the function returns, you can adjust the ->enabled and ->duty_cycle
162 * ->duty_cycle is initially set to zero to avoid cases where the current
163 * ->duty_cycle value exceed the pwm_args->period one, which would trigger
164 * an error if the user calls pwm_apply_might_sleep() without adjusting ->duty_cycle
178 state->period = args.period; in pwm_init_state()
179 state->polarity = args.polarity; in pwm_init_state()
180 state->duty_cycle = 0; in pwm_init_state()
181 state->usage_power = false; in pwm_init_state()
185 * pwm_get_relative_duty_cycle() - Get a relative duty cycle value
186 * @state: PWM state to extract the duty cycle from
187 * @scale: target scale of the relative duty cycle
189 * This functions converts the absolute duty cycle stored in @state (expressed
195 * duty = pwm_get_relative_duty_cycle(&state, 100);
200 if (!state->period) in pwm_get_relative_duty_cycle()
203 return DIV_ROUND_CLOSEST_ULL((u64)state->duty_cycle * scale, in pwm_get_relative_duty_cycle()
204 state->period); in pwm_get_relative_duty_cycle()
208 * pwm_set_relative_duty_cycle() - Set a relative duty cycle value
210 * @duty_cycle: relative duty cycle value
213 * This functions converts a relative into an absolute duty cycle (expressed
214 * in nanoseconds), and puts the result in state->duty_cycle.
216 * For example if you want to configure a 50% duty cycle, call:
222 * This functions returns -EINVAL if @duty_cycle and/or @scale are
230 return -EINVAL; in pwm_set_relative_duty_cycle()
232 state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)duty_cycle * in pwm_set_relative_duty_cycle()
233 state->period, in pwm_set_relative_duty_cycle()
240 * struct pwm_capture - PWM capture data
242 * @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
250 * struct pwm_ops - PWM controller operations
269 * struct pwm_chip - abstract a PWM controller
276 * @atomic: can the driver's ->apply() be called in atomic context
298 return chip->dev.parent; in pwmchip_parent()
303 return dev_get_drvdata(&chip->dev); in pwmchip_get_drvdata()
308 dev_set_drvdata(&chip->dev, data); in pwmchip_set_drvdata()
318 * pwm_config() - change a PWM device configuration
321 * @period_ns: duration (in nanoseconds) of one cycle
331 return -EINVAL; in pwm_config()
334 return -EINVAL; in pwm_config()
346 * pwm_enable() - start a PWM output toggling
356 return -EINVAL; in pwm_enable()
367 * pwm_disable() - stop a PWM output toggling
386 * pwm_might_sleep() - is pwm_apply_atomic() supported?
393 return !pwm->chip->atomic; in pwm_might_sleep()
430 return -EOPNOTSUPP; in pwm_apply_might_sleep()
436 return -EOPNOTSUPP; in pwm_apply_atomic()
441 return -EOPNOTSUPP; in pwm_adjust_config()
448 return -EINVAL; in pwm_config()
454 return -EINVAL; in pwm_enable()
470 return ERR_PTR(-EINVAL); in pwmchip_alloc()
482 return -EINVAL; in pwmchip_add()
487 return -EINVAL; in pwmchip_remove()
492 return -EINVAL; in devm_pwmchip_add()
499 return ERR_PTR(-ENODEV); in pwm_get()
511 return ERR_PTR(-ENODEV); in devm_pwm_get()
519 return ERR_PTR(-ENODEV); in devm_fwnode_pwm_get()
549 state.polarity = pwm->args.polarity; in pwm_apply_args()
550 state.period = pwm->args.period; in pwm_apply_args()