From: Josep Orga Date: Tue, 7 Nov 2023 18:50:04 +0000 (+0100) Subject: usb: dwc3: drd: Add support for usb-conn-gpio based usb-role-switch X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.3~2 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=f006496b255a9f75a09f18e8853ffec25f10bc37;p=linux.git usb: dwc3: drd: Add support for usb-conn-gpio based usb-role-switch usb-conn-gpio devices are a subnode of the USB interface controller, which needs to be populated. This allows having a non-type-c connector providing dual-role. Signed-off-by: Alexander Stein Link: https://lore.kernel.org/r/20220105071407.2240302-1-alexander.stein@ew.tq-group.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 7528c36b02b6..3cf1b19260b5 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -565,6 +566,18 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc) if (IS_ERR(dwc->role_sw)) return PTR_ERR(dwc->role_sw); + if (IS_ENABLED(CONFIG_OF)) { + /* populate connector entry */ + int ret = devm_of_platform_populate(dwc->dev); + + if (ret) { + usb_role_switch_unregister(dwc->role_sw); + dwc->role_sw = NULL; + dev_err(dwc->dev, "DWC3 platform devices creation failed: %i\n", ret); + return ret; + } + } + dwc3_set_mode(dwc, mode); return 0; }