summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2015-02-16 22:13:43 +0100
committerHans de Goede <hdegoede@redhat.com>2015-02-21 16:53:33 +0100
commit52defe8f65700ad625c3ca63f723564210b2dc82 (patch)
treefc1cab3185c9751d748bb4615d9a1898b0df8b0c /drivers
parent636317c9eea8df0657fe702e1eddeedff605b0c7 (diff)
downloadu-boot-imx-52defe8f65700ad625c3ca63f723564210b2dc82.zip
u-boot-imx-52defe8f65700ad625c3ca63f723564210b2dc82.tar.gz
u-boot-imx-52defe8f65700ad625c3ca63f723564210b2dc82.tar.bz2
sunxi: musb: Check Vbus-det before enabling otg port power
Sending out 5V when there is a charger connected to the otg port is not a good idea, so check for this and error out. Note this commit currently breaks otg support on the q8h tablets, as we need to do some magic with the pmic there to get vbus info, this is deliberate (better safe then sorry), fixing this is on my TODO list. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Ian Campbell <ijc@hellion.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/musb-new/sunxi.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 4646a3d..fe45db1 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -22,7 +22,9 @@
*/
#include <common.h>
#include <asm/arch/cpu.h>
+#include <asm/arch/gpio.h>
#include <asm/arch/usbc.h>
+#include <asm-generic/gpio.h>
#include "linux-compat.h"
#include "musb_core.h"
@@ -224,6 +226,33 @@ static int sunxi_musb_init(struct musb *musb)
pr_debug("%s():\n", __func__);
+ if (is_host_enabled(musb)) {
+ int vbus_det = sunxi_name_to_gpio(CONFIG_USB0_VBUS_DET);
+ if (vbus_det == -1) {
+ eprintf("Error invalid Vusb-det pin\n");
+ return -EINVAL;
+ }
+
+ err = gpio_request(vbus_det, "vbus0_det");
+ if (err)
+ return err;
+
+ err = gpio_direction_input(vbus_det);
+ if (err) {
+ gpio_free(vbus_det);
+ return err;
+ }
+
+ err = gpio_get_value(vbus_det);
+ if (err) {
+ eprintf("Error: A charger is plugged into the OTG\n");
+ gpio_free(vbus_det);
+ return -EIO;
+ }
+
+ gpio_free(vbus_det);
+ }
+
err = sunxi_usbc_request_resources(0);
if (err)
return err;