From 7d1c15d09e6f9e5ad84f9e9893ab71258ff6e521 Mon Sep 17 00:00:00 2001 From: Johannes Meister Date: Thu, 24 Feb 2022 08:06:27 +0100 Subject: [PATCH] drivers: peci: xec: Handle PECI command PING properly Handle PECI command PING properly, also get Write FCS Byte as a check. Now it is possible to perform a PECI Ping without crashing the bus or blocking it for subsequent PECI transactions. It is also possible to check whether the Ping was sucessful or not with the Write FCS Byte. Signed-off-by: Johannes Meister --- drivers/peci/peci_mchp_xec.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/peci/peci_mchp_xec.c b/drivers/peci/peci_mchp_xec.c index 0535a1ac8a2..6bb15527461 100644 --- a/drivers/peci/peci_mchp_xec.c +++ b/drivers/peci/peci_mchp_xec.c @@ -313,6 +313,12 @@ static int peci_xec_read(const struct device *dev, struct peci_msg *msg) /* Get write block FCS just for debug */ tx_fcs = regs->RD_DATA; LOG_DBG("TX FCS %x", tx_fcs); + + /* If a Ping is done, write Tx fcs to rx buffer*/ + if (msg->cmd_code == PECI_CMD_PING) { + rx_buf->buf[0] = tx_fcs; + break; + } } else if (i == (rx_buf->len + 1)) { /* Get read block FCS, but don't count it */ rx_buf->buf[i-1] = regs->RD_DATA; @@ -353,8 +359,9 @@ static int peci_xec_transfer(const struct device *dev, struct peci_msg *msg) /* If a PECI transmission is successful, it may or not involve * a read operation, check if transaction expects a response + * Also perform a read when PECI cmd is Ping to get Write FCS */ - if (msg->rx_buffer.len) { + if (msg->rx_buffer.len || (msg->cmd_code == PECI_CMD_PING)) { ret = peci_xec_read(dev, msg); if (ret) { return ret;