From patchwork Tue Sep 4 06:49:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 10586791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCFE814BD for ; Tue, 4 Sep 2018 06:50:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB16528FFC for ; Tue, 4 Sep 2018 06:50:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB22D2900A; Tue, 4 Sep 2018 06:50:47 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 30F6528FF9 for ; Tue, 4 Sep 2018 06:50:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727645AbeIDLO3 (ORCPT ); Tue, 4 Sep 2018 07:14:29 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:55944 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727623AbeIDLO3 (ORCPT ); Tue, 4 Sep 2018 07:14:29 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id w846oSt1094927; Tue, 4 Sep 2018 01:50:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536043828; bh=It+a1Y8h0aYNVd1xtw8hw+ImyxlOg9ahOiCtWfP/QwU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=sLMk3GW+k1fxF9VXeD6sl8wp7E8quYjgN9NmwsZF+n4zwgm+spgWHxR1HYfUFMwqV dQKRjG8aCoEPIhRxs+Y92ely27exYTUhjIufO0D4278Kkrs9oMFubOt16p0CRE2iu7 GEL1fwsIakn+HKvfnxDRS8Og7ZHn168XDsXEKecY= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w846oSSW030689; Tue, 4 Sep 2018 01:50:28 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 4 Sep 2018 01:50:28 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 4 Sep 2018 01:50:28 -0500 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w846oBce005776; Tue, 4 Sep 2018 01:50:25 -0500 From: Keerthy To: , , , CC: , , , , , , Subject: [PATCH v3 RESEND 4/4] ti: pm33xx: Save/restore clk context based on enable_off_mode setting Date: Tue, 4 Sep 2018 12:19:38 +0530 Message-ID: <1536043778-2232-5-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1536043778-2232-1-git-send-email-j-keerthy@ti.com> References: <1536043778-2232-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 Save/restore clk context based on enable_off_mode setting. The context needs to be saved at the very end of suspend path and restored at the beginning of resume path. Signed-off-by: Keerthy --- arch/arm/mach-omap2/pm33xx-core.c | 15 +++++++++++++++ drivers/soc/ti/pm33xx.c | 13 +++++++++++++ include/linux/platform_data/pm33xx.h | 1 + 3 files changed, 29 insertions(+) diff --git a/arch/arm/mach-omap2/pm33xx-core.c b/arch/arm/mach-omap2/pm33xx-core.c index f4971e4..ccba2cd 100644 --- a/arch/arm/mach-omap2/pm33xx-core.c +++ b/arch/arm/mach-omap2/pm33xx-core.c @@ -38,6 +38,20 @@ static int __init am43xx_map_scu(void) return 0; } +static int am43xx_check_off_mode_enable(void) +{ + /* + * Check for am437x-sk-evm which due to HW design cannot support + * this mode reliably. + */ + if (of_machine_is_compatible("ti,am437x-sk-evm") && enable_off_mode) { + pr_warn("WARNING: This platform does not support off-mode, entering DeepSleep suspend.\n"); + return 0; + } + + return enable_off_mode; +} + static int amx3_common_init(void) { gfx_pwrdm = pwrdm_lookup("gfx_pwrdm"); @@ -166,6 +180,7 @@ void __iomem *am43xx_get_rtc_base_addr(void) .soc_suspend = am33xx_suspend, .get_sram_addrs = amx3_get_sram_addrs, .get_rtc_base_addr = am43xx_get_rtc_base_addr, + .check_off_mode_enable = am43xx_check_off_mode_enable, }; static struct am33xx_pm_platform_data am43xx_ops = { diff --git a/drivers/soc/ti/pm33xx.c b/drivers/soc/ti/pm33xx.c index d0dab32..1a8df56 100644 --- a/drivers/soc/ti/pm33xx.c +++ b/drivers/soc/ti/pm33xx.c @@ -6,6 +6,7 @@ * Vaibhav Bedia, Dave Gerlach */ +#include #include #include #include @@ -54,6 +55,14 @@ static int am33xx_pm_suspend(suspend_state_t suspend_state) { int i, ret = 0; + /* + * For RTC only mode with DDR in selfresh we need to save + * clocks context at the very end + */ + if (suspend_state == PM_SUSPEND_MEM && + pm_ops->check_off_mode_enable()) + clk_save_context(); + ret = pm_ops->soc_suspend((unsigned long)suspend_state, am33xx_do_wfi_sram, suspend_wfi_flags); @@ -79,6 +88,10 @@ static int am33xx_pm_suspend(suspend_state_t suspend_state) } } + if (suspend_state == PM_SUSPEND_MEM && + pm_ops->check_off_mode_enable()) + clk_restore_context(); + return ret; } diff --git a/include/linux/platform_data/pm33xx.h b/include/linux/platform_data/pm33xx.h index fbf5ed7..dcea606 100644 --- a/include/linux/platform_data/pm33xx.h +++ b/include/linux/platform_data/pm33xx.h @@ -51,6 +51,7 @@ struct am33xx_pm_platform_data { unsigned long args); struct am33xx_pm_sram_addr *(*get_sram_addrs)(void); void __iomem *(*get_rtc_base_addr)(void); + int (*check_off_mode_enable)(void); }; struct am33xx_pm_sram_data {