From patchwork Wed Nov 29 03:25:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Ott X-Patchwork-Id: 842442 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="D+6qLW9t"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ymmDn0s68z9s7B for ; Wed, 29 Nov 2017 14:27:21 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CF14FC21E37; Wed, 29 Nov 2017 03:26:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A5832C21E06; Wed, 29 Nov 2017 03:25:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8787AC21C4A; Wed, 29 Nov 2017 03:25:48 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lists.denx.de (Postfix) with ESMTPS id 2B65EC21DA0 for ; Wed, 29 Nov 2017 03:25:48 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5B9B920C9A; Tue, 28 Nov 2017 22:25:47 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Tue, 28 Nov 2017 22:25:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=afktCVSdCxyX4m6FAg7LIfLGn7UdfKUJeQg16TLo4Ic=; b=D+6qLW9t r0X4Lvl2v4UVbRfiUSDhJlDLx8yn1hmPYqIOcDBNcpRHB+zz44UU2WiogbmKXJl6 B7jji/tNUmH7GyU9NlJ0GJkMEB0Oj5Z51o605yWpiCB3klH393+qqoSR9KoQ5bGc 7E+vhcgHYb14x2WL8133LB3VkhLmHayvxdgkk9GpHcSA/LVOGoJMVodFX4N06Acc DlNpPrWWJj6OHWuw3quVHRX0kiP0lgfII5obVkX70aGwi89wgM/9n0sVv+HGviTt PgGRmYDQnMUwKmRi6lcm1x1oLUX2hNSoiDRBxpE10pcuCmyEWRkQ+QDxe2Pk1+Mb eII2pJqAj1cATg== X-ME-Sender: Received: from localhost.localdomain (c-71-226-23-158.hsd1.fl.comcast.net [71.226.23.158]) by mail.messagingengine.com (Postfix) with ESMTPA id B81AF7F9A9; Tue, 28 Nov 2017 22:25:46 -0500 (EST) From: Alan Ott To: Heiko Schocher , Nicolas Ferre Date: Tue, 28 Nov 2017 22:25:23 -0500 Message-Id: <20171129032524.14431-2-alan@softiron.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171129032524.14431-1-alan@softiron.com> References: <20171129032524.14431-1-alan@softiron.com> Cc: Marek Vasut , u-boot@lists.denx.de, Alan Ott Subject: [U-Boot] [PATCH 1/2] i2c: at91_i2c: Wait for TXRDY after sending the first byte X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The driver must wait for TXRDY after each byte is pushed into the i2c FIFO before pushing the next byte. Previously this was not done for the first byte, causing a race condition with zeros sometimes being sent for the next byte (which is typically the first actual data byte). Signed-off-by: Alan Ott Acked-by:  Wenyou Yang Reviewed-by: Heiko Schocher --- drivers/i2c/at91_i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c index d394044..20d0929 100644 --- a/drivers/i2c/at91_i2c.c +++ b/drivers/i2c/at91_i2c.c @@ -72,6 +72,8 @@ static int at91_i2c_xfer_msg(struct at91_i2c_bus *bus, struct i2c_msg *msg) } else { writel(msg->buf[0], ®->thr); + ret = at91_wait_for_xfer(bus, TWI_SR_TXRDY); + for (i = 1; !ret && (i < msg->len); i++) { writel(msg->buf[i], ®->thr); ret = at91_wait_for_xfer(bus, TWI_SR_TXRDY); From patchwork Wed Nov 29 03:25:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Ott X-Patchwork-Id: 842441 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="sVADMog5"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ymmDH10R1z9s7B for ; Wed, 29 Nov 2017 14:26:55 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D68AAC21DE4; Wed, 29 Nov 2017 03:26:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1DBFFC21E16; Wed, 29 Nov 2017 03:25:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 37065C21C4A; Wed, 29 Nov 2017 03:25:49 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lists.denx.de (Postfix) with ESMTPS id AE6D3C21DA0 for ; Wed, 29 Nov 2017 03:25:48 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E03D620C4E; Tue, 28 Nov 2017 22:25:47 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Tue, 28 Nov 2017 22:25:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=XZLMDIK2KzZaRGWorYRVxvW1btCO9ExzUKiY/855Ic0=; b=sVADMog5 HEGmJXLUo7HyQYPFnM8qOER4Cv8l7hsEuVV48yk8o+UBMMsXPQ6239coUVpaD6aT eJxQIYx2jngIG9J502DaC3OZLt9z9Avv9blhTNpaNKmLE20MvdEv20vaOL2GfSHh gqOW0cqK16WlZse+h4YoujgikSU460sceqqR+toZn1lRpEbons3XtmRzirGdUPLx oYZZ9XHb3RtJyrk3tnE2NY8hvr6HAoLgn1CpLuSgIP/KeV5keJuYtPRzOvHMeJXZ 3k3BvDtBFIeeH7wCIKrF4sNVd/kiheNtb33Mcs3Bq5zyjcHp7RtkqSVUhh3jMViq HP6m7NEdTrThlg== X-ME-Sender: Received: from localhost.localdomain (c-71-226-23-158.hsd1.fl.comcast.net [71.226.23.158]) by mail.messagingengine.com (Postfix) with ESMTPA id 4B3177F7F6; Tue, 28 Nov 2017 22:25:47 -0500 (EST) From: Alan Ott To: Heiko Schocher , Nicolas Ferre Date: Tue, 28 Nov 2017 22:25:24 -0500 Message-Id: <20171129032524.14431-3-alan@softiron.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171129032524.14431-1-alan@softiron.com> References: <20171129032524.14431-1-alan@softiron.com> Cc: Marek Vasut , u-boot@lists.denx.de, Alan Ott Subject: [U-Boot] [PATCH 2/2] i2c: at91_i2c: remove the .probe_chip function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The .probe_chip function is supposed to probe an i2c device on the bus to determine whether a device is answering to a particular address. at91_i2c_probe_chip() did not do anything resembling this and always returned 0. It looks as though at91_i2c_probe_chip() was intended to be a .probe function for the controller, as it was copied-and-pasted to become at91_i2c_probe() in 0bc8f640a4d7ed. Removing the at91_i2c_probe_chip() function makes the higher layer (i2c_probe_chip()) try a zero-length read transfer to test for the presence of a device instead, which does work. Signed-off-by: Alan Ott Acked-by: Wenyou Yang Reviewed-by: Heiko Schocher --- drivers/i2c/at91_i2c.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c index 20d0929..7917ca1 100644 --- a/drivers/i2c/at91_i2c.c +++ b/drivers/i2c/at91_i2c.c @@ -201,27 +201,6 @@ static int at91_i2c_enable_clk(struct udevice *dev) return 0; } -static int at91_i2c_probe_chip(struct udevice *dev, uint chip, uint chip_flags) -{ - struct at91_i2c_bus *bus = dev_get_priv(dev); - struct at91_i2c_regs *reg = bus->regs; - int ret; - - ret = at91_i2c_enable_clk(dev); - if (ret) - return ret; - - writel(TWI_CR_SWRST, ®->cr); - - at91_calc_i2c_clock(dev, bus->clock_frequency); - - writel(bus->cwgr_val, ®->cwgr); - writel(TWI_CR_MSEN, ®->cr); - writel(TWI_CR_SVDIS, ®->cr); - - return 0; -} - static int at91_i2c_set_bus_speed(struct udevice *dev, unsigned int speed) { struct at91_i2c_bus *bus = dev_get_priv(dev); @@ -256,7 +235,6 @@ static int at91_i2c_ofdata_to_platdata(struct udevice *dev) static const struct dm_i2c_ops at91_i2c_ops = { .xfer = at91_i2c_xfer, - .probe_chip = at91_i2c_probe_chip, .set_bus_speed = at91_i2c_set_bus_speed, .get_bus_speed = at91_i2c_get_bus_speed, };