From patchwork Thu Jan 21 11:19:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 12035669 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.9 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 8107AC433E6 for ; Thu, 21 Jan 2021 11:24:38 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 2B19A238D7 for ; Thu, 21 Jan 2021 11:24:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B19A238D7 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=oUmfgXPpuhS/3XZjyfO97JJ+QTS1mIoa9Wnqccfdy7Q=; b=Kgc7TqzRj+Sf68Y/rCFV2SB35 flzCJtiq6EP6gJLo7ds3JXs8+o6BLTzgNZZOpkIQIGuDph12Nw3OG8hL8rQkyktKvzNHLmm3vHOAM qDeDXfLBGbzXDqfBwR/lKcPqhInt8KVSrB2DqnK1M/IZYHGfzHmZCvBrOxDPTddyebEirrlW/tonz /d6AvSMrNaN3eDxA0vgBZ4rC85540DaemO+f4e82YQ3dhgYcRSgKwEz+E972T8iyGaJwHIBpgeTT1 SmQVqbAqyy/LHR1owtxEZNikko47siCoGkZ0+rHm4GMZ8kFdK/DqQwy0DXkLQcqKhpLPnj4K7o0/I hrFRrtgmA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2Y2G-0006DS-95; Thu, 21 Jan 2021 11:21:56 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2Y03-0005FA-6P for linux-arm-kernel@lists.infradead.org; Thu, 21 Jan 2021 11:19:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1611227979; x=1642763979; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Fdf9OnTBFgfQBR84ixjFKpX80iSmhJBN+KwWlQeFgOU=; b=PN4e/pniE0gDUJol8muI9APNxpuEFQmOsERVLWhJP1Gdv7Ku4nVdYEAR JSCn9zBhfTiUGoovkLx+cbkQJm7bGfzt5YbFi7jtdMW1WV1LbV3VNCANW 3uv67z3sot8N0KmWUTvNd6x8zDdDNhwuusaw9mnXEiidLzrlVF/xxL8hW 4WERlpRP9EP2d0IcqYIfweVIMAv9hNtntDe2EuSshm0B2BmnzpWLwL4qm AXTwmPkzijM0/2jvVBxeUwJ9Xq6Sw2fKma9Wi5PFXGQJc0La1IRb9Zjmk bTQJ6V9G7DcwdfsBYlN/8DaZuXEYFAX89BEwZaVGUltb+SU7XEMyDKKm1 A==; IronPort-SDR: r6WU6ibkMNbBfCpZhZtX+GAGihYWO1yOhpLoHsBgtkVst0gZ8osLtidtRW9vKvC8gaiSjVEibJ bEQpscDtGKkEdYdXBWF8kASXtpyT0qO6Q1rKosm3I3oimwe7aJF3fQETFcFGCoBdGXv2ugsya6 CNzp++KD7UIl6mN3uhGn1+BWT8yys9onN70ff6U4TgaEeev5j0nbg93R4TXGwN4hQvRTiFvDhp E6JpgVWw5oCLN9xfmcZ9q9clqgh1aMtW78uA+Qa2D672k7ht0QI0NBa+dILoxa7Qzi9nkiKAus C0k= X-IronPort-AV: E=Sophos;i="5.79,363,1602572400"; d="scan'208";a="100892437" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 21 Jan 2021 04:19:35 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 21 Jan 2021 04:19:35 -0700 Received: from m18063-ThinkPad-T460p.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Thu, 21 Jan 2021 04:19:31 -0700 From: Claudiu Beznea To: , , , , Subject: [PATCH 2/5] clk: at91: pmc: execute suspend/resume only for backup mode Date: Thu, 21 Jan 2021 13:19:08 +0200 Message-ID: <1611227951-4590-3-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611227951-4590-1-git-send-email-claudiu.beznea@microchip.com> References: <1611227951-4590-1-git-send-email-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210121_061939_393011_4DED536E X-CRM114-Status: GOOD ( 20.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: viresh.kumar@linaro.org, Claudiu Beznea , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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