1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * header file for pwm driver.
5 * Copyright 2016 Google Inc.
6 * Copyright (c) 2011 samsung electronics
15 /* struct pwm_ops: Operations for the PWM uclass */
18 * set_config() - Set the PWM configuration
20 * @dev: PWM device to update
21 * @channel: PWM channel to update
22 * @period_ns: PWM period in nanoseconds
23 * @duty_ns: PWM duty period in nanoseconds
24 * @return 0 if OK, -ve on error
26 int (*set_config)(struct udevice *dev, uint channel, uint period_ns,
30 * set_enable() - Enable or disable the PWM
32 * @dev: PWM device to update
33 * @channel: PWM channel to update
34 * @enable: true to enable, false to disable
35 * @return 0 if OK, -ve on error
37 int (*set_enable)(struct udevice *dev, uint channel, bool enable);
39 * set_invert() - Set the PWM invert
41 * @dev: PWM device to update
42 * @channel: PWM channel to update
43 * @polarity: true to invert, false to keep normal polarity
44 * @return 0 if OK, -ve on error
46 int (*set_invert)(struct udevice *dev, uint channel, bool polarity);
49 #define pwm_get_ops(dev) ((struct pwm_ops *)(dev)->driver->ops)
52 * pwm_set_config() - Set the PWM configuration
54 * @dev: PWM device to update
55 * @channel: PWM channel to update
56 * @period_ns: PWM period in nanoseconds
57 * @duty_ns: PWM duty period in nanoseconds
58 * @return 0 if OK, -ve on error
60 int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
64 * pwm_set_enable() - Enable or disable the PWM
66 * @dev: PWM device to update
67 * @channel: PWM channel to update
68 * @enable: true to enable, false to disable
69 * @return 0 if OK, -ve on error
71 int pwm_set_enable(struct udevice *dev, uint channel, bool enable);
74 * pwm_set_invert() - Set pwm default polarity
76 * @dev: PWM device to update
77 * @channel: PWM channel to update
78 * @polarity: true to invert, false to keep normal polarity
79 * @return 0 if OK, -ve on error
81 int pwm_set_invert(struct udevice *dev, uint channel, bool polarity);
83 /* Legacy interface */
85 int pwm_init (int pwm_id, int div, int invert);
86 int pwm_config (int pwm_id, int duty_ns, int period_ns);
87 int pwm_enable (int pwm_id);
88 void pwm_disable (int pwm_id);