Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3653880imj; Tue, 19 Feb 2019 07:14:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IbOQFmFEURv7ycixFVWmvhBUXEFwRM9zGW0g9EpC2n8YisojdprSbaOVPSBmM/xHJxDxq+V X-Received: by 2002:a17:902:6b03:: with SMTP id o3mr31432972plk.126.1550589240388; Tue, 19 Feb 2019 07:14:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550589240; cv=none; d=google.com; s=arc-20160816; b=Yg7RRzg6VqJD9WaL19fybdDiXuGDbr4SY054swcvrDjB166z5K1VKuhJhnMxY8vgcI DBEhO33JPn27YKDFIO9d78RvPTZj/W2OpAV8tDEYATyWwV1lMvt7vQPeMuiNRC5GF6cd rLLE9uQwjlOlOgyO69UGcDe1QL5mSj1rC2xtYp1+CRbIM0kBEtBWjbA57nTKrUcZMNyL wsoqCyoz9PrD2FKzwBhoSrBufxBmX9z5fv3jLG5w8f72QOmJaKzL0UyweYTiBK1EHzjs 0bRRGkIVH6Yf4a1Kh6kxCavzi0Hg7485ssHbrBXpyUAez7MTcdUdcsIobJzFSRGJ++0V KA4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=HYuuBEnNtu+dMAoTSYK1vm21Ol6Dl95/8+6TgbkS3OY=; b=ylbqIM66mzXIyF2i8R4hPMdY35TwNqUEvgP6eSU6h70qehyaIU9DJ1mC6tBm60QdUu dQG3pcNzMlO7QTPNdMLT66Lms9GfYnPwjwme+eoGdJ4hLvJzrGPia73Taio8Qkq6koFS 98qjevWD77ANpUgGKGE7RWlRZ5Mgo7VmOF8CmAdiFrzcGLLKilVVzcKuYte7Ympfsg76 mAIV5UMBcoO927E6It2bzvwHOREddZx3DGDgCfyp3MAs+NJXnQLBNuAf7zk1texNd99i oHUTbIJ1dJZeZRlRkWS8cPMglOwqxqdnLYxGxiIzGUIiJDtOqrQe0ZlgEhNTsDQnXXQ2 qpIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si14973395pgw.142.2019.02.19.07.13.45; Tue, 19 Feb 2019 07:14:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728646AbfBSPMi (ORCPT + 99 others); Tue, 19 Feb 2019 10:12:38 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:54540 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726384AbfBSPMh (ORCPT ); Tue, 19 Feb 2019 10:12:37 -0500 X-IronPort-AV: E=Sophos;i="5.58,388,1544454000"; d="scan'208";a="8078121" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 20 Feb 2019 00:12:35 +0900 Received: from renesas-VirtualBox.ree.adwin.renesas.com (unknown [10.226.37.56]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 85A634485C21; Wed, 20 Feb 2019 00:12:33 +0900 (JST) From: Gareth Williams To: Jarkko Nikula , Andy Shevchenko , Mika Westerberg , linux-i2c@vger.kernel.org Cc: Phil Edworthy , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Gareth Williams Subject: [PATCH v2 2/2] i2c: designware: Add support for a bus clock Date: Tue, 19 Feb 2019 15:10:42 +0000 Message-Id: <1550589042-11096-3-git-send-email-gareth.williams.jx@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550589042-11096-1-git-send-email-gareth.williams.jx@renesas.com> References: <1550589042-11096-1-git-send-email-gareth.williams.jx@renesas.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Phil Edworthy The Synopsys I2C Controller has a bus clock, but most SoCs hide this away. However, on some SoCs you need to explicity enable the bus clock in order to access the registers. Therefore, add support for an optional bus clock. Signed-off-by: Phil Edworthy Signed-off-by: Gareth Williams --- v2: - Use new devm_clk_get_optional() function as it simplifies handling when the optional clock is not present. --- drivers/i2c/busses/i2c-designware-common.c | 12 +++++++++++- drivers/i2c/busses/i2c-designware-core.h | 1 + drivers/i2c/busses/i2c-designware-platdrv.c | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c index a473011..febcea6 100644 --- a/drivers/i2c/busses/i2c-designware-common.c +++ b/drivers/i2c/busses/i2c-designware-common.c @@ -251,13 +251,23 @@ unsigned long i2c_dw_clk_rate(struct dw_i2c_dev *dev) int i2c_dw_prepare_clk(struct dw_i2c_dev *dev, bool prepare) { + int ret; + if (IS_ERR(dev->clk)) return PTR_ERR(dev->clk); - if (prepare) + if (prepare) { + /* Optional bus clock */ + ret = clk_prepare_enable(dev->busclk); + if (ret) + return ret; + return clk_prepare_enable(dev->clk); + } clk_disable_unprepare(dev->clk); + clk_disable_unprepare(dev->busclk); + return 0; } EXPORT_SYMBOL_GPL(i2c_dw_prepare_clk); diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h index b4a0b2b..9388ae3 100644 --- a/drivers/i2c/busses/i2c-designware-core.h +++ b/drivers/i2c/busses/i2c-designware-core.h @@ -226,6 +226,7 @@ struct dw_i2c_dev { void __iomem *ext; struct completion cmd_complete; struct clk *clk; + struct clk *busclk; struct reset_control *rst; struct i2c_client *slave; u32 (*get_clk_rate_khz) (struct dw_i2c_dev *dev); diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 9eaac3b..fbaa6aa 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -346,6 +346,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) else i2c_dw_configure_master(dev); + /* Optional bus clock */ + dev->busclk = devm_clk_get_optional(&pdev->dev, "bus"); + if (IS_ERR(dev->busclk)) + return PTR_ERR(dev->busclk); + dev->clk = devm_clk_get(&pdev->dev, NULL); if (!i2c_dw_prepare_clk(dev, true)) { u64 clk_khz; -- 2.7.4