blob: 6543db1d623d1c0d86eb4ab7a5e841b6d9f893fd [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassb3f07562016-01-21 19:44:54 -07002/*
3 * Copyright (c) 2016 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glassb3f07562016-01-21 19:44:54 -07005 */
6
Patrick Delaunay81313352021-04-27 11:02:19 +02007#define LOG_CATEGORY UCLASS_PWM
8
Simon Glassb3f07562016-01-21 19:44:54 -07009#include <dm.h>
10#include <pwm.h>
11
Kever Yang4c087422017-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 Glassb3f07562016-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};