[U-Boot] [PATCH 2/4] sunxi: usbc: Initialize vusb value on request_resources

Hans de Goede hdegoede at redhat.com
Fri Mar 27 22:06:41 CET 2015


On boards which use the pmic to enable/disable vbus on the otg port, the
vbus value is not reset to 0 on reset, as reset only resets the SoC and not
the pmic, so explicitly set vbus to 0 on init (request_resources) by moving
the gpio_direction_output call into request_resources.

For consistency also move the gpio_direction_input call for vbus-detect into
request_resources.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 arch/arm/cpu/armv7/sunxi/usbc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/usbc.c b/arch/arm/cpu/armv7/sunxi/usbc.c
index 1c777aa..6285fa5 100644
--- a/arch/arm/cpu/armv7/sunxi/usbc.c
+++ b/arch/arm/cpu/armv7/sunxi/usbc.c
@@ -195,12 +195,16 @@ 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 != -1) {
 		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 != -1) {
 		ret |= gpio_request(sunxi_usbc->gpio_vbus_det, "usbc_vbus_det");
+		ret |= gpio_direction_input(sunxi_usbc->gpio_vbus_det);
+	}
 
 	return ret;
 }
@@ -268,7 +272,7 @@ void sunxi_usbc_vbus_enable(int index)
 	struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
 
 	if (sunxi_usbc->gpio_vbus != -1)
-		gpio_direction_output(sunxi_usbc->gpio_vbus, 1);
+		gpio_set_value(sunxi_usbc->gpio_vbus, 1);
 }
 
 void sunxi_usbc_vbus_disable(int index)
@@ -276,7 +280,7 @@ void sunxi_usbc_vbus_disable(int index)
 	struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
 
 	if (sunxi_usbc->gpio_vbus != -1)
-		gpio_direction_output(sunxi_usbc->gpio_vbus, 0);
+		gpio_set_value(sunxi_usbc->gpio_vbus, 0);
 }
 
 int sunxi_usbc_vbus_detect(int index)
@@ -289,9 +293,5 @@ int sunxi_usbc_vbus_detect(int index)
 		return -1;
 	}
 
-	err = gpio_direction_input(sunxi_usbc->gpio_vbus_det);
-	if (err)
-		return err;
-
 	return gpio_get_value(sunxi_usbc->gpio_vbus_det);
 }
-- 
2.3.4



More information about the U-Boot mailing list