Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions drivers/espi/espi_mchp_xec.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#define ESPI_XEC_VWIRE_ACK_DELAY 10ul

/* Maximum timeout to transmit a virtual wire packet.
* 10 ms expressed in multiples of 100us
* 1 ms expressed in multiples of 1us
*/
#define ESPI_XEC_VWIRE_SEND_TIMEOUT 100ul
#define ESPI_XEC_VWIRE_SEND_TIMEOUT 1000ul

#define VW_MAX_GIRQS 2ul

Expand Down Expand Up @@ -461,10 +461,15 @@ static int espi_xec_send_vwire(const struct device *dev,
/* Ensure eSPI virtual wire packet is transmitted
* There is no interrupt, so need to poll register
*/
uint8_t rd_cnt = ESPI_XEC_VWIRE_SEND_TIMEOUT;
uint16_t rd_cnt = ESPI_XEC_VWIRE_SEND_TIMEOUT;

while (reg->SRC_CHG && rd_cnt--) {
k_busy_wait(100);
k_busy_wait(1);
}

if (rd_cnt == 0) {
LOG_ERR("VW %d send timeout", signal);
return -ETIMEDOUT;
}
}

Expand Down
13 changes: 9 additions & 4 deletions drivers/espi/espi_mchp_xec_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#define ESPI_XEC_VWIRE_ACK_DELAY 10ul

/* Maximum timeout to transmit a virtual wire packet.
* 10 ms expressed in multiples of 100us
* 1 ms expressed in multiples of 1us
*/
#define ESPI_XEC_VWIRE_SEND_TIMEOUT 100ul
#define ESPI_XEC_VWIRE_SEND_TIMEOUT 1000ul

#define VW_MAX_GIRQS 2ul

Expand Down Expand Up @@ -325,10 +325,15 @@ static int espi_xec_send_vwire(const struct device *dev,
/* Ensure eSPI virtual wire packet is transmitted
* There is no interrupt, so need to poll register
*/
uint8_t rd_cnt = ESPI_XEC_VWIRE_SEND_TIMEOUT;
uint16_t rd_cnt = ESPI_XEC_VWIRE_SEND_TIMEOUT;

while (sys_read8(regaddr + SMVW_BI_SRC_CHG) && rd_cnt--) {
k_busy_wait(100);
k_busy_wait(1);
}

if (rd_cnt == 0) {
LOG_ERR("VW %d send timeout", signal);
return -ETIMEDOUT;
}
}

Expand Down
2 changes: 2 additions & 0 deletions include/zephyr/drivers/espi.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,8 @@ static inline int z_impl_espi_write_lpc_request(const struct device *dev,
*
* @retval 0 If successful.
* @retval -EIO General input / output error, failed to send over the bus.
* @retval -EINVAL invalid signal.
* @retval -ETIMEDOUT timeout waiting for eSPI controller to process the VW.
*/
__syscall int espi_send_vwire(const struct device *dev,
enum espi_vwire_signal signal,
Expand Down
Loading