From: David Wu <wdc@rock-chips.com>
To: heiko@sntech.de, wsa@the-dreams.de
Cc: dianders@chromium.org, andy.shevchenko@gmail.com,
huangtao@rock-chips.com, hl@rock-chips.com, xjq@rock-chips.com,
zyw@rock-chips.com, cf@rock-chips.com,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org, david.wu@rock-chips.com
Subject: [PATCH v4 3/3] i2c: rk3x: support I2C Highspeed Mode for rk3399
Date: Tue, 15 Mar 2016 06:52:30 +0800 [thread overview]
Message-ID: <1457995950-46710-4-git-send-email-wdc@rock-chips.com> (raw)
In-Reply-To: <1457995950-46710-1-git-send-email-wdc@rock-chips.com>
From: David Wu <david.wu@rock-chips.com>
The i2c controller of new version1 supports highspeed mode,
1.7M and 3.4M rate. It 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.
Signed-off-by: David Wu <david.wu@rock-chips.com>
---
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 c82c2f9..f1ea801 100644
--- a/drivers/i2c/busses/i2c-rk3x.c
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -704,9 +704,9 @@ static int rk3x_i2c_v1_calc_timings(unsigned long clk_rate,
int ret = 0;
- /* Support standard-mode and fast-mode */
- if (WARN_ON(t->bus_freq_hz > 400000))
- t->bus_freq_hz = 400000;
+ /* Support standard-mode, fast-mode and highspeed-mode */
+ if (WARN_ON(t->bus_freq_hz > 3400000))
+ t->bus_freq_hz = 3400000;
/* prevent scl_rate_khz from becoming 0 */
if (WARN_ON(t->bus_freq_hz < 1000))
@@ -736,6 +736,24 @@ static int rk3x_i2c_v1_calc_timings(unsigned long clk_rate,
spec_min_data_setup_ns = 100;
spec_max_data_hold_ns = 900;
+ } else if (t->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-03-15 14:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-14 22:52 [PATCH v4 0/3] update some i2c changes for rk3399 soc David Wu
2016-03-14 22:52 ` [PATCH v4 1/3] i2c: rk3x: switch to i2c generic dt parsing David Wu
2016-03-14 22:52 ` [PATCH v4 2/3] i2c: rk3x: add new method to caculate i2c timings for rk3399 David Wu
2016-03-14 22:52 ` 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=1457995950-46710-4-git-send-email-wdc@rock-chips.com \
--to=wdc@rock-chips.com \
--cc=andy.shevchenko@gmail.com \
--cc=cf@rock-chips.com \
--cc=david.wu@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-i2c@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
all inboxes | Powered by JetHome®