From: Dmitry Osipenko <digetx@gmail.com>
To: "Akhil R" <akhilrajeev@nvidia.com>,
"christian.koenig@amd.com" <christian.koenig@amd.com>,
"Jonathan Hunter" <jonathanh@nvidia.com>,
"Laxman Dewangan" <ldewangan@nvidia.com>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
"Mikko Perttunen" <mperttunen@nvidia.com>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"sumit.semwal@linaro.org" <sumit.semwal@linaro.org>,
"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
"Svyatoslav Ryhel" <clamor95@gmail.com>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Subject: Re: [PATCH RESEND] i2c: tegra: Add SMBus block read function
Date: Sat, 12 Feb 2022 19:20:44 +0300 [thread overview]
Message-ID: <ff83adba-7919-fa48-4637-a4cb9b94a8e1@gmail.com> (raw)
In-Reply-To: <94fc8b11-6149-56ca-a028-cf7f39930992@gmail.com>
12.02.2022 19:15, Dmitry Osipenko пишет:
> 11.02.2022 12:11, Akhil R пишет:
>>> 10.02.2022 18:36, Akhil R пишет:
>>>> Emulate SMBus block read using ContinueXfer to read the length byte
>>>>
>>>> Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
>>>> ---
>>>> drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++--
>>>> 1 file changed, 16 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
>>>> index 03cea102ab76..2941e42aa6a0 100644
>>>> --- a/drivers/i2c/busses/i2c-tegra.c
>>>> +++ b/drivers/i2c/busses/i2c-tegra.c
>>>> @@ -1233,6 +1233,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev
>>> *i2c_dev,
>>>> return err;
>>>>
>>>> i2c_dev->msg_buf = msg->buf;
>>>> +
>>>> + /* The condition true implies smbus block read and len is already read */
>>>> + if (msg->flags & I2C_M_RECV_LEN && end_state !=
>>> MSG_END_CONTINUE)
>>>> + i2c_dev->msg_buf = msg->buf + 1;
>>>> +
>>>> i2c_dev->msg_buf_remaining = msg->len;
>>>> i2c_dev->msg_err = I2C_ERR_NONE;
>>>> i2c_dev->msg_read = !!(msg->flags & I2C_M_RD);
>>>> @@ -1389,6 +1394,15 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap,
>>> struct i2c_msg msgs[],
>>>> else
>>>> end_type = MSG_END_REPEAT_START;
>>>> }
>>>> + /* If M_RECV_LEN use ContinueXfer to read the first byte */
>>>> + if (msgs[i].flags & I2C_M_RECV_LEN) {
>>>> + ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i],
>>> MSG_END_CONTINUE);
>>>> + if (ret)
>>>> + break;
>>>> + /* Set the read byte as msg len */
>>>> + msgs[i].len = msgs[i].buf[0];
>>>> + dev_dbg(i2c_dev->dev, "reading %d bytes\n", msgs[i].len);
>>>> + }
>>>> ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], end_type);
>>>> if (ret)
>>>> break;
>>>> @@ -1416,10 +1430,10 @@ static u32 tegra_i2c_func(struct i2c_adapter
>>> *adap)
>>>> {
>>>> struct tegra_i2c_dev *i2c_dev = i2c_get_adapdata(adap);
>>>> u32 ret = I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL &
>>> ~I2C_FUNC_SMBUS_QUICK) |
>>>> - I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING;
>>>> + I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING;
>>>>
>>>> if (i2c_dev->hw->has_continue_xfer_support)
>>>> - ret |= I2C_FUNC_NOSTART;
>>>> + ret |= I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_READ_BLOCK_DATA;
>>>>
>>>> return ret;
>>>> }
>>>
>>> Please describe how this was tested.
>> This is tested using an I2C EEPROM to emulate SMBus block read in which
>> we read the first byte as the length of bytes to read. This is an expected
>> feature for NVIDIA Grace chipset where there will be an actual SMBus device.
>
> We have several Tegra30+ tablets that have EC on SMBus. Svyatoslav tried
> your I2C patch + [1] on Asus TF201 and reported that it breaks EC. Any
> idea why it doesn't work?
>
> [1]
> https://github.com/grate-driver/linux/commit/aa8d71f5a960ef40503e5448c622d62d1c53a2c0
Ah, I see now that I2C_FUNC_SMBUS_WRITE_BLOCK_DATA not supported, we
should check again without the write then.
next prev parent reply other threads:[~2022-02-12 16:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 15:36 [PATCH RESEND] i2c: tegra: Add SMBus block read function Akhil R
2022-02-10 20:25 ` Dmitry Osipenko
2022-02-11 9:11 ` Akhil R
2022-02-12 16:15 ` Dmitry Osipenko
2022-02-12 16:20 ` Dmitry Osipenko [this message]
2022-02-12 20:08 ` Dmitry Osipenko
2022-02-14 4:49 ` Akhil R
2022-02-15 21:33 ` Dmitry Osipenko
2022-02-16 3:54 ` Akhil R
2022-02-16 18:50 ` Dmitry Osipenko
2022-02-16 20:32 ` Dmitry Osipenko
2022-02-25 13:03 ` Thierry Reding
2022-03-01 19:37 ` Wolfram Sang
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=ff83adba-7919-fa48-4637-a4cb9b94a8e1@gmail.com \
--to=digetx@gmail.com \
--cc=akhilrajeev@nvidia.com \
--cc=christian.koenig@amd.com \
--cc=clamor95@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=ldewangan@nvidia.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=mperttunen@nvidia.com \
--cc=p.zabel@pengutronix.de \
--cc=sumit.semwal@linaro.org \
--cc=thierry.reding@gmail.com \
/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).