From patchwork Wed Oct 24 10:57:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinya Kuribayashi X-Patchwork-Id: 1637551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 758743FD4E for ; Wed, 24 Oct 2012 10:59:57 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TQyer-0004xl-Ow; Wed, 24 Oct 2012 10:57:57 +0000 Received: from relmlor4.renesas.com ([210.160.252.174]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TQyen-0004vv-1r for linux-arm-kernel@lists.infradead.org; Wed, 24 Oct 2012 10:57:53 +0000 Received: from relmlir2.idc.renesas.com ([10.200.68.152]) by relmlor4.idc.renesas.com ( SJSMS) with ESMTP id <0MCE006C694GPU10@relmlor4.idc.renesas.com> for linux-arm-kernel@lists.infradead.org; Wed, 24 Oct 2012 19:57:52 +0900 (JST) Received: from relmlac4.idc.renesas.com ([10.200.69.24]) by relmlir2.idc.renesas.com ( SJSMS) with ESMTP id <0MCE0065C94G2KF0@relmlir2.idc.renesas.com> for linux-arm-kernel@lists.infradead.org; Wed, 24 Oct 2012 19:57:52 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 13634480A5; Wed, 24 Oct 2012 19:57:52 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 0DDF0480A4; Wed, 24 Oct 2012 19:57:52 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac4.idc.renesas.com with ESMTP id VAE30757; Wed, 24 Oct 2012 19:57:52 +0900 X-IronPort-AV: E=Sophos; i="4.80,639,1344178800"; d="scan'208"; a="103457171" Received: from unknown (HELO [10.161.64.55]) ([10.161.64.55]) by relmlii2.idc.renesas.com with ESMTP; Wed, 24 Oct 2012 19:57:52 +0900 Message-id: <5087C9AF.409@renesas.com> Date: Wed, 24 Oct 2012 19:57:51 +0900 From: Shinya Kuribayashi User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-version: 1.0 To: w.sang@pengutronix.de, ben-linux@fluff.org, magnus.damm@gmail.com Subject: [PATCH 3/5] i2c: i2c-sh_mobile: fix ICCH to avoid violation of the tHD;STA timing spec References: <5087C93F.6080601@renesas.com> In-reply-to: <5087C93F.6080601@renesas.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The optimized ICCH/ICCL values in the previous commit afterward turned out to violate tHD;STA timing spec. We had to take into account the fall time of SDA signal (tf) at START condition. Fix it accordingly. With this change, sh_mobile_i2c_icch() is virtually identical to sh_mobile_i2c_iccl(), but they're providing good descriptions of SH-/R-Mobile I2C hardware spec, and I'd leave them as separated. Signed-off-by: Shinya Kuribayashi --- drivers/i2c/busses/i2c-sh_mobile.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 1ad80c9..4dc0cc3 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c @@ -203,18 +203,23 @@ static u32 sh_mobile_i2c_iccl(unsigned long count_khz, u32 tLOW, u32 tf, int off return (((count_khz * (tLOW + tf)) + 5000) / 10000) + offset; } -static u32 sh_mobile_i2c_icch(unsigned long count_khz, u32 tHIGH, int offset) +static u32 sh_mobile_i2c_icch(unsigned long count_khz, u32 tHIGH, u32 tf, int offset) { /* * Conditional expression: - * ICCH >= COUNT_CLK * tHIGH + * ICCH >= COUNT_CLK * (tHIGH + tf) * * SH-Mobile IIC hardware is aware of SCL transition period 'tr', * and can ignore it. SH-Mobile IIC controller starts counting * the HIGH period of the SCL signal (tHIGH) after the SCL input * voltage increases at VIH. + * + * Afterward it turned out calculating ICCH using only tHIGH spec + * will result in violation of the tHD;STA timing spec. We need + * to take into account the fall time of SDA signal (tf) at START + * condition, in order to meet both tHIGH and tHD;STA specs. */ - return ((count_khz * tHIGH) + 5000) / 10000 + offset; + return (((count_khz * (tHIGH + tf)) + 5000) / 10000) + offset; } static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) @@ -250,7 +255,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) else pd->icic &= ~ICIC_ICCLB8; - pd->icch = sh_mobile_i2c_icch(i2c_clk_khz, tHIGH, offset); + pd->icch = sh_mobile_i2c_icch(i2c_clk_khz, tHIGH, tf, offset); /* one more bit of ICCH in ICIC */ if ((pd->icch > 0xff) && (pd->flags & IIC_FLAG_HAS_ICIC67)) pd->icic |= ICIC_ICCHB8;