diff options
author | Simon Glass <sjg@chromium.org> | 2015-01-05 20:05:31 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-01-29 17:09:51 -0700 |
commit | a02af4aeece40e93bc7d79cd5dc912409efb7020 (patch) | |
tree | 799cf6f844e86be0164e4cc1649b62d1c9911eb5 /drivers/demo/demo-uclass.c | |
parent | 5d1c17e9a5803af9c65966e469437735ac29659e (diff) |
dm: demo: Add a simple GPIO demonstration
Add a new 'demo light' command which uses GPIOs to control imaginary lights.
Each light is assigned a bit number in the overall value. This provides an
example driver for using the new GPIO API.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/demo/demo-uclass.c')
-rw-r--r-- | drivers/demo/demo-uclass.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/demo/demo-uclass.c b/drivers/demo/demo-uclass.c index f6510d602c..725f06898f 100644 --- a/drivers/demo/demo-uclass.c +++ b/drivers/demo/demo-uclass.c @@ -43,6 +43,26 @@ int demo_status(struct udevice *dev, int *status) return ops->status(dev, status); } +int demo_get_light(struct udevice *dev) +{ + const struct demo_ops *ops = device_get_ops(dev); + + if (!ops->get_light) + return -ENOSYS; + + return ops->get_light(dev); +} + +int demo_set_light(struct udevice *dev, int light) +{ + const struct demo_ops *ops = device_get_ops(dev); + + if (!ops->set_light) + return -ENOSYS; + + return ops->set_light(dev, light); +} + int demo_parse_dt(struct udevice *dev) { struct dm_demo_pdata *pdata = dev_get_platdata(dev); |