From patchwork Wed Jun 29 13:58:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 9205297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 61032607D8 for ; Wed, 29 Jun 2016 13:59:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51F17284B7 for ; Wed, 29 Jun 2016 13:59:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 468B32865B; Wed, 29 Jun 2016 13:59:56 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D284284B7 for ; Wed, 29 Jun 2016 13:59:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bIG0q-0002yy-Ku; Wed, 29 Jun 2016 13:58:44 +0000 Received: from a.mx.sdesigns.eu ([78.31.43.6]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bIG0n-0002hI-Oc for linux-arm-kernel@lists.infradead.org; Wed, 29 Jun 2016 13:58:42 +0000 Received: from [172.27.0.114] (summerrain.france.sdesigns.com [172.27.0.114]) by hibou.france.sdesigns.com (Postfix) with ESMTP id 5B4391C028E; Wed, 29 Jun 2016 15:58:19 +0200 (CEST) To: linux-pm , Linux ARM From: Marc Gonzalez Subject: [RFC PATCH v1] ARM: tango: add Suspend-to-RAM support Message-ID: <5773D3FB.4030101@sigmadesigns.com> Date: Wed, 29 Jun 2016 15:58:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160629_065841_980772_0D829F74 X-CRM114-Status: GOOD ( 13.80 ) 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: Mark Rutland , Thomas Petazzoni , Kevin Hilman , Thibaud Cornic , Mason , Sebastian Frias , Robin Murphy 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 Ask firmware to put RAM in self-refresh mode and power system down. echo mem > /sys/power/state See Documentation/power/states.txt Signed-off-by: Marc Gonzalez --- This is a RFC because I have a few doubts: 1) return value when tango_suspend() fails and unexpectedly returns (I used -EIO) 2) conditionally building pm.c (using CONFIG_SUSPEND? CONFIG_PM_SLEEP? other?) 3) .valid is required, right? --- arch/arm/mach-tango/Makefile | 1 + arch/arm/mach-tango/pm.c | 37 +++++++++++++++++++++++++++++++++++++ arch/arm/mach-tango/smc.h | 1 + 3 files changed, 39 insertions(+) create mode 100644 arch/arm/mach-tango/pm.c diff --git a/arch/arm/mach-tango/Makefile b/arch/arm/mach-tango/Makefile index 7ca753aa9fb6..822b7ca803c6 100644 --- a/arch/arm/mach-tango/Makefile +++ b/arch/arm/mach-tango/Makefile @@ -3,3 +3,4 @@ AFLAGS_smc.o := -Wa,-march=armv7-a$(plus_sec) obj-y += setup.o smc.o xenv.o obj-$(CONFIG_SMP) += platsmp.o +obj-$(CONFIG_SUSPEND) += pm.o diff --git a/arch/arm/mach-tango/pm.c b/arch/arm/mach-tango/pm.c new file mode 100644 index 000000000000..08a39beaea09 --- /dev/null +++ b/arch/arm/mach-tango/pm.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include "smc.h" + +static int tango_pm_powerdown(unsigned long arg) +{ + tango_suspend(virt_to_phys(cpu_resume)); + + return -EIO; /* tango_suspend has failed */ +} + +static int tango_pm_enter(suspend_state_t state) +{ + if (state == PM_SUSPEND_MEM) + return cpu_suspend(0, tango_pm_powerdown); + + return -EINVAL; +} + +static int tango_pm_valid(suspend_state_t state) +{ + return state == PM_SUSPEND_MEM; +} + +static const struct platform_suspend_ops tango_pm_ops = { + .enter = tango_pm_enter, + .valid = tango_pm_valid, +}; + +static int __init tango_pm_init(void) +{ + suspend_set_ops(&tango_pm_ops); + return 0; +} + +late_initcall(tango_pm_init); diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h index 3d31f984f44c..57919539da1b 100644 --- a/arch/arm/mach-tango/smc.h +++ b/arch/arm/mach-tango/smc.h @@ -3,5 +3,6 @@ extern int tango_smc(unsigned int val, unsigned int service); #define tango_set_l2_control(val) tango_smc(val, 0x102) #define tango_start_aux_core(val) tango_smc(val, 0x104) #define tango_set_aux_boot_addr(val) tango_smc(val, 0x105) +#define tango_suspend(val) tango_smc(val, 0x120) #define tango_aux_core_die(val) tango_smc(val, 0x121) #define tango_aux_core_kill(val) tango_smc(val, 0x122)