RE: How to put extra clock cycles on i2c cavinci, problems on omapl138 (logic pd som)

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

 



Dear Sekhar,

> 
> RE: How to put extra clock cycles on i2c cavinci, problems on 
> omapl138 (logic pd som)
> 
> On Thu, Mar 17, 2011 at 18:55:00, Ben Gardiner wrote:
> 
> > I noticed on the e2e forums that there is a reason why the PSP uses a
> > bitbanging i2c interface -- since the 1.0v OPP makes the i2c
> > controller unusable [1] (I've added Sekhar to the CC since he pointed
> > out the problem in that post).
> 
> There was a problem with the way I2C was implemented on the SoM. Here is
> the information I have for the modifications required on the SoM.
> 
> "
> It is likely that the errors seen were a result of the buffer on the
> I2C clock.  The hardware fix for this issue is to remove U24 and 
> R161 and short U24 pins 2 to 4.
> "

I have a hardware here without this buffer in the I2C clock wire!
 
> There should be an EVM with these fixes already, though I have not
> tested it myself.
> 
> Also, recently a bug in the I2C driver was brought to my attention.
> In the bus busy function:
> 
> /*
>  * Waiting for bus not busy
>  */
> static int i2c_davinci_wait_bus_not_busy(struct davinci_i2c_dev *dev,
>                 char allow_sleep)
> {
>    unsigned long timeout;
>    static u16 to_cnt;
> 
>    timeout = jiffies + dev->adapter.timeout;
>    while (davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG)
>           & DAVINCI_I2C_STR_BB) {
>       if (to_cnt <= DAVINCI_I2C_MAX_TRIES) {
>          if (time_after(jiffies, timeout)) {
>             dev_warn(dev->dev,
>             "timeout waiting for bus ready\n");
>             to_cnt++;
>             return -ETIMEDOUT;
>          } else {
>             to_cnt = 0;
>             i2c_recover_bus(dev);
>             i2c_davinci_init(dev);
>          }
>       }
>       if (allow_sleep)
>          schedule_timeout(1);
>    }
> 
>    return 0;
> }
> 
> If there is a context switch immediately after the while statement,
> the loop can return a timeout error while there is none. The
> simple solution would be to check for bus busy again if the
> timeout condition occurs. 

It seems the following patch suggests to your presumption, but 
it is not the solution yet.

diff --git a/drivers/i2c/busses/i2c-davinci.c 
b/drivers/i2c/busses/i2c-davinci.c
index 5795c83..5ddefd6 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -283,11 +283,13 @@ static int i2c_davinci_wait_bus_not_busy(struct 
davinci_i2c_dev *dev,
               & DAVINCI_I2C_STR_BB) {
                if (to_cnt <= DAVINCI_I2C_MAX_TRIES) {
                        if (time_after(jiffies, timeout)) {
-                               dev_warn(dev->dev,
+                               dev_err(dev->dev,
                                "timeout waiting for bus ready\n");
                                to_cnt++;
                                return -ETIMEDOUT;
                        } else {
+                               dev_err(dev->dev,
+                               "timeout waiting for bus ready2\n");
                                to_cnt = 0;
                                i2c_recover_bus(dev);
                                i2c_davinci_init(dev);
@@ -381,6 +383,15 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct 
i2c_msg *msg, int sto
 dev->adapter.timeout);
        if (r == 0) {
                dev_err(dev->dev, "controller timed out\n");
+               if(i2c_davinci_wait_bus_not_busy(dev, 1))
+ 
+                   dev_err(dev->dev, "there is really a timeout\n");
+ 
+               else
+ 
+                   dev_err(dev->dev, "there is no timeout\n");
+ 
+                 }


                dev->buf_len = 0;

This is the result:

tps6507x 1-0048: ADC config write failed
i2c_davinci i2c_davinci.1: controller timed out
i2c_davinci i2c_davinci.1: there is no timeout
i2c_davinci i2c_davinci.1: controller timed out
i2c_davinci i2c_davinci.1: there is no timeout
tps6507x 1-0048: TSC mode read failed
i2c_davinci i2c_davinci.1: controller timed out
i2c_davinci i2c_davinci.1: there is no timeout
i2c_davinci i2c_davinci.1: controller timed out
i2c_davinci i2c_davinci.1: there is no timeout
tps6507x 1-0048: TSC mode read failed

...and so on.

> There should be a more elegant way
> to write the loop, but it is too late in the evening to think
> about it :)
> 

Perhaps you can help us in the morning, please. 

> I doubt if this is related to the errors you guys are seeing,
> but it is worth trying anyway.
> 
> Thanks,
> Sekhar
> 

Best Regards,

Bastian.

--
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