summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWealian Liao <whliao@nuvoton.corp-partner.google.com>2021-12-30 10:23:54 +0800
committerCommit Bot <commit-bot@chromium.org>2022-01-04 23:24:36 +0000
commitf6a281368b487985f6253368a87eebe6c16d5553 (patch)
tree4a100bbd376ca941d9306c8c4e0c4bd30088a8c6
parent7254d0bfe2499f6952c191459248b1fa28fea8cb (diff)
downloadchrome-ec-f6a281368b487985f6253368a87eebe6c16d5553.tar.gz
zephyr: cros_shi_npcx: Change get time API for timeout checking
SHI driver gets an error time from k_uptime_get() API when SHI ISR preempt npcx_itim_evt_isr() which between k_spin_unlock() & sys_clock_announce(). This CL change to use the k_cycle_get_64() for timeout check. So SHI driver will not get the error time for timeout. The Cros shi driver uses 8192us as the shi timeout value. The current Zephyr shi driver uses a timeout value that is close to 10ms. This makes the timing difference between Cros & Zephyr shi driver. This CL also changes the shi timeout back to 8192us. BUG=b:210974566 BRANCH=none TEST=Pass software sync 15 hours Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Ib2bef521e41b46d7c9bad164a6d772d0f25d5097 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3361066 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/drivers/cros_shi/cros_shi_npcx.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/zephyr/drivers/cros_shi/cros_shi_npcx.c b/zephyr/drivers/cros_shi/cros_shi_npcx.c
index a290e320fc..118c0c40ea 100644
--- a/zephyr/drivers/cros_shi/cros_shi_npcx.c
+++ b/zephyr/drivers/cros_shi/cros_shi_npcx.c
@@ -54,7 +54,7 @@ LOG_MODULE_REGISTER(cros_shi, LOG_LEVEL_DBG);
* practically want to run the SHI interface, since running it slower
* significantly impacts firmware update times.
*/
-#define SHI_CMD_RX_TIMEOUT_MS 9
+#define SHI_CMD_RX_TIMEOUT_US 8192
/*
* The AP blindly clocks back bytes over the SPI interface looking for a
@@ -237,7 +237,7 @@ static int shi_read_inbuf_wait(struct shi_reg *const inst, uint32_t szbytes)
*/
while (shi_params.rx_buf ==
inst->IBUF + shi_read_buf_pointer(inst)) {
- if (k_uptime_get() > shi_params.rx_deadline) {
+ if (k_cycle_get_64() >= shi_params.rx_deadline) {
return 0;
}
}
@@ -445,7 +445,8 @@ static void shi_parse_header(struct shi_reg *const inst)
DEBUG_CPRINTF("RV-");
/* Setup deadline time for receiving */
- shi_params.rx_deadline = k_uptime_get() + SHI_CMD_RX_TIMEOUT_MS;
+ shi_params.rx_deadline =
+ k_cycle_get_64() + k_us_to_cyc_near64(SHI_CMD_RX_TIMEOUT_US);
/* Wait for version, command, length bytes */
if (!shi_read_inbuf_wait(inst, 3))