From patchwork Tue Jan 8 09:52:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10751741 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 38F0E14E5 for ; Tue, 8 Jan 2019 09:53:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26DA328B97 for ; Tue, 8 Jan 2019 09:53:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AFFC28BC3; Tue, 8 Jan 2019 09:53:15 +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 F210828BC5 for ; Tue, 8 Jan 2019 09:53:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728463AbfAHJw5 (ORCPT ); Tue, 8 Jan 2019 04:52:57 -0500 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:24195 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727236AbfAHJw4 (ORCPT ); Tue, 8 Jan 2019 04:52:56 -0500 X-IronPort-AV: E=Sophos;i="5.56,453,1539673200"; d="scan'208";a="25050721" 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 02:52:55 -0700 Received: from NAM04-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 02:52:55 -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=7ypxnDuNXUxh1tSqLT/QnuKbcBjBZLpen7PC47MjcKo=; b=Y/OcdfeRp/VRonsmaG2jwCsT4saizdzuqGE/C9geqBLs5D4XOUx21drHPlMl7LWQWzzP6W23y3GFtIX6ylkdQAuJ3WJYeJAWwRjmpj2qsOtsbVKTi3IJq52SGo0J2Kr1zV2L89wu4HcW08kmj7aykwfpRuH/OyIdrMNodRkhiSQ= Received: from MWHPR11MB1920.namprd11.prod.outlook.com (10.175.54.19) by MWHPR11MB1838.namprd11.prod.outlook.com (10.175.53.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.13; Tue, 8 Jan 2019 09:52:53 +0000 Received: from MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::e553:ff9d:8c0b:9627]) by MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::e553:ff9d:8c0b:9627%6]) with mapi id 15.20.1516.010; Tue, 8 Jan 2019 09:52:53 +0000 From: To: , , , , , , , , CC: , , , Subject: [PATCH 1/3] PM / Suspend: Add support to check if platform's power is off in suspend Thread-Topic: [PATCH 1/3] PM / Suspend: Add support to check if platform's power is off in suspend Thread-Index: AQHUpzfs93rBcN8fLkunLXYHWnxjXQ== Date: Tue, 8 Jan 2019 09:52:53 +0000 Message-ID: <1546941147-18410-2-git-send-email-claudiu.beznea@microchip.com> References: <1546941147-18410-1-git-send-email-claudiu.beznea@microchip.com> In-Reply-To: <1546941147-18410-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: VI1P195CA0081.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:59::34) To MWHPR11MB1920.namprd11.prod.outlook.com (2603:10b6:300:110::19) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR11MB1838;6:kQRGG7fok3dmfdZq1INsIm/iJDAkIILN6nK8LAnM/oJ1R5Mdy25D+h8JcFmoLSLxEHuElpTEWZZetJJMHtkjY3P509XtNp99cQxxlNB77LkqiJDr/9hIRbKFI49WtY3gStoVYoVQST6z7Nl+41dIzmQgXgVdoYOB0stKlL175ovbfnennkw00cXPFJ5Jbn4KwuNJuPIeUqmPeTUNCgPfLX5O+I+WDjAOoDUIJRimGBI9JVDJ1m9kZsA4SbT6GlHf5oO3mt50Qkz9Qq8hzD5HPCZa15wwbL5faTIBSVyQ6sxds4YaoPSylm4VWU7EKbWfGVJuAKeCN2Wzf2avW2fFHP1hFsctf3OgWgv+pnd6T3O+iwGcVI91/nsj0GieY2A9BcEJKmk585GVsZcURZ701OCCtEy5LM2Fh5AA5HRwW/2GYFiHc/andXgspud04NQ/G23nj/FUvU2D83m65HrNug==;5:cKwpVYFRK4BSQXTfFe15GCiko7SZRKeuUIqaIKD+Irtd3k7q7kak+6LjSzMwBrVbeadalbA9LYDsJonlO96uyPiXIKyOcmLduhf0SuRWW64pahzn9IsDCjpfZeih1kzF766Kq3G84mcO+ID6tS5vsR6MQgia1wBViiwZBQqLfl9mGMQcekXpshBf63MDpcetq0OfK6rl6bgPRP/vSiM2Fw==;7:KRS8vAeISmuQWJG25cwFuhn4pA/JU8VRJftSIKg/jkDLCXs0g+703cZQnVrSNRuHXuYMHg0WaB2uG/7UJmgD5qOuFqpkVrHALiw3KgHBJb/jMqW4TKq6vIoKLmBXjQUDnBOuZnaqe27LaOARQUiNKw== x-ms-office365-filtering-correlation-id: 81145ac0-d99f-4532-3e92-08d6754f0ea3 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:MWHPR11MB1838; x-ms-traffictypediagnostic: MWHPR11MB1838: x-microsoft-antispam-prvs: x-forefront-prvs: 0911D5CE78 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(346002)(376002)(136003)(39860400002)(189003)(199004)(6436002)(110136005)(305945005)(107886003)(54906003)(6512007)(76176011)(52116002)(99286004)(8936002)(105586002)(53936002)(5660300001)(81166006)(7416002)(81156014)(8676002)(4326008)(39060400002)(7736002)(316002)(106356001)(25786009)(97736004)(36756003)(14454004)(72206003)(478600001)(6486002)(66066001)(68736007)(2501003)(15650500001)(486006)(386003)(6506007)(575784001)(86362001)(476003)(2616005)(2906002)(71190400001)(71200400001)(186003)(14444005)(6116002)(3846002)(2201001)(102836004)(6346003)(11346002)(446003)(256004)(26005);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR11MB1838;H:MWHPR11MB1920.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) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Claudiu.Beznea@microchip.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: KrudZr9xiBu89BgVPS3QMYOrtwg3ikhla3SW+HYSwJYhgTHftJp5ZXFwfuFb0qzomAePg0rLF5CGYNmL7e6I/wnBA1dtc9yJLbb0aaUl9BAg97HJGV3+aUVDnmZV/o5zK+O46zJuFoLZYWNFGkmqDwzbWKiBqmOUqs/86czMZYjt9YKVNsex0CsHGTd1gueZQGgOcpBMi6j4FcLEpgQCGFpdBxBExo57qhhtYerdPYykROBmhOdchxv96KGLxrZ28e9ytEQUa5qAwH6WmHYmR53JM2TwK6SFAMwYXQZR++YYQj4MVwhyYrD5bXAWEOeW spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 81145ac0-d99f-4532-3e92-08d6754f0ea3 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2019 09:52:53.1302 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1838 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 wheather 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 09:52:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10751739 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 75C4C13B5 for ; Tue, 8 Jan 2019 09:53:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63CBE28B97 for ; Tue, 8 Jan 2019 09:53:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5832528BC6; Tue, 8 Jan 2019 09:53:14 +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 3EB1328B97 for ; Tue, 8 Jan 2019 09:53:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728508AbfAHJxB (ORCPT ); Tue, 8 Jan 2019 04:53:01 -0500 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:1503 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727236AbfAHJxA (ORCPT ); Tue, 8 Jan 2019 04:53:00 -0500 X-IronPort-AV: E=Sophos;i="5.56,453,1539673200"; d="scan'208";a="25223860" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Jan 2019 02:52:59 -0700 Received: from NAM04-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 02:52:59 -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=XjbrXEvd0zPH7JipVlT1O9m5uxmU2/hsg98FIsTY8p0=; b=zTzH9c4eTDmAfhc5e1HZ5bZjDZNmw63WkzC6LTl4pxUSMzFE4V/oi5cdmIz9IaEJEtUXvDCu08YjVu9RGihVg6mVyqtLt0jS+nDitYoH8DUprxNh+azWW5CEKIDr2ju3E/3hCBSAAx3PVGaxAN62vW6XOKT0tTZlVz/tYcvAsdM= Received: from MWHPR11MB1920.namprd11.prod.outlook.com (10.175.54.19) by MWHPR11MB1838.namprd11.prod.outlook.com (10.175.53.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.13; Tue, 8 Jan 2019 09:52:57 +0000 Received: from MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::e553:ff9d:8c0b:9627]) by MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::e553:ff9d:8c0b:9627%6]) with mapi id 15.20.1516.010; Tue, 8 Jan 2019 09:52:57 +0000 From: To: , , , , , , , , CC: , , , Subject: [PATCH 2/3] regulator: core: add helper to check if regulator is disabled in suspend Thread-Topic: [PATCH 2/3] regulator: core: add helper to check if regulator is disabled in suspend Thread-Index: AQHUpzfuSbgXOYh/ZUy6GuHn+HLJVg== Date: Tue, 8 Jan 2019 09:52:57 +0000 Message-ID: <1546941147-18410-3-git-send-email-claudiu.beznea@microchip.com> References: <1546941147-18410-1-git-send-email-claudiu.beznea@microchip.com> In-Reply-To: <1546941147-18410-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: VI1P195CA0081.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:59::34) To MWHPR11MB1920.namprd11.prod.outlook.com (2603:10b6:300:110::19) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR11MB1838;6:602outgIX2dsnktWSAyHb9hNItLEDmWWwWcFLsYrVorAdSAL0R2mnoFec3Zake0vD/hYycDzzeBJI7N5n+j4VNlBXmz2SdeRWP2MVTQXYWrDjr9LlUTqvgiPvh1v3S+QqV8x1eo7RzNIx99S3FgeKx9KpmqLipcvQ0mtBfFE52WyNfuk2pdso2uPOkNw7AYZvsmE8qrAYNr6PfxlDe0zR2am0fG9pnb8kZGjd0CsU73s7hEjp1ZfO3fjuDHMT0pM2g9kzwG8WcCCzGPnbUvzy2Kx/PxADO9EdJnWHJC7Fg3Ee1NyIvdibld0tdmQLuGCL9Mn0sfdij9D79hbBqPLkWN9jRKrCoTb3Xe+JNkdUUKKRI9qfKUI0Svdsn0dNj9Vo3gVvzH5XxvhU6cughgWgo60fFbRClrq1fdvTVyf1jb229oNJbiFlhi61ft5lUlfdocCONWWqXZv5cqOzAg7MA==;5:oyYk+cZsM+o4/mnCLpE4ovd319EU280s+Xgm0zMbSM/rm/5NDT1hfSO9qaBcdT/KsrMrsqmaq35tYVxI5+XsoyPaTZ3VQq5vfd4RiKDWzD0OR2TvYFXvD41v2D72WRd91u8SXofudb7lEKqAI3W2yF81jh4g1056w73FD3293OG0n3Yew/D0ypJxp5RDoyysolj04434llts6xco/5ScWQ==;7:EQzfr9LW7uOrBsanl7DRWltyXS+IAW9bAwXNysYsRlhKNlhDzmdwQq/NmrCFO/++gdLydIkEl8FXUizM+rArDqb58tMLRS2PuDfgtU1oQnPGhuh2BzCmjMo1O42hSyfCq9SkowIfBmU00lIt/eUUeA== x-ms-office365-filtering-correlation-id: 55135e29-257b-4285-c84e-08d6754f1105 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:MWHPR11MB1838; x-ms-traffictypediagnostic: MWHPR11MB1838: x-microsoft-antispam-prvs: x-forefront-prvs: 0911D5CE78 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(346002)(376002)(136003)(39860400002)(189003)(199004)(6436002)(110136005)(305945005)(107886003)(54906003)(6512007)(76176011)(52116002)(99286004)(8936002)(105586002)(53936002)(5660300001)(81166006)(7416002)(81156014)(8676002)(4326008)(39060400002)(7736002)(316002)(106356001)(25786009)(97736004)(36756003)(14454004)(72206003)(478600001)(6486002)(66066001)(68736007)(2501003)(15650500001)(486006)(386003)(6506007)(86362001)(476003)(2616005)(2906002)(71190400001)(71200400001)(186003)(14444005)(6116002)(3846002)(2201001)(102836004)(6346003)(11346002)(446003)(256004)(26005);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR11MB1838;H:MWHPR11MB1920.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) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Claudiu.Beznea@microchip.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: AqFDRG/eXvW6pL3P7KorPGW6hSvfWC9jyz1c8Jee0HCjqz77kX4WKCFUBQChw/VhsOZYIrPu56I/O/kcMs3Ym04rZVcP6LTprZv4nikQ7vr/rW00Ll2SRbEsfaPO3Dkb/a6CiSxDeEkiC53T6WZK0hJAk0N5n1Ztv65HuY/3ErJ1TsPo1h9QNPX9EvuZ/GruJv3/nYzFEBeRwvd3lmvLmR4I2SWBt8ieQt4LhTPdW6zbFuFFOITJkOVT2RIxXhh73Mp8iXEtJBPke+8fb9PF9J1sw8D6qlA6llYLdXmI15mpEFzCj9ZmsFxZSi98UBKD spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 55135e29-257b-4285-c84e-08d6754f1105 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2019 09:52:57.1674 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1838 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..a876ec369450 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 09:53:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10751735 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 730B614E5 for ; Tue, 8 Jan 2019 09:53:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60F0128BC3 for ; Tue, 8 Jan 2019 09:53:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5495328BC6; Tue, 8 Jan 2019 09:53:12 +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 D60C228BC3 for ; Tue, 8 Jan 2019 09:53:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728538AbfAHJxF (ORCPT ); Tue, 8 Jan 2019 04:53:05 -0500 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:64538 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727236AbfAHJxF (ORCPT ); Tue, 8 Jan 2019 04:53:05 -0500 X-IronPort-AV: E=Sophos;i="5.56,453,1539673200"; d="scan'208";a="22333610" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES128-SHA; 08 Jan 2019 02:53:04 -0700 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.37) with Microsoft SMTP Server (TLS) id 14.3.352.0; Tue, 8 Jan 2019 02:53:03 -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=uau7BdXq5QSOlLW/aKr0JEZHPv8bSClmeerllYQSBZY=; b=JWbdhNHWAx/v+fCQ3ZkkC9aODwiI7xggfvjEVtSaQ9YNhpMqwlH691YvzemieW6w3woHUhkNQsAM+OvFCoM9T4g0vSKGckyZ/j/0hxSTfmAtabX0ZBREb+WBsLc9e2O7d6/2nR3QPwMDZdtfYrgy0ZrNRLkg5haO/Swjts35iw0= Received: from MWHPR11MB1920.namprd11.prod.outlook.com (10.175.54.19) by MWHPR11MB1838.namprd11.prod.outlook.com (10.175.53.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.13; Tue, 8 Jan 2019 09:53:01 +0000 Received: from MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::e553:ff9d:8c0b:9627]) by MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::e553:ff9d:8c0b:9627%6]) with mapi id 15.20.1516.010; Tue, 8 Jan 2019 09:53:01 +0000 From: To: , , , , , , , , CC: , , , Subject: [PATCH 3/3] ARM: at91: pm: add support for .off_in_suspend Thread-Topic: [PATCH 3/3] ARM: at91: pm: add support for .off_in_suspend Thread-Index: AQHUpzfx8DbDgJIZCk69o3YuClfTkQ== Date: Tue, 8 Jan 2019 09:53:01 +0000 Message-ID: <1546941147-18410-4-git-send-email-claudiu.beznea@microchip.com> References: <1546941147-18410-1-git-send-email-claudiu.beznea@microchip.com> In-Reply-To: <1546941147-18410-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: VI1P195CA0081.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:59::34) To MWHPR11MB1920.namprd11.prod.outlook.com (2603:10b6:300:110::19) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR11MB1838;6:1Vq78gbFZTs0egHpUw2jz5XH0nckaT9KBJIrgjRPolSjd0WQhXG1++bVL+4c+bApTbN5YQQletz/HlSvWSDrCXOVM9weTgdHCd7UejorTWdYX9SYj3SE3UIMLXXiLHibmm75xhw4ho1egPOoPmIflPsWUSwfPGuDkyn+1Thpkqbzo04b2zCsQnXnj+dLSvaf1RHiKPDJ5DO6XccZLVtsjTIKBfm2UafWSjQj5QHmAxu6A/t/d9zYaFnusfi/CjLNGTji6sekuyNeeYpnLju02Wmakyce+9skL6WQpSIEzb1uqoNUOwu79ougu5ptgS5Qlnu26D8X2oFqmYhX9Zuxfjm4lgbR1g2UtMm81B6Ofq1mvCC2gVQsP3ULtW7s8vWANuwvgQQegAxEELAVYMynW40j03SQNSffdpT8lyrOqaUEzV+hd3ktWiOLYnUGX1SnSlqXpg8UQ7ZxizFQI/LZFw==;5:6EWx5AakByioqhI2RrmW+ZZkga1w68w97GXVPjHWeR0vKWteWFq8a8/8BMhqeBynNkpIBvZ+Ke/PyaqKbbR/7qwBGfCuphXFIqyPMl641nNs9gTRemxXrn4h6+WiEur0iCL35DXKQnNwKkbjArf/svzE2UR5TwFYb6vnbUTeJRcfPsWie+YoAfHVlQ6BK/ZlmcyFsugIntOFQ3qLlBd2bg==;7:Y9wYHRinGAy+4TpjSQ3EIz9nJqT6WlP2esirzRE7KfuK75ds/ZGi8/+hbzKpkuKOqkKjtneC4XcD89x/l5pYvc70ciWihZQziyinW5Vw6UMvrbyrDQIbPK/yS/FJgo7hVT88g+D5puq9LkyaTtBLtg== x-ms-office365-filtering-correlation-id: 5f760287-8539-46ac-7d20-08d6754f13a4 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:MWHPR11MB1838; x-ms-traffictypediagnostic: MWHPR11MB1838: x-microsoft-antispam-prvs: x-forefront-prvs: 0911D5CE78 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(396003)(366004)(346002)(376002)(136003)(39860400002)(189003)(199004)(6436002)(110136005)(305945005)(107886003)(54906003)(6512007)(76176011)(52116002)(99286004)(8936002)(105586002)(53936002)(5660300001)(81166006)(7416002)(81156014)(8676002)(4326008)(39060400002)(7736002)(316002)(106356001)(25786009)(97736004)(36756003)(14454004)(72206003)(478600001)(6486002)(66066001)(68736007)(2501003)(486006)(386003)(6506007)(86362001)(476003)(2616005)(2906002)(71190400001)(71200400001)(186003)(14444005)(6116002)(3846002)(2201001)(102836004)(6346003)(11346002)(446003)(256004)(26005)(142923001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR11MB1838;H:MWHPR11MB1920.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) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Claudiu.Beznea@microchip.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TgSauvBeWI+ueMtKJ0o9dcUL97nCBbSkq/CvL2qJUatiiOUGFvdRTSF07maDjPdv71AfOI4lFyrqMwOhTFAHTKM0U5/dYxcmSSCh+RbxJCRYsOtKMYrKgRa7R95P1kv1M0rwL8vONzRSH69ImCgeFD2czZZwsjB1U2RVxbquJ9RuaKYXlkC5EpKOQgTSU0aiwFG22WvWHRnA5Ioo34c75ZcUrGotHjlEiBqm2fAi1iEEVtYVXi16SJQgc6Ixiu0/c3aiaN0t+//rZ5COuJctHo7Uja5Yf22fAiz3pdFbmFSnM3taqTEIK7knso9wvdYL spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 5f760287-8539-46ac-7d20-08d6754f13a4 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2019 09:53:01.5209 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1838 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..c404d92aa297 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 = {