Implement the above two functions. The format of input parameters is
"x_y", where x is the bank number and y is the pin number in that bank.

Example:
  => gpio i 3_13
  gpio: pin 3_13 (gpio 107) value is 0

Signed-off-by: Marek Vasut <ma...@denx.de>
Cc: Detlev Zundel <d...@denx.de>
Cc: Mike Frysinger <vap...@gentoo.org>
Cc: Stefano Babic <sba...@denx.de>
---
 drivers/gpio/mxs_gpio.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
index 38dbc81..988b105 100644
--- a/drivers/gpio/mxs_gpio.c
+++ b/drivers/gpio/mxs_gpio.c
@@ -130,3 +130,35 @@ int gpio_free(unsigned gpio)
 {
        return 0;
 }
+
+int gpio_from_string(const char *cname)
+{
+       char *name = (char *)cname;
+       char *bank, *pin, *endp;
+       int b, p;
+
+       bank = strtok(name, "_");
+       if (!bank)
+               return -1;
+
+       pin = strtok(NULL, "_");
+       if (!pin)
+               return -1;
+
+       b = simple_strtol(bank, &endp, 10);
+       if (*endp != '\0')
+               return -1;
+
+       p = simple_strtol(pin, &endp, 10);
+       if (*endp != '\0')
+               return -1;
+
+       return MXS_IOMUX_PAD(b, p, 0, 0, 0, 0);
+}
+
+int gpio_to_string(int gpio, char *buf, int buflen)
+{
+       int ret;
+       ret = snprintf(buf, buflen, "%i_%i", PAD_BANK(gpio), PAD_PIN(gpio));
+       return ret < buflen;
+}
-- 
1.7.10

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to