From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Subject: Re: [PATCH V2 2/3] i2c: mxs: Rework the PIO mode operation Date: Sun, 25 Aug 2013 18:19:57 +0200 Message-ID: <201308251819.57351.marex@denx.de> References: <1375219237-9594-1-git-send-email-marex@denx.de> <1375219237-9594-2-git-send-email-marex@denx.de> <8771910.JgfUXiMKri@linux-1fbo.site> Mime-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <8771910.JgfUXiMKri-BVXpyJtzy6LO1Ldfs0Uenw@public.gmane.org> Sender: linux-i2c-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Torsten Fleischer Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Alexandre Belloni , Christoph Baumann , Fabio Estevam , Shawn Guo , Wolfram Sang List-Id: linux-i2c@vger.kernel.org Dear Torsten Fleischer, > Hi Marek, > > > + > > + mxs_i2c_pio_trigger_write_cmd(i2c, > > + start | MXS_I2C_CTRL0_MASTER_MODE | > > + MXS_I2C_CTRL0_DIRECTION | > > + MXS_I2C_CTRL0_XFER_COUNT(xlen), data); > > + > > + /* The START condition is sent only once. */ > > + start &= ~MXS_I2C_CTRL0_PRE_SEND_START; > > + > > + /* Wait for the end of the transfer. */ > > + ret = mxs_i2c_pio_wait_xfer_end(i2c); > > + if (ret) { > > + dev_err(i2c->dev, > > + "PIO: Failed to finish WRITE cmd!\n"); > > + break; > > + } > > + > > + /* Check NAK here ? */ > > checking for the NAK at this point is really necessary. > > I've tested the patches by writing to the EEPROM using the at24 driver. > If the data to write cross the EEPROM's page boundary then the at24 driver > splits the I2C write commands. > > After the first I2C write command is done the at24 driver immediately tries > to send the next I2C write command. Normally the EEPROM signals a NAK, > because the previous write operation is internally still in progress. The > NAK will be handled by the at24 driver. It later retries the I2C write > command. > > But if the the EEPROM signals a NAK and the I2C write command has more than > 3 and less than 7 bytes then the error "PIO: Failed to finish WRITE cmd!" > appears, because the loop is not exited due to the NAK. Ok, so we check HW_I2C_STAT :: GOT_A_NAK bit at the end of the loop and if it's set, we "goto cleanup" with ret = -ENXIO . How does it sound to you? Wolfram, is -ENXIO the right one here? Best regards, Marek Vasut