summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuan-Yu Lin <guanyulin@google.com>2023-09-01 20:43:44 +0800
committerWill McVicker <willmcvicker@google.com>2024-04-16 11:58:49 -0700
commitfef936464903c5ddc81f3c0f15ab24de1ed139d9 (patch)
tree21f05479a0ec0782ca8ffb34d1d6abf50b81b7c7
parent5b3f06f18d9114f5c7c28eddf0d1a503ec2874f1 (diff)
downloadraviole-device-fef936464903c5ddc81f3c0f15ab24de1ed139d9.tar.gz
usb: dwc3: support usb function recovery during aoc ssr
Add a function to control otg_fsm during aoc ssr. Additionally, remove the old funciton for this feature. (Additional patch for aligning implementation in kernel 6.1) Bug: 297480242 Test: The following 6 tests passed: 1. AoC SSR during USB_ROLE_NONE. 2. AoC SSR during USB_ROLE_HOST. 3. AoC SSR during USB_ROLE_DEVICE. 4. Role changed during AoC SSR. 5. Restart pixel with USB_ROLE_HOST engaged. 6. Restart pixel with USB_ROLE_DEVICE engaged. Change-Id: Iba91a5bd8665b04df64869530676d9b32e203def Signed-off-by: Guan-Yu Lin <guanyulin@google.com>
-rw-r--r--drivers/usb/dwc3/dwc3-exynos-otg.c16
-rw-r--r--drivers/usb/dwc3/exynos-otg.h1
2 files changed, 9 insertions, 8 deletions
diff --git a/drivers/usb/dwc3/dwc3-exynos-otg.c b/drivers/usb/dwc3/dwc3-exynos-otg.c
index 81563ce14..d62edce83 100644
--- a/drivers/usb/dwc3/dwc3-exynos-otg.c
+++ b/drivers/usb/dwc3/dwc3-exynos-otg.c
@@ -96,7 +96,7 @@ static int dwc3_otg_statemachine(struct otg_fsm *fsm)
case OTG_STATE_A_IDLE:
if (fsm->id) {
otg->state = OTG_STATE_B_IDLE;
- } else {
+ } else if (dotg->host_ready) {
ret = otg_start_host(fsm, 1);
if (!ret) {
otg_drv_vbus(fsm, 1);
@@ -107,7 +107,7 @@ static int dwc3_otg_statemachine(struct otg_fsm *fsm)
}
break;
case OTG_STATE_A_HOST:
- if (fsm->id) {
+ if (fsm->id || !dotg->host_ready) {
otg_drv_vbus(fsm, 0);
ret = otg_start_host(fsm, 0);
if (!ret)
@@ -854,7 +854,7 @@ static struct dwc3_exynos *exynos_dwusb_get_struct(void)
return NULL;
}
-int dwc3_otg_fsm_try_reset(bool reset)
+int dwc3_otg_host_ready(bool ready)
{
struct dwc3_exynos *exynos;
struct otg_fsm *fsm;
@@ -870,15 +870,14 @@ int dwc3_otg_fsm_try_reset(bool reset)
fsm = &exynos->dotg->fsm;
otg = fsm->otg;
dotg = container_of(otg, struct dwc3_otg, otg);
- dotg->fsm_reset = reset;
+ dotg->host_ready = ready;
- // Skip role switch when we are resetting in gadget state
- if (!(dotg->fsm_reset && fsm->b_sess_vld))
- dwc3_otg_run_sm(fsm);
+ dev_info(exynos->dev, "host mode %s\n", ready ? "ready" : "unready");
+ dwc3_otg_run_sm(fsm);
return 0;
}
-EXPORT_SYMBOL_GPL(dwc3_otg_fsm_try_reset);
+EXPORT_SYMBOL_GPL(dwc3_otg_host_ready);
bool dwc3_otg_check_usb_suspend(struct dwc3_exynos *exynos)
{
@@ -1131,6 +1130,7 @@ int dwc3_exynos_otg_init(struct dwc3 *dwc, struct dwc3_exynos *exynos)
dotg->otg.set_host = NULL;
dotg->otg.state = OTG_STATE_UNDEFINED;
+ dotg->host_ready = false;
dotg->in_shutdown = false;
mutex_init(&dotg->fsm.lock);
diff --git a/drivers/usb/dwc3/exynos-otg.h b/drivers/usb/dwc3/exynos-otg.h
index 144d69dfd..609d6f827 100644
--- a/drivers/usb/dwc3/exynos-otg.h
+++ b/drivers/usb/dwc3/exynos-otg.h
@@ -50,6 +50,7 @@ struct dwc3_otg {
struct wakeup_source *reconn_wakelock;
unsigned ready:1;
+ bool host_ready;
int otg_connection;
struct regulator *vbus_reg;