From patchwork Wed Jun 29 13:52:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9205299 X-Patchwork-Delegate: sboyd@codeaurora.org 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 3EB58607D8 for ; Wed, 29 Jun 2016 14:00:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EEDB2865A for ; Wed, 29 Jun 2016 14:00:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 222A328664; Wed, 29 Jun 2016 14:00:26 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 171262865A for ; Wed, 29 Jun 2016 14:00:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932091AbcF2N7v (ORCPT ); Wed, 29 Jun 2016 09:59:51 -0400 Received: from mail-by2on0055.outbound.protection.outlook.com ([207.46.100.55]:59588 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932075AbcF2N7s (ORCPT ); Wed, 29 Jun 2016 09:59:48 -0400 Received: from BN3PR0301CA0011.namprd03.prod.outlook.com (10.160.180.149) by BN3PR0301MB0850.namprd03.prod.outlook.com (10.160.154.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16; Wed, 29 Jun 2016 13:59:44 +0000 Received: from BL2FFO11OLC007.protection.gbl (2a01:111:f400:7c09::187) by BN3PR0301CA0011.outlook.office365.com (2a01:111:e400:4000::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Wed, 29 Jun 2016 13:59:45 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11OLC007.mail.protection.outlook.com (10.173.160.142) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Wed, 29 Jun 2016 13:59:44 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u5TDx9xA014881; Wed, 29 Jun 2016 06:59:40 -0700 From: Dong Aisheng To: CC: , , , , , , , , , , , Subject: [PATCH RFC 7/7] clk: imx: clk-busy: convert to set_rate_hw and set_parent_hw Date: Wed, 29 Jun 2016 21:52:15 +0800 Message-ID: <1467208335-29876-8-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467208335-29876-1-git-send-email-aisheng.dong@nxp.com> References: <1467208335-29876-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131116823846675400; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(8666005)(7846002)(8936002)(50226002)(229853001)(2351001)(81156014)(68736007)(356003)(2950100001)(77096005)(81166006)(97736004)(19580405001)(19580395003)(586003)(106466001)(110136002)(86362001)(92566002)(85426001)(47776003)(104016004)(8676002)(48376002)(305945005)(6806005)(36756003)(33646002)(105606002)(50986999)(76176999)(4326007)(189998001)(50466002)(87936001)(2906002)(5003940100001)(7059030)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0301MB0850; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC007; 1:Rb+LIOm2sgylAU8r7K205K2O2X6BClZvEssMwaR67bQs9KPxXnDs7EwXbZVY+drAHi5X7Ps0lP6LMxbQXXHimThlFQprUeSKT/EGL/jK0zGUa6ij47pKbdixCNe+HbseLPPuStp+kNUqwSVbkuQyimfkwen5lfCkTPqNkBn/rDpQJ+BArpnPDjg4TrmO7MCexRDSGc1mfOCPdif+2HmT8v2gMSDPB6PHkVQlyYaqqjWNoKgDtTXSuiwT8eN31OJECCQvXapmx3qtRqDQ+E7SuJrwrkgM+bTrKwz0CsQpUmQYVCr5QMkAD/2gplG/bPcVPoTH3RiIp2sJUq4WMthLgsg9zgMMv5Syfy5iRvaOhzrG57k3VeXs2LW0FwrbkqhZZzEnws42PlDqkrhV3L5ee+DF1nSKEYzeajVNA+OgwbhDQFo/he/E7Uguuwbj//KZhmJziFYB2iAXsh3rKrJjPXyVdQNB2Xqz5axnpx+Dk2J88V5zpzRRmf2xpuQscHmB511JmN8wxtgk+FtqmCgMGVH4bmgDAS4dXUUC32KS+DF1bMcOiIdGBgFdk0wK7q+Z7DGV2kFrywV096G6+KBFDmyaawZFWwj0xfLnnFC/gk2F+V0JBuxzbta3coBH8DwnD/6b7cPCL4RE9oRZC0foYBPR0MWm5BAqILOpalVJKYfpvbTMKhz7lMuZlMpHMepqLL03Q6bqJuln831Im/NMniSGESiEfrlJeIQDIs4V5Dc= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 337fc358-f920-4a89-026b-08d3a0259fea X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB0850; 2:2s3Opo+gQwlCHddBN9PrOOHEdx21xkW20w4JYOLEp0G1QxQnGbOcXa8Ap8N32UAn5vlqkbniTSepNC6c9NT68PSacDL2PADk5UGL24lRrfpnqOIxOAzilt5mEyuPfYF5LA5YCFgp7F97Eb53t0B47UJ8ZbDNBHIltpksoG3p7xerdBOPk9Voln+nPMfd8kct; 3:1hMw2VB8mlvigCS967fUu6jpl76GdHaVNjmLoAdb5GYl0IiFHiRnN/UB9Vs9C33IEkk6dLI9e2DMlVIoUsPQ9IP3wQ4XaquqGNRhb5KD1BmT9KiaGMuoUPOMV9rWSS4iiTB3QOJ5MMViAT7GlR41Y+RfEUOkkO40l3fGsxuqJwm+ZnSfMf86bJFR4KYsrL9rOZjjnBTps1Jfysb+naWbrwdjzBo61BBvCvvVWHndNIA=; 25:J1zDsxFQsW7CtiYahgDnEOiqmQ/8Ign1srv58l0x3kpedeA5U9GS4TxzQ2PPs0aPQG5lNWJiU8txF7qRA47UIdHjlaSsvBF0RsahTDQoUyI7WThzRZkrLxOgYCoiSPXoZ6YnoJAMd/4zqmxlCNxFJiO3j8ETVqa7+ES80XhqMFJLm7Sw3DtmBoKMI/emWIgi1ptwxm97FE1cMARZAAD+YqD23b7i8CIT8g6+mDZ7I3XdsuWv51dqnSm3OkHFMvMmoYMVkyM3odmg7dD0snumaiPryUFRJPuE6DPC4rHAoHbbK70YWNp488UVfvE+5a3FXFmJZxm2fiCOg3FUTPo+n3af+Ozx4U2zPDj7Ue4exu6ySdCTYgLA6WfjeqNMRpLefaJPRJT3hrOwwYPiO/INReH6q3a6hdKkewmcxdToU0M= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB0850; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB0850; 31:pUjIyMZaMdSn/S8tGKbbJ/ud/eAIgwaiWEDt74QN64s9RdmwwVXvrdHTKgX14iSJ+jDwJfhQ6msW8OrASiQE5/K2yVZYY7io4Mmr6IsZTxLt9Z2jE5jTQzhSPNDKj4PVSHLNJO2P3C104PuexooJPg5Nz93iHACBRCrUUlu/DX7G13Oz2SeQnIP0gZor9aeqK9ElsGs2qJ/0aale29Gaqg==; 4:7kH54Lbe/RVLSB69xxWw0ElDUD+hEibh1YkJoOPWfu1av/mgLHq3nH3ZMZznuiqXWTmPJF/YfdaKAl5jXcJJplAABX02ubB5KpepkxkHhnIHX++YBCHlJq9kaL2N6FP5OOYh19Wt3TuMRvy9pHPgj7YTmEtcElY5CukZYXiZMYHczvfmAcAc+P9ghUZr3MrL1jN62q1aH4dRcA/74UWLDC8YvKW5Jfjzhlu9eUU6zbO7Ee8WbBqp00yHt75p0a6dEDheVm32IJ5E5HAX8z+B1bBsYZJAMIoiIY9T72mKbAkf4STIDp/QLybYPsNIcUOeKbb/iJCgokrkEyyW1+foeASFM7wznvTrLWSvpj67v0iqp32RRLwp1D9ivBu8aFz9fUG67ioPrGImBTJ9agFK58JEP9dd7QR0oZXXaZ4P0umVhkdP4rDOcm8CFQsMct8iiRsxScY1i8qwrW1rvk6TEW5xPsw4cX10nqEu553QsIahSBm4+i/ekP8+lHHeeTQXQEHwerHH4l0tmAenQfQKWA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13024025)(13017025)(13015025)(13023025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:BN3PR0301MB0850; BCL:0; PCL:0; RULEID:(400006); SRVR:BN3PR0301MB0850; X-Forefront-PRVS: 09888BC01D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0301MB0850; 23:ibsvBtgJzJkGJiIhBf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E/oCKwiTMtxIC+8KGZgoLzAiTDGkn+zjZzb4yLe/eoRSZ5kmFwqLqGba/X4agb7qZj+3Z+CeT6cC++jlieSXIx0oFyfHyLPECy3c2FJ5vOIeLkXrU37lA21Pr+136mNWVNOFu/X2N52PUy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2016 13:59:44.4803 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0301MB0850 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert to prepare_hw and set_rate_hw and let the clk core to handle the polling process automatically. Signed-off-by: Dong Aisheng --- drivers/clk/imx/clk-busy.c | 52 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/clk/imx/clk-busy.c b/drivers/clk/imx/clk-busy.c index 5cc99590f9a3..5af622fc726b 100644 --- a/drivers/clk/imx/clk-busy.c +++ b/drivers/clk/imx/clk-busy.c @@ -18,17 +18,6 @@ #include #include "clk.h" -static int clk_busy_wait(void __iomem *reg, u8 shift) -{ - unsigned long timeout = jiffies + msecs_to_jiffies(10); - - while (readl_relaxed(reg) & (1 << shift)) - if (time_after(jiffies, timeout)) - return -ETIMEDOUT; - - return 0; -} - struct clk_busy_divider { struct clk_divider div; const struct clk_ops *div_ops; @@ -36,6 +25,11 @@ struct clk_busy_divider { u8 shift; }; +static int clk_is_busy(void __iomem *reg, u8 shift) +{ + return readl_relaxed(reg) & (1 << shift); +} + static inline struct clk_busy_divider *to_clk_busy_divider(struct clk_hw *hw) { struct clk_divider *div = to_clk_divider(hw); @@ -59,23 +53,26 @@ static long clk_busy_divider_round_rate(struct clk_hw *hw, unsigned long rate, return busy->div_ops->round_rate(&busy->div.hw, rate, prate); } -static int clk_busy_divider_set_rate(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate) +static int clk_busy_divider_set_rate_hw_done(struct clk_hw *hw) { struct clk_busy_divider *busy = to_clk_busy_divider(hw); - int ret; - ret = busy->div_ops->set_rate(&busy->div.hw, rate, parent_rate); - if (!ret) - ret = clk_busy_wait(busy->reg, busy->shift); + return !clk_is_busy(busy->reg, busy->shift); +} + +static int clk_busy_divider_set_rate_hw(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + struct clk_busy_divider *busy = to_clk_busy_divider(hw); - return ret; + return busy->div_ops->set_rate(&busy->div.hw, rate, parent_rate); } static struct clk_ops clk_busy_divider_ops = { .recalc_rate = clk_busy_divider_recalc_rate, .round_rate = clk_busy_divider_round_rate, - .set_rate = clk_busy_divider_set_rate, + .set_rate_hw = clk_busy_divider_set_rate_hw, + .set_rate_done = clk_busy_divider_set_rate_hw_done, }; struct clk *imx_clk_busy_divider(const char *name, const char *parent_name, @@ -135,21 +132,24 @@ static u8 clk_busy_mux_get_parent(struct clk_hw *hw) return busy->mux_ops->get_parent(&busy->mux.hw); } -static int clk_busy_mux_set_parent(struct clk_hw *hw, u8 index) +static int clk_busy_mux_set_parent_done(struct clk_hw *hw) { struct clk_busy_mux *busy = to_clk_busy_mux(hw); - int ret; - ret = busy->mux_ops->set_parent(&busy->mux.hw, index); - if (!ret) - ret = clk_busy_wait(busy->reg, busy->shift); + return !clk_is_busy(busy->reg, busy->shift); +} + +static int clk_busy_mux_set_parent_hw(struct clk_hw *hw, u8 index) +{ + struct clk_busy_mux *busy = to_clk_busy_mux(hw); - return ret; + return busy->mux_ops->set_parent(&busy->mux.hw, index); } static struct clk_ops clk_busy_mux_ops = { .get_parent = clk_busy_mux_get_parent, - .set_parent = clk_busy_mux_set_parent, + .set_parent_hw = clk_busy_mux_set_parent_hw, + .set_parent_done = clk_busy_mux_set_parent_done, }; struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,