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 | |
Patrick Delaunay | 8131335 | 2021-04-27 11:02:19 +0200 | [diff] [blame] | 7 | #define LOG_CATEGORY UCLASS_PWM |
| 8 | |
Simon Glass | b3f0756 | 2016-01-21 19:44:54 -0700 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <pwm.h> |
| 11 | |
Kever Yang | 4c08742 | 2017-04-24 10:27:49 +0800 | [diff] [blame] | 12 | int 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 Glass | b3f0756 | 2016-01-21 19:44:54 -0700 | [diff] [blame] | 22 | int 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 | |
| 33 | int 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 | |
| 43 | UCLASS_DRIVER(pwm) = { |
| 44 | .id = UCLASS_PWM, |
| 45 | .name = "pwm", |
| 46 | }; |