From 53cc74484c4b352dbdfb03ded96e285634d17dd4 Mon Sep 17 00:00:00 2001 From: CHLin Date: Mon, 29 Jun 2020 14:10:16 +0800 Subject: npcx: monitor: set DEVALT0.bit7 for the internal flash The npcx monitor LFW (little firmware) can be used in two scenarios: 1. For npcx5 which supports the external flash and doesn't support UUT, it is used by the openocd via servo JTAG to flash the EC image. 2. For npcx7 (and newer chips) which support the internal flash and UUT, it is used by the UUT via UART to flash the EC image. For case 1, the DEVALT0.bit7 (NO_F_SPI) should be cleared in order to program the external flash. In case 2, this bit should be set because the internal flash is used. Otherwise, the GPIOA0 (F_CS0) will also toggles while programming the internal flash. Before this CL, the monitor unconditionally clears this bit when programming the flash. In this CL, the monitor decides to set/clear this bit according to the value of the tag filed in the monitor header. (Assuming that when UUT is used, the target is always the internal flash.) BUG=none BRANCH=none TEST=No error for "make buildall" TEST=Programming the internal flash via UUT, make sure the GPIOA0 doesn't toggle with scope. Change-Id: I9f1695351b201767cc5ed32877fb395c1e459bc8 Signed-off-by: CHLin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2272419 Reviewed-by: Aseda Aboagye Commit-Queue: CH Lin Commit-Queue: Aseda Aboagye Tested-by: CH Lin --- chip/npcx/spiflashfw/npcx_monitor.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'chip/npcx') diff --git a/chip/npcx/spiflashfw/npcx_monitor.c b/chip/npcx/spiflashfw/npcx_monitor.c index a0b011476d..cd52e7a80f 100644 --- a/chip/npcx/spiflashfw/npcx_monitor.c +++ b/chip/npcx/spiflashfw/npcx_monitor.c @@ -294,8 +294,15 @@ sspi_flash_upload(int spi_offset, int spi_size) /* UMA Unlock */ CLEAR_BIT(NPCX_UMA_ECTS, NPCX_UMA_ECTS_UMA_LOCK); - /* Set pinmux first */ - sspi_flash_pinmux(1); + /* + * If UUT is used, assuming the target is the internal flash. + * Don't switch the pinmux and make sure bit 7 of DEVALT0 is set. + */ + if (uut_tag == NPCX_MONITOR_UUT_TAG) + SET_BIT(NPCX_DEVALT(0), NPCX_DEVALT0_NO_F_SPI); + else + /* Set pinmux first */ + sspi_flash_pinmux(1); /* Get size of image automatically */ if (sz_image == 0) @@ -313,8 +320,9 @@ sspi_flash_upload(int spi_offset, int spi_size) if (sspi_flash_verify(spi_offset, sz_image, image_base)) *flag_upload |= 0x02; } - /* Disable pinmux */ - sspi_flash_pinmux(0); + if (uut_tag != NPCX_MONITOR_UUT_TAG) + /* Disable pinmux */ + sspi_flash_pinmux(0); /* Mark we have finished upload work */ *flag_upload |= 0x01; -- cgit v1.2.1