From patchwork Wed Jul 1 15:47:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 6704521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2C402C05AC for ; Wed, 1 Jul 2015 15:49:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4247520741 for ; Wed, 1 Jul 2015 15:49:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45F4320458 for ; Wed, 1 Jul 2015 15:49:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZAKEY-0002sW-H9; Wed, 01 Jul 2015 15:47:34 +0000 Received: from down.free-electrons.com ([37.187.137.238] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZAKEV-0002iQ-Pe for linux-arm-kernel@lists.infradead.org; Wed, 01 Jul 2015 15:47:32 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 7CDFB1F4D; Wed, 1 Jul 2015 17:47:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (AToulouse-657-1-1071-25.w92-134.abo.wanadoo.fr [92.134.77.25]) by mail.free-electrons.com (Postfix) with ESMTPSA id F18C738A; Wed, 1 Jul 2015 17:47:13 +0200 (CEST) Date: Wed, 1 Jul 2015 17:47:09 +0200 From: Thomas Petazzoni To: Gregory CLEMENT Subject: Re: [PATCH v2 2/4] ARM: mvebu: Add standby support Message-ID: <20150701174709.2d55007d@free-electrons.com> In-Reply-To: <1435684740-24912-3-git-send-email-gregory.clement@free-electrons.com> References: <1435684740-24912-1-git-send-email-gregory.clement@free-electrons.com> <1435684740-24912-3-git-send-email-gregory.clement@free-electrons.com> Organization: Free Electrons X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.27; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150701_084732_135157_00EF7042 X-CRM114-Status: GOOD ( 21.85 ) X-Spam-Score: -2.5 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lior Amsalem , Andrew Lunn , Jason Cooper , Tawfik Bayouk , Boris BREZILLON , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Nadav Haklai , Ezequiel Garcia , Maxime Ripard , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Dear Gregory CLEMENT, On Tue, 30 Jun 2015 19:18:58 +0200, Gregory CLEMENT wrote: > Until now only one Armada XP and one Armada 388 based board supported > suspend to ram. However, most of the recent mvebu SoCs can support the > standby mode. Unlike for the suspend to ram, nothing special have to have -> has > be done for these SoCs. This patch allows the system to use the > standby mode on Armada 370, 38x, 39x and XP SoCs. There are issues > with the Armada 375, and the support would be added (if possible) in a would -> might > future patch. > > Signed-off-by: Gregory CLEMENT > --- > arch/arm/mach-mvebu/common.h | 5 ++-- > arch/arm/mach-mvebu/pm-board.c | 17 ++++++++----- > arch/arm/mach-mvebu/pm.c | 57 ++++++++++++++++++++++++++++++++++++------ > 3 files changed, 64 insertions(+), 15 deletions(-) On the implementation side, this is much more complicated that it needs to be I believe. You don't need this mechanism to register the board-specific hook. Just make pm.c register the suspend_ops in a late_initcall(), and the pm-board.c register the board specific hook in a late_initcall(), and have pm.c say that it supports suspend to RAM only if the board-specific hook has been registered. Something like the below (only compile tested, not runtime tested) : commit 0b74c5b2916cb4be216bd2c607faf5c10a482284 Author: Gregory CLEMENT Date: Tue Jun 30 19:18:58 2015 +0200 ARM: mvebu: Add standby support Until now only one Armada XP and one Armada 388 based board supported suspend to ram. However, most of the recent mvebu SoCs can support the standby mode. Unlike for the suspend to ram, nothing special have to be done for these SoCs. This patch allows the system to use the standby mode on Armada 370, 38x, 39x and XP SoCs. There are issues with the Armada 375, and the support would be added (if possible) in a future patch. Signed-off-by: Gregory CLEMENT diff --git a/arch/arm/mach-mvebu/common.h b/arch/arm/mach-mvebu/common.h index 3e0aca1..6b77549 100644 --- a/arch/arm/mach-mvebu/common.h +++ b/arch/arm/mach-mvebu/common.h @@ -25,6 +25,6 @@ int mvebu_system_controller_get_soc_id(u32 *dev, u32 *rev); void __iomem *mvebu_get_scu_base(void); -int mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 srcmd)); - +int mvebu_pm_suspend_init(void (*board_pm_enter)(void __iomem *sdram_reg, + u32 srcmd)); #endif diff --git a/arch/arm/mach-mvebu/pm-board.c b/arch/arm/mach-mvebu/pm-board.c index acc69e3..4dccc64 100644 --- a/arch/arm/mach-mvebu/pm-board.c +++ b/arch/arm/mach-mvebu/pm-board.c @@ -135,7 +135,7 @@ static int __init mvebu_armada_pm_init(void) if (!gpio_ctrl) return -ENOMEM; - mvebu_pm_init(mvebu_armada_pm_enter); + mvebu_pm_suspend_init(mvebu_armada_pm_enter); out: of_node_put(np); diff --git a/arch/arm/mach-mvebu/pm.c b/arch/arm/mach-mvebu/pm.c index f249c8e..db31cbb 100644 --- a/arch/arm/mach-mvebu/pm.c +++ b/arch/arm/mach-mvebu/pm.c @@ -204,13 +204,10 @@ static int mvebu_pm_store_bootinfo(void) return 0; } -static int mvebu_pm_enter(suspend_state_t state) +static int mvebu_enter_suspend(void) { int ret; - if (state != PM_SUSPEND_MEM) - return -EINVAL; - ret = mvebu_pm_store_bootinfo(); if (ret) return ret; @@ -226,16 +223,57 @@ static int mvebu_pm_enter(suspend_state_t state) set_cpu_coherent(); cpu_pm_exit(); + return 0; +} + +static int mvebu_pm_enter(suspend_state_t state) +{ + switch (state) { + case PM_SUSPEND_STANDBY: + cpu_do_idle(); + break; + case PM_SUSPEND_MEM: + return mvebu_enter_suspend(); + default: + return -EINVAL; + } + return 0; +} + +static int mvebu_pm_valid(suspend_state_t state) +{ + if (state == PM_SUSPEND_STANDBY) + return 1; + + if (state == PM_SUSPEND_MEM && mvebu_board_pm_enter != NULL) + return 1; return 0; } static const struct platform_suspend_ops mvebu_pm_ops = { .enter = mvebu_pm_enter, - .valid = suspend_valid_only_mem, + .valid = mvebu_pm_valid, }; -int __init mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 srcmd)) +static int __init mvebu_pm_init(void) +{ + if (!of_machine_is_compatible("marvell,armadaxp") && + !of_machine_is_compatible("marvell,armada370") && + !of_machine_is_compatible("marvell,armada380") && + !of_machine_is_compatible("marvell,armada390")) + return -ENODEV; + + suspend_set_ops(&mvebu_pm_ops); + + return 0; +} + + +late_initcall(mvebu_pm_init); + +int __init mvebu_pm_suspend_init(void (*board_pm_enter)(void __iomem *sdram_reg, + u32 srcmd)) { struct device_node *np; struct resource res; @@ -267,7 +305,5 @@ int __init mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 src mvebu_board_pm_enter = board_pm_enter; - suspend_set_ops(&mvebu_pm_ops); - return 0; }