mode = USB_DR_MODE_HOST;
else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
mode = USB_DR_MODE_PERIPHERAL;
+ else if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE))
+ mode = USB_DR_MODE_OTG;
}
if (mode != dwc->dr_mode) {
{
switch (dwc->current_dr_role) {
case DWC3_GCTL_PRTCAP_DEVICE:
+ case DWC3_GCTL_PRTCAP_OTG:
+#ifndef CONFIG_USB_DWC3_HISI
if (dwc->connected)
return -EBUSY;
+#endif
break;
case DWC3_GCTL_PRTCAP_HOST:
default:
device_init_wakeup(dev, true);
+ pm_runtime_put(dev);
return 0;
}
}
pm_runtime_mark_last_busy(dev);
+ /* maybe drop this? */
+ pm_runtime_get(dev);
return 0;
}
dwc3_runtime_idle)
};
+int dwc3_resume_device(struct dwc3 *dwc)
+{
+ int status;
+
+ pr_info("[dwc3_resume_device] +\n");
+ status = dwc3_runtime_resume(dwc->dev);
+ if (status < 0) {
+ pr_err("dwc3_runtime_resume err, status:%d\n", status);
+ }
+ pr_info("[dwc3_resume_device] -\n");
+ return status;
+}
+
+void dwc3_suspend_device(struct dwc3 *dwc)
+{
+ int status;
+
+ pr_info("[dwc3_suspend_device] +\n");
+ status = dwc3_runtime_suspend(dwc->dev);
+ if (status < 0) {
+ pr_err("dwc3_runtime_suspend err, status:%d\n", status);
+ }
+ pr_info("[dwc3_suspend_device] -\n");
+}
+
#ifdef CONFIG_OF
static const struct of_device_id of_dwc3_match[] = {
{
switch (evt) {
case DWC3_OTG_EVT_ID_SET:
dwc3_otg_stop_host(dwc_otg);
+ dwc3_suspend_device(dwc_otg->dwc);
break;
case DWC3_OTG_EVT_ID_CLEAR:
+ ret = dwc3_resume_device(dwc_otg->dwc);
if (ret) {
pr_err("%s: resume device failed!\n", __func__);
return ret;
ret = dwc3_otg_start_host(dwc_otg);
if (ret) {
pr_err("%s: start host failed!\n", __func__);
+ dwc3_suspend_device(dwc_otg->dwc);
return ret;
}
break;
case DWC3_OTG_EVT_VBUS_SET:
+ ret = dwc3_resume_device(dwc_otg->dwc);
if (ret) {
pr_err("%s: resume device failed!\n", __func__);
return ret;
ret = dwc3_otg_start_peripheral(dwc_otg);
if (ret) {
pr_err("%s: start peripheral failed!\n", __func__);
+ dwc3_suspend_device(dwc_otg->dwc);
return ret;
}
break;
case DWC3_OTG_EVT_VBUS_CLEAR:
ret = dwc3_otg_stop_peripheral(dwc_otg);
+ dwc3_suspend_device(dwc_otg->dwc);
break;
default:
break;
{
const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
struct dwc3 *dwc = dep->dwc;
- u32 timeout = 1000;
+ u32 timeout = 3000;
u32 reg;
int cmd_status = 0;
dwc->gadget.speed = USB_SPEED_UNKNOWN;
dwc->gadget.sg_supported = true;
dwc->gadget.name = "dwc3-gadget";
+#ifndef CONFIG_USB_DWC3_HISI
dwc->gadget.is_otg = dwc->dr_mode == USB_DR_MODE_OTG;
+#endif
/*
* FIXME We might be setting max_speed to <SUPER, however versions