summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Broch <tbroch@chromium.org>2014-12-03 13:16:03 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-05 10:06:19 +0000
commitb5557217aa7343a565ab172ce22488af5fc1de03 (patch)
tree50014b1673f53af4a8397e91205352cb7e7d2690
parentfb04700b3a78588f2ec17f659f1e14b143f4d7eb (diff)
downloadchrome-ec-b5557217aa7343a565ab172ce22488af5fc1de03.tar.gz
pd: dingdong/hoho: Fix hard reset recovery timeout.
dingdong/hoho have no capability to measure VBUS which is advantageous in determining what timeouts to honor. Previously we simply assumed vbus was on and that made things happy until, e0c80ac pd: on hard reset go to a hard reset recovery state which introduced proper handling around sink & source reset recovery. With VBUS assumed 'on' this leads to short timeouts chosen (PD_T_SAFE_0V) which in turn causes sink to resend hard resets before source has had time (PD_T_SRC_RECOVER) to handle request. This change creates config CONFIG_USB_PD_NO_VBUS_DETECT for devices without the capability to account for lack of VBUS detect. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:34090 TEST=manual from samus_pd 'pd 1 flash reboot' is successful Change-Id: I9ef9b0115c7be6c56c64556d2ce8c296f95c614e Reviewed-on: https://chromium-review.googlesource.com/233024 Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
-rw-r--r--board/dingdong/board.h1
-rw-r--r--board/hoho/board.h1
-rw-r--r--common/usb_pd_protocol.c23
-rw-r--r--include/config.h3
4 files changed, 28 insertions, 0 deletions
diff --git a/board/dingdong/board.h b/board/dingdong/board.h
index 29eeab1891..7315645ee9 100644
--- a/board/dingdong/board.h
+++ b/board/dingdong/board.h
@@ -35,6 +35,7 @@
#define CONFIG_USB_PD_INTERNAL_COMP
#define CONFIG_USB_PD_IDENTITY_HW_VERS 1
#define CONFIG_USB_PD_IDENTITY_SW_VERS 1
+#define CONFIG_USB_PD_NO_VBUS_DETECT
#undef CONFIG_WATCHDOG_HELP
#undef CONFIG_LID_SWITCH
#undef CONFIG_TASK_PROFILING
diff --git a/board/hoho/board.h b/board/hoho/board.h
index 30aa1d49b8..98f94a5d0c 100644
--- a/board/hoho/board.h
+++ b/board/hoho/board.h
@@ -43,6 +43,7 @@
#define CONFIG_USB_PD_INTERNAL_COMP
#define CONFIG_USB_PD_IDENTITY_HW_VERS 1
#define CONFIG_USB_PD_IDENTITY_SW_VERS 1
+#define CONFIG_USB_PD_NO_VBUS_DETECT
#undef CONFIG_WATCHDOG_HELP
#undef CONFIG_LID_SWITCH
#undef CONFIG_TASK_PROFILING
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 967f002dcd..d24a8ef524 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -837,6 +837,10 @@ static void handle_data_request(int port, uint16_t head,
case PD_DATA_SOURCE_CAP:
if ((pd[port].task_state == PD_STATE_SNK_DISCOVERY)
|| (pd[port].task_state == PD_STATE_SNK_TRANSITION)
+#ifdef CONFIG_USB_PD_NO_VBUS_DETECT
+ || (pd[port].task_state ==
+ PD_STATE_SNK_HARD_RESET_RECOVER)
+#endif
|| (pd[port].task_state == PD_STATE_SNK_READY)) {
pd_store_src_cap(port, cnt, payload);
/* src cap 0 should be fixed PDO */
@@ -1498,7 +1502,9 @@ void pd_task(void)
#ifdef CONFIG_USB_PD_DUAL_ROLE
uint64_t next_role_swap = PD_T_DRP_SNK;
int hard_reset_count = 0;
+#ifndef CONFIG_USB_PD_NO_VBUS_DETECT
int snk_hard_reset_vbus_off = 0;
+#endif
#ifdef CONFIG_CHARGE_MANAGER
static int initialized[PD_PORT_COUNT];
int typec_curr = 0, typec_curr_change = 0;
@@ -1918,6 +1924,22 @@ void pd_task(void)
}
break;
case PD_STATE_SNK_HARD_RESET_RECOVER:
+ if (pd[port].last_state != pd[port].task_state) {
+ pd[port].flags |= PD_FLAGS_DATA_SWAPPED;
+ pd[port].flags |= PD_FLAGS_NEW_CONTRACT;
+ }
+#ifdef CONFIG_USB_PD_NO_VBUS_DETECT
+ /*
+ * Can't measure vbus state so this is the maximum
+ * recovery time for the source.
+ */
+ if (pd[port].last_state != pd[port].task_state)
+ set_state_timeout(port, get_time().val +
+ PD_T_SAFE_0V +
+ PD_T_SRC_RECOVER_MAX +
+ PD_T_SRC_TURN_ON,
+ PD_STATE_SNK_DISCONNECTED);
+#else
/* Wait for VBUS to go low and then high*/
if (pd[port].last_state != pd[port].task_state) {
snk_hard_reset_vbus_off = 0;
@@ -1949,6 +1971,7 @@ void pd_task(void)
* Don't need to set timeout because VBUS changing
* will trigger an interrupt and wake us up.
*/
+#endif
break;
case PD_STATE_SNK_DISCOVERY:
/*
diff --git a/include/config.h b/include/config.h
index 67963d3e4e..1eafd6368a 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1120,6 +1120,9 @@
/* Define if using internal comparator for PD receive */
#undef CONFIG_USB_PD_INTERNAL_COMP
+/* Define if USB-PD device has no way of detecting USB VBUS */
+#undef CONFIG_USB_PD_NO_VBUS_DETECT
+
/* Simple DFP, such as power adapter, will not send discovery VDM on connect */
#undef CONFIG_USB_PD_SIMPLE_DFP