Skip to content

Commit a0d6c69

Browse files
committed
fwk: support virtual wire index 33h for AMD zstate
Signed-off-by: Josh-Tsai <[email protected]>
1 parent 65ae0b1 commit a0d6c69

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

drivers/espi/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ config ESPI_FLASH_CHANNEL
7979
help
8080
eSPI Controller supports flash channel.
8181

82+
if ESPI_VWIRE_CHANNEL
83+
84+
config ESPI_VWIRE_INDEX_33H
85+
bool "Enable virtual wire index 33h"
86+
default n
87+
help
88+
AMD z-state use the virtual wire index 33h to notify the system state
89+
to EC.
90+
91+
endif #ESPI_VWIRE_CHANNEL
92+
8293
if ESPI_PERIPHERAL_CHANNEL
8394

8495
config ESPI_PERIPHERAL_UART

drivers/espi/espi_npcx.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,26 @@ static void espi_vw_config_input(const struct device *dev,
352352
LOG_DBG("VWEVMS%d 0x%08X", idx, inst->VWEVMS[idx]);
353353
}
354354

355+
#if defined(CONFIG_ESPI_VWIRE_INDEX_33H)
356+
/* eSPI local virtual-wire 33h service functions */
357+
static void espi_vw_config_33h_input(const struct device *dev)
358+
{
359+
struct espi_reg *const inst = HAL_INSTANCE(dev);
360+
const int idx = 8;
361+
362+
SET_FIELD(inst->VWEVMS[idx], NPCX_VWEVMS_INDEX, 0x33);
363+
364+
/* IE & WE bits are already set? */
365+
if (IS_BIT_SET(inst->VWEVMS[idx], NPCX_VWEVMS_IE) &&
366+
IS_BIT_SET(inst->VWEVMS[idx], NPCX_VWEVMS_WE))
367+
return;
368+
369+
/* Set IE & WE bits in VWEVMS */
370+
inst->VWEVMS[idx] |= BIT(NPCX_VWEVMS_IE) | BIT(NPCX_VWEVMS_WE) | BIT(NPCX_VWEVMS_INDEX_EN);
371+
LOG_DBG("33h VWEVMS%d 0x%08X", idx, inst->VWEVMS[idx]);
372+
}
373+
#endif
374+
355375
static void espi_vw_config_output(const struct device *dev,
356376
const struct npcx_vw_out_config *config_out)
357377
{
@@ -1239,7 +1259,10 @@ static int espi_npcx_init(const struct device *dev)
12391259
/* Configure Virtual Wire input signals */
12401260
for (i = 0; i < ARRAY_SIZE(vw_in_tbl); i++)
12411261
espi_vw_config_input(dev, &vw_in_tbl[i]);
1242-
1262+
#if defined(CONFIG_ESPI_VWIRE_INDEX_33H)
1263+
/* Configure Virtual Wire index 33h */
1264+
espi_vw_config_33h_input(dev);
1265+
#endif
12431266
/* Configure Virtual Wire output signals */
12441267
for (i = 0; i < ARRAY_SIZE(vw_out_tbl); i++)
12451268
espi_vw_config_output(dev, &vw_out_tbl[i]);

soc/arm/nuvoton_npcx/common/reg/reg_def.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,8 @@ struct espi_reg {
760760
#define NPCX_ESPISTS_ESPIRST_LVL 24
761761
#define NPCX_VWEVMS_WIRE FIELD(0, 4)
762762
#define NPCX_VWEVMS_VALID FIELD(4, 4)
763+
#define NPCX_VWEVMS_INDEX FIELD(8, 7)
764+
#define NPCX_VWEVMS_INDEX_EN 15
763765
#define NPCX_VWEVMS_IE 18
764766
#define NPCX_VWEVMS_WE 20
765767
#define NPCX_VWEVSM_WIRE FIELD(0, 4)

0 commit comments

Comments
 (0)