Skip to content

Commit edad4af

Browse files
committed
espi/it8xxx2: waiting till completion of VW send to host
On it8xxx2, there are VW transmitted registers indicating that VW signal has been transmitted to host. This patch checks the register to ensure successful transmission of VW state change. fixes: #89298 Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
1 parent 9a409d6 commit edad4af

File tree

1 file changed

+54
-34
lines changed

1 file changed

+54
-34
lines changed

drivers/espi/espi_it8xxx2.c

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ LOG_MODULE_REGISTER(espi, CONFIG_ESPI_LOG_LEVEL);
7676
#define IT8XXX2_ESPI_PUT_FLASH_TAG_MASK GENMASK(7, 4)
7777
#define IT8XXX2_ESPI_PUT_FLASH_LEN_MASK GENMASK(6, 0)
7878

79+
/* Register used to record VWx data transmitted to the eSPI host. */
80+
#define IT8XXX2_ESPI_VW_REC_VW4 0xe1
81+
#define IT8XXX2_ESPI_VW_REC_VW5 0xe2
82+
#define IT8XXX2_ESPI_VW_REC_VW6 0xe3
83+
#define IT8XXX2_ESPI_VW_REC_VW40 0xe4
84+
7985
struct espi_it8xxx2_wuc {
8086
/* WUC control device structure */
8187
const struct device *wucs;
@@ -110,9 +116,10 @@ struct espi_it8xxx2_data {
110116
};
111117

112118
struct vw_channel_t {
113-
uint8_t vw_index; /* VW index of signal */
114-
uint8_t level_mask; /* level bit of signal */
115-
uint8_t valid_mask; /* valid bit of signal */
119+
uint8_t vw_index; /* VW index of signal */
120+
uint8_t level_mask; /* level bit of signal */
121+
uint8_t valid_mask; /* valid bit of signal */
122+
uint8_t vw_sent_reg; /* vw signal sent to host */
116123
};
117124

118125
struct vwidx_isr_t {
@@ -587,41 +594,44 @@ static void pmc2_it8xxx2_init(const struct device *dev)
587594
}
588595
#endif
589596

597+
#define IT8XXX2_ESPI_VW_SEND_TIMEOUT_US (USEC_PER_MSEC * 10)
598+
590599
/* eSPI api functions */
591-
#define VW_CHAN(signal, index, level, valid) \
592-
[signal] = {.vw_index = index, .level_mask = level, .valid_mask = valid}
600+
#define VW_CHAN(signal, index, level, valid, reg) \
601+
[signal] = {.vw_index = index, .level_mask = level, \
602+
.valid_mask = valid, .vw_sent_reg = reg}
593603

594604
/* VW signals used in eSPI */
595605
static const struct vw_channel_t vw_channel_list[] = {
596-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S3, 0x02, BIT(0), BIT(4)),
597-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S4, 0x02, BIT(1), BIT(5)),
598-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S5, 0x02, BIT(2), BIT(6)),
599-
VW_CHAN(ESPI_VWIRE_SIGNAL_OOB_RST_WARN, 0x03, BIT(2), BIT(6)),
600-
VW_CHAN(ESPI_VWIRE_SIGNAL_PLTRST, 0x03, BIT(1), BIT(5)),
601-
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_STAT, 0x03, BIT(0), BIT(4)),
602-
VW_CHAN(ESPI_VWIRE_SIGNAL_NMIOUT, 0x07, BIT(2), BIT(6)),
603-
VW_CHAN(ESPI_VWIRE_SIGNAL_SMIOUT, 0x07, BIT(1), BIT(5)),
604-
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_RST_WARN, 0x07, BIT(0), BIT(4)),
605-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_A, 0x41, BIT(3), BIT(7)),
606-
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_PWRDN_ACK, 0x41, BIT(1), BIT(5)),
607-
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_WARN, 0x41, BIT(0), BIT(4)),
608-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_WLAN, 0x42, BIT(1), BIT(5)),
609-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_LAN, 0x42, BIT(0), BIT(4)),
610-
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_C10, 0x47, BIT(0), BIT(4)),
611-
VW_CHAN(ESPI_VWIRE_SIGNAL_DNX_WARN, 0x4a, BIT(1), BIT(5)),
612-
VW_CHAN(ESPI_VWIRE_SIGNAL_PME, 0x04, BIT(3), BIT(7)),
613-
VW_CHAN(ESPI_VWIRE_SIGNAL_WAKE, 0x04, BIT(2), BIT(6)),
614-
VW_CHAN(ESPI_VWIRE_SIGNAL_OOB_RST_ACK, 0x04, BIT(0), BIT(4)),
615-
VW_CHAN(ESPI_VWIRE_SIGNAL_TARGET_BOOT_STS, 0x05, BIT(3), BIT(7)),
616-
VW_CHAN(ESPI_VWIRE_SIGNAL_ERR_NON_FATAL, 0x05, BIT(2), BIT(6)),
617-
VW_CHAN(ESPI_VWIRE_SIGNAL_ERR_FATAL, 0x05, BIT(1), BIT(5)),
618-
VW_CHAN(ESPI_VWIRE_SIGNAL_TARGET_BOOT_DONE, 0x05, BIT(0), BIT(4)),
619-
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_RST_ACK, 0x06, BIT(3), BIT(7)),
620-
VW_CHAN(ESPI_VWIRE_SIGNAL_RST_CPU_INIT, 0x06, BIT(2), BIT(6)),
621-
VW_CHAN(ESPI_VWIRE_SIGNAL_SMI, 0x06, BIT(1), BIT(5)),
622-
VW_CHAN(ESPI_VWIRE_SIGNAL_SCI, 0x06, BIT(0), BIT(4)),
623-
VW_CHAN(ESPI_VWIRE_SIGNAL_DNX_ACK, 0x40, BIT(1), BIT(5)),
624-
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_ACK, 0x40, BIT(0), BIT(4)),
606+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S3, 0x02, BIT(0), BIT(4), 0),
607+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S4, 0x02, BIT(1), BIT(5), 0),
608+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S5, 0x02, BIT(2), BIT(6), 0),
609+
VW_CHAN(ESPI_VWIRE_SIGNAL_OOB_RST_WARN, 0x03, BIT(2), BIT(6), 0),
610+
VW_CHAN(ESPI_VWIRE_SIGNAL_PLTRST, 0x03, BIT(1), BIT(5), 0),
611+
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_STAT, 0x03, BIT(0), BIT(4), 0),
612+
VW_CHAN(ESPI_VWIRE_SIGNAL_NMIOUT, 0x07, BIT(2), BIT(6), 0),
613+
VW_CHAN(ESPI_VWIRE_SIGNAL_SMIOUT, 0x07, BIT(1), BIT(5), 0),
614+
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_RST_WARN, 0x07, BIT(0), BIT(4), 0),
615+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_A, 0x41, BIT(3), BIT(7), 0),
616+
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_PWRDN_ACK, 0x41, BIT(1), BIT(5), 0),
617+
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_WARN, 0x41, BIT(0), BIT(4), 0),
618+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_WLAN, 0x42, BIT(1), BIT(5), 0),
619+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_LAN, 0x42, BIT(0), BIT(4), 0),
620+
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_C10, 0x47, BIT(0), BIT(4), 0),
621+
VW_CHAN(ESPI_VWIRE_SIGNAL_DNX_WARN, 0x4a, BIT(1), BIT(5), 0),
622+
VW_CHAN(ESPI_VWIRE_SIGNAL_PME, 0x04, BIT(3), BIT(7), IT8XXX2_ESPI_VW_REC_VW4),
623+
VW_CHAN(ESPI_VWIRE_SIGNAL_WAKE, 0x04, BIT(2), BIT(6), IT8XXX2_ESPI_VW_REC_VW4),
624+
VW_CHAN(ESPI_VWIRE_SIGNAL_OOB_RST_ACK, 0x04, BIT(0), BIT(4), IT8XXX2_ESPI_VW_REC_VW4),
625+
VW_CHAN(ESPI_VWIRE_SIGNAL_TARGET_BOOT_STS, 0x05, BIT(3), BIT(7), IT8XXX2_ESPI_VW_REC_VW5),
626+
VW_CHAN(ESPI_VWIRE_SIGNAL_ERR_NON_FATAL, 0x05, BIT(2), BIT(6), IT8XXX2_ESPI_VW_REC_VW5),
627+
VW_CHAN(ESPI_VWIRE_SIGNAL_ERR_FATAL, 0x05, BIT(1), BIT(5), IT8XXX2_ESPI_VW_REC_VW5),
628+
VW_CHAN(ESPI_VWIRE_SIGNAL_TARGET_BOOT_DONE, 0x05, BIT(0), BIT(4), IT8XXX2_ESPI_VW_REC_VW5),
629+
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_RST_ACK, 0x06, BIT(3), BIT(7), IT8XXX2_ESPI_VW_REC_VW6),
630+
VW_CHAN(ESPI_VWIRE_SIGNAL_RST_CPU_INIT, 0x06, BIT(2), BIT(6), IT8XXX2_ESPI_VW_REC_VW6),
631+
VW_CHAN(ESPI_VWIRE_SIGNAL_SMI, 0x06, BIT(1), BIT(5), IT8XXX2_ESPI_VW_REC_VW6),
632+
VW_CHAN(ESPI_VWIRE_SIGNAL_SCI, 0x06, BIT(0), BIT(4), IT8XXX2_ESPI_VW_REC_VW6),
633+
VW_CHAN(ESPI_VWIRE_SIGNAL_DNX_ACK, 0x40, BIT(1), BIT(5), IT8XXX2_ESPI_VW_REC_VW40),
634+
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_ACK, 0x40, BIT(0), BIT(4), IT8XXX2_ESPI_VW_REC_VW40),
625635
};
626636

