Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp72138ybb; Thu, 19 Mar 2020 16:52:09 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsBtiRRz10P/mMvxURWJ5RBKGjH8Eyu4QvEBKzP8tMvPlmW9wvdWkKf6L3AiL3+Pj9lkgec X-Received: by 2002:aca:a883:: with SMTP id r125mr4182469oie.10.1584661929053; Thu, 19 Mar 2020 16:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584661929; cv=none; d=google.com; s=arc-20160816; b=AIDxv4kXJUEn8dLi4ir0XStwNb0+aee7GRIjjYwKDIRVAO+S+FK39hPmlcNuf8NoYp /j2JXLEZVNxhOQr303RPwKvNJPCWy5ZPAiOcUbpm7jflsk+sPNXUfnwviG/0SKaPYqus 1zVwwXUSXtxdmnR2w5FpVYmZEn/dOzpktrU2TfWjTMCxJAi4NO2DnKIxTOmJZDzry9+g 3/ant1/XBfz+822D2eBMDxH9pooPIMB78QGg14o4n/n6QDzX156KZBSyiwlS89qb5KEZ tmqlljVgeed/fRV41dWaGpBw4uJ4uJNUm81YRSfgpiA4jJKx71Bt1S7I3jY9hyWTPAth dNIQ== 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=UpjoUTnLLmzcwlBlzEYmrsaCzW6J1z6M8c+h/98xvus=; b=Wf+xIz3owzThcUtTu3KW5cg3Z/RCKZjaBmtPOVHhLBiHpoMwiM2lgi21m9ic5YDgVk BkdqSobCQ7bmy/5mP9M9nqS7hqqj6taz4ZeH3fFkmG2YeTdnYfdrIUhH8FtXWafH9Afr +PF9u+G4DigEneLdrHwTCN3vHMyk64RgTyB4xI1EHe+ihBQTDyprv2R48+f5YU4GX9mA i1zwNysE54Bj//miQmA4z9mQt3kPZE5roXVN/aixP6LtDzgMQeaQwjJMpJVk6kpTcSYP F2FoGkw0IkXdM9+Wpw90Dy4pZPkCvkV5HlZBfu8Dqx2WfZbUOjy3d2Eh7WU7iNr/LKLH JsVQ== 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 u199si1830609oif.110.2020.03.19.16.51.56; Thu, 19 Mar 2020 16:52:09 -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 S1727207AbgCSXvG (ORCPT + 99 others); Thu, 19 Mar 2020 19:51:06 -0400 Received: from inva020.nxp.com ([92.121.34.13]:34732 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbgCSXvG (ORCPT ); Thu, 19 Mar 2020 19:51:06 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 0A8EA1A0121; Fri, 20 Mar 2020 00:51:04 +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 F09191A0058; Fri, 20 Mar 2020 00:50:56 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 5E1464029F; Fri, 20 Mar 2020 07:50:48 +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, gustavo@embeddedor.com, gregkh@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 V2] clk: imx: clk-pllv3: Use readl_relaxed_poll_timeout() for PLL lock wait Date: Fri, 20 Mar 2020 07:44:03 +0800 Message-Id: <1584661443-12032-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_relaxed_poll_timeout() for PLL lock wait which can simplify the code a lot. Signed-off-by: Anson Huang Reviewed-by: Abel Vesa --- Changes since V1: - Use readl_relaxed_poll_timeout() instead of readl_poll_timeout(). --- 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..a7db930 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_relaxed_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