aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpio
diff options
context:
space:
mode:
authorSimon Glass2015-03-25 12:21:58 -0600
committerSimon Glass2015-04-18 11:11:19 -0600
commit56a71f891b78351e949d98bdfc14d89fd0782640 (patch)
tree5454b85fcf05bcc3085859d81ec479df68885d24 /drivers/gpio
parentc5785673bc6f4b8f2a4974979710a2c5c15eb063 (diff)
dm: gpio: Add an implementation for gpio_get_number()
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>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-uclass.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index ca94bbb9046..381868bfb15 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -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);