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: 10105579 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 8DC7F602A7 for ; Mon, 11 Dec 2017 17:03:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75C0F223A1 for ; Mon, 11 Dec 2017 17:03:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6967D28753; Mon, 11 Dec 2017 17:03:30 +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 D39DF223A1 for ; Mon, 11 Dec 2017 17:03:29 +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=b2eObF+UU0eqBOcObfykixyk/5TAXvKyGr9r8fIagjw=; b=od9fsgF/LJmRz2zcvAvFa6+6b8 Rgm0DIzfv0/0Z/yIoVrWVL1I8PLGWk1iNjbPbOzZtsrJNDQkrxAPEHbjDYpAFrY65cWAiNmbc3POX nkmpsLejy25y2aqKFSDWu6ZUoP8gMvO30eKhuFpiz4msofxSjwaJvLQdOtOiF/wWotBGq8X38DOdd 9BAmHzK2bLmhT43WwolnG4BbaOCzUF8bCAvzEVZS7hxfitm+l0QzSg+ZoOwbQJLRViA3Qq5SoJKT/ tqyIsDCzi3Uk+k4BHMBmfFfwEQ5b2ysEbsYoGaK0LqoXRvsI/PD0ZzyfB1ETezoCddqN7eXvt9hYB F+0yj8mw==; 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 1eORUG-0003ZH-G5; Mon, 11 Dec 2017 17:03:28 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eORTS-00028Z-HU for linux-arm-kernel@bombadil.infradead.org; Mon, 11 Dec 2017 17:02:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1gkh47XRV8eIIVxVQv855bOIrFrr11OUMzYxW8T6+gk=; b=SAEheIiNd217dA/YX/dkAz5Du WB24M+HNBgrjwpJ/Z2Uslv9YWPkL0qAVaLxeolhLpxMmS42rcLzuSXLReH6RgXnpJ8h+ZHJsRtc+m r31Q4UzQg45x57bzaAQ5Puugvwi0CeE/ZF6T2emj+Qb0iwx+C74LQ4lbm2ojKPzA9oFS4lb3EtsL6 fBLtitbvXI/IwVRi1/lVUQOh7jlRptTdheXvcu46bgdkKjkQJ2yNBLDFSl1t7IeLtQpEFfqp5CL/1 EWs4Y8Lt/9+nzlpYsVhhcHfbDRAfukgkgxvgjDF2UkGrItNwbZEJLoKtO+RrDQydW8Kx3TiLy+YDs Wp2Q6NhrA==; Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eORNT-0003OH-2s for linux-arm-kernel@lists.infradead.org; Mon, 11 Dec 2017 16:56:28 +0000 Received: by mail-wm0-x241.google.com with SMTP id n138so15736893wmg.2 for ; Mon, 11 Dec 2017 08:56:06 -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=ilHYzmeNVIp39oPJ0rZJMFC/Txs9bTJBZeZfzyHGV2KrIXOaa5fxH9ObiMOaWddZjq PVnjnH3WU856aWwdfaBxEnzwUL3S+J5sNMSp4CUe9uBMpP7DrP8EKDtiUS3mDBtCf0f+ giUfYtwupohsZbGuLTnk6Dkc5MEs9f6g5wrBH0ZA9k9AFlNDsu5laOiUpSvCbapB/3D+ 9XiwPRgrirs+JPtC6sgsrTQyOj6ig+Rn9SCxxU2xyVP2sx/WfX7RAeXi3uMZfQzpk6Fx bH8Z6fiJNr8dselXGCtWxw/QsWGnv73hFl/OMnRIMmisnnPnBYio/vthc7KzJSq7QfWR HhhQ== X-Gm-Message-State: AKGB3mIORq4OeJ3AhELRx2ADjcGMtdtppsLAu9D6tI9WnqjfTs7GNXWf VRTPb7H0iYNLdxDdI6slRpc= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171211_165627_145869_94C89AF7 X-CRM114-Status: GOOD ( 14.19 ) 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 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 = {