blob: 027181c6465277d1c5d4cec2d1c72937d6f3646d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassfc760cb2016-01-21 19:44:54 -07002/*
3 * Copyright (c) 2016 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glassfc760cb2016-01-21 19:44:54 -07005 */
6
7#include <common.h>
8#include <dm.h>
9#include <pwm.h>
10
Kever Yang0b601112017-04-24 10:27:49 +080011int 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
Simon Glassfc760cb2016-01-21 19:44:54 -070021int 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};