Skip to content

Commit 97f3ca9

Browse files
Tom ChangLeilaCY-Lin
authored andcommitted
drivers: espi: npcx: ensure the host receives the value from eSPI VW
This commit adds an option to verify weather the host has read the value after the wire 3-0 bits have been updated. (cherry picked from commit eb5597e) Original-Signed-off-by: Tom Chang <CHChang19@nuvoton.com> GitOrigin-RevId: eb5597e Cr-Build-Id: 8717253966315925441 Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8717253966315925441 Copybot-Job-Name: zephyr-main-copybot-downstream Change-Id: I861cd5968b7e1d7cb7aac9ea1812ced8c2533873 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/6469084 Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: Keith Short <keithshort@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
1 parent af2f1cc commit 97f3ca9

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

drivers/espi/Kconfig.npcx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ config ESPI_NPCX_PERIPHERAL_DEBUG_PORT_80_RING_BUF_SIZE
6060
The size of the ring buffer in byte used by the Port80 ISR to store
6161
Postcodes from Host.
6262

63+
config ESPI_NPCX_VWIRE_ENABLE_SEND_CHECK
64+
bool "Check the value was read by host after wire bits changed"
65+
help
66+
This option enables the function to check whether the host has read the value
67+
after the wire data changes.
68+
69+
config ESPI_NPCX_WIRE_SEND_TIMEOUT_US
70+
int "eSPI virtual wire send timeout count"
71+
default 1000
72+
help
73+
The times to check status after sending the eSPI virtual wire signal. The unit
74+
is microseconds (µs).
75+
6376
config ESPI_TAF_NPCX
6477
bool "Nuvoton NPCX embedded controller (EC) ESPI TAF driver"
6578
depends on SOC_SERIES_NPCX4

drivers/espi/espi_npcx.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,25 @@ static int espi_npcx_send_vwire(const struct device *dev,
879879
if (signal >= ESPI_VWIRE_SIGNAL_TARGET_GPIO_0) {
880880
SET_FIELD(inst->VWGPSM[reg_idx], NPCX_VWEVSM_WIRE, val);
881881
reg_val = inst->VWGPSM[reg_idx];
882+
883+
if (IS_ENABLED(CONFIG_ESPI_NPCX_VWIRE_ENABLE_SEND_CHECK)) {
884+
if (!WAIT_FOR(!IS_BIT_SET(inst->VWGPSM[reg_idx], NPCX_VWEVSM_DIRTY),
885+
CONFIG_ESPI_NPCX_WIRE_SEND_TIMEOUT_US, NULL)) {
886+
LOG_ERR("%s signal %d timeout", __func__, signal);
887+
return -ETIMEDOUT;
888+
}
889+
}
882890
} else {
883891
SET_FIELD(inst->VWEVSM[reg_idx], NPCX_VWEVSM_WIRE, val);
884892
reg_val = inst->VWEVSM[reg_idx];
893+
894+
if (IS_ENABLED(CONFIG_ESPI_NPCX_VWIRE_ENABLE_SEND_CHECK)) {
895+
if (!WAIT_FOR(!IS_BIT_SET(inst->VWEVSM[reg_idx], NPCX_VWEVSM_DIRTY),
896+
CONFIG_ESPI_NPCX_WIRE_SEND_TIMEOUT_US, NULL)) {
897+
LOG_ERR("%s signal %d timeout", __func__, signal);
898+
return -ETIMEDOUT;
899+
}
900+
}
885901
}
886902

887903
LOG_DBG("Send VW: %s%d 0x%08X", reg_name, reg_idx, reg_val);

soc/nuvoton/npcx/common/npcxn/include/reg_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ struct espi_reg {
727727
#define NPCX_VWEVSM_INDEX FIELD(8, 7)
728728
#define NPCX_VWEVSM_INDEX_EN 15
729729
#define NPCX_VWEVSM_BIT_VALID(n) (4+n)
730+
#define NPCX_VWEVSM_DIRTY 16
730731
#define NPCX_VWEVSM_HW_WIRE FIELD(24, 4)
731732
#define NPCX_VWGPSM_INDEX_EN 15
732733
#define NPCX_OOBCTL_OOB_FREE 0

0 commit comments

Comments
 (0)