Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | b3f0756 | 2016-01-21 19:44:54 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
Simon Glass | b3f0756 | 2016-01-21 19:44:54 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | #include <pwm.h> |
| 10 | |
Kever Yang | 4c08742 | 2017-04-24 10:27:49 +0800 | [diff] [blame] | 11 | int 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 Glass | b3f0756 | 2016-01-21 19:44:54 -0700 | [diff] [blame] | 21 | int 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 | |
| 32 | int 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 | |
| 42 | UCLASS_DRIVER(pwm) = { |
| 43 | .id = UCLASS_PWM, |
| 44 | .name = "pwm", |
| 45 | }; |