From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Tim Harvey <tharvey@gateworks.com>
Cc: Wolfram Sang <wsa@the-dreams.de>,
Fabio Estevam <fabio.estevam@freescale.com>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c: imx: add retries for i2c-0 on Ventana boards
Date: Fri, 8 Jul 2016 08:28:46 +0200 [thread overview]
Message-ID: <20160708062846.GI16643@pengutronix.de> (raw)
In-Reply-To: <1467900229-5262-1-git-send-email-tharvey@gateworks.com>
Hello Tim,
On Thu, Jul 07, 2016 at 07:03:49AM -0700, Tim Harvey wrote:
> Gateworks Ventana IMX6 based boards have a Gateworks System Controller [1]
> (gsc) device that can NAK i2c transactions when its busy in an ADC loop. As
> this is always on i2c-0 we will add retries for that bus for any Ventana
> board.
The right thing is to fix the drivers IMHO.
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 1844bc9..aec71c3 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -460,6 +460,8 @@ static int i2c_imx_acked(struct imx_i2c_struct *i2c_imx)
> {
> if (imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR) & I2SR_RXAK) {
> dev_dbg(&i2c_imx->adapter.dev, "<%s> No ACK\n", __func__);
> + if (i2c_imx->adapter.retries)
> + return -EAGAIN;
This is wrong, struct i2c_adapter::retries is for restarting a transfer
on arbitration loss.
> return -ENXIO; /* No ACK */
> }
>
> @@ -1068,6 +1070,16 @@ static int i2c_imx_probe(struct platform_device *pdev)
> i2c_imx->adapter.dev.of_node = pdev->dev.of_node;
> i2c_imx->base = base;
>
> + /*
> + * The Gateworks Ventana has an i2c based system controller on i2c-0
> + * which emulates several standard i2c devices with existing drivers.
> + * That device can NAK when its in an ADC loop. Add bus retries.
> + */
> + if (of_machine_is_compatible("gw,ventana") && phy_addr == 0x021a0000) {
Please don't. If you want to do handle a device in a special way, invent
a device tree property, add it to your machine description and add
handling here. Using of_machine_is_compatible + base address of the
device to decide about configuration is a no go.
> + dev_info(&pdev->dev, "Adding retries for Ventana GSC\n");
> + i2c_imx->adapter.retries = 3;
> + }
> +
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2016-07-08 6:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-07 14:03 [PATCH] i2c: imx: add retries for i2c-0 on Ventana boards Tim Harvey
2016-07-08 6:28 ` Uwe Kleine-König [this message]
2016-07-08 19:49 ` Tim Harvey
2016-07-08 21:07 ` Uwe Kleine-König
2016-07-09 2:31 ` 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=20160708062846.GI16643@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=fabio.estevam@freescale.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tharvey@gateworks.com \
--cc=wsa@the-dreams.de \
/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).