diff options
author | Bryan O'Donoghue <bryan.odonoghue@linaro.org> | 2021-07-02 03:27:53 +0100 |
---|---|---|
committer | Bryan O'Donoghue <bryan.odonoghue@linaro.org> | 2022-06-22 14:10:14 +0100 |
commit | c9258493b71b52d005e1a19a36f3fd6d5d73f151 (patch) | |
tree | 779ac80c31f20d24c464d6fa5c348cbcebcfd177 | |
parent | 426d1a34ab60c639898a5bbca22c19a527132439 (diff) |
usb: dwc3: Add role switch relay supportlinux-stable-22-06-22+imx577-rb5-tcpm
Add the ability to relay a role switch message from the core to the parent
device of the controller.
This is useful for the qcom-dwc3 wrapper which wants to receive role-switch
notifications in order to waggle internal SoC UTMI signals.
Having the core trigger the parent wrapper has the advantage of keeping the
connector mechanism agnostic from dwc3 wrapper code and means that any
other wrapper implementation on any other SoC or architecture need not
write custom code to find various types of Type-C role switch mechanisms.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
-rw-r--r-- | drivers/usb/dwc3/core.h | 2 | ||||
-rw-r--r-- | drivers/usb/dwc3/drd.c | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 81c486b3941c..4aa80a56ec59 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1015,6 +1015,7 @@ struct dwc3_scratchpad_array { * - USBPHY_INTERFACE_MODE_UTMI * - USBPHY_INTERFACE_MODE_UTMIW * @role_sw: usb_role_switch handle + * @role_sw_relay: usb_role_switch relay handle * @role_switch_default_mode: default operation mode of controller while * usb role is USB_ROLE_NONE. * @usb_psy: pointer to power supply interface. @@ -1168,6 +1169,7 @@ struct dwc3 { struct notifier_block edev_nb; enum usb_phy_interface hsphy_mode; struct usb_role_switch *role_sw; + struct usb_role_switch *role_sw_relay; enum usb_dr_mode role_switch_default_mode; struct power_supply *usb_psy; diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 039bf241769a..cec92dd8d888 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -462,6 +462,9 @@ static int dwc3_usb_role_switch_set(struct usb_role_switch *sw, } dwc3_set_mode(dwc, mode); + if (dwc->role_sw_relay) + usb_role_switch_set_role(dwc->role_sw_relay, role); + return 0; } @@ -526,6 +529,10 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc) } } + dwc->role_sw_relay = usb_role_switch_get(dwc->dev); + if (IS_ERR(dwc->role_sw_relay)) + return PTR_ERR(dwc->role_sw_relay); + dwc3_set_mode(dwc, mode); return 0; } @@ -588,6 +595,9 @@ void dwc3_drd_exit(struct dwc3 *dwc) { unsigned long flags; + if (dwc->role_sw_relay) + usb_role_switch_put(dwc->role_sw_relay); + if (dwc->role_sw) usb_role_switch_unregister(dwc->role_sw); |