From patchwork Tue Mar 14 21:51:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9624603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5EAE7604A9 for ; Tue, 14 Mar 2017 21:54:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FC2627B2F for ; Tue, 14 Mar 2017 21:54:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44A1F285A7; Tue, 14 Mar 2017 21:54:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA26927B2F for ; Tue, 14 Mar 2017 21:54:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:References:To:Subject:From:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6zGPzdICfhTO9fQDadltazGKlCWWcuN3HeTHlHbfENE=; b=A7kNZVVc2R2zVL DNa683avP2P7M/UwWpL7MTi3RQL7RQupGDJdJwnpS8Rvh7iSzpk1tCxpAhXntlD7F9ylDX3tdqKH8 K07JiwQ/L+jDlfQ0Mek1Ck9BDovoFMmVdR1LU3i3h/WDi8zg5O9pG7L3r8skGbxL9u5VH5n1mA21z 8+XqNEDLVMpXBHdHy6KnsB1eqtqYBNb352lnSwIMgnqrA3pZJ2rfpV230zwJc1TxKwV+tW2rR/mdB oYnyC101ic5m1TRFigsF/bro+LLp1QeM6Ob5M9BnNhgUqkZGncfBV/mxElLK/Twkt3c85tD6X78dU hNILIGrs3rbLua1WT+6g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cnuP5-0006WI-K3; Tue, 14 Mar 2017 21:54:51 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cnuP0-0006Qa-7U for linux-amlogic@lists.infradead.org; Tue, 14 Mar 2017 21:54:48 +0000 Received: by mail-wr0-x244.google.com with SMTP id g10so25528267wrg.0 for ; Tue, 14 Mar 2017 14:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=oHB0iSogOBi5Erzwvq7dQy3m4kXKpfQh4djGwiYitZE=; b=BQ7TrLvVcNXfBoqT8iGD67iF9HIMpple/rk83bTq0Od6vAMAkLX8sbSVezgAsp5+A9 8HFKISHcLCgGVKXAxF1rzm1C2ROknzfrWrtDiI3AB2F113zRQdAHF5g2eE28KIgu2cMK GR/P2ivaXoy2B+EKX4AWEQr0AC9mVq1rh/VcmIxB4P9ymOYBcAsDhuTLT68cbNM4RgXg 7y+gj11YnaCu4gsYsyKdIyhbBlfl1u3L90PKrn8ix5N30pkM1bXszilofObKGrbDNL6H 6uUq4l3ikIvkjVPMuK+xciZbfcFCiVn2/mEY5ycxLvcHpGTtM8Tll3tegw8znp2W8NtT P2DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=oHB0iSogOBi5Erzwvq7dQy3m4kXKpfQh4djGwiYitZE=; b=fWZVKERQfVgRajBqAahKx70COGJAgXuhJ5yNtqQ8yoxIKIgJ+yFTtlcC+BlWD7rlva mzbMpIuQjhNPbsy6JRpTcY3nTZeJwhmZT2nPuWI5xbxw0aaMBZT1t+CA9RYW/x1Rcorm +Jg7gEXfhqSJu63hTulkw2ld2mKVQgYusKJ97VR34+ySdfDaOh+HJNtQCiaxIxKeN1JK 8lLBm6f/hUR2hZOuKw64Pqs/WoO5sFtoNujCAGkR92hyeBN3oe6GFAwGIZd3YZfyy20J SmsUyuWhvewIadlha1LvNm4Mn8VU7ffj6Y/zoX8FlLE58/Ed5L6+wwyQOq4kHttYUzOE q5nw== X-Gm-Message-State: AMke39nC6ZTU0wi9Y0Jx6bB0dCTf+TYnCX6Lp7aX4Wt83zK+58Z75/48zJ1Ys7sG63EMPQ== X-Received: by 10.223.173.76 with SMTP id p70mr32759936wrc.168.1489528463961; Tue, 14 Mar 2017 14:54:23 -0700 (PDT) Received: from ?IPv6:2003:c6:ebdc:4000:5e3:f718:f7c9:9ef? (p200300C6EBDC400005E3F718F7C909EF.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:5e3:f718:f7c9:9ef]) by smtp.googlemail.com with ESMTPSA id b58sm30772008wra.47.2017.03.14.14.54.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Mar 2017 14:54:23 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH v4 04/10] i2c: meson: use i2c core for DT clock-frequency parsing To: Wolfram Sang , Jerome Brunet , Kevin Hilman References: <1a2ecdc8-a326-a7a7-22ec-658fd147daf4@gmail.com> Message-ID: <96c1b005-063e-ae22-ded4-fbb0b023f02b@gmail.com> Date: Tue, 14 Mar 2017 22:51:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1a2ecdc8-a326-a7a7-22ec-658fd147daf4@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170314_145446_428273_8B0699C4 X-CRM114-Status: GOOD ( 10.28 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, "linux-i2c@vger.kernel.org" Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We don't have to parse the DT manually to retrieve the bus frequency and we don't have to maintain an own default for the bus frequency. Let the i2c core do this for us. Signed-off-by: Heiner Kallweit Reviewed-by: Jerome Brunet --- v2: - added Reviewed-by v3: - changed order of patches v4: - update DT binding documentation --- Documentation/devicetree/bindings/i2c/i2c-meson.txt | 17 +++++++++++++++++ drivers/i2c/busses/i2c-meson.c | 8 +++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-meson.txt b/Documentation/devicetree/bindings/i2c/i2c-meson.txt index 386357d1..6bc10cdc 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-meson.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-meson.txt @@ -8,10 +8,27 @@ Required properties: - #address-cells: should be <1> - #size-cells: should be <0> +For details regarding the following core I2C bindings see also i2c.txt. + Optional properties: - clock-frequency: the desired I2C bus clock frequency in Hz; in absence of this property the default value is used (100 kHz). +- i2c-scl-falling-time-ns + Number of nanoseconds the SCL signal takes to fall; t(f) in the I2C + specification. + +- i2c-scl-internal-delay-ns + Number of nanoseconds the IP core additionally needs to setup SCL. + +- i2c-scl-rising-time-ns + Number of nanoseconds the SCL signal takes to rise; t(r) in the I2C + specification. + +- i2c-sda-falling-time-ns + Number of nanoseconds the SDA signal takes to fall; t(f) in the I2C + specification. + Examples: i2c@c8100500 { diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c index e597764e..ac0ac82d 100644 --- a/drivers/i2c/busses/i2c-meson.c +++ b/drivers/i2c/busses/i2c-meson.c @@ -38,7 +38,6 @@ #define REG_CTRL_CLKDIV_MASK ((BIT(10) - 1) << REG_CTRL_CLKDIV_SHIFT) #define I2C_TIMEOUT_MS 500 -#define DEFAULT_FREQ 100000 enum { TOKEN_END = 0, @@ -387,15 +386,14 @@ static int meson_i2c_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct meson_i2c *i2c; struct resource *mem; - u32 freq; + struct i2c_timings timings; int irq, ret = 0; i2c = devm_kzalloc(&pdev->dev, sizeof(struct meson_i2c), GFP_KERNEL); if (!i2c) return -ENOMEM; - if (of_property_read_u32(pdev->dev.of_node, "clock-frequency", &freq)) - freq = DEFAULT_FREQ; + i2c_parse_fw_timings(&pdev->dev, &timings, true); i2c->dev = &pdev->dev; platform_set_drvdata(pdev, i2c); @@ -453,7 +451,7 @@ static int meson_i2c_probe(struct platform_device *pdev) return ret; } - meson_i2c_set_clk_div(i2c, freq); + meson_i2c_set_clk_div(i2c, timings.bus_freq_hz); return 0; }