From: Quan Nguyen <quan@os.amperecomputing.com>
To: Wolfram Sang <wsa@kernel.org>, Corey Minyard <minyard@acm.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>,
Brendan Higgins <brendanhiggins@google.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
openipmi-developer@lists.sourceforge.net,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org,
linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org,
Open Source Submission <patches@amperecomputing.com>,
Phong Vo <phong@os.amperecomputing.com>,
"Thang Q . Nguyen" <thang@os.amperecomputing.com>
Subject: Re: [PATCH v7 3/3] i2c: aspeed: Assert NAK when slave is busy
Date: Thu, 16 Jun 2022 14:16:14 +0700 [thread overview]
Message-ID: <bf001ece-e981-3a06-53fe-6a8b637d69fe@os.amperecomputing.com> (raw)
In-Reply-To: <YqpB8A2uBi+4epHM@shikoro>
On 16/06/2022 03:32, Wolfram Sang wrote:
> Hi Quan,
>
>> When tested with ast2500, it is observed that there's always a
>> I2C_SLAVE_WRITE_REQUESTED comes first then other I2C_SLAVE_WRITE_RECEIVED's
>> follow for all transactions.
>
> Yes, that's the design of the interface :)
>
>> In case slave is busy, the NAK will be asserted on the first occurrence of
>> I2C_SLAVE_WRITE_REQUESTED make host to stop the current transaction (host
>> later will retry with other transaction) until slave ready.
>>
>> This behavior is expected as we want host to drop all transactions while
>> slave is busy on working on the response. That is why we choose to assert
>> NAK on the first I2C_SLAVE_WRITE_REQUESTED of the transaction instead of
>> I2C_SLAVE_WRITE_RECEIVED.
>
> From Documentation/i2c/slave-interface.rst:
>
> ===
>
> About ACK/NACK
> --------------
>
> It is good behaviour to always ACK the address phase, so the master knows if a
> device is basically present or if it mysteriously disappeared. Using NACK to
> state being busy is troublesome. SMBus demands to always ACK the address phase,
> while the I2C specification is more loose on that. Most I2C controllers also
> automatically ACK when detecting their slave addresses, so there is no option
> to NACK them. For those reasons, this API does not support NACK in the address
> phase.
>
> ===
>
> So, the proper design is to NACK on the first received byte. All EEPROMs
> do it this way when they are busy because of erasing a page.
>
Thanks Wolfram for the review.
On the first occurrence of I2C_SLAVE_WRITE_REQUESTED, the address is
already received with ACK. So if slave return -EBUSY, the NAK will occur
on the next Rx byte (on I2C_SLAVE_WRITE_RECEIVED event).
Tested this patch and capture using Saleae tool, it always shows ACK on
the address and NAK on the first byte follow when slave return -EBUSY,
ie: the byte follow the address, which is single part read command
(0x03) in my case.
+ When slave return -EBUSY:
S-> Aw(ACK)-> RxD(NAK)-> P
0x10 0x03 (Singlepart read)
+ When slave ready:
S-> Aw(ACK)-> RxD(ACK)-> Sr-> Ar-> TxD(ACK)-> ... -> TxD(NAK)-> P
0x10 0x03 0x07 ... 0xDE
Using the Logic 2 (with Saleae tool) to capture, we could see the log as
below:
write to 0x10 ack data: 0x03 <= when slave return -EBUSY
write to 0x10 ack data: 0x03 <= when slave return -EBUSY
write to 0x10 ack data: 0x03 <= when slave return -EBUSY
...
write to 0x10 ack data: 0x03 <= when slave return -EBUSY
write to 0x10 ack data: 0x03 <= when slave is ready
read to 0x10 ack data: 0x07 0xF4 0x1D 0x00 0x01 0x00 0x00 0x00 0xDE
Thanks,
- Quan
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-06-16 7:17 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-22 4:08 [PATCH v7 0/3] Add SSIF BMC driver Quan Nguyen
2022-04-22 4:08 ` [PATCH v7 1/3] ipmi: ssif_bmc: " Quan Nguyen
2022-04-22 4:16 ` Quan Nguyen
2022-04-23 1:51 ` Corey Minyard
2022-05-04 6:45 ` Quan Nguyen
2022-05-04 12:06 ` [Openipmi-developer] " Corey Minyard
2022-06-01 8:23 ` Quan Nguyen
2022-06-02 0:32 ` Corey Minyard
2022-06-02 9:38 ` Quan Nguyen
2022-04-22 4:08 ` [PATCH v7 2/3] bindings: ipmi: Add binding for " Quan Nguyen
2022-04-22 4:16 ` Quan Nguyen
2022-04-22 7:21 ` Krzysztof Kozlowski
2022-04-22 7:56 ` Quan Nguyen
2022-04-25 21:39 ` Rob Herring
2022-04-22 4:08 ` [PATCH v7 3/3] i2c: aspeed: Assert NAK when slave is busy Quan Nguyen
2022-04-22 4:17 ` Quan Nguyen
2022-05-14 14:31 ` Wolfram Sang
2022-05-16 2:32 ` Quan Nguyen
2022-06-15 20:32 ` Wolfram Sang
2022-06-16 7:16 ` Quan Nguyen [this message]
2022-06-16 12:29 ` Wolfram Sang
2022-06-17 7:08 ` Quan Nguyen
2022-07-05 2:45 ` Quan Nguyen
2022-04-22 4:16 ` [PATCH v7 0/3] Add SSIF BMC driver 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=bf001ece-e981-3a06-53fe-6a8b637d69fe@os.amperecomputing.com \
--to=quan@os.amperecomputing.com \
--cc=andrew@aj.id.au \
--cc=benh@kernel.crashing.org \
--cc=brendanhiggins@google.com \
--cc=devicetree@vger.kernel.org \
--cc=joel@jms.id.au \
--cc=krzysztof.kozlowski@canonical.com \
--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=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).