driver: timer: Add the Atmel PIT timer driver
[oweals/u-boot.git] / drivers / gpio / mxs_gpio.c
index d9a7a3aaf663e971b4b28b96801e4f402a6ced51..367b852039da52ccd23b9f99162cc53984dcc516 100644 (file)
@@ -8,8 +8,7 @@
  */
 
 #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 +94,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 +113,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);
+}