From: Li Jun Date: Thu, 16 Oct 2014 14:18:00 +0000 (+0800) Subject: MLK-9618-7 usb: chipidea: otg: delay turn on vbus when detecting data pulse X-Git-Tag: C0P2-H0.0--20200415~4713 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=3c687dd3d368576a3068c9bffc489bf26e025be3;p=linux.git MLK-9618-7 usb: chipidea: otg: delay turn on vbus when detecting data pulse This patch adds a timer to delay turn on vbus after detecting data pulse from B-device, this is required by OTG SRP timing. Signed-off-by: Li Jun (cherry picked from commit f02ee3e93715c41f5b1e11140f36e350c7ed4d6b) --- diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index e5fdeb37ad2b..701d4f767531 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -1099,13 +1099,10 @@ static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci) { if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) && (ci->fsm.a_bus_drop == 1) && (ci->fsm.a_bus_req == 0)) { - if (!hw_read_otgsc(ci, OTGSC_ID)) { - ci->fsm.a_srp_det = 1; - ci->fsm.a_bus_drop = 0; - } else { + if (!hw_read_otgsc(ci, OTGSC_ID)) + otg_add_timer(&ci->fsm, A_DP_END); + else ci->fsm.id = 1; - } - ci_otg_queue_work(ci); } } diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index ea1594ad2e5c..75525d46e237 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -218,6 +218,7 @@ static unsigned otg_timer_ms[] = { 0, TB_DATA_PLS, TB_SSEND_SRP, + TA_DP_END, }; /* @@ -363,6 +364,13 @@ static int b_ssend_srp_tmout(struct ci_hdrc *ci) return 1; } +static int a_dp_end_tmout(struct ci_hdrc *ci) +{ + ci->fsm.a_bus_drop = 0; + ci->fsm.a_srp_det = 1; + return 0; +} + /* * Keep this list in the same order as timers indexed * by enum otg_fsm_timer in include/linux/usb/otg-fsm.h @@ -380,6 +388,7 @@ static int (*otg_timer_handlers[])(struct ci_hdrc *) = { NULL, /* A_WAIT_ENUM */ b_data_pls_tmout, /* B_DATA_PLS */ b_ssend_srp_tmout, /* B_SSEND_SRP */ + a_dp_end_tmout, /* A_DP_END */ }; /* @@ -767,8 +776,7 @@ irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci) if (otg_int_src) { if (otg_int_src & OTGSC_DPIS) { hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS); - fsm->a_srp_det = 1; - fsm->a_bus_drop = 0; + ci_otg_add_timer(ci, A_DP_END); } else if (otg_int_src & OTGSC_IDIS) { hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS); if (fsm->id == 0) { diff --git a/drivers/usb/chipidea/otg_fsm.h b/drivers/usb/chipidea/otg_fsm.h index 7be894a392d2..96b79a501bdd 100644 --- a/drivers/usb/chipidea/otg_fsm.h +++ b/drivers/usb/chipidea/otg_fsm.h @@ -43,6 +43,8 @@ * for safe */ +#define TA_DP_END (200) + /* * B-device timing constants */ diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h index 62e6f8c80e1d..e9d3a89c3149 100644 --- a/include/linux/usb/otg-fsm.h +++ b/include/linux/usb/otg-fsm.h @@ -68,6 +68,7 @@ enum otg_fsm_timer { A_WAIT_ENUM, B_DATA_PLS, B_SSEND_SRP, + A_DP_END, NUM_OTG_FSM_TIMERS, };