From patchwork Tue Jan 8 10:56:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10751821 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 DCE2F13B4 for ; Tue, 8 Jan 2019 10:56:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB20328BB5 for ; Tue, 8 Jan 2019 10:56:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF09628BEA; Tue, 8 Jan 2019 10:56: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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 8A27B28BB5 for ; Tue, 8 Jan 2019 10:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728171AbfAHK4c (ORCPT ); Tue, 8 Jan 2019 05:56:32 -0500 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:33316 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbfAHK4b (ORCPT ); Tue, 8 Jan 2019 05:56:31 -0500 X-IronPort-AV: E=Sophos;i="5.56,453,1539673200"; d="scan'208";a="22335034" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Jan 2019 03:56:30 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.107) with Microsoft SMTP Server (TLS) id 14.3.352.0; Tue, 8 Jan 2019 03:56:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gxkZa9nA/bv+2ZamBOfPn1B/WEZr148ZjJQ8WZkDHts=; b=YttKn1X/gffiKpEAaJju8gUHc3aSygfolkI9HZxk9K4IJlSjWMNjyERNUgAIGF0qES3+FP1EJpns4gyVuK9csg8ce+XbasNXPb/OF6C4B+PjV5Ivve/QrERdYUOHXxOY+TlAklOKnnzQp6OTcPvtYK7tbFIGzbrc7ZifaaeTTZU= Received: from CY4PR11MB1909.namprd11.prod.outlook.com (10.175.61.147) by CY4PR11MB1399.namprd11.prod.outlook.com (10.173.17.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.9; Tue, 8 Jan 2019 10:56:29 +0000 Received: from CY4PR11MB1909.namprd11.prod.outlook.com ([fe80::5478:c9ff:e5b2:2b4e]) by CY4PR11MB1909.namprd11.prod.outlook.com ([fe80::5478:c9ff:e5b2:2b4e%9]) with mapi id 15.20.1495.011; Tue, 8 Jan 2019 10:56:29 +0000 From: To: , , , , , , , , CC: , , , Subject: [PATCH v2 1/3] PM / Suspend: Add support to check if platform's power is off in suspend Thread-Topic: [PATCH v2 1/3] PM / Suspend: Add support to check if platform's power is off in suspend Thread-Index: AQHUp0DOM7WMwuf4TU6Qg1UGEhg3kQ== Date: Tue, 8 Jan 2019 10:56:29 +0000 Message-ID: <1546944944-13911-2-git-send-email-claudiu.beznea@microchip.com> References: <1546944944-13911-1-git-send-email-claudiu.beznea@microchip.com> In-Reply-To: <1546944944-13911-1-git-send-email-claudiu.beznea@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR04CA0113.eurprd04.prod.outlook.com (2603:10a6:803:64::48) To CY4PR11MB1909.namprd11.prod.outlook.com (2603:10b6:903:11f::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Claudiu.Beznea@microchip.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR11MB1399;6:pGE9I4sJ+TJekKlBbjJkL5i6RMw0auPLJcr9DlU3ocMCwj/bhmnXdnpCjDVk6Z5AVG7O4TaoQhjCFaV58+AGOP/HleuKwYOY8AFfoq82/wSN0R/48Lg2ggwMdMhbQNrSU7vKMXY3HqioZwUiEpHMZ+u+a4flCG0VTKx15dq6h/C9Mtuz7p8gXYa+qGIff7/rV6t7uOiPGlGxSNDQa8eH2D0pXCkgD/IKzn89uJ5wsMfgl5zg9ve7lRClKQutua6xA4mWUidybE7Qx/2sYPj36crsGYoo0qQrfcSZSLgO5Y7/ppjGUxaqCuEOc35+qDb4/RFP1xPCF7zFoNNZ78+Hrr40nPilJ2udBIMD8QOqyPIjQnF+iNERB+U7C5T6pbmapz8zLbM+kTsEMnjkcpONbi26sCqp2U48Ph6R4W3D7USP48PyPXnNa/Wfl3zbPQDyXoqohALqO+bGvMGlBuGLRQ==;5:3Z9YwSlG7YN+BuwK0rGrM9Mf5DdLvxx2vRkT4RmSF6apaRGotneaD+oqPRxkvQ7td6qG19spYHS4q0XmavBqj94zV+vQBsWDXd4v3Cx/1WTBDGzY+3f2aC65qK3c2INIUg3g0RXz7uUiMUEoRtTJSBQfDfx91OlNYOVgXsQfRt86J1GGJdHgDHOvzcZlHKxTST0h/EwE0KH929rv6OHY9g==;7:GC1I9CNyz68FyBscPD5anyT+x0U/YUXoRs7OVRi+u0Zorh5mgmpgy1C/1T1bAzplggrL9/aLFBevc8YzmqDvj6qtLT4SLCWhUktE6p1MjOLH9TqmJqQCfR69OPFD4/ouNzRZhqV/uopMlzOV39wWbA== x-ms-office365-filtering-correlation-id: 08bc4f42-f8ab-45c7-7ab0-08d67557f122 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:CY4PR11MB1399; x-ms-traffictypediagnostic: CY4PR11MB1399: x-microsoft-antispam-prvs: x-forefront-prvs: 0911D5CE78 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(39860400002)(376002)(346002)(396003)(366004)(189003)(199004)(6512007)(72206003)(8936002)(2616005)(476003)(102836004)(478600001)(11346002)(97736004)(36756003)(256004)(575784001)(14444005)(86362001)(71190400001)(2906002)(71200400001)(66066001)(3846002)(6116002)(2201001)(316002)(54906003)(186003)(2501003)(110136005)(305945005)(7736002)(14454004)(446003)(6486002)(6436002)(8676002)(7416002)(6506007)(386003)(81156014)(81166006)(5660300001)(25786009)(99286004)(26005)(39060400002)(107886003)(15650500001)(106356001)(105586002)(76176011)(52116002)(68736007)(4326008)(486006)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR11MB1399;H:CY4PR11MB1909.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: pnRgqE5h8A70thdxtDiV16ezvMa7t69J+RivdNuWkshvY12G0XgiOHwq23ePXXk80ONkM8t/MA+HsC2qRRfj8YRhJSUZ8JMaM7Lc59nNQN1Zs9sCidQyiIJRhS+Hthxldg7sAqbPgzrfnUdhWLpcCrwmUNi3WvzwAgviu6YgOMRGdSCs24DS1ZcCiPP6Gs+9DYHMb+R3hj80YqsXLC6aacK26z9aa+832u4ogJHiW+UNqAwiVkFM9CkeQbWFsFMIQmm4/puRGT1/XtVrUhgKAulk9H7IZgfhae+r7so+u1iIdZ8hw6wzNmrquFTo4lW9 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 08bc4f42-f8ab-45c7-7ab0-08d67557f122 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2019 10:56:29.0176 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1399 X-OriginatorOrg: microchip.com Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Claudiu Beznea Add support to check if platform's power will be cut off in suspend. This will help drivers shared by multiple platforms to take only the necessary actions while suspending/resuming (some platform may not need to save/restore all the registers if platforms remains powered while suspended). In this way suspend/resume time could be improved. Signed-off-by: Claudiu Beznea --- include/linux/suspend.h | 6 ++++++ kernel/power/suspend.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 3f529ad9a9d2..21f19b167fe2 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -173,6 +173,9 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step) * Called by the PM core if the suspending of devices fails. * This callback is optional and should only be implemented by platforms * which require special recovery actions in that situation. + * + * @off_in_suspend: Returns wether the platform's power will be cut off at + * the end of suspend procedure or not. */ struct platform_suspend_ops { int (*valid)(suspend_state_t state); @@ -185,6 +188,7 @@ struct platform_suspend_ops { bool (*suspend_again)(void); void (*end)(void); void (*recover)(void); + bool (*off_in_suspend)(suspend_state_t state); }; struct platform_s2idle_ops { @@ -275,6 +279,7 @@ extern void arch_suspend_disable_irqs(void); extern void arch_suspend_enable_irqs(void); extern int pm_suspend(suspend_state_t state); +extern bool platform_off_in_suspend(suspend_state_t state); #else /* !CONFIG_SUSPEND */ #define suspend_valid_only_mem NULL @@ -287,6 +292,7 @@ static inline bool pm_suspend_via_s2idle(void) { return false; } static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {} static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; } +static inline bool platform_off_in_suspend(suspend_state_t state) { return false; } static inline bool idle_should_enter_s2idle(void) { return false; } static inline void __init pm_states_init(void) {} static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {} diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 0bd595a0b610..e1f60c8a17b9 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -319,6 +319,19 @@ static bool platform_suspend_again(suspend_state_t state) suspend_ops->suspend_again() : false; } +/** + * platform_off_in_suspend() - specifies if SoC's power will pe cut off at the + * end of suspend procedure. + */ +bool platform_off_in_suspend(suspend_state_t state) +{ + if (!suspend_ops || !suspend_ops->off_in_suspend) + return false; + + return suspend_ops->off_in_suspend(state); +} +EXPORT_SYMBOL_GPL(platform_off_in_suspend); + #ifdef CONFIG_PM_DEBUG static unsigned int pm_test_delay = 5; module_param(pm_test_delay, uint, 0644); From patchwork Tue Jan 8 10:56:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10751819 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 1C39191E for ; Tue, 8 Jan 2019 10:56:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0958C28BB5 for ; Tue, 8 Jan 2019 10:56:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0FBE28BEA; Tue, 8 Jan 2019 10:56:45 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 D1BE028BB5 for ; Tue, 8 Jan 2019 10:56:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728341AbfAHK4f (ORCPT ); Tue, 8 Jan 2019 05:56:35 -0500 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:59679 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbfAHK4e (ORCPT ); Tue, 8 Jan 2019 05:56:34 -0500 X-IronPort-AV: E=Sophos;i="5.56,453,1539673200"; d="scan'208";a="25051843" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Jan 2019 03:56:33 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.38) with Microsoft SMTP Server (TLS) id 14.3.352.0; Tue, 8 Jan 2019 03:56:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jfPvz3EWSyHiOROnv51qNGv0c8PxUBr56m9FxRmG9fA=; b=R9rdhltOP2j6OaQZCRkfXkO9uLTwD20QmWss52ZKu0T+Ac6a8L1bk3EGEQh8rMpaxD7j50O1jzQnlLo+qS+EcRnNFy1/hghMJxcWF0fQHfksOM8FiJJbdMRb3nrUPQhUCbTuJt9rHI2dk2qzs/EFCm4rHwedERSeeicI0PAjKbE= Received: from CY4PR11MB1909.namprd11.prod.outlook.com (10.175.61.147) by CY4PR11MB1399.namprd11.prod.outlook.com (10.173.17.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.9; Tue, 8 Jan 2019 10:56:32 +0000 Received: from CY4PR11MB1909.namprd11.prod.outlook.com ([fe80::5478:c9ff:e5b2:2b4e]) by CY4PR11MB1909.namprd11.prod.outlook.com ([fe80::5478:c9ff:e5b2:2b4e%9]) with mapi id 15.20.1495.011; Tue, 8 Jan 2019 10:56:32 +0000 From: To: , , , , , , , , CC: , , , Subject: [PATCH v2 2/3] regulator: core: add helper to check if regulator is disabled in suspend Thread-Topic: [PATCH v2 2/3] regulator: core: add helper to check if regulator is disabled in suspend Thread-Index: AQHUp0DQuBK0W+8S40WNFSmYgBfyCg== Date: Tue, 8 Jan 2019 10:56:32 +0000 Message-ID: <1546944944-13911-3-git-send-email-claudiu.beznea@microchip.com> References: <1546944944-13911-1-git-send-email-claudiu.beznea@microchip.com> In-Reply-To: <1546944944-13911-1-git-send-email-claudiu.beznea@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR04CA0113.eurprd04.prod.outlook.com (2603:10a6:803:64::48) To CY4PR11MB1909.namprd11.prod.outlook.com (2603:10b6:903:11f::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Claudiu.Beznea@microchip.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR11MB1399;6:vF6n5IdIE6ZLBYV5Ypa9W3jX+MTFS9CFVisic1T4JFjgyPQMnRpKS55Wkn3uB5oH4IZ8nc6CkySFn4q8SDXV1Hl9dAtOW94/0Ucr26OCCDfepq7jQgB+jFVIUfsNIgzoJmBswLtftnOTlX6Nl7oa6klnaTFpgeDxgtwAO77bydBQYaUCEAP+GJzChq1OgmDr9I547zuWvv9UJmozdFVL1FDUJd1Qn+1+6viACg0C7MOi7sI8F79YtwoAOc9X6psZdX0xTyRqaOwqThkHHsOQmCR+FNesXudOyOoBaP4Q+K2mNh7ZHJTfv7wI+ofnhVSeuVPVFruvFEkDyD/aPag2l5a1O0Gqj4zr9a5B15NOjxsULeB6bPiGM8/6FzUmACWpLgAMNF/G4k4GRpaMPWLfHG3uiXp5Ob0Y39lAFxuB30EToFmvcSqWC1KSR2+kG0J2XY01gjEXHxMxgTeOSHmV/w==;5:gGudJ/08/hjm7SMPekg3IFX+ghFLeD4k/CmD4e7EW+EmaOrIempw0TkJmfqNK1SabJpJvP7Rvuf2qsu5tSsbYpImXS76cIvTpbIjbOYozKtVR/+zn5H85S4ED8MxsV5A4V5LgL5seqz7wcK2YGXCKP0WuVZMRc7m6AkUBChRZX/HLrY3zoQFpPLPgFKSl5RUe/iZnpu1bJRhUzD+Mgdwaw==;7:YRBTUtspPj9i8KcpNjY2IFm4KBUIm+jTNNDeBbglS5ckLATApe8/ex2G9M7TVFwyLBDB/WpYA2UYdgAArNj9o7KOuYA42veJtG9fXfus3ID1BRFuEBYRDMUY2plIeesMmMQOndWfund5lUIuydRyGg== x-ms-office365-filtering-correlation-id: eaf88f77-5609-418d-aa2b-08d67557f301 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:CY4PR11MB1399; x-ms-traffictypediagnostic: CY4PR11MB1399: x-microsoft-antispam-prvs: x-forefront-prvs: 0911D5CE78 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(39860400002)(376002)(346002)(396003)(366004)(189003)(199004)(6512007)(72206003)(8936002)(2616005)(476003)(102836004)(478600001)(11346002)(97736004)(36756003)(256004)(14444005)(86362001)(71190400001)(2906002)(71200400001)(66066001)(3846002)(6116002)(2201001)(316002)(54906003)(186003)(2501003)(110136005)(305945005)(7736002)(14454004)(446003)(6486002)(6436002)(8676002)(7416002)(6506007)(386003)(81156014)(81166006)(5660300001)(25786009)(99286004)(26005)(39060400002)(107886003)(15650500001)(106356001)(105586002)(76176011)(52116002)(68736007)(4326008)(486006)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR11MB1399;H:CY4PR11MB1909.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ClAkgeg/6e9R6tGeKCPfI9UXQ4ZliithjGgdRFZzdF1Ee2tqGKFgWM+6jBeplapkmBv00RNankxUNdyAIrBAMyOmbnfgNyqx85M3EZrOYgVIz3Cw/cLDfHrsbkv8BaeovngGmcmfw81Y51kMvaVPDC+MYJOKyFk3hECCVxGDWJMmMDZmbrXsl8dGpKPX9XgPcusNJZjmmAcs6amV3zZtsdL7PB+cgrqks6n4tM3YXLB6Dm3JVIVz8H6EqLPyLrWqZFBhtF/7RQC03gcoVsXPHfuyXGP/T2KJWiIyKsV0sTi9V2mubdDhAx7UjmMdBS8G spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: eaf88f77-5609-418d-aa2b-08d67557f301 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2019 10:56:32.1580 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1399 X-OriginatorOrg: microchip.com Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Claudiu Beznea Add helper to check if regulator will be disabled in suspend. Signed-off-by: Claudiu Beznea --- drivers/regulator/core.c | 17 +++++++++++++++++ include/linux/regulator/consumer.h | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index b9d7b45c7295..3b761969732a 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3786,6 +3786,23 @@ int regulator_suspend_disable(struct regulator_dev *rdev, } EXPORT_SYMBOL_GPL(regulator_suspend_disable); +bool regulator_is_disabled_in_suspend(struct regulator *regulator, + suspend_state_t state) +{ + struct regulator_state *rstate; + + if (!regulator->rdev->constraints) + return false; + + rstate = regulator_get_suspend_state(regulator->rdev, state); + if (!rstate) + return false; + + return regulator->rdev->desc->ops->set_suspend_disable && + rstate->enabled == DISABLE_IN_SUSPEND; +} +EXPORT_SYMBOL_GPL(regulator_is_disabled_in_suspend); + static int _regulator_set_suspend_voltage(struct regulator *regulator, int min_uV, int max_uV, suspend_state_t state) diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index f3f76051e8b0..cf5e71dc63ce 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -36,6 +36,7 @@ #define __LINUX_REGULATOR_CONSUMER_H_ #include +#include struct device; struct notifier_block; @@ -285,6 +286,9 @@ void devm_regulator_unregister_notifier(struct regulator *regulator, void *regulator_get_drvdata(struct regulator *regulator); void regulator_set_drvdata(struct regulator *regulator, void *data); +/* regulator suspend/resume state */ +bool regulator_is_disabled_in_suspend(struct regulator *regulator, + suspend_state_t state); #else /* @@ -579,6 +583,9 @@ static inline int regulator_list_voltage(struct regulator *regulator, unsigned s return -EINVAL; } +bool regulator_is_disabled_in_suspend(struct regulator *regulator, + suspend_state_t state); + #endif static inline int regulator_set_voltage_triplet(struct regulator *regulator, From patchwork Tue Jan 8 10:56:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10751817 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 029A291E for ; Tue, 8 Jan 2019 10:56:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4CFD28BB5 for ; Tue, 8 Jan 2019 10:56:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6A9628BEA; Tue, 8 Jan 2019 10:56:43 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 6586728BB5 for ; Tue, 8 Jan 2019 10:56:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728435AbfAHK4i (ORCPT ); Tue, 8 Jan 2019 05:56:38 -0500 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:28505 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbfAHK4i (ORCPT ); Tue, 8 Jan 2019 05:56:38 -0500 X-IronPort-AV: E=Sophos;i="5.56,453,1539673200"; d="scan'208";a="23118877" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Jan 2019 03:56:38 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.106) with Microsoft SMTP Server (TLS) id 14.3.352.0; Tue, 8 Jan 2019 03:56:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0jjXhJLdT1geE9ulSsjd5ZzNAHclKGpmSIcGE+hVYCw=; b=W1KiKe8Es9h+lUdsZ3AO4XeIgsiM6jfHLG8bYPiKwoHdLRBMtTJvH274odCLxV6/YmoKC+wBYzAI7jHtGk3KiSai0JAkO/nqvrtSAv0k18zJ197tAZfJ/wy4QTzAlNPA9yLaX/tHrUHt2Bp5g0YBK4/REQwb/OhmKl5SQuXo/iY= Received: from CY4PR11MB1909.namprd11.prod.outlook.com (10.175.61.147) by CY4PR11MB1399.namprd11.prod.outlook.com (10.173.17.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.9; Tue, 8 Jan 2019 10:56:35 +0000 Received: from CY4PR11MB1909.namprd11.prod.outlook.com ([fe80::5478:c9ff:e5b2:2b4e]) by CY4PR11MB1909.namprd11.prod.outlook.com ([fe80::5478:c9ff:e5b2:2b4e%9]) with mapi id 15.20.1495.011; Tue, 8 Jan 2019 10:56:35 +0000 From: To: , , , , , , , , CC: , , , Subject: [PATCH v2 3/3] ARM: at91: pm: add support for .off_in_suspend Thread-Topic: [PATCH v2 3/3] ARM: at91: pm: add support for .off_in_suspend Thread-Index: AQHUp0DSqhp6gp2dHEi7kDW5NVtLFg== Date: Tue, 8 Jan 2019 10:56:35 +0000 Message-ID: <1546944944-13911-4-git-send-email-claudiu.beznea@microchip.com> References: <1546944944-13911-1-git-send-email-claudiu.beznea@microchip.com> In-Reply-To: <1546944944-13911-1-git-send-email-claudiu.beznea@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR04CA0113.eurprd04.prod.outlook.com (2603:10a6:803:64::48) To CY4PR11MB1909.namprd11.prod.outlook.com (2603:10b6:903:11f::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Claudiu.Beznea@microchip.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR11MB1399;6:CfO4UyLDMsICUQSx7Vytv4w6cSTqKrNFUZTHUn0jau9qjKgJzqTVqBKAkHtMqUSwfX5V/WzSMep37sITZiVmVw0lxnKmnFjMuXbQQZTVR+aSbar6GiQKPCd/B13jaCI//c3B66Hr/QVHELKKlX8M73muAtuCenNWclPVeryeTHkBBoSnL0MvochQJUHC8md+nf09q+PbF12cS8y9LrLigRgsUBRDr/Vv5oVSD4X0uCjHkfGCXXkb499g156AeonjBGLTrdX9YNdFi12nlhhwJnXfQv0Xcci/gLYJE+L4YLrIizRDmJr9UzOQXUYNCZzfEYgxHtgZhFnkpV4G6IdjL9KjNd5UQvRf2jpQHrZXr2ZSph8UksDBWQ0wB1SZo8pn78wmg2rAGTvIFBZD5poAmpsPmjOtl811tka0m/9II1I43vh9OQrg9SpYUyLuqHek9FSsP0EEOurl/BF/GOIPRQ==;5:2jFMTt5OtCb0pbsjo7ZcXWJDU2NsRbKutlH4c9+K42TO8vKXefF913BL2/4hc8zgFrDnmJuswAuJnT8Tk0nFq2K97x0kJMi9mGrPiisdMkEyqrZ9OXmB7C/Z2uk7yxuf8Uk+QOu/DGn0swpqmwWZ/NOR7s/uhyQ488VrcSacnGs7BtNuiEzBvfVEnVjO3XYlYxmbW/S6eSxG+KL8uC0Spg==;7:/xne6YrQbRV1JS1LSLxpwIB4obPNG/E27+DC7Kbjga4IggDNHF4YDp9UzPhuBbcrKbi+i+8sBHSPAeEv6cqkstN6Li4TAYo3JW4yr6JeHG2cHZCPd2BZ3Ly/7JmMYsN0AgQ4ZpoiB1eYoqNoEOKS2A== x-ms-office365-filtering-correlation-id: 550574c7-b04b-4ab8-0090-08d67557f4e8 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:CY4PR11MB1399; x-ms-traffictypediagnostic: CY4PR11MB1399: x-microsoft-antispam-prvs: x-forefront-prvs: 0911D5CE78 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(39860400002)(376002)(346002)(396003)(366004)(189003)(199004)(6512007)(72206003)(8936002)(2616005)(476003)(102836004)(478600001)(11346002)(97736004)(36756003)(256004)(14444005)(86362001)(71190400001)(2906002)(71200400001)(66066001)(3846002)(6116002)(2201001)(316002)(54906003)(186003)(2501003)(110136005)(305945005)(7736002)(14454004)(446003)(6486002)(6436002)(8676002)(7416002)(6506007)(386003)(81156014)(81166006)(5660300001)(25786009)(99286004)(26005)(39060400002)(107886003)(106356001)(105586002)(76176011)(52116002)(68736007)(4326008)(486006)(53936002)(142923001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR11MB1399;H:CY4PR11MB1909.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 4rvXcTFMV1t9ioX0fK9bLxaOH+pdyDCzqRpU3l0vuh8ZCNrM7Vo325Gfajk98eWZqn/E2F/4lUjFZ5LY0mBLEnb0GlqKVwAfPjxojAzEP+YkGsW0WO5e7ruVakl6GaR5tj/QFkAdcxMQuBxcoV+/h0ShvELIOgTHkfP1txej7/cctjaVVOZQoVmrFRXrq2MkzwpCOYYALJcpN8u4dq5i4wFQwi842itkR1D1VgTDRCKMhdbV+Nepll1aKVYQTkL+IVYXv+vdkhQCd7cSHqSOf6qTDlQWSge3AqpM4ggYc1KE8I6/rkEIdiUHERuQAaqD spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 550574c7-b04b-4ab8-0090-08d67557f4e8 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2019 10:56:35.3609 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1399 X-OriginatorOrg: microchip.com Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Claudiu Beznea Add support to check if platform is off in suspend. The check is based on pm_data.mode and CPU's regulator which will be turn off in suspend. Signed-off-by: Claudiu Beznea --- arch/arm/mach-at91/pm.c | 61 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 51e808adb00c..be9bd482772b 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -164,6 +165,47 @@ static int at91_pm_config_ws(unsigned int pm_mode, bool set) return mode ? 0 : -EPERM; } +static const struct of_device_id sama5d2_cpu_reg_ids[] = { + { .compatible = "active-semi,act8945a", .data = "VDD_1V2" }, + { /* sentinel */ } +}; + +static struct regulator *at91_pm_cpu_regulator_get(void) +{ + struct device *cpu_dev = get_cpu_device(0); + static struct regulator *cpu_reg; + const struct of_device_id *match; + struct platform_device *pdev; + struct device_node *np; + + if (!cpu_dev) + return cpu_reg; + + if (!cpu_reg) { + for_each_matching_node_and_match(np, sama5d2_cpu_reg_ids, + &match) { + pdev = of_find_device_by_node(np); + if (!pdev) + continue; + + cpu_reg = regulator_get(cpu_dev, match->data); + put_device(&pdev->dev); + break; + } + } + + return cpu_reg; +} + +static bool at91_pm_state_allowed(suspend_state_t state) +{ + struct regulator *reg; + + reg = at91_pm_cpu_regulator_get(); + + return reg && regulator_is_disabled_in_suspend(reg, state); +} + /* * Called after processes are frozen, but before we shutdown devices. */ @@ -182,6 +224,9 @@ static int at91_pm_begin(suspend_state_t state) pm_data.mode = -1; } + if (pm_data.mode == AT91_PM_BACKUP && !at91_pm_state_allowed(state)) + return -EPERM; + return at91_pm_config_ws(pm_data.mode, true); } @@ -321,12 +366,20 @@ static void at91_pm_end(void) at91_pm_config_ws(pm_data.mode, false); } +static bool at91_pm_off_in_suspend(suspend_state_t state) +{ + if (pm_data.mode != AT91_PM_BACKUP) + return false; + + return at91_pm_state_allowed(state); +} static const struct platform_suspend_ops at91_pm_ops = { - .valid = at91_pm_valid_state, - .begin = at91_pm_begin, - .enter = at91_pm_enter, - .end = at91_pm_end, + .valid = at91_pm_valid_state, + .begin = at91_pm_begin, + .enter = at91_pm_enter, + .end = at91_pm_end, + .off_in_suspend = at91_pm_off_in_suspend, }; static struct platform_device at91_cpuidle_device = {