drivers: espi: espi_mchp_xec: Fix the VW change check time

Adjusted the VW change check timings:
- Polling time changed from 100 uSec to 1 uSec.
- Timeout value changed from 10 mSec to 1 mSec.

This is to achieve the lowest possible pulse width for SCI VW in S0,
while ensuring that the VW change check is still reliable for S0iX
where SoC may take longer to process upstream events.

Also added -ETIMEDOUT error when failure.

Signed-off-by: Aditya Bhutada <aditya.bhutada@intel.com>
This commit is contained in:
Aditya Bhutada 2025-04-14 14:14:57 -07:00 committed by Benjamin Cabé
commit 2c36616dd2
2 changed files with 18 additions and 8 deletions

View file

@ -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
@ -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;
}
}

View file

@ -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
@ -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;
}
}