Skip to content

Commit a02b5ed

Browse files
pritamsutarjannau
authored andcommitted
usb: dwc3: Allow usb role swich control from userspace
There is a possibility of user needs for USB mode switching on boards that lack external hardware support for dynamic host/device role detection. This is particularly relevant in automotive applications where userspace applications need to switch USB roles (host to device) at runtime for CarPlay/Android Auto integration. Add an `allow_userspace_control` flag to handle such cases. When enabled, it exposes a sysfs attribute that allows userspace to switch the USB role manually between host and device. This provides flexibility for platforms that cannot rely on hardware-based mode detection. The role switch can be done as below echo host > /sys/class/usb_role/<ADDR>.usb-role-switch/role echo device > /sys/class/usb_role/<ADDR>.usb-role-switch/role Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Signed-off-by: Pritam Manohar Sutar <pritam.sutar@samsung.com> Link: https://patch.msgid.link/20251024085455.789555-1-pritam.sutar@samsung.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 82150bb commit a02b5ed

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/usb/dwc3/drd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
515515
dwc3_role_switch.set = dwc3_usb_role_switch_set;
516516
dwc3_role_switch.get = dwc3_usb_role_switch_get;
517517
dwc3_role_switch.driver_data = dwc;
518+
dwc3_role_switch.allow_userspace_control = true;
518519
dwc->role_sw = usb_role_switch_register(dwc->dev, &dwc3_role_switch);
519520
if (IS_ERR(dwc->role_sw))
520521
return PTR_ERR(dwc->role_sw);

0 commit comments

Comments
 (0)