From: Qii Wang <qii.wang@mediatek.com>
To: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Nicolas Boichat <drinkcat@chromium.org>,
Alexandru M Stan <amstan@chromium.org>,
Wolfram Sang <wsa@the-dreams.de>, Jun Gao <jun.gao@mediatek.com>,
linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
linux-i2c@vger.kernel.org,
Matthias Brugger <matthias.bgg@gmail.com>,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] i2c: mediatek: disable zero-length transfers for mt8183
Date: Fri, 23 Aug 2019 16:09:32 +0800 [thread overview]
Message-ID: <1566547772.19935.2.camel@mhfsdcap03> (raw)
In-Reply-To: <20190822094516.55130-1-hsinyi@chromium.org>
On Thu, 2019-08-22 at 17:45 +0800, Hsin-Yi Wang wrote:
> When doing i2cdetect quick write mode, we would get transfer
> error ENOMEM, and i2cdetect shows there's no device at the address.
> Quoting from mt8183 datasheet, the number of transfers to be
> transferred in one transaction should be set to bigger than 1,
> so we should forbid zero-length transfer and update functionality.
>
> Incorrect return:
> localhost ~ # i2cdetect -q -y 0
> 0 1 2 3 4 5 6 7 8 9 a b c d e f
> 00: -- -- -- -- -- -- -- -- -- -- -- -- --
> 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 70: -- -- -- -- -- -- -- --
>
> After this patch:
> localhost ~ # i2cdetect -q -y 0
> Error: Can't use SMBus Quick Write command on this bus
>
> localhost ~ # i2cdetect -y 0
> Warning: Can't use SMBus Quick Write command, will skip some addresses
> 0 1 2 3 4 5 6 7 8 9 a b c d e f
> 00:
> 10:
> 20:
> 30: -- -- -- -- -- -- -- --
> 40:
> 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 60:
> 70:
>
> Reported-by: Alexandru M Stan <amstan@chromium.org>
> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
> ---
> Change from v1:
> * restore the order of algo and quirks
> ---
> drivers/i2c/busses/i2c-mt65xx.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index 252edb433fdf..29eae1bf4f86 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -234,6 +234,10 @@ static const struct i2c_adapter_quirks mt7622_i2c_quirks = {
> .max_num_msgs = 255,
> };
>
> +static const struct i2c_adapter_quirks mt8183_i2c_quirks = {
> + .flags = I2C_AQ_NO_ZERO_LEN,
> +};
> +
> static const struct mtk_i2c_compatible mt2712_compat = {
> .regs = mt_i2c_regs_v1,
> .pmic_i2c = 0,
> @@ -298,6 +302,7 @@ static const struct mtk_i2c_compatible mt8173_compat = {
> };
>
> static const struct mtk_i2c_compatible mt8183_compat = {
> + .quirks = &mt8183_i2c_quirks,
> .regs = mt_i2c_regs_v2,
> .pmic_i2c = 0,
> .dcm = 0,
> @@ -870,7 +875,11 @@ static irqreturn_t mtk_i2c_irq(int irqno, void *dev_id)
>
> static u32 mtk_i2c_functionality(struct i2c_adapter *adap)
> {
> - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
> + if (adap->quirks->flags & I2C_AQ_NO_ZERO_LEN)
> + return I2C_FUNC_I2C |
> + (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
> + else
> + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
It can be removed?
> }
>
> static const struct i2c_algorithm mtk_i2c_algorithm = {
_______________________________________________
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:[~2019-08-23 8:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-22 9:45 [PATCH v2] i2c: mediatek: disable zero-length transfers for mt8183 Hsin-Yi Wang
2019-08-23 8:09 ` Qii Wang [this message]
2019-08-23 8:13 ` Hsin-Yi Wang
2019-08-24 3:23 ` Qii Wang
2019-08-30 13:08 ` 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=1566547772.19935.2.camel@mhfsdcap03 \
--to=qii.wang@mediatek.com \
--cc=amstan@chromium.org \
--cc=drinkcat@chromium.org \
--cc=hsinyi@chromium.org \
--cc=jun.gao@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=tglx@linutronix.de \
--cc=wsa@the-dreams.de \
--cc=yingjoe.chen@mediatek.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).