From: Quan Nguyen <quan@os.amperecomputing.com>
To: Randy Dunlap <rdunlap@infradead.org>,
Wolfram Sang <wsa@kernel.org>, Corey Minyard <minyard@acm.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Brendan Higgins <brendan.higgins@linux.dev>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>,
openipmi-developer@lists.sourceforge.net,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org,
Open Source Submission <patches@amperecomputing.com>
Cc: Phong Vo <phong@os.amperecomputing.com>,
thang@os.amperecomputing.com,
Quan Nguyen <quan@os.amperecomputing.com>
Subject: [PATCH v9 3/3] i2c: aspeed: Assert NAK when slave is busy
Date: Thu, 29 Sep 2022 15:03:26 +0700 [thread overview]
Message-ID: <20220929080326.752907-4-quan@os.amperecomputing.com> (raw)
In-Reply-To: <20220929080326.752907-1-quan@os.amperecomputing.com>
On I2C_SLAVE_WRITE_REQUESTED event, Slave already ACK'ed on the address
phase. But as the backend driver is busy and unable to process any
request from Master, issue RxCmdLast for Slave to auto send NACK on
next incoming byte.
Signed-off-by: Quan Nguyen <quan@os.amperecomputing.com>
---
v9:
+ Update commit message and add comment to explain
the effect of issuing RxCmdLast when Slave busy [Quan]
v7 -> v8:
+ None
v6:
+ New introduced in v6 [Quan]
drivers/i2c/busses/i2c-aspeed.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 185dedfebbac..3d70f1ce6c6a 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -244,6 +244,7 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
u32 command, irq_handled = 0;
struct i2c_client *slave = bus->slave;
u8 value;
+ int ret;
if (!slave)
return 0;
@@ -311,7 +312,13 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
break;
case ASPEED_I2C_SLAVE_WRITE_REQUESTED:
bus->slave_state = ASPEED_I2C_SLAVE_WRITE_RECEIVED;
- i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value);
+ ret = i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value);
+ /*
+ * Slave ACK's on this address phase already but as the backend driver insists it
+ * is busy, turn on RxCmdLast for Slave to NACK on the next Rx byte.
+ */
+ if (ret == -EBUSY)
+ writel(ASPEED_I2CD_M_S_RX_CMD_LAST, bus->base + ASPEED_I2C_CMD_REG);
break;
case ASPEED_I2C_SLAVE_WRITE_RECEIVED:
i2c_slave_event(slave, I2C_SLAVE_WRITE_RECEIVED, &value);
--
2.35.1
next prev parent reply other threads:[~2022-09-29 8:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-29 8:03 [PATCH v9 0/3] Add SSIF BMC driver Quan Nguyen
2022-09-29 8:03 ` [PATCH v9 1/3] ipmi: ssif_bmc: " Quan Nguyen
2022-09-29 8:03 ` [PATCH v9 2/3] bindings: ipmi: Add binding for " Quan Nguyen
2022-09-29 8:03 ` Quan Nguyen [this message]
2022-10-01 22:55 ` [PATCH v9 3/3] i2c: aspeed: Assert NAK when slave is busy Wolfram Sang
2022-10-03 2:06 ` Quan Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220929080326.752907-4-quan@os.amperecomputing.com \
--to=quan@os.amperecomputing.com \
--cc=andrew@aj.id.au \
--cc=benh@kernel.crashing.org \
--cc=brendan.higgins@linux.dev \
--cc=devicetree@vger.kernel.org \
--cc=joel@jms.id.au \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minyard@acm.org \
--cc=openbmc@lists.ozlabs.org \
--cc=openipmi-developer@lists.sourceforge.net \
--cc=patches@amperecomputing.com \
--cc=phong@os.amperecomputing.com \
--cc=rdunlap@infradead.org \
--cc=robh+dt@kernel.org \
--cc=thang@os.amperecomputing.com \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).