sunxi: axp: Change axp_gpio_foo prototypes to match gpio uclass ops
[oweals/u-boot.git] / drivers / gpio / sunxi_gpio.c
index cf5c62463ea12518751a38ffbc11712f3b421b18..0774b709343fccfd7fedaae5fb71a4482f77178b 100644 (file)
@@ -81,7 +81,7 @@ int gpio_direction_input(unsigned gpio)
 {
 #ifdef AXP_GPIO
        if (gpio >= SUNXI_GPIO_AXP0_START)
-               return axp_gpio_direction_input(gpio - SUNXI_GPIO_AXP0_START);
+               return axp_gpio_direction_input(NULL, gpio - SUNXI_GPIO_AXP0_START);
 #endif
        sunxi_gpio_set_cfgpin(gpio, SUNXI_GPIO_INPUT);
 
@@ -92,7 +92,7 @@ int gpio_direction_output(unsigned gpio, int value)
 {
 #ifdef AXP_GPIO
        if (gpio >= SUNXI_GPIO_AXP0_START)
-               return axp_gpio_direction_output(gpio - SUNXI_GPIO_AXP0_START,
+               return axp_gpio_direction_output(NULL, gpio - SUNXI_GPIO_AXP0_START,
                                                 value);
 #endif
        sunxi_gpio_set_cfgpin(gpio, SUNXI_GPIO_OUTPUT);
@@ -104,7 +104,7 @@ int gpio_get_value(unsigned gpio)
 {
 #ifdef AXP_GPIO
        if (gpio >= SUNXI_GPIO_AXP0_START)
-               return axp_gpio_get_value(gpio - SUNXI_GPIO_AXP0_START);
+               return axp_gpio_get_value(NULL, gpio - SUNXI_GPIO_AXP0_START);
 #endif
        return sunxi_gpio_input(gpio);
 }
@@ -113,25 +113,11 @@ int gpio_set_value(unsigned gpio, int value)
 {
 #ifdef AXP_GPIO
        if (gpio >= SUNXI_GPIO_AXP0_START)
-               return axp_gpio_set_value(gpio - SUNXI_GPIO_AXP0_START, value);
+               return axp_gpio_set_value(NULL, gpio - SUNXI_GPIO_AXP0_START, value);
 #endif
        return sunxi_gpio_output(gpio, value);
 }
 
-int sunxi_name_to_gpio_bank(const char *name)
-{
-       int group = 0;
-
-       if (*name == 'P' || *name == 'p')
-               name++;
-       if (*name >= 'A') {
-               group = *name - (*name > 'a' ? 'a' : 'A');
-               return group;
-       }
-
-       return -1;
-}
-
 int sunxi_name_to_gpio(const char *name)
 {
        int group = 0;
@@ -171,7 +157,32 @@ int sunxi_name_to_gpio(const char *name)
 }
 #endif
 
+int sunxi_name_to_gpio_bank(const char *name)
+{
+       int group = 0;
+
+       if (*name == 'P' || *name == 'p')
+               name++;
+       if (*name >= 'A') {
+               group = *name - (*name > 'a' ? 'a' : 'A');
+               return group;
+       }
+
+       return -1;
+}
+
 #ifdef CONFIG_DM_GPIO
+/* TODO(sjg@chromium.org): Remove this function and use device tree */
+int sunxi_name_to_gpio(const char *name)
+{
+       unsigned int gpio;
+       int ret;
+
+       ret = gpio_lookup_name(name, NULL, NULL, &gpio);
+
+       return ret ? ret : gpio;
+}
+
 static int sunxi_gpio_direction_input(struct udevice *dev, unsigned offset)
 {
        struct sunxi_gpio_platdata *plat = dev_get_platdata(dev);
@@ -249,10 +260,11 @@ static char *gpio_bank_name(int bank)
 {
        char *name;
 
-       name = malloc(2);
+       name = malloc(3);
        if (name) {
-               name[0] = 'A' + bank;
-               name[1] = '\0';
+               name[0] = 'P';
+               name[1] = 'A' + bank;
+               name[2] = '\0';
        }
 
        return name;
@@ -310,7 +322,14 @@ static int gpio_sunxi_bind(struct udevice *parent)
 }
 
 static const struct udevice_id sunxi_gpio_ids[] = {
+       { .compatible = "allwinner,sun4i-a10-pinctrl" },
+       { .compatible = "allwinner,sun5i-a10s-pinctrl" },
+       { .compatible = "allwinner,sun5i-a13-pinctrl" },
+       { .compatible = "allwinner,sun6i-a31-pinctrl" },
+       { .compatible = "allwinner,sun6i-a31s-pinctrl" },
        { .compatible = "allwinner,sun7i-a20-pinctrl" },
+       { .compatible = "allwinner,sun8i-a23-pinctrl" },
+       { .compatible = "allwinner,sun9i-a80-pinctrl" },
        { }
 };