aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>2021-07-02 03:27:53 +0100
committerBryan O'Donoghue <bryan.odonoghue@linaro.org>2023-01-31 00:31:17 +0000
commit671d98b6228c2066f0c08aacd46665f23a04cd58 (patch)
treedeb0599c7deda62d139796318eb54eaae243dd2a
parentb6865f125212180853cc9cf0d1114d4736e8630b (diff)
usb: dwc3: Add role switch relay support
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.h2
-rw-r--r--drivers/usb/dwc3/drd.c10
2 files changed, 12 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 8f9959ba9fd4..15173ed4ba64 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1018,6 +1018,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.
@@ -1175,6 +1176,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);