X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fpwm%2Fsandbox_pwm.c;h=4b50b19c618d0318b5b494ef42a84e34afc79cd0;hb=c590e62d3b6f6dd72eae1183614f919e3fd7ffcb;hp=c2ce974ddea4fb03eecce65db7334babebd72d5d;hpb=4f66e09bb9fbc47b73f67c3cc08ee2663e8fcdb1;p=u-boot diff --git a/drivers/pwm/sandbox_pwm.c b/drivers/pwm/sandbox_pwm.c index c2ce974dde..4b50b19c61 100644 --- a/drivers/pwm/sandbox_pwm.c +++ b/drivers/pwm/sandbox_pwm.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2015 Google, Inc * Written by Simon Glass - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -11,8 +10,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - enum { NUM_CHANNELS = 3, }; @@ -21,6 +18,7 @@ struct sandbox_pwm_chan { uint period_ns; uint duty_ns; bool enable; + bool polarity; }; struct sandbox_pwm_priv { @@ -56,9 +54,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[] = {