From patchwork Mon Feb 18 12:51:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Ruppert X-Patchwork-Id: 221325 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 308A42C0889 for ; Mon, 18 Feb 2013 23:53:18 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755021Ab3BRMwz (ORCPT ); Mon, 18 Feb 2013 07:52:55 -0500 Received: from mail.abilis.ch ([195.70.19.74]:14713 "EHLO mail.abilis.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755933Ab3BRMwj (ORCPT ); Mon, 18 Feb 2013 07:52:39 -0500 Received: from vzimbra0.lan (vzimbra0.lan [10.41.22.42]) by mail.abilis.ch (8.13.8/8.13.8) with ESMTP id r1ICpmNj004636; Mon, 18 Feb 2013 13:51:48 +0100 Received: from ab42.lan (ab42.lan [10.41.22.170]) by vzimbra0.lan (Postfix) with ESMTP id B50CD901182; Mon, 18 Feb 2013 13:51:48 +0100 (CET) Received: by ab42.lan (Postfix, from userid 2100) id AD68D140F; Mon, 18 Feb 2013 13:51:48 +0100 (CET) From: Christian Ruppert To: Wolfram Sang , "Ben Dooks (embedded platforms)" Cc: Grant Likely , Rob Herring , Rob Landley , devicetree-discuss@lists.ozlabs.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Vineet Gupta , Christian Ruppert , Pierrick Hascoet Subject: [PATCH v3] i2c-designware: make SDA hold time configurable Date: Mon, 18 Feb 2013 13:51:45 +0100 Message-Id: <1361191905-30099-1-git-send-email-christian.ruppert@abilis.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <20130218105742.GK20771@intel.com> References: <20130218105742.GK20771@intel.com> X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on dmmail0.lan Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This patch makes the SDA hold time configurable through device tree. It was tested on a hybrid of i2c/next and arc-3.8-baseline (see https://github.com/foss-for-synopsys-dwc-arc-processors/linux/commits/arc-3.8-baseline) since our platform is ARC based and this architecture is not yet supported by i2c/next. Signed-off-by: Christian Ruppert Signed-off-by: Pierrick Hascoet Reviewed-by: Mika Westerberg --- .../devicetree/bindings/i2c/i2c-designware.txt | 15 +++++++++++++++ drivers/i2c/busses/i2c-designware-core.c | 5 +++++ drivers/i2c/busses/i2c-designware-core.h | 1 + drivers/i2c/busses/i2c-designware-platdrv.c | 5 +++++ 4 files changed, 26 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-designware.txt b/Documentation/devicetree/bindings/i2c/i2c-designware.txt index e42a2ee..fb2eac8 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-designware.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-designware.txt @@ -10,6 +10,10 @@ Recommended properties : - clock-frequency : desired I2C bus clock frequency in Hz. +Optional properties : + - sda-hold-time : If this property is present, the register SDA_HOLD will + be initialised with its value. + Example : i2c@f0000 { @@ -20,3 +24,14 @@ Example : interrupts = <11>; clock-frequency = <400000>; }; + + i2c@1120000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,designware-i2c"; + reg = <0x1120000 0x1000>; + interrupt-parent = <&ictl>; + interrupts = <12 1>; + clock-frequency = <400000>; + sda-hold-time = <0x64>; + }; diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c index 94fd818..ba40e14 100644 --- a/drivers/i2c/busses/i2c-designware-core.c +++ b/drivers/i2c/busses/i2c-designware-core.c @@ -67,6 +67,7 @@ #define DW_IC_STATUS 0x70 #define DW_IC_TXFLR 0x74 #define DW_IC_RXFLR 0x78 +#define DW_IC_SDA_HOLD 0x7c #define DW_IC_TX_ABRT_SOURCE 0x80 #define DW_IC_COMP_PARAM_1 0xf4 #define DW_IC_COMP_TYPE 0xfc @@ -310,6 +311,10 @@ int i2c_dw_init(struct dw_i2c_dev *dev) dw_writel(dev, lcnt, DW_IC_FS_SCL_LCNT); dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt); + /* Configure SDA Hold Time if required */ + if (dev->sda_hold_time) + dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD); + /* Configure Tx/Rx FIFO threshold levels */ dw_writel(dev, dev->tx_fifo_depth - 1, DW_IC_TX_TL); dw_writel(dev, 0, DW_IC_RX_TL); diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h index 9c1840e..33dfec3 100644 --- a/drivers/i2c/busses/i2c-designware-core.h +++ b/drivers/i2c/busses/i2c-designware-core.h @@ -88,6 +88,7 @@ struct dw_i2c_dev { u32 master_cfg; unsigned int tx_fifo_depth; unsigned int rx_fifo_depth; + u32 sda_hold_time; }; #define ACCESS_SWAP 0x00000001 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index d2a33e9..cb44bae 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -136,6 +137,10 @@ static int dw_i2c_probe(struct platform_device *pdev) } clk_prepare_enable(dev->clk); + if (pdev->dev.of_node) + of_property_read_u32(pdev->dev.of_node, "sda-hold-time", + &dev->sda_hold_time); + dev->functionality = I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR |