From: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
To: w.sang@pengutronix.de, ben-linux@fluff.org, magnus.damm@gmail.com
Cc: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sh@vger.kernel.org
Subject: [PATCH 3/5] i2c: i2c-sh_mobile: fix ICCH to avoid violation of the tHD;STA timing spec
Date: Wed, 24 Oct 2012 19:57:51 +0900 [thread overview]
Message-ID: <5087C9AF.409@renesas.com> (raw)
In-Reply-To: <5087C93F.6080601@renesas.com>
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 <shinya.kuribayashi.px@renesas.com>
---
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;
--
1.7.12.4
next prev parent reply other threads:[~2012-10-24 10:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-24 10:55 [PATCH 0/5] i2c-sh_mobile non-urgent changes Shinya Kuribayashi
[not found] ` <5087C93F.6080601-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2012-10-24 10:56 ` [PATCH 1/5] i2c: i2c-sh_mobile: calculate clock parameters at driver probing time Shinya Kuribayashi
2012-11-16 8:07 ` [PATCH 0/5] i2c-sh_mobile non-urgent changes Wolfram Sang
2012-11-16 8:53 ` Shinya Kuribayashi
2012-11-17 23:27 ` Guennadi Liakhovetski
2012-10-24 10:57 ` [PATCH 2/5] i2c: i2c-sh_mobile: optimize ICCH/ICCL values according to I2C bus speed Shinya Kuribayashi
2012-10-24 10:57 ` Shinya Kuribayashi [this message]
2012-10-24 10:58 ` [PATCH 4/5] i2c: i2c-sh_mobile: support I2C hardware block with a faster operating clock Shinya Kuribayashi
2012-10-24 10:58 ` [PATCH 5/5] i2c: i2c-sh_mobile: fix spurious transfer request timed out Shinya Kuribayashi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5087C9AF.409@renesas.com \
--to=shinya.kuribayashi.px@renesas.com \
--cc=ben-linux@fluff.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=w.sang@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).