summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-04-10 15:46:39 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-11 14:36:40 -0700
commitd2e77ddbc913a34c14e87eaa9c3104f62ec40142 (patch)
treee03164ade39f482235da299cc432fe0b44e28885 /common
parenta3341ee7e9bf93e3757684816b8319ae726d2044 (diff)
downloadchrome-ec-d2e77ddbc913a34c14e87eaa9c3104f62ec40142.tar.gz
pd: Add config to disable PD communication in locked RO
The scheme to disable PD communication in locked RO needs to be implemented on other platforms, so move it to common code, behind CONFIG_USB_PD_COMM_LOCKED. BUG=chrome-os-partner:52157 BRANCH=glados TEST=Manual on chell. Lock system and boot to recovery, then verify PD communication is functional. Enable CONFIG_USB_PD_COMM_LOCKED and verify PD communication isn't functional under the same test conditions. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I8d1f24c0b60cf1c54e329af003b7083ee55ffc40 Reviewed-on: https://chromium-review.googlesource.com/338064 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usb_pd_protocol.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index d903831d6f..2e34367459 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -46,8 +46,12 @@ static int debug_level;
* detects source/sink connection and disconnection, and will still
* provide VBUS, but never sends any PD communication.
*/
-static uint8_t pd_comm_enabled = CONFIG_USB_PD_COMM_ENABLED;
+#if !defined(CONFIG_USB_PD_COMM_ENABLED) || defined(CONFIG_USB_PD_COMM_LOCKED)
+static uint8_t pd_comm_enabled;
#else
+static uint8_t pd_comm_enabled = 1;
+#endif
+#else /* CONFIG_COMMON_RUNTIME */
#define CPRINTF(format, args...)
static const int debug_level;
static const uint8_t pd_comm_enabled = 1;
@@ -3335,4 +3339,20 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_SET_AMODE,
#endif /* HAS_TASK_HOSTCMD */
+#ifdef CONFIG_USB_PD_COMM_LOCKED
+/* Enable PD communication at init if we're in RO or unlocked. */
+static void pd_comm_init(void)
+{
+ int pd_enable = 1;
+
+ if (system_get_image_copy() != SYSTEM_IMAGE_RW
+ && system_is_locked()) {
+ ccprintf("[%T PD comm disabled]\n");
+ pd_enable = 0;
+ }
+
+ pd_comm_enable(pd_enable);
+}
+DECLARE_HOOK(HOOK_INIT, pd_comm_init, HOOK_PRIO_LAST);
+#endif /* CONFIG_USB_PD_COMM_LOCKED */
#endif /* CONFIG_COMMON_RUNTIME */