blob: 69051fe1b5663f75b3ff4af71e4e85efc6a615eb [file] [log] [blame]
Simon Glassfc760cb2016-01-21 19:44:54 -07001/*
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
Kever Yang0b601112017-04-24 10:27:49 +080012int pwm_set_invert(struct udevice *dev, uint channel, bool polarity)
13{
14 struct pwm_ops *ops = pwm_get_ops(dev);
15
16 if (!ops->set_invert)
17 return -ENOSYS;
18
19 return ops->set_invert(dev, channel, polarity);
20}
21
Simon Glassfc760cb2016-01-21 19:44:54 -070022int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
23 uint duty_ns)
24{
25 struct pwm_ops *ops = pwm_get_ops(dev);
26
27 if (!ops->set_config)
28 return -ENOSYS;
29
30 return ops->set_config(dev, channel, period_ns, duty_ns);
31}
32
33int pwm_set_enable(struct udevice *dev, uint channel, bool enable)
34{
35 struct pwm_ops *ops = pwm_get_ops(dev);
36
37 if (!ops->set_enable)
38 return -ENOSYS;
39
40 return ops->set_enable(dev, channel, enable);
41}
42
43UCLASS_DRIVER(pwm) = {
44 .id = UCLASS_PWM,
45 .name = "pwm",
46};