summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-11-04 14:34:00 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-11 00:10:35 +0000
commit2c83bfc7da317e254dedd32a0bea7763345d3510 (patch)
tree1b060376d6032a61ef19870165cfd9f5b1e4be7a
parent3fd064745ba37a626df1ed34a79765821e259a46 (diff)
downloadchrome-ec-2c83bfc7da317e254dedd32a0bea7763345d3510.tar.gz
pd: add delay for power supply startup before sending src cap
Add delay for power supply startup time before sending source capabilities packets. BUG=none BRANCH=samus TEST=load on samus, plug in C to A receptacle adapter, see that VBUS enabled before source cap packet sent. Change-Id: If3b595e1671d089e859693b420841a639fdb146b Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227423
-rw-r--r--board/dingdong/usb_pd_config.h4
-rw-r--r--board/hoho/usb_pd_config.h4
-rw-r--r--board/host/usb_pd_config.h2
-rw-r--r--board/ryu/usb_pd_config.h4
-rw-r--r--board/ryu_p2/usb_pd_config.h4
-rw-r--r--board/samus_pd/usb_pd_config.h4
-rw-r--r--common/usb_pd_protocol.c16
-rw-r--r--include/usb_pd.h1
8 files changed, 25 insertions, 14 deletions
diff --git a/board/dingdong/usb_pd_config.h b/board/dingdong/usb_pd_config.h
index e68eb1f662..3af9e0a189 100644
--- a/board/dingdong/usb_pd_config.h
+++ b/board/dingdong/usb_pd_config.h
@@ -137,6 +137,6 @@ static inline int pd_snk_is_vbus_provided(int port)
/* we are acting only as a sink */
#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED
-/* delay necessary for the voltage transition on the power supply */
-#define PD_POWER_SUPPLY_TRANSITION_DELAY 50000 /* us */
+/* we are never a source : don't care about power supply */
+#define PD_POWER_SUPPLY_TRANSITION_DELAY 0 /* us */
#endif /* __USB_PD_CONFIG_H */
diff --git a/board/hoho/usb_pd_config.h b/board/hoho/usb_pd_config.h
index e68eb1f662..3af9e0a189 100644
--- a/board/hoho/usb_pd_config.h
+++ b/board/hoho/usb_pd_config.h
@@ -137,6 +137,6 @@ static inline int pd_snk_is_vbus_provided(int port)
/* we are acting only as a sink */
#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED
-/* delay necessary for the voltage transition on the power supply */
-#define PD_POWER_SUPPLY_TRANSITION_DELAY 50000 /* us */
+/* we are never a source : don't care about power supply */
+#define PD_POWER_SUPPLY_TRANSITION_DELAY 0 /* us */
#endif /* __USB_PD_CONFIG_H */
diff --git a/board/host/usb_pd_config.h b/board/host/usb_pd_config.h
index 6770b8e11d..d9eb607874 100644
--- a/board/host/usb_pd_config.h
+++ b/board/host/usb_pd_config.h
@@ -36,6 +36,6 @@ int pd_snk_is_vbus_provided(int port);
#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED
/* delay necessary for the voltage transition on the power supply */
-#define PD_POWER_SUPPLY_TRANSITION_DELAY 50000 /* us */
+#define PD_POWER_SUPPLY_TRANSITION_DELAY 20000 /* us */
#endif /* __USB_PD_CONFIG_H */
diff --git a/board/ryu/usb_pd_config.h b/board/ryu/usb_pd_config.h
index 8bea5276c2..8adc002e8c 100644
--- a/board/ryu/usb_pd_config.h
+++ b/board/ryu/usb_pd_config.h
@@ -170,7 +170,7 @@ static inline int pd_snk_is_vbus_provided(int port)
/* start as a sink in case we have no other power supply/battery */
#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED
-/* delay necessary for the voltage transition on the power supply */
-#define PD_POWER_SUPPLY_TRANSITION_DELAY 50000 /* us */
+/* delay for the voltage transition on the power supply, chip max is 16us */
+#define PD_POWER_SUPPLY_TRANSITION_DELAY 20000 /* us */
#endif /* __USB_PD_CONFIG_H */
diff --git a/board/ryu_p2/usb_pd_config.h b/board/ryu_p2/usb_pd_config.h
index e8edb86de0..374cb083d7 100644
--- a/board/ryu_p2/usb_pd_config.h
+++ b/board/ryu_p2/usb_pd_config.h
@@ -170,7 +170,7 @@ static inline int pd_snk_is_vbus_provided(int port)
/* start as a sink in case we have no other power supply/battery */
#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED
-/* delay necessary for the voltage transition on the power supply */
-#define PD_POWER_SUPPLY_TRANSITION_DELAY 50000 /* us */
+/* delay for the voltage transition on the power supply, chip max is 16us */
+#define PD_POWER_SUPPLY_TRANSITION_DELAY 20000 /* us */
#endif /* __USB_PD_CONFIG_H */
diff --git a/board/samus_pd/usb_pd_config.h b/board/samus_pd/usb_pd_config.h
index 62b699f3c0..d38999e2be 100644
--- a/board/samus_pd/usb_pd_config.h
+++ b/board/samus_pd/usb_pd_config.h
@@ -258,7 +258,7 @@ static inline int pd_snk_is_vbus_provided(int port)
/* start as a sink in case we have no other power supply/battery */
#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED
-/* delay necessary for the voltage transition on the power supply */
-#define PD_POWER_SUPPLY_TRANSITION_DELAY 50000 /* us */
+/* delay for the voltage transition on the power supply, chip max is 16us */
+#define PD_POWER_SUPPLY_TRANSITION_DELAY 20000 /* us */
#endif /* __USB_PD_CONFIG_H */
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 2e15e8bc7b..01a997366c 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1411,7 +1411,7 @@ void pd_task(void)
pd_set_vconn(port, pd[port].polarity, 1);
#endif
- set_state(port, PD_STATE_SRC_DISCOVERY);
+ set_state(port, PD_STATE_SRC_STARTUP);
caps_count = 0;
#ifdef CONFIG_USB_PD_DUAL_ROLE
/* Keep VBUS up for the hold period */
@@ -1433,6 +1433,15 @@ void pd_task(void)
}
#endif
break;
+ case PD_STATE_SRC_STARTUP:
+ /* Wait for power source to enable */
+ if (pd[port].last_state != pd[port].task_state)
+ set_state_timeout(
+ port,
+ get_time().val +
+ PD_POWER_SUPPLY_TRANSITION_DELAY,
+ PD_STATE_SRC_DISCOVERY);
+ break;
case PD_STATE_SRC_DISCOVERY:
/* Send source cap some minimum number of times */
if (caps_count < PD_CAPS_COUNT) {
@@ -2169,8 +2178,9 @@ static int command_pd(int argc, char **argv)
"SNK_SWAP_SNK_DISABLE", "SNK_SWAP_SRC_DISABLE",
"SNK_SWAP_STANDBY", "SNK_SWAP_COMPLETE",
#endif /* CONFIG_USB_PD_DUAL_ROLE */
- "SRC_DISCONNECTED", "SRC_DISCOVERY", "SRC_NEGOCIATE",
- "SRC_ACCEPTED", "SRC_TRANSITION", "SRC_READY",
+ "SRC_DISCONNECTED", "SRC_STARTUP", "SRC_DISCOVERY",
+ "SRC_NEGOCIATE", "SRC_ACCEPTED", "SRC_TRANSITION",
+ "SRC_READY",
#ifdef CONFIG_USB_PD_DUAL_ROLE
"SRC_SWAP_INIT", "SRC_SWAP_SNK_DISABLE",
"SRC_SWAP_SRC_DISABLE", "SRC_SWAP_STANDBY",
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 017b8031f4..bd19600282 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -504,6 +504,7 @@ enum pd_states {
#endif /* CONFIG_USB_PD_DUAL_ROLE */
PD_STATE_SRC_DISCONNECTED,
+ PD_STATE_SRC_STARTUP,
PD_STATE_SRC_DISCOVERY,
PD_STATE_SRC_NEGOCIATE,
PD_STATE_SRC_ACCEPTED,