Skip to content

Commit

Permalink
Merge pull request zephyrproject-rtos#10 from FrameworkComputer/fwk.s…
Browse files Browse the repository at this point in the history
…upport_amd_zstate

fwk: support virtual wire index 33h for AMD zstate
  • Loading branch information
kiram9 authored Oct 3, 2023
2 parents 65ae0b1 + a0d6c69 commit 29ee081
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions drivers/espi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ config ESPI_FLASH_CHANNEL
help
eSPI Controller supports flash channel.

if ESPI_VWIRE_CHANNEL

config ESPI_VWIRE_INDEX_33H
bool "Enable virtual wire index 33h"
default n
help
AMD z-state use the virtual wire index 33h to notify the system state
to EC.

endif #ESPI_VWIRE_CHANNEL

if ESPI_PERIPHERAL_CHANNEL

config ESPI_PERIPHERAL_UART
Expand Down
25 changes: 24 additions & 1 deletion drivers/espi/espi_npcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,26 @@ static void espi_vw_config_input(const struct device *dev,
LOG_DBG("VWEVMS%d 0x%08X", idx, inst->VWEVMS[idx]);
}

#if defined(CONFIG_ESPI_VWIRE_INDEX_33H)
/* eSPI local virtual-wire 33h service functions */
static void espi_vw_config_33h_input(const struct device *dev)
{
struct espi_reg *const inst = HAL_INSTANCE(dev);
const int idx = 8;

SET_FIELD(inst->VWEVMS[idx], NPCX_VWEVMS_INDEX, 0x33);

/* IE & WE bits are already set? */
if (IS_BIT_SET(inst->VWEVMS[idx], NPCX_VWEVMS_IE) &&
IS_BIT_SET(inst->VWEVMS[idx], NPCX_VWEVMS_WE))
return;

/* Set IE & WE bits in VWEVMS */
inst->VWEVMS[idx] |= BIT(NPCX_VWEVMS_IE) | BIT(NPCX_VWEVMS_WE) | BIT(NPCX_VWEVMS_INDEX_EN);
LOG_DBG("33h VWEVMS%d 0x%08X", idx, inst->VWEVMS[idx]);
}
#endif

static void espi_vw_config_output(const struct device *dev,
const struct npcx_vw_out_config *config_out)
{
Expand Down Expand Up @@ -1239,7 +1259,10 @@ static int espi_npcx_init(const struct device *dev)
/* Configure Virtual Wire input signals */
for (i = 0; i < ARRAY_SIZE(vw_in_tbl); i++)
espi_vw_config_input(dev, &vw_in_tbl[i]);

#if defined(CONFIG_ESPI_VWIRE_INDEX_33H)
/* Configure Virtual Wire index 33h */
espi_vw_config_33h_input(dev);
#endif
/* Configure Virtual Wire output signals */
for (i = 0; i < ARRAY_SIZE(vw_out_tbl); i++)
espi_vw_config_output(dev, &vw_out_tbl[i]);
Expand Down
2 changes: 2 additions & 0 deletions soc/arm/nuvoton_npcx/common/reg/reg_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,8 @@ struct espi_reg {
#define NPCX_ESPISTS_ESPIRST_LVL 24
#define NPCX_VWEVMS_WIRE FIELD(0, 4)
#define NPCX_VWEVMS_VALID FIELD(4, 4)
#define NPCX_VWEVMS_INDEX FIELD(8, 7)
#define NPCX_VWEVMS_INDEX_EN 15
#define NPCX_VWEVMS_IE 18
#define NPCX_VWEVMS_WE 20
#define NPCX_VWEVSM_WIRE FIELD(0, 4)
Expand Down

0 comments on commit 29ee081

Please sign in to comment.