From: Wolfram Sang <wsa@the-dreams.de>
To: Mans Rullgard <mans@mansr.com>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@pengutronix.de, Aisheng Dong <aisheng.dong@nxp.com>,
Shawn Guo <shawnguo@kernel.org>
Subject: Re: [RESEND][PATCH] i2c: imx: add support for I2C_M_STOP flag
Date: Fri, 5 Jul 2019 20:38:48 +0200 [thread overview]
Message-ID: <20190705183848.GH4717@kunai> (raw)
In-Reply-To: <20190703164732.27973-1-mans@mansr.com>
[-- Attachment #1: Type: text/plain, Size: 2561 bytes --]
On Wed, Jul 03, 2019 at 05:47:32PM +0100, Mans Rullgard wrote:
> Add support for the I2C_M_STOP flag to the i2c-imx driver. This allows
> devices requiring a stop between messages to work with this controller.
>
> Signed-off-by: Mans Rullgard <mans@mansr.com>
The problem with this driver is that it is unmaintained, sadly :( I'll
cc some people who might be interested...
> ---
> drivers/i2c/busses/i2c-imx.c | 26 ++++++++++++++++++++++----
> 1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 7bd409eaf0ac..a7f801bb5dc9 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -908,10 +908,17 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
>
> /* read/write data */
> for (i = 0; i < num; i++) {
> - if (i == num - 1)
> - is_lastmsg = true;
> + if (is_lastmsg) {
> + /* previous message had I2C_M_STOP flag set */
> + temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
> + temp |= I2CR_MSTA;
> + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
> + result = i2c_imx_bus_busy(i2c_imx, 1);
> + if (result)
> + goto fail0;
> + }
>
> - if (i) {
> + if (i && !is_lastmsg) {
> dev_dbg(&i2c_imx->adapter.dev,
> "<%s> repeated start\n", __func__);
> temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
> @@ -921,6 +928,10 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
> if (result)
> goto fail0;
> }
> +
> + if (i == num - 1 || (msgs[i].flags & I2C_M_STOP))
> + is_lastmsg = true;
> +
> dev_dbg(&i2c_imx->adapter.dev,
> "<%s> transfer message: %d\n", __func__, i);
> /* write/read data */
> @@ -948,6 +959,13 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
> result = i2c_imx_dma_write(i2c_imx, &msgs[i]);
> else
> result = i2c_imx_write(i2c_imx, &msgs[i]);
> +
> + if (msgs[i].flags & I2C_M_STOP) {
> + temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
> + temp &= ~I2CR_MSTA;
> + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
> + i2c_imx_bus_busy(i2c_imx, 0);
> + }
> }
> if (result)
> goto fail0;
> @@ -1034,7 +1052,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
>
> static u32 i2c_imx_func(struct i2c_adapter *adapter)
> {
> - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL
> + return I2C_FUNC_I2C | I2C_FUNC_PROTOCOL_MANGLING | I2C_FUNC_SMBUS_EMUL
> | I2C_FUNC_SMBUS_READ_BLOCK_DATA;
> }
>
> --
> 2.22.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2019-07-05 18:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 16:47 [RESEND][PATCH] i2c: imx: add support for I2C_M_STOP flag Mans Rullgard
2019-07-05 18:38 ` Wolfram Sang [this message]
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=20190705183848.GH4717@kunai \
--to=wsa@the-dreams.de \
--cc=aisheng.dong@nxp.com \
--cc=kernel@pengutronix.de \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mans@mansr.com \
--cc=shawnguo@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