MLK-9637-4 usb: chipidea: otg: test: add otg_srp_reqd timer for start srp
authorLi Jun <B47624@freescale.com>
Sat, 27 Sep 2014 12:19:30 +0000 (20:19 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:11 +0000 (14:47 -0500)
This patch adds a timer for chipidea otg fsm driver to start data pulse
after A host ends the session.

Acked-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Li Jun <b47624@freescale.com>
(cherry picked from commit 35e92b59080b58925c3b96e36511056cb51d4a00)
(cherry picked from commit eeded24ce2d20b1c19d5c666e916f41995cf2385)

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

index 94dc741..dd5ef2c 100644 (file)
@@ -220,6 +220,7 @@ static unsigned otg_timer_ms[] = {
        TB_SSEND_SRP,
        TA_DP_END,
        TA_TST_MAINT,
+       TB_SRP_REQD,
        0,
 };
 
@@ -388,6 +389,21 @@ static int a_tst_maint_tmout(struct ci_hdrc *ci)
        return 0;
 }
 
+/*
+ * otg_srp_reqd feature
+ * After A(PET) turn off vbus, B(UUT) should start this timer to do SRP
+ * when the timer expires.
+ */
+static int b_srp_reqd_tmout(struct ci_hdrc *ci)
+{
+       ci->fsm.otg_srp_reqd = 0;
+       if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
+               ci->fsm.b_bus_req = 1;
+               return 0;
+       }
+       return 1;
+}
+
 /*
  * Keep this list in the same order as timers indexed
  * by enum otg_fsm_timer in include/linux/usb/otg-fsm.h
@@ -407,6 +423,7 @@ static int (*otg_timer_handlers[])(struct ci_hdrc *) = {
        b_ssend_srp_tmout,      /* B_SSEND_SRP */
        a_dp_end_tmout,         /* A_DP_END */
        a_tst_maint_tmout,      /* A_TST_MAINT */
+       b_srp_reqd_tmout,       /* B_SRP_REQD */
        NULL,                   /* HNP_POLLING */
 };
 
@@ -813,6 +830,8 @@ irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
                                        ci_otg_add_timer(ci, B_SSEND_SRP);
                                if (fsm->b_bus_req)
                                        fsm->b_bus_req = 0;
+                               if (fsm->otg_srp_reqd)
+                                       ci_otg_add_timer(ci, B_SRP_REQD);
                        } else {
                                ci->vbus_glitch_check_event = true;
                        }
index c934615..33b66d1 100644 (file)
@@ -68,6 +68,9 @@
 #define TB_SSEND_SRP         (1500)    /* minimum 1.5 sec, section:5.1.2 */
 
 #define TB_AIDL_BDIS         (20)      /* 4ms ~ 150ms, section 5.2.1 */
+#define TB_SRP_REQD          (2000)    /* For otg_srp_reqd to start data
+                                        * pulse after A(PET) turn off v-bus
+                                        */
 
 #if IS_ENABLED(CONFIG_USB_OTG_FSM)
 
index f6d6daf..b06f57c 100644 (file)
@@ -70,6 +70,7 @@ enum otg_fsm_timer {
        B_SSEND_SRP,
        A_DP_END,
        A_TST_MAINT,
+       B_SRP_REQD,
 
        NUM_OTG_FSM_TIMERS,
 };