From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Wed, 25 Jun 2014 22:09:11 -0600 Subject: [U-Boot] [PATCH 1/3] i2c: tegra: use repeated start for reads In-Reply-To: References: <1403715449-2177-1-git-send-email-swarren@wwwdotorg.org> Message-ID: <53AB9CE7.80101@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 06/25/2014 08:12 PM, Simon Glass wrote: > Hi Stephen, > > On 25 June 2014 10:57, Stephen Warren wrote: >> >> From: Stephen Warren >> >> I2C read transactions are typically implemented as follows: >> >> START(write) address REPEATED_START(read) data... STOP >> >> However, Tegra's I2C driver currently implements reads as follows: >> >> START(write) address STOP START(read) data... STOP >> >> This sequence confuses at least the AS3722 PMIC on the Jetson TK1 board, >> leading to corrupted read data in some cases. Fix the driver to chain >> the transactions together using repeated starts to solve this. >> diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c >> @@ -209,7 +212,8 @@ static int send_recv_packets(struct i2c_bus *i2c_bus, >> int_status = readl(&control->int_status); >> writel(int_status, &control->int_status); >> >> - send_packet_headers(i2c_bus, trans, 1); >> + send_packet_headers(i2c_bus, trans, 1, >> + trans->flags & I2C_USE_REPEATED_START); > > I'm not sure if it is safe/advisable to pass this value to a bool > type. Perhaps the function parameter should be int? My understanding > of bool is that it is supposed to be 0 or 1, but I'm happy to be > corrected. I believe that the "promotion" from int to bool clamps the range to 0 or 1. I've certainly seen compilers warn that this promotion might be a performance issue!. If not, I can always add !! in front.