627637
static int espi_it8xxx2_configure(const struct device *dev,
@@ -704,6 +714,7 @@ static int espi_it8xxx2_send_vwire(const struct device *dev,
704714
uint8_t vw_index = vw_channel_list[signal].vw_index;
705715
uint8_t level_mask = vw_channel_list[signal].level_mask;
706716
uint8_t valid_mask = vw_channel_list[signal].valid_mask;
717+
uint8_t vw_sent = vw_channel_list[signal].vw_sent_reg;
707718

708719
if (signal > ARRAY_SIZE(vw_channel_list)) {
709720
return -EIO;
@@ -717,6 +728,15 @@ static int espi_it8xxx2_send_vwire(const struct device *dev,
717728

718729
vw_reg->VW_INDEX[vw_index] |= valid_mask;
719730

731+
if (espi_it8xxx2_channel_ready(dev, ESPI_CHANNEL_VWIRE) && vw_sent) {
732+
if (!WAIT_FOR(vw_reg->VW_INDEX[vw_index] ==
733+
sys_read8(config->base_espi_vw + vw_sent),
734+
IT8XXX2_ESPI_VW_SEND_TIMEOUT_US, k_busy_wait(10))) {
735+
LOG_WRN("VW send to host has timed out vw[0x%x] = 0x%x",
736+
vw_index, vw_reg->VW_INDEX[vw_index]);
737+
}
738+
}
739+
720740
return 0;
721741
}
722742

0 commit comments

Comments
 (0)