From patchwork Thu Dec 17 02:23:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 58518 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp92047lbb; Wed, 16 Dec 2015 18:24:11 -0800 (PST) X-Received: by 10.98.31.69 with SMTP id f66mr10528672pff.78.1450319051389; Wed, 16 Dec 2015 18:24:11 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k86si8907812pfj.113.2015.12.16.18.24.11; Wed, 16 Dec 2015 18:24:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-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-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755232AbbLQCYJ (ORCPT + 1 other); Wed, 16 Dec 2015 21:24:09 -0500 Received: from mail-bn1on0072.outbound.protection.outlook.com ([157.56.110.72]:62561 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753073AbbLQCYI (ORCPT ); Wed, 16 Dec 2015 21:24:08 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from ssuthiku-ubuntu-lt.amd.com (165.204.77.1) by CY1PR12MB0443.namprd12.prod.outlook.com (10.163.91.21) with Microsoft SMTP Server (TLS) id 15.1.361.13; Thu, 17 Dec 2015 02:24:03 +0000 From: Suravee Suthikulpanit To: , CC: , , , , , , , "Suravee Suthikulpanit" Subject: [PATCH v2] i2c: designware: Do not require clock when SSCN and FFCN are provided Date: Wed, 16 Dec 2015 20:23:45 -0600 Message-ID: <1450319025-19120-1-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BY1PR15CA0009.namprd15.prod.outlook.com (25.162.17.147) To CY1PR12MB0443.namprd12.prod.outlook.com (25.163.91.21) X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0443; 2:mRIcOnacsd6AUFqPGEluuxN9/6oIItqATLRAAqFhLKFjMmavwr/SSy5bl3ftSjoS8iHE6vf0R1qaMBIEULtigcBDLFaV89poVyTlWhMLbIVlIHV07xD2fZaHEP8g7E+tCahvciN9sXieEqyFrfjBng==; 3:OBCYxLa2/RgHyeR4PwsmNBpAi3iCOKX5XS69HFLxY/+BmyvqbRnMcyXvL3iiME0B0ZwRI1ZZfczQqLf2IkAmMf3S4KPkVMbyLfPCmVlCgkAyt2F6Ztkr5ysV/YTkiXuW; 25:Of0L5+kYY/27BNXMR4wOXFdlSL/iIpbv+0asufy8dlmxQUUrTpFx3IewmmlQ83EkbfFxhIIJIvSv+9nm4P9bgDZ+S721k5cBdcOUGDdctTgLBuih1t0m2m8gkMDK+Cts0bN4KJb4aycU/pzYRxtgyM3j8FoTtI2O2D81arL5NpGQSi7fPVfzNgn5Esuu4/eVh4TSmwDYHvHa96atCvWlq5hd+zHnlVQJWmv/JEfH9aITj4thsSFnViIF3o8eC+lgINGTV6kBRkVL89iNjBx4gA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0443; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0443; 20:6cK0d8zUNX4KsirfX5832b95UCnR5HzF5izanhg4nWlTiNxKsfV7nmv738gs13FP5DLZgRRn5NUpk12IbL19hF22ZU2Mk5ah8BQ4z9Lw+UpEUipY6qfx77M55elbl1nugcXYFt4/567uimtup9M2PjJYhCdouikXOi5DABgM7sTgS2Rm/N8iitf3hF9jOKN+6Sg40rMC44xR/S8vn2JcU0+24Xfx3x+0QMJHCmNZ0xV2pdghvJ1j43QC5LNtnmBxTEctqJ+NzwgboWw32WUScvi01y3SkAWZuCpBv/RluFxNrPimOSqFpYCi6oxUiASM+Z/8vyjguW5GAFM8QAi8k+kIKkwpZS6jLJujflr8r9PRjt/Wxmv7Z1FgU9Jquy5SQzjWBr5wzXaCBYJqpqN7M0JikRIktPdeFW+ZwoLAoXK80XGwBROnPoLxPnkBXTgguuPGimnFL3BWfbkrMb52hoYgk2ztdoNuJKlEfwBcqYPRMDJ4VbLMyudbIb9uWISS; 4:RnvDp5KZm9fk2EXCeWrRfAX+psq9RDcTdRcs6KdrPjoIqVwWjzCbwaDzgJ0wHUAEzZHACoT1dCVLHLGqFBIjoLGUkadzhxeGWQNbHMMlIucZE85pDSTnD7e/o8j5WLW7Deec3N025j5X8s78o+lgcQn2IDHvaBSsToKPNfCv1izyaeFNqyHddpN7jWizvjaa5OQUOfjoQmt4j0ek+TeoF4pWkpsyFCDLFWJipcsVa3zHjuQ9QIzklyJIQOz0rlCEI7x3Lx0ILqO7EW8sSDpZt3H+abTOZtGk30U0Ra9aTPLDb3WafoWVdTh9Lnsti+P2dFft5fKunPRMwqwDEMatbrJKfP+36uEl1NYmW/Jb9SrtYQFRPL0IeWt80EqPg0CXDtduddqcinGVXEAF74g3sZHuedzLzj36CCJxJxL+ZSc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:CY1PR12MB0443; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0443; X-Forefront-PRVS: 07935ACF08 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(101416001)(77096005)(50226001)(50466002)(5008740100001)(19580405001)(189998001)(229853001)(36756003)(5004730100002)(122386002)(42186005)(92566002)(86362001)(5003940100001)(40100003)(66066001)(47776003)(97736004)(5001770100001)(3846002)(53416004)(6116002)(50986999)(19580395003)(48376002)(586003)(87976001)(1096002)(106356001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0443; H:ssuthiku-ubuntu-lt.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0443; 23:69/6fzaZzRs6Doy1KoP4R6MZSPLpEgzXbyMGfwZKHbabHONKOT0cb0zWHG152wgH2gpxDnxjSgcD+jHZ/27y47w5kY7zDYZ+LbwX6GQkehK777pbTFzXQ+ihEEjv+qdZbTkofrTSw1UCV0J1PSGWksj6EfQMwk8vjYqoErxPHZnpfF1hh/iqUozA+5ItveAsgmJpj/YhJoPy167MgL4H6+cXHUXu9ANETQQXYGPP38dfuOwYZDYUujaMCpagPaM5qrFm4H1z6NSml2biPweEJ9K/gR0k2Qs0NkTQRCbbLbp3gMjzx4ilcVM6yuFmqpWwu2Ck5UfuLps16c3ThfoDKIFGSgfAaLFN+ZbDb1HwZFZbrDun+Twy6medbPWDNv6LVyWk/r1FJytHsooCHb7y2Dmj+aKiOppcim0nQUfDb+wppIsVOarrB9WEuWGhOco7r/Up7FM3CnFyBvMxb+i0jmn9PrA+bYFR5Lpt9fkA0+BVsX0dkWDwhd8m8CJlawou3Mm+rijeWVhgjDbN6dZw7iLgxs6Xl2zQjBEyQW0tiuHahZWtGXnZaGqggO1anybWrNSFMC8ny2XxNU58AeUy0Wct4f6SMBvl3uqd42udovoJ84pg9azUCLnnzjQVIVVn4Foy7sXjr1QoJ1m4nv2AGPcqtxIrdFlc/LG7R/8seTxRVlKRP6tbStViYctrBV3/KUz7b1FWi+oMlNVJSSrs1SYo3ZH2rWQEb1Imt5rfRjtTPdKQSNY8S4uGMW1m2QQle6I8xLrH3r7VErgth7zkm8mn/6Rv9gTYb8LsVMGuoZBIdPceJ3q29UblSlSdkYFFr2b9YfiMH7y7tUhQcGAMA1z2XDcxGF/nC7guDI9fuV5xMXGHA20X4pWHBVqW9oq8VpxB31nybzYiIaUFiRUv3QNNktSy1fkSNy9QlO+zccE= X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0443; 5:Jd1M05vAysYVKCf0yq/9vGzRPTrawSViSJuZr8KoRvGncPG2xupULYWnR4uG+HMNfbWCWW+qfq/91ak9Ufsxag2GYJyJQ99K5UFTw9wRlhiGsFjFeake1x4ndwZ6BFx2E9vjp4gogONFZ659nIyXsw==; 24:N3HUnvAtrttJ1TtwvDg33cywKBssqlXF+5MSgTwCYlQ8MFFStzY1YE7ukiwQH+T3+xpBmHsrXQlQpwtsWhJ4YbPW0oOPKVxamWbwcxbW07Q=; 20:n57/iZm7WsAzRVNMr3vbjQy1p7rk80Qz+krYLBS6qSmR1fFtswEJHnu7Q3z5nboSzI7AYYsjj5nNQniZ7gTdke3Eld0PYK9VP6aCubu17TD/xXdQj5VUUEDHkAwg4THMFvIpDlTDEWMstJmbXrw/kcNl6MtVhIHkrraDgOG0cxqDNObfBRWWruE9FuXT6GqHugnsvlRpxbM8TP1tgZbmYVWp5g3gVUqQWd6G3BwfOVqMRKWv5TeulL95DHxaF7eL X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2015 02:24:03.7207 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0443 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The current driver uses input clock source frequency to calculate values for [SS|FS]_[HC|LC] registers. However, when booting ACPI, we do not currently have a good way to provide the frequency information. Instead, we can leverage the SSCN and FFCN ACPI methods, which can be used to directly provide these values. So, the clock information should no longer be required during probing. However, since clk can be invalid, additional checks must be done where we are making use of it. Signed-off-by: Suravee Suthikulpanit --- Note: This has been tested on AMD Seattle RevB for both DT and ACPI. Changes in V2: In v1, I disregarded the clock if SSCN and FMCN are provided, assuming that it was not needed. That was incorrect assumption, and is now fixed in v2. drivers/i2c/busses/i2c-designware-platdrv.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 8ffc36b..4615fe3 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -44,6 +44,9 @@ static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev) { + if (IS_ERR(dev->clk)) + return 0; + return clk_get_rate(dev->clk)/1000; } @@ -206,9 +209,8 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) dev->clk = devm_clk_get(&pdev->dev, NULL); dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; - if (IS_ERR(dev->clk)) - return PTR_ERR(dev->clk); - clk_prepare_enable(dev->clk); + if (!IS_ERR(dev->clk)) + clk_prepare_enable(dev->clk); if (!dev->sda_hold_time && ht) { u32 ic_clk = dev->get_clk_rate_khz(dev); @@ -297,7 +299,8 @@ static int dw_i2c_plat_suspend(struct device *dev) struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); i2c_dw_disable(i_dev); - clk_disable_unprepare(i_dev->clk); + if (!IS_ERR(i_dev->clk)) + clk_disable_unprepare(i_dev->clk); return 0; } @@ -307,7 +310,8 @@ static int dw_i2c_plat_resume(struct device *dev) struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); - clk_prepare_enable(i_dev->clk); + if (!IS_ERR(i_dev->clk)) + clk_prepare_enable(i_dev->clk); if (!i_dev->pm_runtime_disabled) i2c_dw_init(i_dev);