Skip to content

Commit 3f95fd4

Browse files
vphiremanashif
authored andcommitted
eSPI: NPCX/ITE: Enable conditional virtual wire valid bit check
On the new Intel SoC, the "Valid" bit of the Virtual Wire is set only for Virtual Wires that undergo changes. This behavior differs from previous generations. Therefore, to maintain backward compatibility, a conditional check for the virtual wire valid bit is added for processing the virtual wire level. Signed-off-by: Vijay Hiremath <[email protected]>
1 parent 7e7e1aa commit 3f95fd4

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

drivers/espi/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ config ESPI_VWIRE_CHANNEL
4646
help
4747
eSPI Controller supports virtual wires channel.
4848

49+
config ESPI_VWIRE_VALID_BIT_CHECK
50+
bool "eSPI virtual wire valid bit check"
51+
default y
52+
depends on ESPI_VWIRE_CHANNEL
53+
help
54+
Enable the checking of the eSPI virtual wire valid bit. If this
55+
configuration is not set, treat the new values as the previously
56+
retained valid values and return the received virtual wire level.
57+
4958
config ESPI_AUTOMATIC_WARNING_ACKNOWLEDGE
5059
bool "Automatic acknowledge for eSPI HOST warnings"
5160
default y

drivers/espi/espi_it8xxx2.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,15 @@ static int espi_it8xxx2_receive_vwire(const struct device *dev,
730730
return -EIO;
731731
}
732732

733-
if (vw_reg->VW_INDEX[vw_index] & valid_mask) {
734-
*level = !!(vw_reg->VW_INDEX[vw_index] & level_mask);
733+
if (IS_ENABLED(CONFIG_ESPI_VWIRE_VALID_BIT_CHECK)) {
734+
if (vw_reg->VW_INDEX[vw_index] & valid_mask) {
735+
*level = !!(vw_reg->VW_INDEX[vw_index] & level_mask);
736+
} else {
737+
/* Not valid */
738+
*level = 0;
739+
}
735740
} else {
736-
/* Not valid */
737-
*level = 0;
741+
*level = !!(vw_reg->VW_INDEX[vw_index] & level_mask);
738742
}
739743

740744
return 0;

drivers/espi/espi_npcx.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,11 @@ static int espi_npcx_receive_vwire(const struct device *dev,
872872

873873
val = GET_FIELD(inst->VWEVMS[reg_idx],
874874
NPCX_VWEVMS_WIRE);
875-
val &= GET_FIELD(inst->VWEVMS[reg_idx],
875+
876+
if (IS_ENABLED(CONFIG_ESPI_VWIRE_VALID_BIT_CHECK)) {
877+
val &= GET_FIELD(inst->VWEVMS[reg_idx],
876878
NPCX_VWEVMS_VALID);
879+
}
877880

878881
*level = !!(val & bitmask);
879882
return 0;
@@ -888,8 +891,12 @@ static int espi_npcx_receive_vwire(const struct device *dev,
888891

889892
val = GET_FIELD(inst->VWEVSM[reg_idx],
890893
NPCX_VWEVSM_WIRE);
891-
val &= GET_FIELD(inst->VWEVSM[reg_idx],
894+
895+
if (IS_ENABLED(CONFIG_ESPI_VWIRE_VALID_BIT_CHECK)) {
896+
val &= GET_FIELD(inst->VWEVSM[reg_idx],
892897
NPCX_VWEVSM_VALID);
898+
}
899+
893900
*level = !!(val & bitmask);
894901
return 0;
895902
}

0 commit comments

Comments
 (0)