From patchwork Thu Apr 1 12:27:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 12177995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, TVD_PH_BODY_ACCOUNTS_PRE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB4E9C433B4 for ; Thu, 1 Apr 2021 12:29:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 63C29610D2 for ; Thu, 1 Apr 2021 12:29:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63C29610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZTlWoAEEARn/4R8vKiOhbV0tgZXqJUtUGT9TvFqY8do=; b=Q5XWOIKfjlp750Gg3BltbilKU z/TiWVRNO0+bJMVn3BxjrBEgu2UrOIdNCkEngbjFBdwWzZjeXpb13LnI8zR3jSADF34mryhKzKNAK 1nofkp7F6/hmOArUbbv3WSFzkFWburJZCmdNl0n8VA3nqGy23bBGF+gbEGvtUl7tL7DqlAjWqu03S IKokD/ZvI6gSFpx0puxzHAn2tDkk3iDuNhwUz0DIlncLGv3xMS8oFMn0AG5+d/53h6R66REM4xmrS xdnGKoucqg0FCn7/BIyIYoYZ2cDjGIgKu1Awv85G2sa1/2pgHI4H6jDX25gKZOONzC+U3PRd6l2Sn Ov+CByOmA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRwQZ-009a4n-JS; Thu, 01 Apr 2021 12:27:59 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lRwQE-009a0w-PG for linux-arm-kernel@lists.infradead.org; Thu, 01 Apr 2021 12:27:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1617280059; x=1648816059; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EL+7YZiuBOEuw3rdP+GGFj0w1dSQCtzlJBMqg/Kiiro=; b=gLC/wgHmCSVW/ghwSY7jV7FfqhnouLzvtPBEW29chs3Pd+qnDtFAu+oo 6ZLg58vvS0PSJbksKQXn0utBeuACgG0OQVbp9mipparGSyXWX/vJPBxUu eRnXam46U9S2bi5Z8x7xfafTO/e9kLlZtNA/uz2uW4Qp2ya2148aXLs47 eZVLRbDs0DZCM37WyEiU4BfaxpBO6/s1wogit1NY/g4TSx4rY5CRVPN8n vdKGXcAMZnnKmm5MtHoEK7R8Np7v0dXVh9rQrEurSBCS4hZb4+OUIR8nU 8hmkkMdDdAURFGdHW2WuQULRxOO2vZZNYIEX5vLQEW7ZUh0iZxkzhwG9v A==; IronPort-SDR: hHkWY4BKPIUX8hGGjxe0M9lB/iROJacgnyGWWc6eoxil6K0Cnd6GMAAuTWBXGBOszJqdp29BKg YjSMQU4px+sg9xR+Ik1+F5JFEKOCoJQ0hPXJ5eQfqomg9jJz8hp3alwve1hXWCNu/yio9BhaZd xLX329ryODf6b/nsU0PrWa5JNihJCaaTFqmV4oeY49ZiJw3fi9gx64F5TRaEGhw6UhgUNsaYoO e4G/puTlNM67RxM7LYBInBmeYprWFxZlv0wfP6UzYTl9jnJeqhCfq9rCJsB3nZ2MQHz9L0qoHX Z7g= X-IronPort-AV: E=Sophos;i="5.81,296,1610434800"; d="scan'208";a="112137114" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 01 Apr 2021 05:27:37 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 1 Apr 2021 05:27:36 -0700 Received: from rob-dk-mpu01.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Thu, 1 Apr 2021 05:27:34 -0700 From: Claudiu Beznea To: , , , , CC: , , , , Claudiu Beznea Subject: [PATCH v2 2/6] clk: at91: pmc: execute suspend/resume only for backup mode Date: Thu, 1 Apr 2021 15:27:22 +0300 Message-ID: <20210401122726.28528-3-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210401122726.28528-1-claudiu.beznea@microchip.com> References: <20210401122726.28528-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210401_132739_292853_7FCA3B5A X-CRM114-Status: GOOD ( 18.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Before going to backup mode architecture specific PM code sets the first word in securam (and it will be cleared in a subsequent commit for the rest of power saving modes). Thus take this into account when suspending/resuming clocks. This will avoid executing unnecessary instructions when suspending to non backup modes. Since the clear of the 1st word in securam will be done in a subsequent commit the current commit will not broke the current behavior since up to this moment the suspend/resume were executed for all AT91 PM modes. The difference now is that the suspend/resume for clocks will be executed for the rest of AT91 PM modes just after the 1st enter/exit to/from backup mode. Also this commit changed the postcore_initcall() with subsys_initcall() to be able to execute of_find_compatible_node() since this was not available at the moment of postcore_initcall(). This should not alter the tcb_clksrc since the changes are related to clocks suspend/resume procedure that will be executed at the user space request, thus long ago after postcore_initcall(). Signed-off-by: Claudiu Beznea --- drivers/clk/at91/pmc.c | 48 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 77b57c9f5dcb..c226d33cd899 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -110,13 +112,35 @@ struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem, } #ifdef CONFIG_PM + +/* Address in SECURAM that say if we suspend to backup mode. */ +static void __iomem *at91_pmc_backup_suspend; + static int at91_pmc_suspend(void) { + unsigned int backup; + + if (!at91_pmc_backup_suspend) + return 0; + + backup = *(unsigned int *)at91_pmc_backup_suspend; + if (!backup) + return 0; + return clk_save_context(); } static void at91_pmc_resume(void) { + unsigned int backup; + + if (!at91_pmc_backup_suspend) + return; + + backup = *(unsigned int *)at91_pmc_backup_suspend; + if (!backup) + return; + clk_restore_context(); } @@ -125,24 +149,30 @@ static struct syscore_ops pmc_syscore_ops = { .resume = at91_pmc_resume, }; -static const struct of_device_id sama5d2_pmc_dt_ids[] = { - { .compatible = "atmel,sama5d2-pmc" }, - { /* sentinel */ } -}; - static int __init pmc_register_ops(void) { + struct platform_device *pdev; struct device_node *np; - np = of_find_matching_node(NULL, sama5d2_pmc_dt_ids); + np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam"); if (!np) - return 0; + return -ENODEV; + + pdev = of_find_device_by_node(np); of_node_put(np); + if (!pdev) + return -ENODEV; + + at91_pmc_backup_suspend = of_iomap(np, 0); + if (!at91_pmc_backup_suspend) { + pr_warn("%s(): unable to map securam\n", __func__); + return -ENOMEM; + } register_syscore_ops(&pmc_syscore_ops); return 0; } -/* This has to happen before arch_initcall because of the tcb_clksrc driver */ -postcore_initcall(pmc_register_ops); + +subsys_initcall(pmc_register_ops); #endif