From patchwork Wed Sep 27 08:35:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 9973445 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 CB946603FA for ; Wed, 27 Sep 2017 08:39:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA68F2910D for ; Wed, 27 Sep 2017 08:39:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AECAA2910F; Wed, 27 Sep 2017 08:39:10 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 A1D6829117 for ; Wed, 27 Sep 2017 08:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752578AbdI0IgU (ORCPT ); Wed, 27 Sep 2017 04:36:20 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:46771 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752487AbdI0IgO (ORCPT ); Wed, 27 Sep 2017 04:36:14 -0400 Received: by mail-wm0-f66.google.com with SMTP id m72so15481186wmc.1; Wed, 27 Sep 2017 01:36:13 -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=F3lk96+JS4bvFaGYoy2MEdUk42Z4fNxTJ+LYRkCeR89A1dDEukmVQJlv8L/fEyV/f1 rWyot8tSq5SNGhUFhiQn07y5UTDFtV79hV2wGTV55deEG8tx7QOp58PHv6dkPHKdcaaP karjnMiPYU5uTTuJtfOouc/BNX+af/DAQriGfvLZb9IlLpqO3Q0Dj3a5GHvlVli1oIeK bJcelXXTDlk0o1qRJoTzUfnxdJk6KrHj+Cj3kFUUAyrx8uPYdOZsUYXfRIq+PBtSALPo CK876vJklL4gUsK7BxGWBRwmsHI4cU3Yq1SA7vtzu+gYTTO7ibTdYXSJcVNV6vsHcOfn AVUw== 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=CejRLTHdh/nbbuhwlFDM6us9G5RwCM8oZ+lxRCZW79yvWl07RPiA3iWoBN7qJuxSAF DDbNLiMVHO4Hy58Tqf4kcXXSqq9dFVXNBu+/rvCIN5SBTXGAB868LxDc4bFilBtULjYi qXzqFqlSDhVKYraTZsZ6/7K+dRmWi/fwLCEhiCDXv9zgA3Q1ds0s3wqZ/ZbG1T+/riXo zHiIiM95yQlMpuycwQIY2NY2pmlA15axWXb5HKvSSzDbKG2mKnACo9BqCBJ8eYcgyRuV T+4Jiyv8mNn1zknz97geyTyftCRGRJQXCyrHy0IhbIFo9V/R+zbdoOG+w+lCSqPG364B kL5Q== X-Gm-Message-State: AHPjjUjjoO4FPlCJOAotx/XZ1yyodgJ6D+CFgEdH9w/Ecmm0Xhf/6iV9 YM70NC74B2HlmfNXzx7ImIE= X-Google-Smtp-Source: AOwi7QC8de/LX7DtKfMfi8SNQ+mtUl0r03rkwEBNWagZeggs51mwGBQraPxvcv6K0Io8et8nDUveUQ== X-Received: by 10.28.174.67 with SMTP id x64mr909409wme.82.1506501373069; Wed, 27 Sep 2017 01:36:13 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id r6sm9699900wrg.40.2017.09.27.01.36.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 01:36:12 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pwm@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, Romain Izard Subject: [PATCH v3 1/8] clk: at91: pmc: Wait for clocks when resuming Date: Wed, 27 Sep 2017 10:35:48 +0200 Message-Id: <20170927083555.16580-2-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927083555.16580-1-romain.izard.pro@gmail.com> References: <20170927083555.16580-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 --- 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 = {