From patchwork Thu Aug 22 14:19:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory CLEMENT X-Patchwork-Id: 269082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 856022C00BD for ; Fri, 23 Aug 2013 00:19:22 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753865Ab3HVOTQ (ORCPT ); Thu, 22 Aug 2013 10:19:16 -0400 Received: from top.free-electrons.com ([176.31.233.9]:44434 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753891Ab3HVOTO (ORCPT ); Thu, 22 Aug 2013 10:19:14 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id D994D81F; Thu, 22 Aug 2013 16:19:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.3.2 Received: from localhost (tra42-5-83-152-246-54.fbx.proxad.net [83.152.246.54]) by mail.free-electrons.com (Postfix) with ESMTPSA id 591E681C; Thu, 22 Aug 2013 16:19:14 +0200 (CEST) From: Gregory CLEMENT To: Wolfram Sang , linux-i2c@vger.kernel.org, Jason Cooper , Andrew Lunn , Gregory CLEMENT Cc: Thomas Petazzoni , Ezequiel Garcia , Sebastian Hesselbarth , linux-arm-kernel@lists.infradead.org, Nicolas Pitre , Lior Amsalem , Maen Suleiman , Tawfik Bayouk , Shadi Ammouri , Eran Ben-Avi , Yehuda Yitschak , Nadav Haklai , Ike Pan , Chris Van Hoof , Dan Frazier , Leif Lindholm , Jon Masters , David Marlin , Zbigniew Bodek Subject: [PATCH v6 2/4] i2c-mv64xxx: Fix timing issue on Armada XP (errata FE-8471889) Date: Thu, 22 Aug 2013 16:19:06 +0200 Message-Id: <1377181146-17341-2-git-send-email-gregory.clement@free-electrons.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1377181146-17341-1-git-send-email-gregory.clement@free-electrons.com> References: <1377181146-17341-1-git-send-email-gregory.clement@free-electrons.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org All the Armada XP (mv78230, mv78260 and mv78460) have a silicon issue in the I2C controller which violate the i2c repeated start timing. The I2C standard requires a minimum of 4.7us for the repeated start condition whereas the I2C controller of the Armada XP this time is 2.9us. So this patch adds a 5us delay for the start case only if the the compatible i2c-mv78230 is set. Based on the initals patches from Zbigniew Bodek Signed-off-by: Gregory CLEMENT Signed-off-by: Zbigniew Bodek --- drivers/i2c/busses/i2c-mv64xxx.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 2404c4e..bc60f9a 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -24,6 +24,7 @@ #include #include #include +#include #define MV64XXX_I2C_ADDR_ADDR(val) ((val & 0x7f) << 1) #define MV64XXX_I2C_BAUD_DIV_N(val) (val & 0x7) @@ -147,6 +148,8 @@ struct mv64xxx_i2c_data { struct i2c_msg *msg; struct i2c_adapter adapter; bool offload_enabled; +/* 5us delay in order to avoid repeated start timing violation */ + bool errata_delay; }; static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_mv64xxx = { @@ -440,6 +443,9 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) /* Setup for the next message */ mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs); } + if (drv_data->errata_delay) + udelay(5); + /* * We're never at the start of the message here, and by this * time it's already too late to do any protocol mangling. @@ -499,6 +505,9 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_STOP, drv_data->reg_base + drv_data->reg_offsets.control); drv_data->block = 0; + if (drv_data->errata_delay) + udelay(5); + wake_up(&drv_data->waitq); break; @@ -766,10 +775,12 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data, /* * For controllers embedded in new SoCs activate the - * Transaction Generator support. + * Transaction Generator support and the errata fix. */ - if (of_device_is_compatible(np, "marvell,mv78230-i2c")) + if (of_device_is_compatible(np, "marvell,mv78230-i2c")) { drv_data->offload_enabled = true; + drv_data->errata_delay = true; + } out: return rc;