From f3426fb32fe98e17ecb7ebaf91010f112e7d8561 Mon Sep 17 00:00:00 2001 From: Li Jun Date: Wed, 24 Sep 2014 14:35:31 +0800 Subject: [PATCH] MLK-9606-4 usb: chipidea: otg: test: tst_maint timer implementation This patch implements otg test device session maintain timer, if the timer expires, A device as host should end the session, and clear tst_maint flag when turn off vbus. Acked-by: Peter Chen Signed-off-by: Li Jun (cherry picked from commit 9d3bd049aef442f11dce77226a0ca09893a6656b) --- drivers/usb/chipidea/otg_fsm.c | 19 +++++++++++++++++++ drivers/usb/chipidea/otg_fsm.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index e8486d524b13..7e2fca1d45f0 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -219,6 +219,8 @@ static unsigned otg_timer_ms[] = { TB_DATA_PLS, TB_SSEND_SRP, TA_DP_END, + TA_TST_MAINT, + 0, }; /* @@ -371,6 +373,21 @@ static int a_dp_end_tmout(struct ci_hdrc *ci) return 0; } +static int a_tst_maint_tmout(struct ci_hdrc *ci) +{ + ci->fsm.tst_maint = 0; + if (ci->fsm.otg_vbus_off) { + ci->fsm.otg_vbus_off = 0; + dev_dbg(ci->dev, + "test device does not disconnect, end the session!\n"); + } + + /* End the session */ + ci->fsm.a_bus_req = 0; + ci->fsm.a_bus_drop = 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 @@ -389,6 +406,8 @@ static int (*otg_timer_handlers[])(struct ci_hdrc *) = { b_data_pls_tmout, /* B_DATA_PLS */ b_ssend_srp_tmout, /* B_SSEND_SRP */ a_dp_end_tmout, /* A_DP_END */ + a_tst_maint_tmout, /* A_TST_MAINT */ + NULL, /* HNP_POLLING */ }; /* diff --git a/drivers/usb/chipidea/otg_fsm.h b/drivers/usb/chipidea/otg_fsm.h index 96b79a501bdd..c93461513739 100644 --- a/drivers/usb/chipidea/otg_fsm.h +++ b/drivers/usb/chipidea/otg_fsm.h @@ -44,6 +44,9 @@ */ #define TA_DP_END (200) +#define TA_TST_MAINT (9900) /* OTG test device session maintain + * timer, 9.9s~10.1s + */ /* * B-device timing constants