Skip to content

Commit 4dabf18

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 e22ca6b commit 4dabf18

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
@@ -648,6 +648,12 @@ IT8XXX2_ESPI_REG_SIZE_CHECK(espi_queue1_regs, 0xc0);
648648
IT8XXX2_ESPI_REG_OFFSET_CHECK(espi_queue1_regs, UPSTREAM_DATA, 0x00);
649649
IT8XXX2_ESPI_REG_OFFSET_CHECK(espi_queue1_regs, PUT_FLASH_NP_DATA, 0x80);
650650

651+
/* Register used to record VWx data transmitted to the eSPI host. */
652+
#define IT8XXX2_ESPI_VW_REC_VW4 0xe1
653+
#define IT8XXX2_ESPI_VW_REC_VW5 0xe2
654+
#define IT8XXX2_ESPI_VW_REC_VW6 0xe3
655+
#define IT8XXX2_ESPI_VW_REC_VW40 0xe4
656+
651657
struct espi_it8xxx2_wuc {
652658
/* WUC control device structure */
653659
const struct device *wucs;
@@ -682,9 +688,10 @@ struct espi_it8xxx2_data {
682688
};
683689

684690
struct vw_channel_t {
685-
uint8_t vw_index; /* VW index of signal */
686-
uint8_t level_mask; /* level bit of signal */
687-
uint8_t valid_mask; /* valid bit of signal */
691+
uint8_t vw_index; /* VW index of signal */
692+
uint8_t level_mask; /* level bit of signal */
693+
uint8_t valid_mask; /* valid bit of signal */
694+
uint8_t vw_sent_reg; /* vw signal sent to host */
688695
};
689696

690697
struct vwidx_isr_t {
@@ -1171,41 +1178,44 @@ static void pmc2_it8xxx2_init(const struct device *dev)
11711178
}
11721179
#endif
11731180

1181+
#define IT8XXX2_ESPI_VW_SEND_TIMEOUT_US (USEC_PER_MSEC * 10)
1182+
11741183
/* eSPI api functions */
1175-
#define VW_CHAN(signal, index, level, valid) \
1176-
[signal] = {.vw_index = index, .level_mask = level, .valid_mask = valid}
1184+
#define VW_CHAN(signal, index, level, valid, reg) \
1185+
[signal] = {.vw_index = index, .level_mask = level, \
1186+
.valid_mask = valid, .vw_sent_reg = reg}
11771187

11781188
/* VW signals used in eSPI */
11791189
static const struct vw_channel_t vw_channel_list[] = {
1180-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S3, 0x02, BIT(0), BIT(4)),
1181-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S4, 0x02, BIT(1), BIT(5)),
1182-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S5, 0x02, BIT(2), BIT(6)),
1183-
VW_CHAN(ESPI_VWIRE_SIGNAL_OOB_RST_WARN, 0x03, BIT(2), BIT(6)),
1184-
VW_CHAN(ESPI_VWIRE_SIGNAL_PLTRST, 0x03, BIT(1), BIT(5)),
1185-
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_STAT, 0x03, BIT(0), BIT(4)),
1186-
VW_CHAN(ESPI_VWIRE_SIGNAL_NMIOUT, 0x07, BIT(2), BIT(6)),
1187-
VW_CHAN(ESPI_VWIRE_SIGNAL_SMIOUT, 0x07, BIT(1), BIT(5)),
1188-
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_RST_WARN, 0x07, BIT(0), BIT(4)),
1189-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_A, 0x41, BIT(3), BIT(7)),
1190-
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_PWRDN_ACK, 0x41, BIT(1), BIT(5)),
1191-
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_WARN, 0x41, BIT(0), BIT(4)),
1192-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_WLAN, 0x42, BIT(1), BIT(5)),
1193-
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_LAN, 0x42, BIT(0), BIT(4)),
1194-
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_C10, 0x47, BIT(0), BIT(4)),
1195-
VW_CHAN(ESPI_VWIRE_SIGNAL_DNX_WARN, 0x4a, BIT(1), BIT(5)),
1196-
VW_CHAN(ESPI_VWIRE_SIGNAL_PME, 0x04, BIT(3), BIT(7)),
1197-
VW_CHAN(ESPI_VWIRE_SIGNAL_WAKE, 0x04, BIT(2), BIT(6)),
1198-
VW_CHAN(ESPI_VWIRE_SIGNAL_OOB_RST_ACK, 0x04, BIT(0), BIT(4)),
1199-
VW_CHAN(ESPI_VWIRE_SIGNAL_TARGET_BOOT_STS, 0x05, BIT(3), BIT(7)),
1200-
VW_CHAN(ESPI_VWIRE_SIGNAL_ERR_NON_FATAL, 0x05, BIT(2), BIT(6)),
1201-
VW_CHAN(ESPI_VWIRE_SIGNAL_ERR_FATAL, 0x05, BIT(1), BIT(5)),
1202-
VW_CHAN(ESPI_VWIRE_SIGNAL_TARGET_BOOT_DONE, 0x05, BIT(0), BIT(4)),
1203-
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_RST_ACK, 0x06, BIT(3), BIT(7)),
1204-
VW_CHAN(ESPI_VWIRE_SIGNAL_RST_CPU_INIT, 0x06, BIT(2), BIT(6)),
1205-
VW_CHAN(ESPI_VWIRE_SIGNAL_SMI, 0x06, BIT(1), BIT(5)),
1206-
VW_CHAN(ESPI_VWIRE_SIGNAL_SCI, 0x06, BIT(0), BIT(4)),
1207-
VW_CHAN(ESPI_VWIRE_SIGNAL_DNX_ACK, 0x40, BIT(1), BIT(5)),
1208-
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_ACK, 0x40, BIT(0), BIT(4)),
1190+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S3, 0x02, BIT(0), BIT(4), 0),
1191+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S4, 0x02, BIT(1), BIT(5), 0),
1192+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_S5, 0x02, BIT(2), BIT(6), 0),
1193+
VW_CHAN(ESPI_VWIRE_SIGNAL_OOB_RST_WARN, 0x03, BIT(2), BIT(6), 0),
1194+
VW_CHAN(ESPI_VWIRE_SIGNAL_PLTRST, 0x03, BIT(1), BIT(5), 0),
1195+
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_STAT, 0x03, BIT(0), BIT(4), 0),
1196+
VW_CHAN(ESPI_VWIRE_SIGNAL_NMIOUT, 0x07, BIT(2), BIT(6), 0),
1197+
VW_CHAN(ESPI_VWIRE_SIGNAL_SMIOUT, 0x07, BIT(1), BIT(5), 0),
1198+
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_RST_WARN, 0x07, BIT(0), BIT(4), 0),
1199+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_A, 0x41, BIT(3), BIT(7), 0),
1200+
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_PWRDN_ACK, 0x41, BIT(1), BIT(5), 0),
1201+
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_WARN, 0x41, BIT(0), BIT(4), 0),
1202+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_WLAN, 0x42, BIT(1), BIT(5), 0),
1203+
VW_CHAN(ESPI_VWIRE_SIGNAL_SLP_LAN, 0x42, BIT(0), BIT(4), 0),
1204+
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_C10, 0x47, BIT(0), BIT(4), 0),
1205+
VW_CHAN(ESPI_VWIRE_SIGNAL_DNX_WARN, 0x4a, BIT(1), BIT(5), 0),
1206+
VW_CHAN(ESPI_VWIRE_SIGNAL_PME, 0x04, BIT(3), BIT(7), IT8XXX2_ESPI_VW_REC_VW4),
1207+
VW_CHAN(ESPI_VWIRE_SIGNAL_WAKE, 0x04, BIT(2), BIT(6), IT8XXX2_ESPI_VW_REC_VW4),
1208+
VW_CHAN(ESPI_VWIRE_SIGNAL_OOB_RST_ACK, 0x04, BIT(0), BIT(4), IT8XXX2_ESPI_VW_REC_VW4),
1209+
VW_CHAN(ESPI_VWIRE_SIGNAL_TARGET_BOOT_STS, 0x05, BIT(3), BIT(7), IT8XXX2_ESPI_VW_REC_VW5),
1210+
VW_CHAN(ESPI_VWIRE_SIGNAL_ERR_NON_FATAL, 0x05, BIT(2), BIT(6), IT8XXX2_ESPI_VW_REC_VW5),
1211+
VW_CHAN(ESPI_VWIRE_SIGNAL_ERR_FATAL, 0x05, BIT(1), BIT(5), IT8XXX2_ESPI_VW_REC_VW5),
1212+
VW_CHAN(ESPI_VWIRE_SIGNAL_TARGET_BOOT_DONE, 0x05, BIT(0), BIT(4), IT8XXX2_ESPI_VW_REC_VW5),
1213+
VW_CHAN(ESPI_VWIRE_SIGNAL_HOST_RST_ACK, 0x06, BIT(3), BIT(7), IT8XXX2_ESPI_VW_REC_VW6),
1214+
VW_CHAN(ESPI_VWIRE_SIGNAL_RST_CPU_INIT, 0x06, BIT(2), BIT(6), IT8XXX2_ESPI_VW_REC_VW6),
1215+
VW_CHAN(ESPI_VWIRE_SIGNAL_SMI, 0x06, BIT(1), BIT(5), IT8XXX2_ESPI_VW_REC_VW6),
1216+
VW_CHAN(ESPI_VWIRE_SIGNAL_SCI, 0x06, BIT(0), BIT(4), IT8XXX2_ESPI_VW_REC_VW6),
1217+
VW_CHAN(ESPI_VWIRE_SIGNAL_DNX_ACK, 0x40, BIT(1), BIT(5), IT8XXX2_ESPI_VW_REC_VW40),
1218+
VW_CHAN(ESPI_VWIRE_SIGNAL_SUS_ACK, 0x40, BIT(0), BIT(4), IT8XXX2_ESPI_VW_REC_VW40),
12091219
};
12101220

