From mboxrd@z Thu Jan 1 00:00:00 1970 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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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=unavailable 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 39B3EC433F5 for ; Fri, 17 Sep 2021 12:06:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FA6E60187 for ; Fri, 17 Sep 2021 12:06:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243532AbhIQMIQ (ORCPT ); Fri, 17 Sep 2021 08:08:16 -0400 Received: from esa.microchip.iphmx.com ([68.232.154.123]:25398 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241146AbhIQMIN (ORCPT ); Fri, 17 Sep 2021 08:08:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1631880411; x=1663416411; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2RWqN9QB2QVB/b7ge5LAdzUZ1SFAzssOZe07e839kf4=; b=vdqVAXxnOAmmixffxJQXXfbcCZkUXEVOh5NbWUEo5PMG9c/LJT5jNnfq OQK/5/pGDJKMFHUzqELuKBoX8oF2rto53ACA8ENGgwuPzvju6XS4BKDl/ e208wDCxBByP5u63xJiDuZtgsR5Xw62UQ6wn/RsAM4LE39TcWvTaItO5M PWqQkmK2M7/F4VIeSpGNGrIZVZ9WLQpXDIi+3bwDayEcjwW/ao8i8GNCt gQtJWoDV55w1CuOEBk7z8QRrfX9B6d9FM2cZQKykGu8fv054VyPrw4HPQ QgGkPFZ26RdDYFiGgV737hCxVWQNNW1dqx4u03h8zIbePKkE3aGnbGDFt w==; IronPort-SDR: q+jhQewa8qJAxgiDhFw9cFzTPH24rX41Mp5Z8DWVCt0uY6KzcqrXUgjz3Rw5dre9G1gtz0dhi9 pyOkss/Pq67TOfzvuU3YvEtyWfZp6aSg+XDU8utzSOp5BCP1bu+RkfYksxIZiNaaKbqQLn8S2u dH6KGvIrldDt4U3NlESsnrMRYfdyDGQUcTHWKfly1CLZMXZbywiwVO/zqGxrRvLQI9qycC+ycJ y5wzThmTbQPszamGbmBR+pI2oXvZCxm0G7Qn+KcC2ES9iF5UYG5mgOs6q/l7jMNh8pXzTeRZng QX8JKkEGNxVQsWhidBpKbki9 X-IronPort-AV: E=Sophos;i="5.85,301,1624345200"; d="scan'208";a="129673906" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2021 05:06:50 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 17 Sep 2021 05:06:50 -0700 Received: from rob-dk-mpu01.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 17 Sep 2021 05:06:48 -0700 From: Claudiu Beznea To: , , , , CC: , , , Claudiu Beznea Subject: [PATCH v3 02/17] clk: at91: pmc: execute suspend/resume only for backup mode Date: Fri, 17 Sep 2021 15:06:27 +0300 Message-ID: <20210917120642.8993-3-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210917120642.8993-1-claudiu.beznea@microchip.com> References: <20210917120642.8993-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before going to backup mode architecture specific PM code sets the first word in securam (file arch/arm/mach-at91/pm.c, function at91_pm_begin()). Thus take this into account when suspending/resuming clocks. This will avoid executing unnecessary instructions when suspending to non backup modes. 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 subsys_initcall(). Signed-off-by: Claudiu Beznea --- drivers/clk/at91/pmc.c | 49 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index b2806946a77a..58e9c088cb22 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(); } @@ -132,6 +156,7 @@ static const struct of_device_id sama5d2_pmc_dt_ids[] = { 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); @@ -144,10 +169,30 @@ static int __init pmc_register_ops(void) } of_node_put(np); + np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam"); + if (!np) + return -ENODEV; + + if (!of_device_is_available(np)) { + of_node_put(np); + 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 -- 2.25.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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=-17.1 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=unavailable 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 D1602C433F5 for ; Fri, 17 Sep 2021 12:10:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 9A13F60187 for ; Fri, 17 Sep 2021 12:10:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9A13F60187 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=/stTYu2pggG0dgam8vTJHzMMmpOWa5yMga9E7vz/r1I=; b=KN40HS95cvi9pD /SO6autVVC1UrOpZ4p4IXbcLjMJ6u2yDjcfrpxWrsc+MOGzV56ArcQeycpAzPKTHRZCfWejMlhUHV gAHTNkCUoN1xhwabJGAUbUhY9rDp1v8mHX3hjyoLgILUllw3QxzUbsZ2jyT2B184S2xoptK5I279j ogz5cB1dtVotoO19MtVB1gF3uMbxVFl0/lhbKJww8C/p8iBa7d9Q6Cmh50VEHT9dBDklapy90Z6be KYBs6MfPszH6lf7xZOsCikbI2MRQXgzY8nhvpEsUWQhpXYrLewBItJ33S7rC2RT5mDdrFvY+SA/xQ sRLNlD1xtK3QtaO5Fxiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mRCeE-00Dw55-3U; Fri, 17 Sep 2021 12:07:18 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mRCdo-00DvyQ-Cb for linux-arm-kernel@lists.infradead.org; Fri, 17 Sep 2021 12:06:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1631880412; x=1663416412; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2RWqN9QB2QVB/b7ge5LAdzUZ1SFAzssOZe07e839kf4=; b=nfvKu2wGT0rIbpO0xT3VobfG9Gl9rcLgbcXQdXV3My0Tagp33dqBuV6Q 7zblsjo4oZTUqcPDISh+WC2hWilOj8nih1TFbP/k5ncyvAo27GF3R2Gg9 JpdLRacKHhQPTvnlVcWqds8f2I7jqBGzLjZqBvMN6yoYAAAGrjJE1ffb0 WVeBswEk7IHQ/WbO3pTijR5wCEzyFiBG7BJlpxm1M5yY4A310m+ZGLlcu Ev7eHTceaNWuWQfmvjOnfg1DLglCgk+HtFZsS2S0bxr9VvFs1HlpxczvW m8wR0EvZQBI6lQXgnlz/wH5szVHxMYyKRA+uFjg6n0VdyQ07B3QjECdTj Q==; IronPort-SDR: q+jhQewa8qJAxgiDhFw9cFzTPH24rX41Mp5Z8DWVCt0uY6KzcqrXUgjz3Rw5dre9G1gtz0dhi9 pyOkss/Pq67TOfzvuU3YvEtyWfZp6aSg+XDU8utzSOp5BCP1bu+RkfYksxIZiNaaKbqQLn8S2u dH6KGvIrldDt4U3NlESsnrMRYfdyDGQUcTHWKfly1CLZMXZbywiwVO/zqGxrRvLQI9qycC+ycJ y5wzThmTbQPszamGbmBR+pI2oXvZCxm0G7Qn+KcC2ES9iF5UYG5mgOs6q/l7jMNh8pXzTeRZng QX8JKkEGNxVQsWhidBpKbki9 X-IronPort-AV: E=Sophos;i="5.85,301,1624345200"; d="scan'208";a="129673906" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2021 05:06:50 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 17 Sep 2021 05:06:50 -0700 Received: from rob-dk-mpu01.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 17 Sep 2021 05:06:48 -0700 From: Claudiu Beznea To: , , , , CC: , , , Claudiu Beznea Subject: [PATCH v3 02/17] clk: at91: pmc: execute suspend/resume only for backup mode Date: Fri, 17 Sep 2021 15:06:27 +0300 Message-ID: <20210917120642.8993-3-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210917120642.8993-1-claudiu.beznea@microchip.com> References: <20210917120642.8993-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-20210917_050652_602565_6F3C8A1C X-CRM114-Status: GOOD ( 16.84 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 (file arch/arm/mach-at91/pm.c, function at91_pm_begin()). Thus take this into account when suspending/resuming clocks. This will avoid executing unnecessary instructions when suspending to non backup modes. 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 subsys_initcall(). Signed-off-by: Claudiu Beznea --- drivers/clk/at91/pmc.c | 49 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index b2806946a77a..58e9c088cb22 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(); } @@ -132,6 +156,7 @@ static const struct of_device_id sama5d2_pmc_dt_ids[] = { 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); @@ -144,10 +169,30 @@ static int __init pmc_register_ops(void) } of_node_put(np); + np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam"); + if (!np) + return -ENODEV; + + if (!of_device_is_available(np)) { + of_node_put(np); + 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 -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel