summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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