Mailing List archive

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

[linux-dvb] Re: Busy waiting in i2c_busy_rise_and_fall (was: Re: Re: full featured card without signal and required video memory investigation)



On Monday 14 July 2003 17:54, Johannes Stezenbach wrote:
> Oliver Endriss wrote:
> > On Monday 14 July 2003 14:33, Johannes Stezenbach wrote:
> What I get from Roberts description it's not a timing problem (it's
> not sufficient to udelay(1), or do a dummy read from some other
> register), but one should explicitely do one dummy read from IICSTA,
> discard the value, and then do a second read to get valid data.

Hm, I tested this and could *not* verify this problem:
Reading IICSTA always returns a valid value (busy flag set).
Really strange. Anyway, to be on the safe side, a dummy read
should be added.

> [...]
>
> > Well, I prefer busy-reading over busy-waiting unless there is a
> > reason not to do it (?)
>
> I don't know. It occupies the PCI bus some.

Yes, that's right. The PCI bus is more likely a bottleneck than the CPU.

Putting everything together I suggest the following implementation:

        ...
        i2c_status_check(saa);

        /* wait until busy-flag is inactive or error is reported */
        for (i = timeout; i > 0; i--) {

                hprintk("saa7146: i2c_busy_rise_and_fall; fall wait %d\n",i);

                /* see if anything can be done while we're waiting */
                cond_resched();
                udelay(20);

                status = i2c_status_check(saa);

                /* check busy flag */
                if ( 0 == (status & SAA7146_I2C_BUSY))
                        break;

                /* check error flag */
                if ( 0 != (status & SAA7146_I2C_ERR))
                        break;

        }
        ...

Typically my system loops 2..5 times with 275kHz I2C bus speed.
Shall I add this to CVS?

Oliver


-- 
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index