1
2
3
4
5
6
7#include <common.h>
8#include <dm.h>
9#include <pwm.h>
10
11int pwm_set_invert(struct udevice *dev, uint channel, bool polarity)
12{
13 struct pwm_ops *ops = pwm_get_ops(dev);
14
15 if (!ops->set_invert)
16 return -ENOSYS;
17
18 return ops->set_invert(dev, channel, polarity);
19}
20
21int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
22 uint duty_ns)
23{
24 struct pwm_ops *ops = pwm_get_ops(dev);
25
26 if (!ops->set_config)
27 return -ENOSYS;
28
29 return ops->set_config(dev, channel, period_ns, duty_ns);
30}
31
32int pwm_set_enable(struct udevice *dev, uint channel, bool enable)
33{
34 struct pwm_ops *ops = pwm_get_ops(dev);
35
36 if (!ops->set_enable)
37 return -ENOSYS;
38
39 return ops->set_enable(dev, channel, enable);
40}
41
42UCLASS_DRIVER(pwm) = {
43 .id = UCLASS_PWM,
44 .name = "pwm",
45};
46