From patchwork Mon Dec 11 16:55:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 10105553 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 4EF61602A7 for ; Mon, 11 Dec 2017 16:58:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A328297C2 for ; Mon, 11 Dec 2017 16:58:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E7662976F; Mon, 11 Dec 2017 16:58:24 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 A61552976F for ; Mon, 11 Dec 2017 16:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752905AbdLKQ6X (ORCPT ); Mon, 11 Dec 2017 11:58:23 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:41158 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752348AbdLKQ4G (ORCPT ); Mon, 11 Dec 2017 11:56:06 -0500 Received: by mail-wm0-f68.google.com with SMTP id g75so15848917wme.0; Mon, 11 Dec 2017 08:56:05 -0800 (PST) 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=1gkh47XRV8eIIVxVQv855bOIrFrr11OUMzYxW8T6+gk=; b=Uux0uGLjdmXip5q1z5isTPGUvwJbZmSlAVGvKnFCDP69V+peiDofdzanURf75O4YRa W8SCq6o29aeJY9IPuQad/NvI0RoTwAM/xgzngHGPMQjmpY4oFDMaFd2O4+8zp/CIvAGK 0/8fFt3kdUowl52+8CsEh2j7SoruNv0v7yBTmkyxXLCjcL8bKsVFJbs820udMiPQQd3Q KK5/blOTmhYbKmhYvyz6wr7qA0s3rWrpA72ZTtcmgWxa45GVZ71cAHqhQg26fGghs59C 4JsVVwdenq1EFATiowMFrlXxjh/BQ7BL7ZrHGYVjgGWyjFliokfsyIBsgKuA6ar1lhiP RHCw== 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=1gkh47XRV8eIIVxVQv855bOIrFrr11OUMzYxW8T6+gk=; b=pP1iT9mNAYAkIORt4qsH60IZ609WQ9pWnfXRDGptuAdOur+0BzGebKSh4UHb6ThuBE x1YBzOgwuV3MkJPZSY96St6Y9x2q3BlxpazaK0ypVVbhOPk8XKKCHKhe5ZqXFLhwHloq 13jChtUH3MqjbsJmW0ni8H+oQy+s4hGvv2oPdW+gbEQ8tUZy3YVViFRdALBke8y81SOd +Nq1d9EY+DqydXWGo/EN0A0iqg+bwjSEGeX7O/p9zfKUUAeinKRV5X88Qd9vTgtqO073 Ngwv/hausih8SJVsu5OVGXLuTp15pilQOsL3Fq7FTqzum4P6k8Uy25WOVH3mTBXERfrc ZnmQ== X-Gm-Message-State: AKGB3mKBazIuzHXsC+8zMfRvmQoKiVn2iyA6OhUd1A6k0LxQsxa6ffUC 0HfGJZIUk1GMzmcE/hHmkfM= X-Google-Smtp-Source: ACJfBov0aH4r8B0uyQgfupWlthFEWnBgHQGToBDr3Igrq0PJJcuT2P05OxEobeNDfNPRatxe9KKMJA== X-Received: by 10.28.18.145 with SMTP id 139mr1366246wms.43.1513011365298; Mon, 11 Dec 2017 08:56:05 -0800 (PST) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id j77sm12699597wmf.36.2017.12.11.08.56.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 08:56:04 -0800 (PST) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Alexandre Belloni , Nicolas Ferre , Ludovic Desroches Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Romain Izard Subject: [PATCH v6 1/3] clk: at91: pmc: Wait for clocks when resuming Date: Mon, 11 Dec 2017 17:55:33 +0100 Message-Id: <20171211165535.5126-2-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171211165535.5126-1-romain.izard.pro@gmail.com> References: <20171211165535.5126-1-romain.izard.pro@gmail.com> 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 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 Acked-by: Alexandre Belloni --- 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 = {