Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp513065ybh; Wed, 18 Mar 2020 04:14:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt8vcrHq6ZMzEVwoKXqNO+iK6CLwopxUST1x3HaZ0jlJIh/6dyAm5OgZz5yTt/D63qBDj+z X-Received: by 2002:aca:be09:: with SMTP id o9mr2784786oif.177.1584530086749; Wed, 18 Mar 2020 04:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584530086; cv=none; d=google.com; s=arc-20160816; b=a9Aa/DA/qjbW1JJXQA3rfDBXk9pgMx9eOQOoosOJ7hx+01FrJN/HfO053KQ6oCjBmT niYEI09+TC4ZIf7FBJFspDTN6fWP5+p3XtSKAQcOdnzMJiYLoPXbYkQb3KhHbdMoAok+ d+xiHqJ8m6f+apXF6lGErBRcScVO0o6JYcILJ8HpKHpcg5eJt4Hy4IleT3U+NC51rwIA mUKnxPiVudPGwRC1OGP+kXrr5qECNZWigBd3gPq1XwEV9ol9z5CCw+jlWK4IfU7dB8mv JM2fQxoP35hTff6cKLZFvJnJ8vBwh91B9a650VKPc83KBONr3JSGQrkWAr+0Dat34U+W hEYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=fcohBG/hwxeqYHYugtHhHGWohZ30KSpUZP23m4SFreQ=; b=oDP9jLczrYxzAtI+KKwfrMiyLE90EztZljxcYJZ91Uz2jfWtaefFDmmOmBvVTeF2Ne vOIKUJnEZKnaErwQlAJ+kg13gcRpvmIc7ghl1mv/g+HV+ksZ62XvARZF1aHtY4fqwGro kOKaP6gSBso2V+bklGgBj/SOZuqmtlaRE5xi1D+N28D+qTl6xQf73hU+Nrj8vtu/AM2r eyYkN33ZzD+3x8/NKgB2zuDo4PYiaKaGp7+//glDyjudfp0gu72VpM3Sk8Tbvmfn4ecy R0Mgk5VpUaAw79ek94Y26lAHlLrsuelmV39aRcPtqUjsuqQvl+TNX3lyZD67HeQHyc30 crBg== 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 v142si3250420oie.217.2020.03.18.04.14.34; Wed, 18 Mar 2020 04:14:46 -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 S1727780AbgCRLOC (ORCPT + 99 others); Wed, 18 Mar 2020 07:14:02 -0400 Received: from inva021.nxp.com ([92.121.34.21]:41134 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727764AbgCRLOC (ORCPT ); Wed, 18 Mar 2020 07:14:02 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E43852003C6; Wed, 18 Mar 2020 12:14:00 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D4F96201205; Wed, 18 Mar 2020 12:14:00 +0100 (CET) Received: from localhost (fsr-ub1664-175.ea.freescale.net [10.171.82.40]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id BA35820506; Wed, 18 Mar 2020 12:14:00 +0100 (CET) Date: Wed, 18 Mar 2020 13:14:00 +0200 From: Abel Vesa To: Anson Huang Cc: 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, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linux-imx@nxp.com Subject: Re: [PATCH] clk: imx: clk-pllv3: Use readl_poll_timeout() for PLL lock wait Message-ID: <20200318111400.ynpazqpzmeyhuyy3@fsr-ub1664-175> References: <1584502004-11349-1-git-send-email-Anson.Huang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1584502004-11349-1-git-send-email-Anson.Huang@nxp.com> User-Agent: NeoMutt/20180622 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 On 20-03-18 11:26:44, Anson Huang wrote: > Use readl_poll_timeout() for PLL lock wait which can simplify the > code a lot. > > Signed-off-by: Anson Huang Reviewed-by: Abel Vesa > --- > 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 >