From patchwork Thu Oct 19 16:42:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 10017709 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 C0FB660224 for ; Thu, 19 Oct 2017 16:43:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B44E728B64 for ; Thu, 19 Oct 2017 16:43:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A91C928D49; Thu, 19 Oct 2017 16:43:13 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 43F3F28B64 for ; Thu, 19 Oct 2017 16:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=sC4yz2yigdBg7SoI+OSm9lHGuCAWrOctLJNoggUxcNE=; b=FZFAf+oMyKiKAYdmumtOW6CfDa w6fPSIcaaKe+kB0GbG1wiNIrbCkBuAUisS8Bxw1lfxNndaTb4A6ozbo1BD/loOhDUt19opAS+hOiN I7mRtSvp0v3EG9ifw0+NIKLIpGrqysnIRE7leLqUypYoaQKqTqKSGZ2SLuNeE1m9LvOCNTRp2BDWr ieLnTa0f5zqJwgpBD2glIsKyIQ82K7F9pdCfWkcDP/6QkjhIEo0Dq6vJE+m8q6hBb3+blApIm9VrR hVycICTRH5e/xleMe2RNwCrmKJ/oa16Gy6PDY0VKYFywPeo2cj8ftdsRwBD+/vyna00Oravw1afBX 4pF5oq/w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e5Dua-00071X-Q8; Thu, 19 Oct 2017 16:43:12 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e5DuE-0006YY-Fs for linux-arm-kernel@lists.infradead.org; Thu, 19 Oct 2017 16:42:58 +0000 Received: by mail-wr0-x241.google.com with SMTP id j14so8969392wre.8 for ; Thu, 19 Oct 2017 09:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SXCU17pSZBd7SdVZm1ZcLIHKqn3I6ldleFFnCs7nces=; b=brPL8VjCDwf0ijHqTt9aUJC7gOol1jlfN37WoPUaJ1eI4QQnnjSijWMPI2iLWShQZB X0usxwGa3Uv6BKu/iAY8SoNWUD3LkHIebHpp55RVdaWZNPLUXVYEfldjNmBER4kz6lf7 Nvz0Y/9457peivkrZKLi0BtWN9ufsIyQVGV1ZRmNyg6fdrqUjaB+W3KzFgE3NyqkuYQK 5i+ogEXLlHWk8jPyTV/d8JZZUGQS0JFgct6ot0ta/Lv232diHYd+/OdDpOvu/0M/ZcaX ZKHFF2FrOfkoLYRnxFw2e0nJWyRyQx6tVWkLB0we/at1rmRz+gb/JTQgORFoRZCxlhjk VJXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SXCU17pSZBd7SdVZm1ZcLIHKqn3I6ldleFFnCs7nces=; b=mBYeSQIVDfVV+LH3elf+/gLPI5QOK6H6h1OQIFe5Z2mwCJ/D/xbvfWxq9N0kEvPjg/ BVNVDYQJS/lQSk4oPTThgB05nfdW2CHOGS36nd6yMRzMDGPfDNHdbtOYgX+OmKGNrmi4 txhAUbkR2AB9my12JILOp7BXlNt7fQohWIvku58QFbGamC/1WE1KQC61yx97cUIlMFDL 7sWKYEcJI+tgfS51y4EJAcc+QBHVJMihQgyzk00EKc8S5VKJD5y30NhcYqYG/VxksO/m Nvnf5nPRPLAx0V6pI16MwU2g9VpxIrblELRileKUY/N2ku9L1E/jGCMojaBdUxokdVo4 2tsA== X-Gm-Message-State: AMCzsaUMy/TjCZh+6wW+DOIyertz3pZHXHp8BVjE3sTsod3s/50hETpC X+gBcuC3qEO0LGqvVMzx+2w= X-Google-Smtp-Source: ABhQp+TqQRSVCq7QCGZfyfbColFnOfqNPUp1pCDVDAjhc4FZb2HP0VZCrJJiNrI0IKcCMZv5ayFUTg== X-Received: by 10.223.157.136 with SMTP id p8mr2297172wre.28.1508431347946; Thu, 19 Oct 2017 09:42:27 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id a195sm1458905wme.34.2017.10.19.09.42.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Oct 2017 09:42:27 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Alexandre Belloni , Nicolas Ferre , Ludovic Desroches Subject: [PATCH v5 1/3] clk: at91: pmc: Wait for clocks when resuming Date: Thu, 19 Oct 2017 18:42:05 +0200 Message-Id: <20171019164207.32717-2-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171019164207.32717-1-romain.izard.pro@gmail.com> References: <20171019164207.32717-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171019_094251_189373_DAD57E79 X-CRM114-Status: GOOD ( 13.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Romain Izard , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Wait for the syncronization of all clocks when resuming, not only the UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG() when interrupts are masked, which is the case in here. Signed-off-by: Romain Izard Acked-by: Ludovic Desroches Acked-by: Nicolas Ferre --- drivers/clk/at91/pmc.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 775af473fe11..5c2b26de303e 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -107,10 +107,20 @@ static int pmc_suspend(void) return 0; } +static bool pmc_ready(unsigned int mask) +{ + unsigned int status; + + regmap_read(pmcreg, AT91_PMC_SR, &status); + + return ((status & mask) == mask) ? 1 : 0; +} + static void pmc_resume(void) { - int i, ret = 0; + int i; u32 tmp; + u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA; regmap_read(pmcreg, AT91_PMC_MCKR, &tmp); if (pmc_cache.mckr != tmp) @@ -134,13 +144,11 @@ static void pmc_resume(void) AT91_PMC_PCR_CMD); } - if (pmc_cache.uckr & AT91_PMC_UPLLEN) { - ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp, - !(tmp & AT91_PMC_LOCKU), - 10, 5000); - if (ret) - pr_crit("USB PLL didn't lock when resuming\n"); - } + if (pmc_cache.uckr & AT91_PMC_UPLLEN) + mask |= AT91_PMC_LOCKU; + + while (!pmc_ready(mask)) + cpu_relax(); } static struct syscore_ops pmc_syscore_ops = {