From 046ea8b390f9c8986f52e4bd2c7bffabd4749330 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 27 Mar 2015 21:57:54 +0100 Subject: [PATCH] sunxi: usbc: Initialize vusb value on request_resources 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 Acked-by: Ian Campbell --- 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 1c777aac49..6285fa5ecb 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); }