aboutsummaryrefslogtreecommitdiff
path: root/drivers/pwm
diff options
context:
space:
mode:
authorKever Yang <kever.yang@rock-chips.com>2017-04-24 10:27:52 +0800
committerSimon Glass <sjg@chromium.org>2017-05-10 13:37:21 -0600
commit5540e25aebee68806012d7f23b19805dbbab7c18 (patch)
treea8aebb523b0623ad930a1bbdc58b9be635db404d /drivers/pwm
parent1df7ee573ee68a951fc7b31fd34daec4d1dba4d1 (diff)
downloadu-boot-5540e25aebee68806012d7f23b19805dbbab7c18.zip
u-boot-5540e25aebee68806012d7f23b19805dbbab7c18.tar.gz
u-boot-5540e25aebee68806012d7f23b19805dbbab7c18.tar.bz2
dm: sandbox: pwm: add test for pwm_set_invert()
Add test case for new interface set_invert(). Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org> Fix typo in subject and build error in sandbox_pwm_set_invert(): Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/sandbox_pwm.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/pwm/sandbox_pwm.c b/drivers/pwm/sandbox_pwm.c
index c2ce974..fcb1084 100644
--- a/drivers/pwm/sandbox_pwm.c
+++ b/drivers/pwm/sandbox_pwm.c
@@ -21,6 +21,7 @@ struct sandbox_pwm_chan {
uint period_ns;
uint duty_ns;
bool enable;
+ bool polarity;
};
struct sandbox_pwm_priv {
@@ -56,9 +57,24 @@ static int sandbox_pwm_set_enable(struct udevice *dev, uint channel,
return 0;
}
+static int sandbox_pwm_set_invert(struct udevice *dev, uint channel,
+ bool polarity)
+{
+ struct sandbox_pwm_priv *priv = dev_get_priv(dev);
+ struct sandbox_pwm_chan *chan;
+
+ if (channel >= NUM_CHANNELS)
+ return -ENOSPC;
+ chan = &priv->chan[channel];
+ chan->polarity = polarity;
+
+ return 0;
+}
+
static const struct pwm_ops sandbox_pwm_ops = {
.set_config = sandbox_pwm_set_config,
.set_enable = sandbox_pwm_set_enable,
+ .set_invert = sandbox_pwm_set_invert,
};
static const struct udevice_id sandbox_pwm_ids[] = {