summaryrefslogtreecommitdiff
path: root/board/cr50/usb_spi.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-02-01 17:43:00 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-02 16:42:51 -0800
commit04cf17251c05bdb02091938c23cf0319ed829979 (patch)
treebf88d376446656d209b1670b39c78deb0a5b0f21 /board/cr50/usb_spi.c
parenteb5ab132163c31c4ae7c79d279af8d1763da42f9 (diff)
downloadchrome-ec-04cf17251c05bdb02091938c23cf0319ed829979.tar.gz
cr50: usb_spi: Block SPI when console locked.
The commit changes the behaviour to block accesses over the USB-SPI bridge while the console is restricted. BUG=chrome-os-partner:62340 BRANCH=None TEST=Build and flash cr50 on snappy; lock console; try to flash EC bin using CCD. Verify that it fails with flashrom not able to find a flash chip. TEST=Disable console lock; Try to flash EC bin; verify it succeeds. TEST=Repeat above tests but trying to read AP flash instead. TEST=make -j buildall Change-Id: Ib69af1a7372d841783acee2262efbf995d031234 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/435437 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'board/cr50/usb_spi.c')
-rw-r--r--board/cr50/usb_spi.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/board/cr50/usb_spi.c b/board/cr50/usb_spi.c
index ea9c2258ed..ff4055ff98 100644
--- a/board/cr50/usb_spi.c
+++ b/board/cr50/usb_spi.c
@@ -70,9 +70,16 @@ static void update_finished(void)
}
DECLARE_DEFERRED(update_finished);
-void usb_spi_board_enable(struct usb_spi_config const *config)
+int usb_spi_board_enable(struct usb_spi_config const *config)
{
hook_call_deferred(&update_finished_data, -1);
+
+ /* Prevent SPI access if the console is currently locked. */
+ if (console_is_restricted()) {
+ CPRINTS("usb_spi access denied (console is restricted.");
+ return EC_ERROR_ACCESS_DENIED;
+ }
+
update_in_progress = 1;
disable_ec_ap_spi();
@@ -83,7 +90,7 @@ void usb_spi_board_enable(struct usb_spi_config const *config)
enable_ap_spi();
else {
CPRINTS("DEVICE NOT SUPPORTED");
- return;
+ return EC_ERROR_INVAL;
}
/* Connect DIO A4, A8, and A14 to the SPI peripheral */
@@ -97,6 +104,8 @@ void usb_spi_board_enable(struct usb_spi_config const *config)
gpio_get_level(GPIO_AP_FLASH_SELECT) ? "AP" : "EC");
spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+
+ return EC_SUCCESS;
}
void usb_spi_board_disable(struct usb_spi_config const *config)