]> git.sur5r.net Git - u-boot/blobdiff - drivers/gpio/mxs_gpio.c
Merge branch 'master' of git://git.denx.de/u-boot-socfpga
[u-boot] / drivers / gpio / mxs_gpio.c
index d9a7a3aaf663e971b4b28b96801e4f402a6ced51..c2c8a25886ab18233d2416cbe5d0c32e1bbe9fc4 100644 (file)
@@ -1,15 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Freescale i.MX28 GPIO control code
  *
  * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
  * on behalf of DENX Software Engineering GmbH
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
-#include <netdev.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/arch/iomux.h>
 #include <asm/arch/imx-regs.h>
@@ -95,10 +93,10 @@ int gpio_direction_output(unsigned gpio, int value)
        struct mxs_register_32 *reg =
                (struct mxs_register_32 *)(MXS_PINCTRL_BASE + offset);
 
-       writel(1 << PAD_PIN(gpio), &reg->reg_set);
-
        gpio_set_value(gpio, value);
 
+       writel(1 << PAD_PIN(gpio), &reg->reg_set);
+
        return 0;
 }
 
@@ -114,3 +112,18 @@ int gpio_free(unsigned gpio)
 {
        return 0;
 }
+
+int name_to_gpio(const char *name)
+{
+       unsigned bank, pin;
+       char *end;
+
+       bank = simple_strtoul(name, &end, 10);
+
+       if (!*end || *end != ':')
+               return bank;
+
+       pin = simple_strtoul(end + 1, NULL, 10);
+
+       return (bank << MXS_PAD_BANK_SHIFT) | (pin << MXS_PAD_PIN_SHIFT);
+}