Skip to content

Commit ade23d7

Browse files
QSchulzgregkh
authored andcommitted
usb: dwc2: power on/off phy for peripheral mode in dual-role mode
The PHY power is handled for peripheral mode but only when the device is forced into this peripheral mode. It is missing when the device is operating in peripheral mode when dual-role mode is enabled, so let's update the condition to match this scenario. Signed-off-by: Quentin Schulz <[email protected]> Link: https://lore.kernel.org/r/20221206-dwc2-gadget-dual-role-v1-2-36515e1092cd@theobroma-systems.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 42a317d commit ade23d7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/usb/dwc2/gadget.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4549,7 +4549,8 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget,
45494549
hsotg->gadget.dev.of_node = hsotg->dev->of_node;
45504550
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
45514551

4552-
if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) {
4552+
if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL ||
4553+
(hsotg->dr_mode == USB_DR_MODE_OTG && dwc2_is_device_mode(hsotg))) {
45534554
ret = dwc2_lowlevel_hw_enable(hsotg);
45544555
if (ret)
45554556
goto err;
@@ -4611,7 +4612,8 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget)
46114612
if (!IS_ERR_OR_NULL(hsotg->uphy))
46124613
otg_set_peripheral(hsotg->uphy->otg, NULL);
46134614

4614-
if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
4615+
if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL ||
4616+
(hsotg->dr_mode == USB_DR_MODE_OTG && dwc2_is_device_mode(hsotg)))
46154617
dwc2_lowlevel_hw_disable(hsotg);
46164618

46174619
return 0;

drivers/usb/dwc2/platform.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,8 @@ static int dwc2_driver_probe(struct platform_device *dev)
576576
dwc2_debugfs_init(hsotg);
577577

578578
/* Gadget code manages lowlevel hw on its own */
579-
if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
579+
if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL ||
580+
(hsotg->dr_mode == USB_DR_MODE_OTG && dwc2_is_device_mode(hsotg)))
580581
dwc2_lowlevel_hw_disable(hsotg);
581582

582583
#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \

0 commit comments

Comments
 (0)