summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-08-21 17:54:16 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-23 02:43:38 +0000
commit6cfc7a68aee5901f74a73acf900170d003ed7a4e (patch)
tree0c321c9d744776cb3d68cc6ebce9b08e739ffe49
parent9e79ca794904953cda23df3285579ea1a11c53ce (diff)
downloadchrome-ec-6cfc7a68aee5901f74a73acf900170d003ed7a4e.tar.gz
samus_pd: enable check for protected mode to prevent PD comm
Enable check for protected mode. If we are in RO and we are write protected, then don't allow PD communication. BUG=chrome-os-partner:31125 BRANCH=none TEST=Booted with and without battery, made sure PD communication works and we can boot (note we are currently not protected). Then commnented out CONFIG_SYSTEM_UNLOCKED, and ran flashwp enable from PD console to protect the system. Now when boot with battery, we don't communicate over PD and just take VBUS 5V. Removed battery and attempted to boot with just AC, but not enough power to boot off just 5V. EC goes to S0 and back to G3 after about 100ms. Change-Id: Ib26f8f0f5e9134d0337ebbd7f087f50fa41842d8 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/213738 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
-rw-r--r--board/samus_pd/board.c11
-rw-r--r--common/usb_pd_protocol.c22
2 files changed, 23 insertions, 10 deletions
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c
index 78635e444c..882c02fd16 100644
--- a/board/samus_pd/board.c
+++ b/board/samus_pd/board.c
@@ -15,6 +15,7 @@
#include "power.h"
#include "registers.h"
#include "switch.h"
+#include "system.h"
#include "task.h"
#include "usb_pd.h"
#include "usb_pd_config.h"
@@ -130,11 +131,6 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_PCH_SLP_S3_L);
gpio_enable_interrupt(GPIO_PCH_SLP_S5_L);
- /* TODO(crosbug.com/p/31125): remove #if and keep #else for EVT */
-#if 1
- /* Enable PD communication */
- pd_enable = 1;
-#else
/*
* Do not enable PD communication in RO as a security measure.
* We don't want to allow communication to outside world until
@@ -143,13 +139,12 @@ static void board_init(void)
* booting without a battery.
*/
if (system_get_image_copy() != SYSTEM_IMAGE_RW
- && !gpio_get_level(GPIO_WP_L)) {
- CPRINTF("[%T PD communication disabled]\n");
+ && system_is_locked()) {
+ ccprintf("[%T PD communication disabled]\n");
pd_enable = 0;
} else {
pd_enable = 1;
}
-#endif
pd_comm_enable(pd_enable);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index d0759184af..2825cf9eb2 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1057,6 +1057,23 @@ int pd_get_polarity(int port)
void pd_comm_enable(int enable)
{
pd_comm_enabled = enable;
+
+#ifdef CONFIG_USB_PD_DUAL_ROLE
+ /*
+ * If communications are enabled, start hard reset timer for
+ * any port in PD_SNK_DISCOVERY.
+ */
+ if (enable) {
+ int i;
+ for (i = 0; i < PD_PORT_COUNT; i++) {
+ if (pd[i].task_state == PD_STATE_SNK_DISCOVERY)
+ set_state_timeout(i,
+ get_time().val +
+ PD_T_SINK_WAIT_CAP,
+ PD_STATE_HARD_RESET);
+ }
+ }
+#endif
}
void pd_ping_enable(int port, int enable)
@@ -1269,8 +1286,9 @@ void pd_task(void)
break;
case PD_STATE_SNK_DISCOVERY:
- /* Wait for source cap expired */
- if (pd[port].last_state != pd[port].task_state)
+ /* Wait for source cap expired only if we are enabled */
+ if ((pd[port].last_state != pd[port].task_state)
+ && pd_comm_enabled)
set_state_timeout(port,
get_time().val +
PD_T_SINK_WAIT_CAP,