]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
dm: sandbox: pwm: add test for pwm_set_invert()
authorKever Yang <kever.yang@rock-chips.com>
Mon, 24 Apr 2017 02:27:52 +0000 (10:27 +0800)
committerSimon Glass <sjg@chromium.org>
Wed, 10 May 2017 19:37:21 +0000 (13:37 -0600)
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>
drivers/pwm/sandbox_pwm.c
test/dm/pwm.c

index c2ce974ddea4fb03eecce65db7334babebd72d5d..fcb10845515650ba51f439325393d2188e87faa2 100644 (file)
@@ -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[] = {
index 7bdc75af099af5966bdb34f43270e9b962d816b1..f1e38c77dd680d507fcc07639fe2a7b61a719b63 100644 (file)
@@ -23,6 +23,7 @@ static int dm_test_pwm_base(struct unit_test_state *uts)
        ut_assertok(pwm_set_enable(dev, 1, true));
        ut_assertok(pwm_set_enable(dev, 2, true));
        ut_asserteq(-ENOSPC, pwm_set_enable(dev, 3, true));
+       ut_assertok(pwm_set_invert(dev, 0, true));
 
        ut_assertok(uclass_get_device(UCLASS_PWM, 1, &dev));
        ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PWM, 2, &dev));