[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190211124431.kys66uzp5hwa5ret@ninjato>
Date: Mon, 11 Feb 2019 13:44:32 +0100
From: Wolfram Sang <wsa@...-dreams.de>
To: Sowjanya Komatineni <skomatineni@...dia.com>
Cc: thierry.reding@...il.com, jonathanh@...dia.com,
mkarthik@...dia.com, smohammed@...dia.com, talho@...dia.com,
peda@...ntia.se, digetx@...il.com, linux-tegra@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-i2c@...r.kernel.org
Subject: Re: [PATCH V18 2/6] i2c: tegra: add bus clear Master Support
Hi,
On Fri, Feb 08, 2019 at 10:59:38AM -0800, Sowjanya Komatineni wrote:
> Bus clear feature of Tegra I2C controller helps to recover from
> bus hang when I2C master loses the bus arbitration due to the
> slave device holding SDA LOW continuously for some unknown reasons.
>
> Per I2C specification, the device that held the bus LOW should
> release it within 9 clock pulses.
>
> During bus clear operation, Tegra I2C controller sends 9 clock
> pulses and terminates the transaction with STOP condition.
> Upon successful bus clear operation, bus goes to idle state and
> driver retries the transaction.
>
> Acked-by: Thierry Reding <treding@...dia.com>
> Reviewed-by: Dmitry Osipenko <digetx@...il.com>
> Signed-off-by: Sowjanya Komatineni <skomatineni@...dia.com>
We have a bus recovery infrastructure in the core. Tying your code into
it should be easy. You probably just need a 'struct
i2c_bus_recovery_info', populate the 'recover_bus' callback with
'tegra_i2c_issue_bus_clear()', and attach this struct to the 'struct
adapter' if the IP core supports bus recovery, otherwise leave it empty.
Then, you can...
> +static int tegra_i2c_issue_bus_clear(struct tegra_i2c_dev *i2c_dev)
> +{
> + int err;
> + unsigned long time_left;
> + u32 reg;
> +
> + if (i2c_dev->hw->supports_bus_clear) {
... remove the if here because the core will check for a valid
i2c_bus_recovery_info...
> @@ -759,6 +818,13 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
> return 0;
>
> tegra_i2c_init(i2c_dev);
> + /* start recovery upon arbitration loss in single master mode */
> + if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) {
> + if (!i2c_dev->is_multimaster_mode)
> + return tegra_i2c_issue_bus_clear(i2c_dev);
... and use simply i2c_recover_bus() here.
This will help making bus recovery use consistent across drivers.
Thanks,
Wolfram
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists