MLK-9638-5 usb: chipidea: otg: test: timer for B host hands host role back
authorLi Jun <B47624@freescale.com>
Sat, 27 Sep 2014 13:44:36 +0000 (21:44 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:12 +0000 (14:47 -0500)
This patch implements a timer for B host to start host role switch back to A
device.

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

drivers/usb/chipidea/otg_fsm.c
drivers/usb/chipidea/otg_fsm.h

index dd5ef2c..259d8b4 100644 (file)
@@ -221,6 +221,7 @@ static unsigned otg_timer_ms[] = {
        TA_DP_END,
        TA_TST_MAINT,
        TB_SRP_REQD,
+       TB_TST_SUSP,
        0,
 };
 
@@ -404,6 +405,20 @@ static int b_srp_reqd_tmout(struct ci_hdrc *ci)
        return 1;
 }
 
+/*
+ * otg_hnp_reqd feature
+ * After B(UUT) switch to host, B should hand host role back
+ * to A(PET) within TB_TST_SUSP after setting configuration.
+ */
+static int b_tst_susp_tmout(struct ci_hdrc *ci)
+{
+       if (ci->fsm.otg->state == OTG_STATE_B_HOST) {
+               ci->fsm.b_bus_req = 0;
+               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
@@ -424,6 +439,7 @@ static int (*otg_timer_handlers[])(struct ci_hdrc *) = {
        a_dp_end_tmout,         /* A_DP_END */
        a_tst_maint_tmout,      /* A_TST_MAINT */
        b_srp_reqd_tmout,       /* B_SRP_REQD */
+       b_tst_susp_tmout,       /* B_TST_SUSP */
        NULL,                   /* HNP_POLLING */
 };
 
index 33b66d1..21f89df 100644 (file)
                                         * pulse after A(PET) turn off v-bus
                                         */
 
+#define TB_TST_SUSP          (20)      /* B-dev hand host role back to A-dev
+                                        * via suspend bus after set config.
+                                        * max: 100ms
+                                        */
+
 #if IS_ENABLED(CONFIG_USB_OTG_FSM)
 
 int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci);