From patchwork Wed Jun 29 13:52:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9205303 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 234E0607D8 for ; Wed, 29 Jun 2016 14:00:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13AB22865A for ; Wed, 29 Jun 2016 14:00:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07D6A2865C; Wed, 29 Jun 2016 14:00:47 +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=unavailable 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 569462865A for ; Wed, 29 Jun 2016 14:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752979AbcF2N7p (ORCPT ); Wed, 29 Jun 2016 09:59:45 -0400 Received: from mail-by2on0059.outbound.protection.outlook.com ([207.46.100.59]:60096 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752960AbcF2N7n (ORCPT ); Wed, 29 Jun 2016 09:59:43 -0400 Received: from BY2PR03CA058.namprd03.prod.outlook.com (10.141.249.31) by BY2PR03MB1926.namprd03.prod.outlook.com (10.164.114.30) with Microsoft SMTP Server (TLS) id 15.1.447.15; Wed, 29 Jun 2016 13:59:40 +0000 Received: from BN1AFFO11FD034.protection.gbl (2a01:111:f400:7c10::126) by BY2PR03CA058.outlook.office365.com (2a01:111:e400:2c5d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.523.12 via Frontend Transport; Wed, 29 Jun 2016 13:59:41 +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 BN1AFFO11FD034.mail.protection.outlook.com (10.58.52.158) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Wed, 29 Jun 2016 13:59:40 +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 u5TDx9x9014881; Wed, 29 Jun 2016 06:59:36 -0700 From: Dong Aisheng To: CC: , , , , , , , , , , , Subject: [PATCH RFC 6/7] clk: imx: pllv3: convert to prepare_hw and set_rate_hw Date: Wed, 29 Jun 2016 21:52:14 +0800 Message-ID: <1467208335-29876-7-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: 131116823803372682; (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)(199003)(189002)(36756003)(33646002)(189998001)(68736007)(586003)(229853001)(86362001)(19580405001)(8676002)(92566002)(356003)(50226002)(7846002)(305945005)(6806005)(85426001)(97736004)(48376002)(77096005)(50986999)(105606002)(50466002)(76176999)(8666005)(5003940100001)(2906002)(81156014)(2351001)(110136002)(8936002)(2950100001)(47776003)(87936001)(81166006)(19580395003)(4326007)(106466001)(104016004)(7059030)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB1926; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD034; 1:jLPcy9r1ZVqWz8zoodPqU1P4HDnghGagk+EQGbk9vdcNmyeJkIN0OuBFHLTVIwBt+lgmn6uw6AWqR/Zn2YTqKWEmt0fV5US/nNLgFK2ufvM5t61oz2qMep5yZY+Ekw+ztvn7G6KKJ02jG+d1s2alVA9miQjPyxbhZqcnS3hHZ8fW4agydj7jY4n0ez5tUj3Z2GvU5NYJ6gW8EDFuZA9gX5OO68wbdiPVe9LQQ+cj6QVqClE7JoSZHavKJDew5mUHGFYenyc6SfOgmzDf+Rpun34DDCplD5Qxmq+S3cVyZj/TM8xE7eOqdwDZsm9j4RTgVzn35V8j4Iy/0lDC0sYYAJ/wt1B/37PbJv6LGoDVPTe7fN1Js3hi/fr4XMRgt38BtlGnl57K5m9nYFDEnEJHfoLW/X+iGF9C/odTZkbZ5/FTCpmVYsgTI+J3YjtZBSY79TwWUvaLJnPjP8Y9VrgEVZIBUCerrzljO2QAIbWdtRFwogN8J2FspJYQBBm5YWOcMarC3pgtaQNljrZmNpyp6kxJ3dC8ua6hGKRXk9BQeclpw2K1rAQawpk3MirH0Za7WjQcOpGKUeL4hB07XlZxCMf31X8Lt4UfllJFkGmX7t4QjdL4UQ4X2ODdGCxFLedRLd1wq4yHhC9mdz7mv6hACyg12fvwxb16aYgmn34RdKZoE07k3WXSTujPX4Ay5DDoaZ3WbEFZ8+L41VodjezjHzjC6vKxFFh6vDeyWZWKg4A= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: d1f56dd0-4f70-438b-4328-08d3a0259d55 X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB1926; 2:MSttNsW0VkY5zvhypew2tsXKKwY7NWy8AHjtfWpSf9BTRLo2zsMVhUV2kXt4uUOR+sR+ew5eZ6UcJCUci5/d+D/dinkiFrUnGeBmWZQjfsu/TUrvPvZntkgbZhFM0RIEY8PTQANozO1gfyd9IQ43wUQSUQq6VvRkRARiYuh+umyHQMyyqKKJA45ak/61RBcz; 3:aFV45gel8zoI9xAiat/uU3oKGqnWNJpo3dmGOgkdUV8lfKIpbT179nkaosxokzqIyj4ZlTDdCZY8G/y34GAvVpj0y1pOZDrfMYCV3qTJS7+3x/zfUnhzwe+RCvclEAXHFiwNOGRUB67qLBtf9fXq0pibULyFmSywS69jiBG2wnJ5Tdd/XK+RltvYE4nomvnH5/O063jUEjnBZVK6kbwU26JeTzAjpx8uQJ6o1TZUB54=; 25:9RFQMls7jCe6ISj2Q6uqz+nC3fWEr4H0ZLd/pWkDGaAneT2H7RvjlXJrnhD8/u1u2wLw7BEIBw4NkgJWI207yVdJ7SgNh2nJ0q21n8YEJfFyTmXmWT8dHAhKKiBGla5srcSgmYds2LN8rUwXPRAAG5XpOCeQ/ZF35G556DNCjoE89eEwyqi45ZAorFDlp3NzZtI3suMwi52z6EmuhhFMUXwHwlI3Lat+T6xsx9jT9BihE4reXc4f6UYD3fAXrCm5 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB1926; 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)(13015025)(8121501046)(5005006)(13017025)(13024025)(13023025)(10201501046)(3002001)(6055026); SRVR:BY2PR03MB1926; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR03MB1926; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB1926; 4:y6mjvcHUB21A+ifwR8vSkO8V/nYbIAm+opVw77A4hPQgIewr/V2VLlVoOALbLDF4yugJJLHGAfEubRhonh1bNX+YIZF2tGZCKqJtnnEUFkzcWUxzBJIzmwI9MtL+036lXFm2otz7qVp08LCiKON0nWwie+f2CFoOhgp2WehyMEKKTcGSTQK50FKjdBUl2RkyKHLoPemNW5if6bson3mGgX5Izyox+NCBLnxBXskQ3h/U7n4UQuYdfBsNjrrHrEpHV1js6MqSy4trbsb5EBk/WE9mzNP2YSNwwpdJM9RRWRp+Vogb48OwvuF9cEQtEe5Gm4SalCLXL7HAuv84erQxup4dLZqHwBlP419kaKhDgIhkIQYZLPVIJDFlBbu7kVhuBfcbS5nZkaAmsTmWK7tminAgm3cebnj0AY26OBqmf39IwWUlwGvwlD2MptLRBf3E0Q5pkD9wHr8DgkvRmfHnH7NASpyByWkLKHTB/5fnC36JN8CSNGPr5k2tfvy6qgz5JBrfZQLz6r9KItSGgW4KAg== X-Forefront-PRVS: 09888BC01D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB1926; 23:9o+DWmgnTmQ2DyULrjjqEJOAe8GaWW43awJAeHa/3?= =?us-ascii?Q?bjN2jCscluxi1W8ID5K7fHqb93KSRR6MnLJqGNqm3eosM7EFWdU+Eatpw+iy?= =?us-ascii?Q?OYInnBGtVv3QiuLhSFInMAm5eRb9Tb9u0xTVyr3vfrOqnL5HGQzxSXcL3WKI?= =?us-ascii?Q?bCPswzbrEWJXQz4dTk8QIadxWDB/VyYnXOReve05gr7km+GHjVNzrdiHgCdn?= =?us-ascii?Q?KP8uMmD3JhGTaXV+vXjeVsAjVDHfrpw3pvZOwCAe5KlBqF364LkftRddMa+i?= =?us-ascii?Q?jEMNQci/jiVh5FLeDNd/Kdyd6WcIDq1V1FG02I3lio1/TMEkcRTHONDeYlUm?= =?us-ascii?Q?ESvSWqAHnZM69F724j6ld9Q3KHy7K8RgO7gxuoWIxhweoxmnlJaFlCZdCvVq?= =?us-ascii?Q?cag1gUB408i4SyRhRPrlSdg9kI1xOJXXQa36kosdWS43oWYkmkOOkrL4WTpC?= =?us-ascii?Q?xC3oF1cGKyIa7/mY/pqAdmOCGKezvFYH0JD19oZr8SevOSXw4n8/KbsOijjM?= =?us-ascii?Q?jVXfosSTpXG8kaohEkAe2UDWPbA/F7PduMBMFVmaDCDGfy2ZHHX6nWK51dyU?= =?us-ascii?Q?IEXThqnovKT1zIY/zc9rQyYppuWvlIdC9jRRhJhURf+fNj1imEk9fn5YtZYC?= =?us-ascii?Q?p4lGc5doArDvLzCL9ijbvuisHM1/oVtq1b9I4I1cogE77iU9CuUy8mFEwRvR?= =?us-ascii?Q?0Q5lJFy6EgyGme8dvexcv72P5jy6CTaFeY0CcuuOQzn5bPkLvO5hvO1uRnoY?= =?us-ascii?Q?0GIixMhR2yEMRnXhjgUVzR0aOdYSlgZN+hM13zwQFYtlxYfm5Hc/l1C4XqWx?= =?us-ascii?Q?gMlnn/8cqoeVNAbPBYTVGExu0VtCCIXOP3EMdHlYFj++tuISxuivk0OaOgvQ?= =?us-ascii?Q?o7JC9jRSJXpGKhpTqy6Lhd5+CTualm/mtl/i5lqL1nMM2KAhkXpnbljUUKTR?= =?us-ascii?Q?OnmOUSlgn4ojD4pp0h2WkZpo63mQ5H/J5xQM67FTO/exyTuI5DSW1uUUv8Su?= =?us-ascii?Q?CXgVu6FZBqElFcX8uW9kyMSeh3BmNhG2fuYjEBhHHqagV611jUi2x/gdZF9C?= =?us-ascii?Q?VaAxHmEo192QT4Xq61bnE2xwijt+ss+9oTux8ykQPCOeEV+vY80lrWv1dY0z?= =?us-ascii?Q?XMffFMFGI5JNGRRMg4j4SBTAqu263iVFSQ/n41IE6/Ldxi8N9BCoPyIR6jhL?= =?us-ascii?Q?2pnKkCBa7Hx13w=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB1926; 5:WikAOjvj+eG4cCpMGvHXYEHUw9aBSq99uNfJd2WMCqS97S9/f8ZFQwLyV0eVfb+s7guB11uPuW2NBeD1jTwvAwtJIx8NF0R+peCnloW7cUMTH6cTENFy+QXdvYBY+92o5gGBiKjL37QATG/3p8SrYublhV6u5wzMycjRJj4cfMQ=; 24:x5JmnmFfHM1CpxevmyTCaQPBBPhLLKuboL0mYTcNh4WNg6SioNatweIA4dxhd//iheUyNqvKZ9FI163rZBub7DNrfHY3u4+/VtUx9L1I7hw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2016 13:59:40.1500 (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: BY2PR03MB1926 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-pllv3.c | 64 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c index 4826b3c9e19e..78184310ad35 100644 --- a/drivers/clk/imx/clk-pllv3.c +++ b/drivers/clk/imx/clk-pllv3.c @@ -49,27 +49,6 @@ struct clk_pllv3 { #define to_clk_pllv3(_hw) container_of(_hw, struct clk_pllv3, hw) -static int clk_pllv3_wait_lock(struct clk_pllv3 *pll) -{ - unsigned long timeout = jiffies + msecs_to_jiffies(10); - u32 val = readl_relaxed(pll->base) & pll->powerdown; - - /* No need to wait for lock when pll is not powered up */ - if ((pll->powerup_set && !val) || (!pll->powerup_set && val)) - return 0; - - /* Wait for PLL to lock */ - do { - if (readl_relaxed(pll->base) & BM_PLL_LOCK) - break; - if (time_after(jiffies, timeout)) - break; - usleep_range(50, 500); - } while (1); - - return readl_relaxed(pll->base) & BM_PLL_LOCK ? 0 : -ETIMEDOUT; -} - static int clk_pllv3_prepare(struct clk_hw *hw) { struct clk_pllv3 *pll = to_clk_pllv3(hw); @@ -82,7 +61,7 @@ static int clk_pllv3_prepare(struct clk_hw *hw) val &= ~BM_PLL_POWER; writel_relaxed(val, pll->base); - return clk_pllv3_wait_lock(pll); + return 0; } static void clk_pllv3_unprepare(struct clk_hw *hw) @@ -126,6 +105,18 @@ static long clk_pllv3_round_rate(struct clk_hw *hw, unsigned long rate, parent_rate * 20; } +static int clk_pllv3_set_rate_done(struct clk_hw *hw) +{ + struct clk_pllv3 *pll = to_clk_pllv3(hw); + u32 val = readl_relaxed(pll->base) & pll->powerdown; + + /* always return true if pll is not powered up */ + if ((pll->powerup_set && !val) || (!pll->powerup_set && val)) + return 1; + + return readl_relaxed(pll->base) & BM_PLL_LOCK; +} + static int clk_pllv3_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { @@ -144,16 +135,18 @@ static int clk_pllv3_set_rate(struct clk_hw *hw, unsigned long rate, val |= (div << pll->div_shift); writel_relaxed(val, pll->base); - return clk_pllv3_wait_lock(pll); + return 0; } static const struct clk_ops clk_pllv3_ops = { - .prepare = clk_pllv3_prepare, + .prepare_hw = clk_pllv3_prepare, + .prepare_done = clk_pllv3_is_prepared, .unprepare = clk_pllv3_unprepare, .is_prepared = clk_pllv3_is_prepared, .recalc_rate = clk_pllv3_recalc_rate, .round_rate = clk_pllv3_round_rate, - .set_rate = clk_pllv3_set_rate, + .set_rate_hw = clk_pllv3_set_rate, + .set_rate_done = clk_pllv3_set_rate_done, }; static unsigned long clk_pllv3_sys_recalc_rate(struct clk_hw *hw, @@ -199,16 +192,18 @@ static int clk_pllv3_sys_set_rate(struct clk_hw *hw, unsigned long rate, val |= div; writel_relaxed(val, pll->base); - return clk_pllv3_wait_lock(pll); + return 0; } static const struct clk_ops clk_pllv3_sys_ops = { - .prepare = clk_pllv3_prepare, + .prepare_hw = clk_pllv3_prepare, + .prepare_done = clk_pllv3_is_prepared, .unprepare = clk_pllv3_unprepare, .is_prepared = clk_pllv3_is_prepared, .recalc_rate = clk_pllv3_sys_recalc_rate, .round_rate = clk_pllv3_sys_round_rate, - .set_rate = clk_pllv3_sys_set_rate, + .set_rate_hw = clk_pllv3_sys_set_rate, + .set_rate_done = clk_pllv3_set_rate_done, }; static unsigned long clk_pllv3_av_recalc_rate(struct clk_hw *hw, @@ -272,16 +267,18 @@ static int clk_pllv3_av_set_rate(struct clk_hw *hw, unsigned long rate, writel_relaxed(mfn, pll->base + PLL_NUM_OFFSET); writel_relaxed(mfd, pll->base + PLL_DENOM_OFFSET); - return clk_pllv3_wait_lock(pll); + return 0; } static const struct clk_ops clk_pllv3_av_ops = { - .prepare = clk_pllv3_prepare, + .prepare_hw = clk_pllv3_prepare, + .prepare_done = clk_pllv3_is_prepared, .unprepare = clk_pllv3_unprepare, .is_prepared = clk_pllv3_is_prepared, .recalc_rate = clk_pllv3_av_recalc_rate, .round_rate = clk_pllv3_av_round_rate, - .set_rate = clk_pllv3_av_set_rate, + .set_rate_hw = clk_pllv3_av_set_rate, + .set_rate_done = clk_pllv3_set_rate_done, }; static unsigned long clk_pllv3_enet_recalc_rate(struct clk_hw *hw, @@ -293,7 +290,8 @@ static unsigned long clk_pllv3_enet_recalc_rate(struct clk_hw *hw, } static const struct clk_ops clk_pllv3_enet_ops = { - .prepare = clk_pllv3_prepare, + .prepare_hw = clk_pllv3_prepare, + .prepare_done = clk_pllv3_is_prepared, .unprepare = clk_pllv3_unprepare, .is_prepared = clk_pllv3_is_prepared, .recalc_rate = clk_pllv3_enet_recalc_rate, @@ -347,6 +345,8 @@ struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name, init.flags = 0; init.parent_names = &parent_name; init.num_parents = 1; + init.delay_min = 50; + init.delay_max = 500; pll->hw.init = &init;