Re: [PATCH V7 1/2] i2c/adapter: Add bus recovery infrastructure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25 November 2012 17:22, Paul Carpenter
<paul@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Viresh Kumar wrote:
>> Add i2c bus recovery infrastructure to i2c adapters as specified in the
>> i2c
>> protocol Rev. 03 section 3.1.16 titled "Bus clear".
>>
>> http://www.nxp.com/documents/user_manual/UM10204.pdf
>
> You should also take note of section 3.1.14 and its notes on Software
> Reset -
>     "Precautions must be taken to ensure that a device is not
>      pulling down the SDA or SCL line after applying the supply
>      voltage, since these low levels would block the bus"

Hmm.. This patch has taken a very long time for being accepted, and the
reason for that was, it was generalizing much more than what is required.

And I am not sure, if checking SCL low would be considered like that only. :)

@Wolfram: I would need your point of view on that, before trying it out.

>> +static int i2c_get_gpios_for_recovery(struct i2c_adapter *adap)
>> +{
>> +    struct i2c_bus_recovery_info *bri = adap->bus_recovery_info;
>> +    struct device *dev = &adap->dev;
>> +    int ret = 0;
>
> Where is the check that SCL is NOT low (bus fault or device doing clock
> stretching)

Pending for Wolfram's point of view :)

>> +static int i2c_generic_recovery(struct i2c_adapter *adap)
>> +{
>> +    /*
>> +     * By this time SCL is high, as we need to give 9 falling-rising
>> edges
>> +     */
>
> In my view that needs to be done by an actual check of the real SCL not
> assumption.

Checking that would be tricky. For GPIO recovery, we have to make it GPIO
first in input mode and read its value. Right?

>> +    delay = DIV_ROUND_UP(delay, bri->clock_rate_khz * 2);
>> +
>> +    for (i = 0; i < RECOVERY_CLK_CNT * 2; i++, val = !val) {
>> +        bri->set_scl(adap, val);
>> +        ndelay(delay);
>> +
>> +        /* break if sda got high, check only when scl line is high */
>> +        if (!bri->skip_sda_polling && val)
>
> Dont use 'val' read the actual SCL line which ensures you you are not
> wasting your time because of hardware fault. Possibly saving your GPIO
> from being stuck permanently.

Again, wolfram can decide if it is really required :)

--
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux