]> git.sur5r.net Git - u-boot/blob - drivers/pwm/pwm-uclass.c
dm: pwm: Add a PWM uclass
[u-boot] / drivers / pwm / pwm-uclass.c
1 /*
2  * Copyright (c) 2016 Google, Inc
3  * Written by Simon Glass <sjg@chromium.org>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <dm.h>
10 #include <pwm.h>
11
12 int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
13                    uint duty_ns)
14 {
15         struct pwm_ops *ops = pwm_get_ops(dev);
16
17         if (!ops->set_config)
18                 return -ENOSYS;
19
20         return ops->set_config(dev, channel, period_ns, duty_ns);
21 }
22
23 int pwm_set_enable(struct udevice *dev, uint channel, bool enable)
24 {
25         struct pwm_ops *ops = pwm_get_ops(dev);
26
27         if (!ops->set_enable)
28                 return -ENOSYS;
29
30         return ops->set_enable(dev, channel, enable);
31 }
32
33 UCLASS_DRIVER(pwm) = {
34         .id             = UCLASS_PWM,
35         .name           = "pwm",
36 };