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: 819044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pcYkHZtl"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="F3lk96+J"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2B660wlhz9t4Z for ; Wed, 27 Sep 2017 18:37:50 +1000 (AEST) 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=3dw90dNA4aPy1GDH9odCKvAVcb67guL9zNlBvjkX0Ys=; b=pcYkHZtldHlZwlKnHxCQravU/x 3u9Jg3+lEIqR51CxcIKJzS96mjpbIlmqyhkEdM9kOtoa3pp+bwlAvGASaFI/50RBsg8VuLwqG85se txjAlLwwPlQOBRvzVU1tdMZth5jKqyGHJysxzdTvJ6ct2QZ7BdJWco+ZoC2pmngW/RWfCRsBksUIS w6wP1dC71P4n5WtWaumbsYU9NqK436toMlFGhlNsa20eCyoSZKxxgs9BYy1Mxmqn8UhmdHoruEH8w WZ3ovooYL5caBYsJYPctRsqdVaZz+AAd0BR0GuGv0Sz3Z0Cz6so2txuf6x2jV0kk3ZubkZdBvYtJN 02+biImg==; 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 1dx7qc-0003yo-8P; Wed, 27 Sep 2017 08:37:38 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dx7pa-0002jJ-Ou for linux-mtd@lists.infradead.org; Wed, 27 Sep 2017 08:36:41 +0000 Received: by mail-wm0-x242.google.com with SMTP id m72so15481192wmc.1 for ; Wed, 27 Sep 2017 01:36:14 -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=pjSeAGUMWZMN5JxOyF19GcAHbaQX6wNrdOathFSi+By4AKTHGyYTAKOXfDBwPgy5CV Jtiz/C7q44DxKkGKon/oM8H+rMAKEARC4zXLBdQ71Qlv4gPhXOIgSw97DcXSqapca1EN jbCKkw0OvmfkZIO/mxgTf/9WMrGQAnfQ7CDQRDhvrZ+RF1wbz+MAW5AJr6/jaSJrUXCz DOEuQxE6GsAreiJf+8utxMlmp9swy7r8bMSZMG7PpNQbCZvVAiKKTnmmdWTmbNzVlI5b QX5/WjaMFrroPOEn0R2yrWKWQAUTbbokMORScdKgo9IZmSZjzWJpbeMiAu68lRCIfw/M RI3w== X-Gm-Message-State: AHPjjUhKZcsHyYfid8e+ojELJmoJYvmZGG7NdKOE3LO5ottCGU+R34p1 92C6EK0hP1sUbnZoOR0twno= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_013634_964479_E4D5BD21 X-CRM114-Status: GOOD ( 12.90 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 = {