gpio: omap_gpio: Name GPIO's by bank and index with DM_GPIO
authorAdam Ford <aford173@gmail.com>
Tue, 12 Jun 2018 01:05:38 +0000 (20:05 -0500)
committerTom Rini <trini@konsulko.com>
Mon, 18 Jun 2018 18:43:14 +0000 (14:43 -0400)
There are multiple GPIO banks with up to 32 pins / bank. When
using 'gpio status -a' to read the pins, this patch displays
both GPIO<bank>_<index> similar to how the device trees
display in addition to displaying  gpio_#

Signed-off-by: Adam Ford <aford173@gmail.com>
drivers/gpio/omap_gpio.c

index d128f942a0681da211648e2cb55caa9f3ef16320..79a975ce71b7ef5de446d61ef0cec79daa247e9c 100644 (file)
@@ -288,11 +288,17 @@ static int omap_gpio_probe(struct udevice *dev)
        struct gpio_bank *bank = dev_get_priv(dev);
        struct omap_gpio_platdata *plat = dev_get_platdata(dev);
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
+       int banknum;
+       char name[18], *str;
 
-       uc_priv->bank_name = plat->port_name;
+       banknum = plat->bank_index;
+       sprintf(name, "GPIO%d_", banknum + 1);
+       str = strdup(name);
+       if (!str)
+               return -ENOMEM;
+       uc_priv->bank_name = str;
        uc_priv->gpio_count = GPIO_PER_BANK;
        bank->base = (void *)plat->base;
-
        return 0;
 }