From patchwork Mon Mar 14 22:52:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wu X-Patchwork-Id: 8589031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 63240C0553 for ; Tue, 15 Mar 2016 14:57:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0E132021B for ; Tue, 15 Mar 2016 14:57:03 +0000 (UTC) Received: from bombadil.infradead.org (unknown [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C14E1201EF for ; Tue, 15 Mar 2016 14:57:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1afqFZ-0007iU-5z; Tue, 15 Mar 2016 14:47:09 +0000 Received: from lucky1.263xmail.com ([211.157.147.133]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1afqFL-0007en-KN; Tue, 15 Mar 2016 14:46:57 +0000 Received: from david.wu?rock-chips.com (unknown [192.168.167.225]) by lucky1.263xmail.com (Postfix) with SMTP id 4AE6A52CE1; Tue, 15 Mar 2016 22:46:32 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 7FC0C446; Tue, 15 Mar 2016 22:46:32 +0800 (CST) X-RL-SENDER: david.wu@rock-chips.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: david.wu@rock-chips.com X-UNIQUE-TAG: <9ffc011b79b405d8f4b152dd21a9470f> X-ATTACHMENT-NUM: 0 X-SENDER: wdc@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 14358GMPW6Z; Tue, 15 Mar 2016 22:46:33 +0800 (CST) From: David Wu To: heiko@sntech.de, wsa@the-dreams.de Subject: [PATCH v4 3/3] i2c: rk3x: support I2C Highspeed Mode for rk3399 Date: Tue, 15 Mar 2016 06:52:30 +0800 Message-Id: <1457995950-46710-4-git-send-email-wdc@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457995950-46710-1-git-send-email-wdc@rock-chips.com> References: <1457995950-46710-1-git-send-email-wdc@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160315_074656_510416_4863B779 X-CRM114-Status: UNSURE ( 8.90 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.9 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangtao@rock-chips.com, hl@rock-chips.com, linux-rockchip@lists.infradead.org, dianders@chromium.org, linux-kernel@vger.kernel.org, cf@rock-chips.com, andy.shevchenko@gmail.com, xjq@rock-chips.com, linux-i2c@vger.kernel.org, david.wu@rock-chips.com, zyw@rock-chips.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, DATE_IN_PAST_12_24, RCVD_IN_DNSWL_MED, RDNS_NONE, UNPARSEABLE_RELAY, URIBL_BLACK autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Wu 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 --- 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 */