From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Babic Date: Fri, 21 Jan 2011 10:08:18 +0100 Subject: [U-Boot] [PATCH V3 05/11] I2C: mxc_i2c: address failure with mx35 processor In-Reply-To: <4D39296B.7020907@denx.de> References: <1295513194-16158-6-git-send-email-sbabic@denx.de> <1295545891-12574-1-git-send-email-sbabic@denx.de> <4D39296B.7020907@denx.de> Message-ID: <4D394D02.8000000@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 01/21/2011 07:36 AM, Heiko Schocher wrote: >> +static int wait_complete(void) >> +{ >> + int timeout = I2C_MAX_TIMEOUT; >> + >> + while ((!(readw(I2C_BASE + I2SR) & I2SR_ICF)) && (--timeout)) { >> + writew(0, I2C_BASE + I2SR); >> + udelay(1); >> + } >> + udelay(200); > > Why is this delay necessary? Why exactly 200? Is this documented > somewhere in the doc? Rather I do not have a clear explanation. In the manual there is a hint regarding a delay that SW must introduce after setting the RSTA bit and before writing data into the I2DR register. Really this delay should be very short, but I checked removing the udelay() or decreasing the value to some uSec and it does not work. This is the output with debugging after removing the udelay call: i2c_read chip: 0x08 addr: 0x0007 alen: 1 len: 3 i2c_addr:chip address cycle fail(a1) i2c_addr failed i2c_read chip: 0x08 addr: 0x001e alen: 1 len: 3 i2c_addr:chip address cycle fail(a1) i2c_addr failed This happens in the i2_read() call, and it is the function where the RSTA bit is set. I can only presume the two things are related. I checked then with the driver provided by Freescale in the LTIB, and also in this driver a delay is set after checking transfer is completed. Stefano -- ===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================