summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2015-04-22 17:39:59 +0200
committerHans de Goede <hdegoede@redhat.com>2015-05-04 16:51:52 +0200
commita725426929515b9fdef1cb725159a29cf67361a7 (patch)
tree184071bbd1dd67ca24eb707bbbabeb37801186af /arch
parent90641f82f1700553640103bf58017c303be4e604 (diff)
downloadu-boot-imx-a725426929515b9fdef1cb725159a29cf67361a7.zip
u-boot-imx-a725426929515b9fdef1cb725159a29cf67361a7.tar.gz
u-boot-imx-a725426929515b9fdef1cb725159a29cf67361a7.tar.bz2
sunxi: usbc: Fix vbus gpio handling to work with the driver-model
The driver-model gpio functions may return another value then -1 as error, make the sunxi usbc properly handle this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Ian Campbell <ijc@hellion.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/cpu/armv7/sunxi/usbc.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/arch/arm/cpu/armv7/sunxi/usbc.c b/arch/arm/cpu/armv7/sunxi/usbc.c
index 7b883fb..21032aa 100644
--- a/arch/arm/cpu/armv7/sunxi/usbc.c
+++ b/arch/arm/cpu/armv7/sunxi/usbc.c
@@ -17,6 +17,7 @@
#include <asm/gpio.h>
#include <asm/io.h>
#include <common.h>
+#include <errno.h>
#ifdef CONFIG_AXP152_POWER
#include <axp152.h>
#endif
@@ -90,7 +91,7 @@ static int get_vbus_gpio(int index)
case 1: return sunxi_name_to_gpio(CONFIG_USB1_VBUS_PIN);
case 2: return sunxi_name_to_gpio(CONFIG_USB2_VBUS_PIN);
}
- return -1;
+ return -EINVAL;
}
static int get_vbus_detect_gpio(int index)
@@ -98,7 +99,7 @@ static int get_vbus_detect_gpio(int index)
switch (index) {
case 0: return sunxi_name_to_gpio(CONFIG_USB0_VBUS_DET);
}
- return -1;
+ return -EINVAL;
}
static void usb_phy_write(struct sunxi_usbc_hcd *sunxi_usbc, int addr,
@@ -188,13 +189,13 @@ int sunxi_usbc_request_resources(int index)
int ret = 0;
sunxi_usbc->gpio_vbus = get_vbus_gpio(index);
- if (sunxi_usbc->gpio_vbus != -1) {
+ if (sunxi_usbc->gpio_vbus >= 0) {
ret |= gpio_request(sunxi_usbc->gpio_vbus, "usbc_vbus");
ret |= gpio_direction_output(sunxi_usbc->gpio_vbus, 0);
}
sunxi_usbc->gpio_vbus_det = get_vbus_detect_gpio(index);
- if (sunxi_usbc->gpio_vbus_det != -1) {
+ if (sunxi_usbc->gpio_vbus_det >= 0) {
ret |= gpio_request(sunxi_usbc->gpio_vbus_det, "usbc_vbus_det");
ret |= gpio_direction_input(sunxi_usbc->gpio_vbus_det);
}
@@ -207,10 +208,10 @@ int sunxi_usbc_free_resources(int index)
struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
int ret = 0;
- if (sunxi_usbc->gpio_vbus != -1)
+ if (sunxi_usbc->gpio_vbus >= 0)
ret |= gpio_free(sunxi_usbc->gpio_vbus);
- if (sunxi_usbc->gpio_vbus_det != -1)
+ if (sunxi_usbc->gpio_vbus_det >= 0)
ret |= gpio_free(sunxi_usbc->gpio_vbus_det);
return ret;
@@ -264,7 +265,7 @@ void sunxi_usbc_vbus_enable(int index)
{
struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
- if (sunxi_usbc->gpio_vbus != -1)
+ if (sunxi_usbc->gpio_vbus >= 0)
gpio_set_value(sunxi_usbc->gpio_vbus, 1);
}
@@ -272,7 +273,7 @@ void sunxi_usbc_vbus_disable(int index)
{
struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
- if (sunxi_usbc->gpio_vbus != -1)
+ if (sunxi_usbc->gpio_vbus >= 0)
gpio_set_value(sunxi_usbc->gpio_vbus, 0);
}
@@ -281,9 +282,9 @@ int sunxi_usbc_vbus_detect(int index)
struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
int err, retries = 3;
- if (sunxi_usbc->gpio_vbus_det == -1) {
+ if (sunxi_usbc->gpio_vbus_det < 0) {
eprintf("Error: invalid vbus detection pin\n");
- return -1;
+ return sunxi_usbc->gpio_vbus_det;
}
err = gpio_get_value(sunxi_usbc->gpio_vbus_det);