Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | fc760cb | 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 | fc760cb | 2016-01-21 19:44:54 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Patrick Delaunay | b953ec2 | 2021-04-27 11:02:19 +0200 | [diff] [blame] | 7 | #define LOG_CATEGORY UCLASS_PWM |
| 8 | |
Simon Glass | fc760cb | 2016-01-21 19:44:54 -0700 | [diff] [blame] | 9 | #include <common.h> |
| 10 | #include <dm.h> |
| 11 | #include <pwm.h> |
| 12 | |
Kever Yang | 0b60111 | 2017-04-24 10:27:49 +0800 | [diff] [blame] | 13 | int pwm_set_invert(struct udevice *dev, uint channel, bool polarity) |
| 14 | { |
| 15 | struct pwm_ops *ops = pwm_get_ops(dev); |
| 16 | |
| 17 | if (!ops->set_invert) |
| 18 | return -ENOSYS; |
| 19 | |
| 20 | return ops->set_invert(dev, channel, polarity); |
| 21 | } |
| 22 | |
Simon Glass | fc760cb | 2016-01-21 19:44:54 -0700 | [diff] [blame] | 23 | int pwm_set_config(struct udevice *dev, uint channel, uint period_ns, |
| 24 | uint duty_ns) |
| 25 | { |
| 26 | struct pwm_ops *ops = pwm_get_ops(dev); |
| 27 | |
| 28 | if (!ops->set_config) |
| 29 | return -ENOSYS; |
| 30 | |
| 31 | return ops->set_config(dev, channel, period_ns, duty_ns); |
| 32 | } |
| 33 | |
| 34 | int pwm_set_enable(struct udevice *dev, uint channel, bool enable) |
| 35 | { |
| 36 | struct pwm_ops *ops = pwm_get_ops(dev); |
| 37 | |
| 38 | if (!ops->set_enable) |
| 39 | return -ENOSYS; |
| 40 | |
| 41 | return ops->set_enable(dev, channel, enable); |
| 42 | } |
| 43 | |
| 44 | UCLASS_DRIVER(pwm) = { |
| 45 | .id = UCLASS_PWM, |
| 46 | .name = "pwm", |
| 47 | }; |