From 8d1d243134b7234a6df5558e715ea497e0fb97b9 Mon Sep 17 00:00:00 2001 From: Aseda Aboagye Date: Thu, 4 Jan 2018 19:07:13 -0800 Subject: cr50: Don't touch EC reset for USB-EC SPI bridge. Cr50 should not automatically touch the EC reset when enabling the USB-EC SPI bridge. Otherwise, this could interefere with ECs that might have internal SPI flash and need to have their resets deasserted in order to access the internal SPI flash. This commits simply removes the assertion of EC reset when enabling the USB-EC SPI bridge. The user or external scripts should control the resets as necessary using servo or the cr50 console. BUG=b:71548795,b:71557464 BRANCH=None TEST=Flash meowth cr50. Verify that I can flash the EC using a servo_v4. TEST=Repeat above test with a servo_micro. TEST=Repeat above test with a SuzyQable. Change-Id: I114c34df43cf1e8ba622e75c3e6ecf517afc40a4 Signed-off-by: Aseda Aboagye Reviewed-on: https://chromium-review.googlesource.com/850865 Commit-Ready: Aseda Aboagye Tested-by: Aseda Aboagye Reviewed-by: Randall Spangler Reviewed-by: Vadim Bendebury --- board/cr50/usb_spi.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/board/cr50/usb_spi.c b/board/cr50/usb_spi.c index 31b900109f..75dcae9d8e 100644 --- a/board/cr50/usb_spi.c +++ b/board/cr50/usb_spi.c @@ -17,13 +17,21 @@ static void disable_ec_ap_spi(void) { - /* Configure SPI GPIOs */ - gpio_set_level(GPIO_AP_FLASH_SELECT, 0); + int was_ap_spi_en = gpio_get_level(GPIO_AP_FLASH_SELECT); + + /* Disable EC SPI access. */ gpio_set_level(GPIO_EC_FLASH_SELECT, 0); - /* Release AP and EC */ - deassert_ec_rst(); - deassert_sys_rst(); + /* Disable AP SPI access. */ + if (was_ap_spi_en) { + /* + * The fact that AP SPI access was enabled means that the EC was + * held in reset. Therefore, it needs to be released here. + */ + gpio_set_level(GPIO_AP_FLASH_SELECT, 0); + deassert_ec_rst(); + deassert_sys_rst(); + } } static void enable_ec_spi(void) @@ -32,8 +40,11 @@ static void enable_ec_spi(void) gpio_set_level(GPIO_AP_FLASH_SELECT, 0); gpio_set_level(GPIO_EC_FLASH_SELECT, 1); - /* Hold EC in reset. This will also hold the AP in reset. */ - assert_ec_rst(); + /* + * Note that we don't hold the EC in reset here. This is because some + * ECs with internal SPI flash cannot be held in reset in order to + * access the flash. + */ } static void enable_ap_spi(void) -- cgit v1.2.1