Lines Matching full:pwm

15  * enum pwm_polarity - polarity of a PWM signal
29 * struct pwm_args - board-dependent PWM arguments
33 * This structure describes board-dependent arguments attached to a PWM
34 * device. These arguments are usually retrieved from the PWM lookup table or
37 * Do not confuse this with the PWM state: PWM arguments represent the initial
38 * configuration that users want to use on this PWM device rather than the
39 * current PWM hardware state.
52 * struct pwm_state - state of a PWM channel
53 * @period: PWM period (in nanoseconds)
54 * @duty_cycle: PWM duty cycle (in nanoseconds)
55 * @polarity: PWM polarity
56 * @enabled: PWM enabled status
57 * @usage_power: If set, the PWM driver is only required to maintain the power
71 * struct pwm_device - PWM channel object
72 * @label: name of the PWM device
73 * @flags: flags associated with the PWM device
74 * @hwpwm: per-chip relative index of the PWM device
75 * @pwm: global index of the PWM device
76 * @chip: PWM chip providing this PWM device
77 * @chip_data: chip-private data associated with the PWM device
78 * @args: PWM arguments
86 unsigned int pwm; member
96 * pwm_get_state() - retrieve the current PWM state
97 * @pwm: PWM device
98 * @state: state to fill with the current PWM state
100 * The returned PWM state represents the state that was applied by a previous call to
105 static inline void pwm_get_state(const struct pwm_device *pwm, in pwm_get_state() argument
108 *state = pwm->state; in pwm_get_state()
111 static inline bool pwm_is_enabled(const struct pwm_device *pwm) in pwm_is_enabled() argument
115 pwm_get_state(pwm, &state); in pwm_is_enabled()
120 static inline void pwm_set_period(struct pwm_device *pwm, u64 period) in pwm_set_period() argument
122 if (pwm) in pwm_set_period()
123 pwm->state.period = period; in pwm_set_period()
126 static inline u64 pwm_get_period(const struct pwm_device *pwm) in pwm_get_period() argument
130 pwm_get_state(pwm, &state); in pwm_get_period()
135 static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty) in pwm_set_duty_cycle() argument
137 if (pwm) in pwm_set_duty_cycle()
138 pwm->state.duty_cycle = duty; in pwm_set_duty_cycle()
141 static inline u64 pwm_get_duty_cycle(const struct pwm_device *pwm) in pwm_get_duty_cycle() argument
145 pwm_get_state(pwm, &state); in pwm_get_duty_cycle()
150 static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm) in pwm_get_polarity() argument
154 pwm_get_state(pwm, &state); in pwm_get_polarity()
159 static inline void pwm_get_args(const struct pwm_device *pwm, in pwm_get_args() argument
162 *args = pwm->args; in pwm_get_args()
167 * @pwm: PWM device
168 * @state: state to fill with the prepared PWM state
171 * to the PWM device with pwm_apply_state(). This is a convenient function
172 * that first retrieves the current PWM state and the replaces the period
173 * and polarity fields with the reference values defined in pwm->args.
182 static inline void pwm_init_state(const struct pwm_device *pwm, in pwm_init_state() argument
188 pwm_get_state(pwm, state); in pwm_init_state()
191 pwm_get_args(pwm, &args); in pwm_init_state()
201 * @state: PWM state to extract the duty cycle from
209 * pwm_get_state(pwm, &state);
224 * @state: PWM state to fill
233 * pwm_init_state(pwm, &state);
235 * pwm_apply_state(pwm, &state);
255 * struct pwm_ops - PWM controller operations
256 * @request: optional hook for requesting a PWM
257 * @free: optional hook for freeing a PWM
258 * @capture: capture and report PWM signal
259 * @apply: atomically apply a new PWM config
260 * @get_state: get the current PWM state. This function is only
261 * called once per PWM device when the PWM chip is
264 * @config: configure duty cycles and period length for this PWM
265 * @set_polarity: configure the polarity of this PWM
266 * @enable: enable PWM output toggling
267 * @disable: disable PWM output toggling
270 int (*request)(struct pwm_chip *chip, struct pwm_device *pwm);
271 void (*free)(struct pwm_chip *chip, struct pwm_device *pwm);
272 int (*capture)(struct pwm_chip *chip, struct pwm_device *pwm,
274 int (*apply)(struct pwm_chip *chip, struct pwm_device *pwm,
276 void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm,
281 int (*config)(struct pwm_chip *chip, struct pwm_device *pwm,
283 int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm,
285 int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm);
286 void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm);
290 * struct pwm_chip - abstract a PWM controller
292 * @ops: callbacks for this PWM controller
293 * @base: number of first PWM controlled by this chip
295 * @of_xlate: request a PWM device given a device tree PWM specifier
296 * @of_pwm_n_cells: number of cells expected in the device tree PWM specifier
298 * @pwms: array of PWM devices allocated by the framework
310 /* only used internally by the PWM framework */
316 * struct pwm_capture - PWM capture data
317 * @period: period of the PWM signal (in nanoseconds)
318 * @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
326 /* PWM user APIs */
328 void pwm_free(struct pwm_device *pwm);
329 int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state);
330 int pwm_adjust_config(struct pwm_device *pwm);
333 * pwm_config() - change a PWM device configuration
334 * @pwm: PWM device
340 static inline int pwm_config(struct pwm_device *pwm, int duty_ns, in pwm_config() argument
345 if (!pwm) in pwm_config()
351 pwm_get_state(pwm, &state); in pwm_config()
357 return pwm_apply_state(pwm, &state); in pwm_config()
361 * pwm_enable() - start a PWM output toggling
362 * @pwm: PWM device
366 static inline int pwm_enable(struct pwm_device *pwm) in pwm_enable() argument
370 if (!pwm) in pwm_enable()
373 pwm_get_state(pwm, &state); in pwm_enable()
378 return pwm_apply_state(pwm, &state); in pwm_enable()
382 * pwm_disable() - stop a PWM output toggling
383 * @pwm: PWM device
385 static inline void pwm_disable(struct pwm_device *pwm) in pwm_disable() argument
389 if (!pwm) in pwm_disable()
392 pwm_get_state(pwm, &state); in pwm_disable()
397 pwm_apply_state(pwm, &state); in pwm_disable()
400 /* PWM provider APIs */
401 int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
403 int pwm_set_chip_data(struct pwm_device *pwm, void *data);
404 void *pwm_get_chip_data(struct pwm_device *pwm);
421 void pwm_put(struct pwm_device *pwm);
435 static inline void pwm_free(struct pwm_device *pwm) in pwm_free() argument
439 static inline int pwm_apply_state(struct pwm_device *pwm, in pwm_apply_state() argument
445 static inline int pwm_adjust_config(struct pwm_device *pwm) in pwm_adjust_config() argument
450 static inline int pwm_config(struct pwm_device *pwm, int duty_ns, in pwm_config() argument
456 static inline int pwm_capture(struct pwm_device *pwm, in pwm_capture() argument
463 static inline int pwm_enable(struct pwm_device *pwm) in pwm_enable() argument
468 static inline void pwm_disable(struct pwm_device *pwm) in pwm_disable() argument
472 static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data) in pwm_set_chip_data() argument
477 static inline void *pwm_get_chip_data(struct pwm_device *pwm) in pwm_get_chip_data() argument
512 static inline void pwm_put(struct pwm_device *pwm) in pwm_put() argument
537 static inline void pwm_apply_args(struct pwm_device *pwm) in pwm_apply_args() argument
542 * PWM users calling pwm_apply_args() expect to have a fresh config in pwm_apply_args()
544 * The problem is, polarity can only be changed when the PWM is in pwm_apply_args()
547 * PWM drivers supporting hardware readout may declare the PWM device in pwm_apply_args()
549 * existing behavior, where all PWM devices are declared as disabled in pwm_apply_args()
554 * the PWM device and set the reference period and polarity config. in pwm_apply_args()
556 * Note that PWM users requiring a smooth handover between the in pwm_apply_args()
558 * PWM devices) will have to switch to the atomic API and avoid calling in pwm_apply_args()
563 state.polarity = pwm->args.polarity; in pwm_apply_args()
564 state.period = pwm->args.period; in pwm_apply_args()
567 pwm_apply_state(pwm, &state); in pwm_apply_args()