From patchwork Tue Dec 15 22:38:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7857911 Return-Path: X-Original-To: patchwork-linux-acpi@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 7E818BEEE1 for ; Tue, 15 Dec 2015 22:39:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E64EF203E1 for ; Tue, 15 Dec 2015 22:39:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75BAF202EC for ; Tue, 15 Dec 2015 22:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965399AbbLOWjY (ORCPT ); Tue, 15 Dec 2015 17:39:24 -0500 Received: from mail-bn1on0078.outbound.protection.outlook.com ([157.56.110.78]:30336 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965407AbbLOWjW (ORCPT ); Tue, 15 Dec 2015 17:39:22 -0500 X-Greylist: delayed 76387 seconds by postgrey-1.27 at vger.kernel.org; Tue, 15 Dec 2015 17:39:22 EST 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 BY1PR12MB0437.namprd12.prod.outlook.com (10.162.147.139) with Microsoft SMTP Server (TLS) id 15.1.355.16; Tue, 15 Dec 2015 22:39:18 +0000 From: Suravee Suthikulpanit To: , CC: , , , , , "Suravee Suthikulpanit" Subject: [PATCH] i2c: designware: Do not require clock when SSCN and FFCN are provided Date: Tue, 15 Dec 2015 16:38:58 -0600 Message-ID: <1450219138-5868-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: SN1PR17CA0013.namprd17.prod.outlook.com (25.169.33.151) To BY1PR12MB0437.namprd12.prod.outlook.com (25.162.147.139) X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0437; 2:Hq7oeF5VNpmdtFwT4IX3sbtfvoOJPFsNZB6zBzmwn3Rr5te6rua8/3OU4T+T70n0KyGJVfxFjF71Fv7Cww82eIVg8sciCdsbOVlvG01pH3QUwkRCzURQ4zfN2M1zx6Oqb1dR6FJf7TFUbECtdOFu9Q==; 3:oGt0VHJlJcb5JF5KSnmH55GXNOA9q4zZv590NYuOINy/Jy15zjArrt96zpjkOOrgOaJsml7GQfRCEJlUuMg1iT51eYcGgywBRMsw3bUFV/O/2cT6LCLzNXNJ7Xv6l+8H; 25:xo2datGCqM/onnlcg3jPETXUu9f9AvUWuucHPAmg3xjVXfAkFkWmx1rkxEx+TNGhUc3LSDOsSKX3qZDSFlMSWoQa52Dg9e3s9AeU8rMnRONkvaFe+SkZcxprG3vnfPfuaJ4jTFgBOM5UMOGj423j9Of92IS78CczFZA/k6eCN74x66ND/cUAdiQPZmQJvRSRvFDMbsVFoY1NbPh2WZHrSweUIQdQNUN6t7fo4bb1GPRIPBeBJIxT1w57u6lwiCbU X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR12MB0437; X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0437; 20:lW0Eo4+0qpCDN3zenFVaJwEoqUDtoRMmx135STbZZfOGcmKQsjyF71F6cvETRQzmVaHGC5eaJR8Ac1voSaFlfZdXQ/fxhRREHgPh/BECrQrhef65qH3a19yZZXUGJKH0NVNQMaO97KHEPo9jWImL99/vbnccBfe+xpEI6XWwZAMKSyfCYdnrLYSUlriHJGtGYeEns0IOLg7/FWxZQj5qYzy25L0+j4hid5eVzOjr06P4PSsOhfXExJGm54bqhkqEkOVmTflihl1W701Q7igJOyth+Ls+n+dmMWxoUCKyt0JP4NqY5MBsk7hyXTIkUcOidsxsNq6ZE0zqy9lMj0RCECF/naXxrqip0cZ3tZVUtn2fsZtSNavKV7uMPOLD8uocAXucGf9nYaxr7TTVsHNJzk+pPPEBn4nBR+PJegUqGTumqv+e12dmaXcyx7OtLaAXdmVBBLTjMUSxeuETg6Lhk0MC/TeJXrTJclPjzs+PgU7MTCLyiAkVx95LuHbyLYCd; 4:bSqu3NNiNiyJjm2iJyKpu+9Iz0hGvKRLPxsg4YEw4yCwH0+tn0cZI9IBgLx/WlmbkkANuSPpgcxYAsi2jfd2n4ZfXjI6/3wdROs7/kd2XyMwzF9gFNg4sbLK++tiRojDGsD03IgbUR13plbNusExjEUmEc3hiXNaG8YS4ObvUUgzN9Lyx3Gg9U8g7BwDYtJb4UH5TArMtz9MU0xV7IPEQOHRkTEGSw4aS3+Dz0US/U9TJBfhiof2PSBCVRHanx1PUmHjCIfdo3+1RS9vUIsCMFx/WsykGSsNWyCSeTqxOiIV86Xb5yr0SweNKEuXjXEgTeYKZR5rBb/jhQx3bKMJis54rlsyk/B7DVl9VC784asiyh3AlC1LzFCRc68Yn6Br57P6vw2YFLPh2PsCIJg8H3BYetObWkxEif5Wv1 cj+KE= 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)(8121501046)(5005006)(3002001)(10201501046); SRVR:BY1PR12MB0437; BCL:0; PCL:0; RULEID:; SRVR:BY1PR12MB0437; X-Forefront-PRVS: 07915F544A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(87976001)(86362001)(92566002)(5008740100001)(40100003)(47776003)(586003)(77096005)(3846002)(229853001)(50986999)(5003940100001)(101416001)(50466002)(53416004)(36756003)(122386002)(48376002)(19580395003)(6116002)(5001770100001)(1096002)(97736004)(50226001)(189998001)(42186005)(106356001)(105586002)(66066001)(19580405001)(5004730100002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR12MB0437; H:ssuthiku-ubuntu-lt.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0437; 23:jy8ex088rqg47rxT568+33aVDyzV8DgUoj4pqSQ3YwuUjG9f59GUpeAyiy1YPJ0E2rwfsgt6bP4FXro8y6kZCXCAVwcY+hq0ces+Xc46o6cdHkIc+4vD3lhE5IR/dvvRt10uJaGo2QQOjg82j3iPWgxLm/SzsqaMQkO1wUFfKkaeObF9vvxFHaeZNfl7sv3UQ0wBMROWSL2LSD2OH+aEcsjPrU2IiJ6pbSoVLo2PuaALGAAWBxm0TtnQhyPT7OVeOcxbnhz8+fSfM7q8tn6xl9fmEuqKew0ua71HpjatAq8CWnWIGRMnAYQY1eMfJWA/hKz0ramsCtvAS938uGOcWf1/3WU0bySCRyWCkRulMJA1HIQmecuwpw1ceM4uiSZzP2whKhvlvhB7igv/wADbgmCmD/pf03ywMR4O84+j0KVPNxoBgmxnaz4m9z/uXExP9Z1nnem/xApEPDmfAy/iuQnWOmX0OgofQTfCrc8O0+oeKKS0GpzT1W0+LuXZScobKzZRifPppKH+k7Y/mFpc8zKONGrHAqiW1uz7iyYKIxx2dhK4FTF6/3i+D4fr1sO0D2ovxfOVuXB0KghTt/8PwPcN/HxWMx3/dwWSFJxSS9H2s2+6nyuLPJ04JpTJAyvzOPBXVKOUrYiLyt5BjQ9teXDgZ5z9Kkeywb+aKwsYiThbFIlti9y11L5DZji1yUXOGBKWJ11+lT+GL30tSTtpVF5f5DUYqLpk+KLkz12vmCzaCiqaSYnv80Rz8R8wiJci8E4RXCn/YGUKftj49nl77uHPubzLhlEkUuyJzouZNXTN+fbPYLSxDdFPqGwIOVEZO7pLN+fTfBL7c5heX40d2OwPkbdVb0zX2DJrzGVfUUcq32u1raC+c2Oy2si+IaovGZ9/aGiTsXWl3+wmfTBN93yxJBf6NSBeiiye1/K3k YE= X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0437; 5:TtEDcezRa7gags9QMyKUgZJ2OixT/BIFOVKH91Hr428J70moZOoLg5Eu+pzwkvwz8Cl+tTjgRKgh6qej7vL+TtAWy1wyMfc+IMoCmHilPlN7PjNA6FTfzZT/E6jfoq4BRWNB30T16JaCVoaFnQ1pXQ==; 24:LFvFDG2OBH1/W2+HdY45ZV4sPgB7OTTnEx1u7jgDQ2mDbOve5hFjLzkLdsOGN44pPIe+3hOJcMr+ImJc63lTySgV7zWcCGVOVU4LAkPb7lg=; 20:aOTgD/So3ECZxf2l3ChxpUvDW/XR5Y1Dp9WDg2DtVVNRn5NqEMjadKFL2DKW5BwbW5BCQavj3j4OWflftVjFqMEboZRC4SjBSYm5anftssWFwHtBSm4epi5kr9cD4jaHBAcjeUuH5IieeS6TAsh1UDGc/MulVW9ISQubc7J5DksSoq3Qxe6+visxE+UW3HmCyqNeLQ17w60k+O2szDcUym1XTJh23RVJi9RpgFC0KrReRl19u0hJI9Aexz3zRD53 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2015 22:39:18.1455 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB0437 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 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, this patch removes the clock requirement when SSCN and FFCN are provided. Signed-off-by: Suravee Suthikulpanit --- Note: This has been tested on AMD Seattle RevB for both DT and ACPI. drivers/i2c/busses/i2c-designware-core.c | 5 +++-- drivers/i2c/busses/i2c-designware-platdrv.c | 30 +++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c index 8c48b27..ec458ec 100644 --- a/drivers/i2c/busses/i2c-designware-core.c +++ b/drivers/i2c/busses/i2c-designware-core.c @@ -281,7 +281,7 @@ static void __i2c_dw_enable(struct dw_i2c_dev *dev, bool enable) */ int i2c_dw_init(struct dw_i2c_dev *dev) { - u32 input_clock_khz; + u32 input_clock_khz = 0; u32 hcnt, lcnt; u32 reg; u32 sda_falling_time, scl_falling_time; @@ -295,7 +295,8 @@ int i2c_dw_init(struct dw_i2c_dev *dev) } } - input_clock_khz = dev->get_clk_rate_khz(dev); + if (dev->get_clk_rate_khz) + input_clock_khz = dev->get_clk_rate_khz(dev); reg = dw_readl(dev, DW_IC_COMP_TYPE); if (reg == ___constant_swab32(DW_IC_COMP_TYPE_VALUE)) { diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 809579e..57f623b 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -127,6 +127,26 @@ static inline int dw_i2c_acpi_configure(struct platform_device *pdev) } #endif +static int dw_i2c_configure_clk(struct platform_device *pdev, + struct dw_i2c_dev *dev) +{ + /* For ACPI, if SSCN and FMCN is provided, we should not + * need the clock value. + */ + if (has_acpi_companion(&pdev->dev) && + dev->ss_hcnt && dev->ss_lcnt && + dev->fs_hcnt && dev->fs_lcnt) + return 0; + + 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); + + return 0; +} + static int dw_i2c_plat_probe(struct platform_device *pdev) { struct dw_i2c_dev *dev; @@ -203,13 +223,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) dev->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE | DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST; - 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); + r = dw_i2c_configure_clk(pdev, dev); + if (r) + return r; - if (!dev->sda_hold_time && ht) { + if (!dev->sda_hold_time && ht && dev->get_clk_rate_khz) { u32 ic_clk = dev->get_clk_rate_khz(dev); dev->sda_hold_time = div_u64((u64)ic_clk * ht + 500000,