From patchwork Thu Oct 19 16:42:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 10017707 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 73C7860224 for ; Thu, 19 Oct 2017 16:43:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6716428B64 for ; Thu, 19 Oct 2017 16:43:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BF1628D49; Thu, 19 Oct 2017 16:43:09 +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 DEE2728B64 for ; Thu, 19 Oct 2017 16:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753364AbdJSQma (ORCPT ); Thu, 19 Oct 2017 12:42:30 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:49843 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752518AbdJSQm3 (ORCPT ); Thu, 19 Oct 2017 12:42:29 -0400 Received: by mail-wr0-f195.google.com with SMTP id g90so8963040wrd.6; Thu, 19 Oct 2017 09:42:28 -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=brPL8VjCDwf0ijHqTt9aUJC7gOol1jlfN37WoPUaJ1eI4QQnnjSijWMPI2iLWShQZB X0usxwGa3Uv6BKu/iAY8SoNWUD3LkHIebHpp55RVdaWZNPLUXVYEfldjNmBER4kz6lf7 Nvz0Y/9457peivkrZKLi0BtWN9ufsIyQVGV1ZRmNyg6fdrqUjaB+W3KzFgE3NyqkuYQK 5i+ogEXLlHWk8jPyTV/d8JZZUGQS0JFgct6ot0ta/Lv232diHYd+/OdDpOvu/0M/ZcaX ZKHFF2FrOfkoLYRnxFw2e0nJWyRyQx6tVWkLB0we/at1rmRz+gb/JTQgORFoRZCxlhjk VJXQ== 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=NpM7npVhweQsHcgLv/h2iWqiogiWvcCMjOH2LDBqDA5tv1MnM7xsFzsm/aZT1IKsxm UBApaw7L3nz5H7YPuBPfRt7Ce0RPX97geHOiGEq+/spL5t3+ZJg8+ztLV1NOISeuG5yD SJ9Y3Ak51Wdndu/MHsBNNiDnJtgPYOhU3US9/fmz9/SDU+b3srWMtowRF5YzQ5drihVy Gqd7z+kah4owC6NeSc2zfE+uVSfUveOKXXX3KmlzlGeMJGYgLjYioGXQIbh7OPKEYQOQ Gq8xTOPxLg6bPFmvi9LSjFbWiGeOKDhOePk4mbjV//ZznxtusRZPqUawtVMbB4sb4wKA DyBQ== X-Gm-Message-State: AMCzsaUZyBdS13d/j5IwvR3XONuPrIz/HQ0ZcrZDIJZNTEgVTbjnd0Cw YFe6xk4liejuIi5CatqXdCM= X-Google-Smtp-Source: ABhQp+TqQRSVCq7QCGZfyfbColFnOfqNPUp1pCDVDAjhc4FZb2HP0VZCrJJiNrI0IKcCMZv5ayFUTg== X-Received: by 10.223.157.136 with SMTP id p8mr2297172wre.28.1508431347946; Thu, 19 Oct 2017 09:42:27 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id a195sm1458905wme.34.2017.10.19.09.42.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Oct 2017 09:42:27 -0700 (PDT) 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 v5 1/3] clk: at91: pmc: Wait for clocks when resuming Date: Thu, 19 Oct 2017 18:42:05 +0200 Message-Id: <20171019164207.32717-2-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171019164207.32717-1-romain.izard.pro@gmail.com> References: <20171019164207.32717-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 = {