From: David Wu <david.wu@rock-chips.com>
To: heiko@sntech.de
Cc: wsa@the-dreams.de, andy.shevchenko@gmail.com,
dianders@chromium.org, huangtao@rock-chips.com,
zyw@rock-chips.com, cf@rock-chips.com, xjq@rock-chips.com,
hl@rock-chips.com, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, David Wu <david.wu@rock-chips.com>
Subject: [PATCH v3 4/4] i2c: rk3x: support I2C Highspeed Mode
Date: Thu, 14 Jan 2016 20:31:39 +0800 [thread overview]
Message-ID: <1452774699-57455-5-git-send-email-david.wu@rock-chips.com> (raw)
In-Reply-To: <1452774699-57455-1-git-send-email-david.wu@rock-chips.com>
The i2c controller of new version1 supports highspeed mode,
1.7M and 3.4M rate. It also could be calculated clocks by the rules.
Note: The final divs would be effected a lot by hardware elements like
scl_rise_ns, scl_fall_ns and sda_rise_ns.
There are two examples of div calculated by the rules, not contain
hardware elements like scl_rise time, scl_fall time and sda_rise time:
1. scl: 1.7M:
Source Pclk: 200M, Target scl: 1700K, Final scl: 1.667K;
Tpclk = 5ns;
divl = 9, divh = 4;
l = 10, h = 5;
tLow = 400ns, tHigh = 200ns;
start_setup_cnt = stop_setup_cnt = 0;
u = p = 1;
tSU;sta = (8h * u + 1) * T = 205ns;
tHD;sta = [8h * (u + 1) - 1] * T = 395ns;
tSU;sto = (8h * p + 1) * T = 205ns;
data_upd_st = 1;
s = data_upd_st + 1 = 2;
tHD;sda = (l * s + 1) * T = 105;
tSU;sda = [(8 - s) * l + 1] * T = 295;
2. scl: 3.4M
Source Pclk: 200M, Target scl: 3400K, Final scl: 3125K;
Tpclk = 5ns;
divl = 4, divh = 2;
l = 5, h = 3;
tLow = 200ns, tHigh = 120ns;
start_setup_cnt = stop_setup_cnt = 1;
u = p = 2;
tSU;sta = (8h * u + 1) * T = 245ns;
tHD;sta = [8h * (u + 1) - 1] * T = 355ns;
tSU;sto = (8h * p + 1) * T = 245ns;
data_upd_st = 1;
s = data_upd_st + 1 = 2;
tHD;sda = (l * s + 1) * T = 55ns;
tSU;sda = [(8 - l) * s + 1] * T = 145ns;
Signed-off-by: David Wu <david.wu@rock-chips.com>
---
Changes in v3: None
changes in v2:
- split patch to three patches(Heiko)
drivers/i2c/busses/i2c-rk3x.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
index b7229a7..bb041aa 100644
--- a/drivers/i2c/busses/i2c-rk3x.c
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -700,9 +700,9 @@ static int rk3x_i2c_v1_calc_clock(unsigned long clk_rate,
int ret = 0;
- /* Support standard-mode and fast-mode */
- if (WARN_ON(t_input->bus_freq_hz > 400000))
- t_input->bus_freq_hz = 400000;
+ /* Support standard-mode, fast-mode and highspeed-mode */
+ if (WARN_ON(t_input->bus_freq_hz > 3400000))
+ t_input->bus_freq_hz = 3400000;
/* prevent scl_rate_khz from becoming 0 */
if (WARN_ON(t_input->bus_freq_hz < 1000))
@@ -732,6 +732,24 @@ static int rk3x_i2c_v1_calc_clock(unsigned long clk_rate,
spec_min_data_setup_ns = 100;
spec_max_data_hold_ns = 900;
+ } else if (t_input->bus_freq_hz <= 1700000) {
+ spec_min_low_ns = 320;
+ spec_min_high_ns = 120;
+
+ spec_min_setup_start_ns = 160;
+ spec_min_stop_setup_ns = 160;
+
+ spec_min_data_setup_ns = 10;
+ spec_max_data_hold_ns = 150;
+ } else {
+ spec_min_low_ns = 160;
+ spec_min_high_ns = 60;
+
+ spec_min_setup_start_ns = 160;
+ spec_min_stop_setup_ns = 160;
+
+ spec_min_data_setup_ns = 10;
+ spec_max_data_hold_ns = 70;
}
/* caculate min-divh and min-divl */
--
1.9.1
prev parent reply other threads:[~2016-01-14 12:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-14 12:31 [PATCH v3 0/4] Add rk3399 i2c clocks calculated method David Wu
2016-01-14 12:31 ` [PATCH v3 1/4] i2c: rk3x: switch to i2c generic dt parsing David Wu
2016-01-14 13:05 ` Andy Shevchenko
2016-01-14 12:31 ` [PATCH v3 2/4] i2c: rk3x: add ops to caculate i2c clocks David Wu
2016-01-14 13:19 ` Andy Shevchenko
2016-01-14 12:31 ` [PATCH v3 3/4] i2c: rk3x: new method " David Wu
2016-01-14 13:29 ` Andy Shevchenko
2016-01-14 16:12 ` Doug Anderson
2016-01-14 12:31 ` David Wu [this message]
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=1452774699-57455-5-git-send-email-david.wu@rock-chips.com \
--to=david.wu@rock-chips.com \
--cc=andy.shevchenko@gmail.com \
--cc=cf@rock-chips.com \
--cc=dianders@chromium.org \
--cc=heiko@sntech.de \
--cc=hl@rock-chips.com \
--cc=huangtao@rock-chips.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=wsa@the-dreams.de \
--cc=xjq@rock-chips.com \
--cc=zyw@rock-chips.com \
/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).