Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp170509ybh; Tue, 17 Mar 2020 20:35:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt5Ey7v2jHYJL8YXpVbj+TSBSXJ03ZYCsHrtXN+Ms0I04HDWkGMWUX5yJQ23M/mtcdg4UKj X-Received: by 2002:aca:dac5:: with SMTP id r188mr1706563oig.176.1584502521823; Tue, 17 Mar 2020 20:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584502521; cv=none; d=google.com; s=arc-20160816; b=oaEFEgaSJMHi/gSAw8bjzTGJLqxizPdu6n0akTPjetztPomCfDkzJ6yKAVbs+sDFOB l56XaLnyM7g9JllnR6SPBObMbaIMPtIy6oPhi3KSU7ehUV+HwSz7tKPcJCk3q6L0hKFF oUwMZZMeZB4fENUFJ6+cfo3+m/4wyun9XURxeymIiJ2Dk/SaVIFTmaDIRd2bc+bpZE7S MrQNylinqnd8J4RZ0c+xOlIzEcpUWb0d+aP4hsOWEHGkZewgtsmgb2s7y3BEl7IL+kJe EN+ijMYIWFcfwUiWvXrorIDtKxGXRCQ6hTlSf7C0iNFYMz5ABDVIbW9ga2t3QcT2hNUo 26IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=HQ90Wx2V1B/UJlI60IdAuHLfjBnX6S7mndbGJoBDKbw=; b=aqtf/xa9ClzebwYeZkFVQjlFLPip4Yc+uM7XXY8/hMnJRMCZBe9tfjvP2Hy4Qmu/5p vbCjDrQakALQHArzmoHJJRXvDfOJWugkqmHB33+DFurj5w3YuF57jGIxWxcbJlBNdNQV nxFmwqyroM3sdV4cySrjDJlVzSkxcXlThXng9l8dy+akFaG11W4ScqHCERRQrneqYyKP 1GHQpUwytZ7gA9ZGDVCi/rXzv4kpwzsvfnVLh4PT4DnrsqwN5KMtYk0Ir7e2haOPbvAz R1hQNbLinn9JVuAGE2CnnvMqjtrImb9JmTkc4/xdifOSjPzaziJLFx0FHgFz5elBmzZa PnsA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11si2673298oih.95.2020.03.17.20.35.09; Tue, 17 Mar 2020 20:35:21 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727197AbgCRDdm (ORCPT + 99 others); Tue, 17 Mar 2020 23:33:42 -0400 Received: from inva020.nxp.com ([92.121.34.13]:37626 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726229AbgCRDdm (ORCPT ); Tue, 17 Mar 2020 23:33:42 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 772C71A104F; Wed, 18 Mar 2020 04:33:40 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E95E61A1050; Wed, 18 Mar 2020 04:33:32 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 8E1A5402C1; Wed, 18 Mar 2020 11:33:23 +0800 (SGT) From: Anson Huang To: mturquette@baylibre.com, sboyd@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, allison@lohutok.net, gustavo@embeddedor.com, kstewart@linuxfoundation.org, tglx@linutronix.de, abel.vesa@nxp.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH] clk: imx: clk-pllv3: Use readl_poll_timeout() for PLL lock wait Date: Wed, 18 Mar 2020 11:26:44 +0800 Message-Id: <1584502004-11349-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use readl_poll_timeout() for PLL lock wait which can simplify the code a lot. Signed-off-by: Anson Huang --- drivers/clk/imx/clk-pllv3.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c index df91a82..3dfa9c3 100644 --- a/drivers/clk/imx/clk-pllv3.c +++ b/drivers/clk/imx/clk-pllv3.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,8 @@ #define IMX7_ENET_PLL_POWER (0x1 << 5) #define IMX7_DDR_PLL_POWER (0x1 << 20) +#define PLL_LOCK_TIMEOUT 10000 + /** * struct clk_pllv3 - IMX PLL clock version 3 * @clk_hw: clock source @@ -53,23 +56,14 @@ struct clk_pllv3 { 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->power_bit; /* 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; + return readl_poll_timeout(pll->base, val, val & BM_PLL_LOCK, 500, + PLL_LOCK_TIMEOUT); } static int clk_pllv3_prepare(struct clk_hw *hw) -- 2.7.4