From: David Wu <wdc-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
To: heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org
Cc: huangtao-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
hl-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org,
dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
xjq-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
David Wu <david.wu-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH v1 3/3] i2c: rk3x: support I2C Hs-mode for rk3399
Date: Fri, 11 Dec 2015 22:33:04 +0800 [thread overview]
Message-ID: <1449844384-6236-3-git-send-email-wdc@rock-chips.com> (raw)
In-Reply-To: <1449844384-6236-1-git-send-email-wdc-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
From: David Wu <david.wu-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
The i2c controller of new version1 supports highspeed mode,
1.7M and 3.4M rate. It also could be calculated divs by the rules.
The final divs would be effected a lot by hardware elements like
scl_rise_ns, scl_fall_ns and sda_rise_ns,sds_fall_ns.
Signed-off-by: David Wu <david.wu-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
---
drivers/i2c/busses/i2c-rk3x.c | 56 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 48 insertions(+), 8 deletions(-)
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
index fae5099..ec0e37f 100644
--- a/drivers/i2c/busses/i2c-rk3x.c
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -700,8 +700,8 @@ static int rk3x_i2c_v1_calc_divs(unsigned long clk_rate, unsigned long scl_rate,
int ret = 0;
- if (WARN_ON(scl_rate > 400000))
- scl_rate = 400000;
+ if (WARN_ON(scl_rate > 3400000))
+ scl_rate = 3400000;
if (WARN_ON(scl_rate < 100000))
scl_rate = 100000;
@@ -719,7 +719,7 @@ static int rk3x_i2c_v1_calc_divs(unsigned long clk_rate, unsigned long scl_rate,
start_setup_cnt = 0;
stop_setup_cnt = 0;
- } else {
+ } else if (scl_rate <= 400000) {
spec_min_setup_start = 600;
spec_min_hold_start = 600;
@@ -732,6 +732,32 @@ static int rk3x_i2c_v1_calc_divs(unsigned long clk_rate, unsigned long scl_rate,
start_setup_cnt = 0;
stop_setup_cnt = 0;
+ } else if (scl_rate <= 1700000) {
+ spec_min_low_ns = 320;
+ spec_min_high_ns = 120;
+
+ spec_min_setup_start = 160;
+ spec_min_hold_start = 160;
+
+ spec_max_data_hold_ns = 150;
+ spec_min_data_setup = 10;
+ spec_min_stop_setup = 160;
+
+ start_setup_cnt = 1;
+ stop_setup_cnt = 1;
+ } else {
+ spec_min_low_ns = 160;
+ spec_min_high_ns = 60;
+
+ spec_min_setup_start = 160;
+ spec_min_hold_start = 160;
+
+ spec_min_data_setup = 10;
+ spec_max_data_hold_ns = 70;
+ spec_min_stop_setup = 160;
+
+ start_setup_cnt = 2;
+ stop_setup_cnt = 2;
}
clk_rate_khz = DIV_ROUND_UP(clk_rate, 1000);
@@ -1126,15 +1152,29 @@ static int rk3x_i2c_probe(struct platform_device *pdev)
&i2c->scl_rise_ns)) {
if (i2c->scl_frequency <= 100000)
i2c->scl_rise_ns = 1000;
- else
+ else if (i2c->scl_frequency <= 400000)
i2c->scl_rise_ns = 300;
+ else if (i2c->scl_frequency <= 1700000)
+ i2c->scl_rise_ns = 80;
+ else
+ i2c->scl_rise_ns = 40;
}
if (of_property_read_u32(pdev->dev.of_node, "i2c-scl-falling-time-ns",
- &i2c->scl_fall_ns))
- i2c->scl_fall_ns = 300;
+ &i2c->scl_fall_ns)) {
+ if (i2c->scl_frequency <= 400000)
+ i2c->scl_fall_ns = 300;
+ else if (i2c->scl_frequency <= 1700000)
+ i2c->scl_fall_ns = 80;
+ else
+ i2c->scl_fall_ns = 40;
+ }
if (of_property_read_u32(pdev->dev.of_node, "i2c-sda-falling-time-ns",
- &i2c->scl_fall_ns))
- i2c->sda_fall_ns = i2c->scl_fall_ns;
+ &i2c->scl_fall_ns)) {
+ if (i2c->scl_frequency <= 400000)
+ i2c->sda_fall_ns = i2c->scl_fall_ns;
+ else
+ i2c->sda_fall_ns = 2 * i2c->scl_fall_ns;
+ }
strlcpy(i2c->adap.name, "rk3x-i2c", sizeof(i2c->adap.name));
i2c->adap.owner = THIS_MODULE;
--
1.9.1
next prev parent reply other threads:[~2015-12-11 14:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-11 14:33 [PATCH v1 1/3] i2c: rk3x: add calc_divs ops for new version David Wu
2015-12-11 14:33 ` [PATCH v1 2/3] i2c: rk3x: new way to calc_divs " David Wu
[not found] ` <1449844384-6236-1-git-send-email-wdc-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-12-11 14:33 ` David Wu [this message]
2015-12-15 0:32 ` [PATCH v1 1/3] i2c: rk3x: add calc_divs ops " Jianqun Xu
2015-12-20 15:43 ` Andy Shevchenko
2016-01-04 19:40 ` Wolfram Sang
2016-01-08 13:12 ` David.Wu
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=1449844384-6236-3-git-send-email-wdc@rock-chips.com \
--to=wdc-tnx95d0mmh7dzftrwevzcw@public.gmane.org \
--cc=david.wu-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
--cc=hl-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=huangtao-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
--cc=xjq-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
/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).