From patchwork Fri Sep 8 15:35:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 9944565 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 2FD2D6035D for ; Fri, 8 Sep 2017 15:39:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F60D287F5 for ; Fri, 8 Sep 2017 15:39:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13F3E287FB; Fri, 8 Sep 2017 15:39:37 +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 A5EBE287F5 for ; Fri, 8 Sep 2017 15:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932091AbdIHPgT (ORCPT ); Fri, 8 Sep 2017 11:36:19 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37138 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756543AbdIHPgR (ORCPT ); Fri, 8 Sep 2017 11:36:17 -0400 Received: by mail-wm0-f67.google.com with SMTP id f4so1972209wmh.4; Fri, 08 Sep 2017 08:36:15 -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=QpAJytz+aiNN6ugMH0pd0IRk4M6Nw+EoUUnBnzUoU6Q=; b=i6EOBulN8YFDPPcLnFOi2ORTbNpVr5uBBKSVaIhENa2jfTZx0sLc+ugZDHWClO1GwQ bhrAv2RM1KdbKFPEv3g4kBTFJKYR0xZGPC1pOAazcu3m+D7dt9Djf/WHPnjTMvsNobRr XQ1fMPAyTJFzk23gt6Qfz2Pp0XAJJsXzF/oOhAcSuG7t1KLFAzqwg516F+WjudqcbEZw EPvojp4xWi0mPdKhRy6Er9Exko5AhW6RFL5KJ2pX7xR2JHzg3J+Dtb7K1YFRYBbN63wt xMNz9zn8kJ2NF6cwfJczwOcnkmCl/+XVNgYM4hWWkAYgT28Khnfyz+wR3jnLXYszsI/8 +GeA== 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=QpAJytz+aiNN6ugMH0pd0IRk4M6Nw+EoUUnBnzUoU6Q=; b=sys6McGkCExm+l5rmpdcQOwwhaVWFhfgz1BsUi2LqlQlQk4tRmKmz727UlNOPE50Sq azIEkZcFI1Xk6npfzvf2gJduepUnJCU/i7ijic3o4CTvlxTuKErekBrunKPn0zhdjcdJ TOdSyTQzAfers/245cvSC2N3CPlCBLHpdym4ETtL2nFhHMLnuOWo/j47Pi+V0C7WVoGs zfBT0PySYbf2Ej0NQw5zZPn27bT3s6yUfdh9W3s3XR6mgYuqlwaglM116ITa3XdP7b7U yKE1xFUq0Vc2VqZUTGWUkob10VInZj+qUX+Jer8jOS1qXNIpx4qkjtKkobXECutauEcL SfYw== X-Gm-Message-State: AHPjjUgnyS/3sJVOcivs4Kqtt885cFB8O8RxVTQbuCTDEvjnvBcvQfFD xtoRrYD4u0F4QADMoLwWYAY= X-Google-Smtp-Source: ADKCNb4fLcqaI4Bbux5Uj+MvxzRvSdLca1ahW6b+xJ5qnWs3ry78s7WhZ/UvNl37XkVAX6PhlG5ZZA== X-Received: by 10.28.48.71 with SMTP id w68mr213535wmw.3.1504884975148; Fri, 08 Sep 2017 08:36:15 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id p199sm1689224wmb.28.2017.09.08.08.36.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Sep 2017 08:36:14 -0700 (PDT) From: Romain Izard To: Nicolas Ferre , Boris Brezillon , Michael Turquette , Stephen Boyd , Ludovic Desroches , Jonathan Cameron , Wenyou Yang , Josh Wu , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Alan Stern Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pwm@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Romain Izard Subject: [PATCH v1 01/10] clk: at91: pmc: Wait for clocks when resuming Date: Fri, 8 Sep 2017 17:35:55 +0200 Message-Id: <20170908153604.28383-2-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170908153604.28383-1-romain.izard.pro@gmail.com> References: <20170908153604.28383-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 --- 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 = {