Skip to content

Commit 2c36616

Browse files
AdiIntelkartben
authored andcommitted
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>
1 parent 9cadc8c commit 2c36616

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

drivers/espi/espi_mchp_xec.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#define ESPI_XEC_VWIRE_ACK_DELAY 10ul
2020

2121
/* Maximum timeout to transmit a virtual wire packet.
22-
* 10 ms expressed in multiples of 100us
22+
* 1 ms expressed in multiples of 1us
2323
*/
24-
#define ESPI_XEC_VWIRE_SEND_TIMEOUT 100ul
24+
#define ESPI_XEC_VWIRE_SEND_TIMEOUT 1000ul
2525

2626
#define VW_MAX_GIRQS 2ul
2727

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

466466
while (reg->SRC_CHG && rd_cnt--) {
467-
k_busy_wait(100);
467+
k_busy_wait(1);
468+
}
469+
470+
if (rd_cnt == 0) {
471+
LOG_ERR("VW %d send timeout", signal);
472+
return -ETIMEDOUT;
468473
}
469474
}
470475

drivers/espi/espi_mchp_xec_v2.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#define ESPI_XEC_VWIRE_ACK_DELAY 10ul
2626

2727
/* Maximum timeout to transmit a virtual wire packet.
28-
* 10 ms expressed in multiples of 100us
28+
* 1 ms expressed in multiples of 1us
2929
*/
30-
#define ESPI_XEC_VWIRE_SEND_TIMEOUT 100ul
30+
#define ESPI_XEC_VWIRE_SEND_TIMEOUT 1000ul
3131

3232
#define VW_MAX_GIRQS 2ul
3333

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

330330
while (sys_read8(regaddr + SMVW_BI_SRC_CHG) && rd_cnt--) {
331-
k_busy_wait(100);
331+
k_busy_wait(1);
332+
}
333+
334+
if (rd_cnt == 0) {
335+
LOG_ERR("VW %d send timeout", signal);
336+
return -ETIMEDOUT;
332337
}
333338
}
334339

0 commit comments

Comments
 (0)