Skip to contentSkip to conversation

usb: dwc3: gadget: Default mode for DRD

PATCH New Thinh Nguyen 1 participant 3 messages Mar 30, 2020

Subsystems (2)
lore
Share & tools
lore

Thinh Nguyen

author maintainer
#0 lore raw

cover usb: dwc3: gadget: Default mode for DRD

DWC3 just learned to use the DRD role-switch API. If the driver is configured to use it, then delegate its default mode selection to the drd role-switch code-path. Also, make sure not to free non-existing OTG irq.

Thinh Nguyen (2):
usb: dwc3: drd: Don't free non-existing irq
usb: dwc3: core: Use role-switch default dr_mode

 drivers/usb/dwc3/core.c | 2 ++
 drivers/usb/dwc3/drd.c  | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH 1/2 usb: dwc3: drd: Don't free non-existing irq

If the driver is configured to use DRD role-switch, it's not OTG. There won't be OTG irq to free. Check for dwc->otg_irq before freeing it.

---
 drivers/usb/dwc3/drd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/drd.c +1 -1
index db68d48c2267..e6ec01972029 100644
@@ -651,6 +651,6 @@ void dwc3_drd_exit(struct dwc3 *dwc)
 		break;
 	}
 
-	if (!dwc->edev)
+	if (dwc->otg_irq)
 		free_irq(dwc->otg_irq, dwc);
 }
Signature · 1 line
2.11.0
author maintainer
#2 lore raw

PATCH 2/2 usb: dwc3: core: Use role-switch default dr_mode

In reply to Thinh Nguyen

If the driver is configured to use DRD role-switch, let the drd code path decide the default dr_mode.

---
 drivers/usb/dwc3/core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/dwc3/core.c +2 -0
index 7046c681fece..ab6323b8e323 100644
@@ -85,6 +85,8 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
 		 * specified or set to OTG, then set the mode to peripheral.
 		 */
 		if (mode == USB_DR_MODE_OTG &&
+		    (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
+		     !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
 		    dwc->revision >= DWC3_REVISION_330A)
 			mode = USB_DR_MODE_PERIPHERAL;
 	}
Signature · 1 line
2.11.0