From 8038f6d2881d58f5322109a2f5ec2de5aaa6fc30 Mon Sep 17 00:00:00 2001 From: Sam Protsenko Date: Tue, 16 Feb 2016 19:59:19 +0200 Subject: usb: gadget: composite: Correct recovery path for register In case when usb_composite_register() failed once (for whatever reason), it will fail further even if all conditions are correct. Example: => fastboot 2 Invalid Controller Index couldn't find an available UDC g_dnl_register: failed!, error: -19 exit not allowed from main input shell. => fastboot 0 g_dnl_register: failed!, error: -22 exit not allowed from main input shell. Despite that 0 is correct index for USB controller, "fastboot 0" command will fail, because "composite" structure wasn't cleared properly on previous fail (on "fastboot 2" command). This patch fixes that erroneous behavior, allowing us to use composite even after previous failure. Signed-off-by: Sam Protsenko --- drivers/usb/gadget/composite.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 60f9272ae6..d0ee7847b9 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1077,6 +1077,8 @@ static struct usb_gadget_driver composite_driver = { */ int usb_composite_register(struct usb_composite_driver *driver) { + int res; + if (!driver || !driver->dev || !driver->bind || composite) return -EINVAL; @@ -1084,7 +1086,11 @@ int usb_composite_register(struct usb_composite_driver *driver) driver->name = "composite"; composite = driver; - return usb_gadget_register_driver(&composite_driver); + res = usb_gadget_register_driver(&composite_driver); + if (res != 0) + composite = NULL; + + return res; } /** -- cgit v1.2.1 From b5ab663a6956e47180706b897bc9567335257d58 Mon Sep 17 00:00:00 2001 From: Dinh Nguyen Date: Fri, 4 Mar 2016 18:57:04 -0600 Subject: usb: dwc2: disable erroneous overcurrent condition For the case where an external VBUS is used, we should enable the external VBUS comparator in the driver. This would prevent an unnecessary overcurrent error which would then disable the host port. The overcurrent condition was happening on the SoCFPGA Cyclone5 devkit, thus USB was not working on the devkit. This patch fixes that problem. Signed-off-by: Dinh Nguyen --- drivers/usb/host/dwc2.c | 4 +++- drivers/usb/host/dwc2.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index c6727c381c..b2f4bc685a 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -263,7 +263,9 @@ static void dwc_otg_core_init(struct dwc2_core_regs *regs) /* Program the ULPI External VBUS bit if needed */ #ifdef CONFIG_DWC2_PHY_ULPI_EXT_VBUS - usbcfg |= DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV; + usbcfg |= (DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV | + DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR | + DWC2_GUSBCFG_INDICATOR_PASSTHROUGH); #else usbcfg &= ~DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV; #endif diff --git a/drivers/usb/host/dwc2.h b/drivers/usb/host/dwc2.h index 594757b609..4482dc621d 100644 --- a/drivers/usb/host/dwc2.h +++ b/drivers/usb/host/dwc2.h @@ -152,6 +152,8 @@ struct dwc2_core_regs { #define DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR_OFFSET 21 #define DWC2_GUSBCFG_TERM_SEL_DL_PULSE (1 << 22) #define DWC2_GUSBCFG_TERM_SEL_DL_PULSE_OFFSET 22 +#define DWC2_GUSBCFG_INDICATOR_PASSTHROUGH (1 << 24) +#define DWC2_GUSBCFG_INDICATOR_PASSTHROUGH_OFFSET 24 #define DWC2_GUSBCFG_IC_USB_CAP (1 << 26) #define DWC2_GUSBCFG_IC_USB_CAP_OFFSET 26 #define DWC2_GUSBCFG_IC_TRAFFIC_PULL_REMOVE (1 << 27) -- cgit v1.2.1