Commit | Line | Data |
---|---|---|
83d290c5 | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
3f129280 DL |
2 | /* |
3 | * header file for pwm driver. | |
4 | * | |
fc760cb8 | 5 | * Copyright 2016 Google Inc. |
3f129280 DL |
6 | * Copyright (c) 2011 samsung electronics |
7 | * Donghwa Lee <dh09.lee@samsung.com> | |
3f129280 DL |
8 | */ |
9 | ||
10 | #ifndef _pwm_h_ | |
11 | #define _pwm_h_ | |
12 | ||
401d1c4f SG |
13 | struct udevice; |
14 | ||
fc760cb8 SG |
15 | /* struct pwm_ops: Operations for the PWM uclass */ |
16 | struct pwm_ops { | |
17 | /** | |
18 | * set_config() - Set the PWM configuration | |
19 | * | |
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 | |
25 | */ | |
26 | int (*set_config)(struct udevice *dev, uint channel, uint period_ns, | |
27 | uint duty_ns); | |
28 | ||
29 | /** | |
30 | * set_enable() - Enable or disable the PWM | |
31 | * | |
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 | |
36 | */ | |
37 | int (*set_enable)(struct udevice *dev, uint channel, bool enable); | |
0b60111a KY |
38 | /** |
39 | * set_invert() - Set the PWM invert | |
40 | * | |
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 | |
45 | */ | |
46 | int (*set_invert)(struct udevice *dev, uint channel, bool polarity); | |
fc760cb8 SG |
47 | }; |
48 | ||
49 | #define pwm_get_ops(dev) ((struct pwm_ops *)(dev)->driver->ops) | |
50 | ||
51 | /** | |
52 | * pwm_set_config() - Set the PWM configuration | |
53 | * | |
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 | |
59 | */ | |
60 | int pwm_set_config(struct udevice *dev, uint channel, uint period_ns, | |
61 | uint duty_ns); | |
62 | ||
63 | /** | |
64 | * pwm_set_enable() - Enable or disable the PWM | |
65 | * | |
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 | |
70 | */ | |
71 | int pwm_set_enable(struct udevice *dev, uint channel, bool enable); | |
72 | ||
0b60111a KY |
73 | /** |
74 | * pwm_set_invert() - Set pwm default polarity | |
75 | * | |
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 | |
80 | */ | |
81 | int pwm_set_invert(struct udevice *dev, uint channel, bool polarity); | |
82 | ||
fc760cb8 SG |
83 | /* Legacy interface */ |
84 | #ifndef CONFIG_DM_PWM | |
3f129280 DL |
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); | |
fc760cb8 | 89 | #endif |
3f129280 DL |
90 | |
91 | #endif /* _pwm_h_ */ |