MLK-9618-7 usb: chipidea: otg: delay turn on vbus when detecting data pulse
authorLi Jun <b47624@freescale.com>
Thu, 16 Oct 2014 14:18:00 +0000 (22:18 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:00 +0000 (14:47 -0500)
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 <b47624@freescale.com>
(cherry picked from commit f02ee3e93715c41f5b1e11140f36e350c7ed4d6b)

drivers/usb/chipidea/core.c
drivers/usb/chipidea/otg_fsm.c
drivers/usb/chipidea/otg_fsm.h
include/linux/usb/otg-fsm.h

index e5fdeb3..701d4f7 100644 (file)
@@ -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);
        }
 }
 
index ea1594a..75525d4 100644 (file)
@@ -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) {
index 7be894a..96b79a5 100644 (file)
@@ -43,6 +43,8 @@
                                         * for safe
                                         */
 
+#define TA_DP_END             (200)
+
 /*
  * B-device timing constants
  */
index 62e6f8c..e9d3a89 100644 (file)
@@ -68,6 +68,7 @@ enum otg_fsm_timer {
        A_WAIT_ENUM,
        B_DATA_PLS,
        B_SSEND_SRP,
+       A_DP_END,
 
        NUM_OTG_FSM_TIMERS,
 };