12111221
static int espi_it8xxx2_configure(const struct device *dev,
@@ -1288,6 +1298,7 @@ static int espi_it8xxx2_send_vwire(const struct device *dev,
12881298
uint8_t vw_index = vw_channel_list[signal].vw_index;
12891299
uint8_t level_mask = vw_channel_list[signal].level_mask;
12901300
uint8_t valid_mask = vw_channel_list[signal].valid_mask;
1301+
uint8_t vw_sent = vw_channel_list[signal].vw_sent_reg;
12911302

12921303
if (signal > ARRAY_SIZE(vw_channel_list)) {
12931304
return -EIO;
@@ -1301,6 +1312,15 @@ static int espi_it8xxx2_send_vwire(const struct device *dev,
13011312

13021313
vw_reg->VW_INDEX[vw_index] |= valid_mask;
13031314

1315+
if (espi_it8xxx2_channel_ready(dev, ESPI_CHANNEL_VWIRE) && vw_sent) {
1316+
if (!WAIT_FOR(vw_reg->VW_INDEX[vw_index] ==
1317+
sys_read8(config->base_espi_vw + vw_sent),
1318+
IT8XXX2_ESPI_VW_SEND_TIMEOUT_US, k_busy_wait(10))) {
1319+
LOG_WRN("VW send to host has timed out vw[0x%x] = 0x%x",
1320+
vw_index, vw_reg->VW_INDEX[vw_index]);
1321+
}
1322+
}
1323+
13041324
return 0;
13051325
}
13061326

0 commit comments

Comments
 (0)