Lines Matching full:pwm

12  * enum pwm_polarity - polarity of a PWM signal
26 * struct pwm_args - board-dependent PWM arguments
30 * This structure describes board-dependent arguments attached to a PWM
31 * device. These arguments are usually retrieved from the PWM lookup table or
34 * Do not confuse this with the PWM state: PWM arguments represent the initial
35 * configuration that users want to use on this PWM device rather than the
36 * current PWM hardware state.
49 * struct pwm_state - state of a PWM channel
50 * @period: PWM period (in nanoseconds)
51 * @duty_cycle: PWM duty cycle (in nanoseconds)
52 * @polarity: PWM polarity
53 * @enabled: PWM enabled status
54 * @usage_power: If set, the PWM driver is only required to maintain the power
68 * struct pwm_device - PWM channel object
69 * @label: name of the PWM device
70 * @flags: flags associated with the PWM device
71 * @hwpwm: per-chip relative index of the PWM device
72 * @pwm: global index of the PWM device
73 * @chip: PWM chip providing this PWM device
74 * @chip_data: chip-private data associated with the PWM device
75 * @args: PWM arguments
83 unsigned int pwm; member
93 * pwm_get_state() - retrieve the current PWM state
94 * @pwm: PWM device
95 * @state: state to fill with the current PWM state
97 * The returned PWM state represents the state that was applied by a previous call to
102 static inline void pwm_get_state(const struct pwm_device *pwm, in pwm_get_state() argument
105 *state = pwm->state; in pwm_get_state()
108 static inline bool pwm_is_enabled(const struct pwm_device *pwm) in pwm_is_enabled() argument
112 pwm_get_state(pwm, &state); in pwm_is_enabled()
117 static inline void pwm_set_period(struct pwm_device *pwm, u64 period) in pwm_set_period() argument
119 if (pwm) in pwm_set_period()
120 pwm->state.period = period; in pwm_set_period()
123 static inline u64 pwm_get_period(const struct pwm_device *pwm) in pwm_get_period() argument
127 pwm_get_state(pwm, &state); in pwm_get_period()
132 static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty) in pwm_set_duty_cycle() argument
134 if (pwm) in pwm_set_duty_cycle()
135 pwm->state.duty_cycle = duty; in pwm_set_duty_cycle()
138 static inline u64 pwm_get_duty_cycle(const struct pwm_device *pwm) in pwm_get_duty_cycle() argument
142 pwm_get_state(pwm, &state); in pwm_get_duty_cycle()
147 static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm) in pwm_get_polarity() argument
151 pwm_get_state(pwm, &state); in pwm_get_polarity()
156 static inline void pwm_get_args(const struct pwm_device *pwm, in pwm_get_args() argument
159 *args = pwm->args; in pwm_get_args()
164 * @pwm: PWM device
165 * @state: state to fill with the prepared PWM state
168 * to the PWM device with pwm_apply_state(). This is a convenient function
169 * that first retrieves the current PWM state and the replaces the period
170 * and polarity fields with the reference values defined in pwm->args.
179 static inline void pwm_init_state(const struct pwm_device *pwm, in pwm_init_state() argument
185 pwm_get_state(pwm, state); in pwm_init_state()
188 pwm_get_args(pwm, &args); in pwm_init_state()
198 * @state: PWM state to extract the duty cycle from
206 * pwm_get_state(pwm, &state);
221 * @state: PWM state to fill
230 * pwm_init_state(pwm, &state);
232 * pwm_apply_state(pwm, &state);
252 * struct pwm_capture - PWM capture data
253 * @period: period of the PWM signal (in nanoseconds)
254 * @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
262 * struct pwm_ops - PWM controller operations
263 * @request: optional hook for requesting a PWM
264 * @free: optional hook for freeing a PWM
265 * @capture: capture and report PWM signal
266 * @apply: atomically apply a new PWM config
267 * @get_state: get the current PWM state. This function is only
268 * called once per PWM device when the PWM chip is
273 int (*request)(struct pwm_chip *chip, struct pwm_device *pwm);
274 void (*free)(struct pwm_chip *chip, struct pwm_device *pwm);
275 int (*capture)(struct pwm_chip *chip, struct pwm_device *pwm,
277 int (*apply)(struct pwm_chip *chip, struct pwm_device *pwm,
279 void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm,
285 * struct pwm_chip - abstract a PWM controller
287 * @ops: callbacks for this PWM controller
288 * @base: number of first PWM controlled by this chip
290 * @of_xlate: request a PWM device given a device tree PWM specifier
291 * @of_pwm_n_cells: number of cells expected in the device tree PWM specifier
293 * @pwms: array of PWM devices allocated by the framework
305 /* only used internally by the PWM framework */
311 /* PWM user APIs */
313 void pwm_free(struct pwm_device *pwm);
314 int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state);
315 int pwm_adjust_config(struct pwm_device *pwm);
318 * pwm_config() - change a PWM device configuration
319 * @pwm: PWM device
325 static inline int pwm_config(struct pwm_device *pwm, int duty_ns, in pwm_config() argument
330 if (!pwm) in pwm_config()
336 pwm_get_state(pwm, &state); in pwm_config()
342 return pwm_apply_state(pwm, &state); in pwm_config()
346 * pwm_enable() - start a PWM output toggling
347 * @pwm: PWM device
351 static inline int pwm_enable(struct pwm_device *pwm) in pwm_enable() argument
355 if (!pwm) in pwm_enable()
358 pwm_get_state(pwm, &state); in pwm_enable()
363 return pwm_apply_state(pwm, &state); in pwm_enable()
367 * pwm_disable() - stop a PWM output toggling
368 * @pwm: PWM device
370 static inline void pwm_disable(struct pwm_device *pwm) in pwm_disable() argument
374 if (!pwm) in pwm_disable()
377 pwm_get_state(pwm, &state); in pwm_disable()
382 pwm_apply_state(pwm, &state); in pwm_disable()
385 /* PWM provider APIs */
386 int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
388 int pwm_set_chip_data(struct pwm_device *pwm, void *data);
389 void *pwm_get_chip_data(struct pwm_device *pwm);
406 void pwm_put(struct pwm_device *pwm);
419 static inline void pwm_free(struct pwm_device *pwm) in pwm_free() argument
424 static inline int pwm_apply_state(struct pwm_device *pwm, in pwm_apply_state() argument
431 static inline int pwm_adjust_config(struct pwm_device *pwm) in pwm_adjust_config() argument
436 static inline int pwm_config(struct pwm_device *pwm, int duty_ns, in pwm_config() argument
443 static inline int pwm_capture(struct pwm_device *pwm, in pwm_capture() argument
450 static inline int pwm_enable(struct pwm_device *pwm) in pwm_enable() argument
456 static inline void pwm_disable(struct pwm_device *pwm) in pwm_disable() argument
461 static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data) in pwm_set_chip_data() argument
466 static inline void *pwm_get_chip_data(struct pwm_device *pwm) in pwm_get_chip_data() argument
496 static inline void pwm_put(struct pwm_device *pwm) in pwm_put() argument
517 static inline void pwm_apply_args(struct pwm_device *pwm) in pwm_apply_args() argument
522 * PWM users calling pwm_apply_args() expect to have a fresh config in pwm_apply_args()
524 * The problem is, polarity can only be changed when the PWM is in pwm_apply_args()
527 * PWM drivers supporting hardware readout may declare the PWM device in pwm_apply_args()
529 * existing behavior, where all PWM devices are declared as disabled in pwm_apply_args()
534 * the PWM device and set the reference period and polarity config. in pwm_apply_args()
536 * Note that PWM users requiring a smooth handover between the in pwm_apply_args()
538 * PWM devices) will have to switch to the atomic API and avoid calling in pwm_apply_args()
543 state.polarity = pwm->args.polarity; in pwm_apply_args()
544 state.period = pwm->args.period; in pwm_apply_args()
547 pwm_apply_state(pwm, &state); in pwm_apply_args()