]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: gpio: Add an implementation for gpio_get_number()
authorSimon Glass <sjg@chromium.org>
Wed, 25 Mar 2015 18:21:58 +0000 (12:21 -0600)
committerSimon Glass <sjg@chromium.org>
Sat, 18 Apr 2015 17:11:19 +0000 (11:11 -0600)
This has a prototype but no implementation. It returns the global GPIO number
given a gpio_desc. It is useful for debugging in some cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
drivers/gpio/gpio-uclass.c

index ca94bbb904649e1372f7d2fbfc278f9d1aae4aea..381868bfb154648c6d56f0af899d293eff68eef2 100644 (file)
@@ -685,6 +685,18 @@ static int gpio_renumber(struct udevice *removed_dev)
        return 0;
 }
 
+int gpio_get_number(struct gpio_desc *desc)
+{
+       struct udevice *dev = desc->dev;
+       struct gpio_dev_priv *uc_priv;
+
+       if (!dev)
+               return -1;
+       uc_priv = dev->uclass_priv;
+
+       return uc_priv->gpio_base + desc->offset;
+}
+
 static int gpio_post_probe(struct udevice *dev)
 {
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);