From patchwork Thu Jun 23 12:14:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sajjan, Vikas C" X-Patchwork-Id: 9194991 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 1524C6075C for ; Thu, 23 Jun 2016 12:19:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFEA0283EE for ; Thu, 23 Jun 2016 12:19:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E36E328451; Thu, 23 Jun 2016 12:19:34 +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=-6.9 required=2.0 tests=BAYES_00,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 523A9283EE for ; Thu, 23 Jun 2016 12:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751040AbcFWMTd (ORCPT ); Thu, 23 Jun 2016 08:19:33 -0400 Received: from g2t1383g.austin.hpe.com ([15.233.16.89]:26372 "EHLO g2t1383g.austin.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751010AbcFWMTd (ORCPT ); Thu, 23 Jun 2016 08:19:33 -0400 Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by g2t1383g.austin.hpe.com (Postfix) with ESMTPS id 2BE64BB0 for ; Thu, 23 Jun 2016 12:19:32 +0000 (UTC) Received: from dctxvm241.in.rdlabs.hpecorp.net (dctxvm241.in.rdlabs.hpecorp.net [15.146.152.172]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id 964FB42; Thu, 23 Jun 2016 12:19:28 +0000 (UTC) From: Vikas C Sajjan To: mark.rutland@arm.com Cc: lorenzo.pieralisi@arm.com, rafael.j.wysocki@intel.com, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, sudeep.holla@arm.com, Vikas C Sajjan Subject: [PATCH] drivers: firmware: psci: Add support for cpu suspend mode as per psci v1.0 spec Date: Thu, 23 Jun 2016 17:44:13 +0530 Message-Id: <1466684053-26966-1-git-send-email-vikas.cha.sajjan@hpe.com> X-Mailer: git-send-email 1.9.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to section 5.1.16 of PSCI spec, an optional feature called PSCI_SET_SUSPEND_MODE was added in v1.0. This patch adds the support for the same. Signed-off-by: Vikas C Sajjan --- drivers/firmware/psci.c | 20 +++++++++++++++++++- include/linux/psci.h | 1 + include/uapi/linux/psci.h | 6 +++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 03e0458..c318972 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -91,6 +91,12 @@ static inline bool psci_has_ext_power_state(void) PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; } +static inline bool psci_has_OS_initiated_mode_support(void) +{ + return psci_cpu_suspend_feature & + PSCI_1_0_FEATURES_CPU_SUSPEND_OS_INITIATED_MODE_MASK; +} + static inline bool psci_power_state_loses_context(u32 state) { const u32 mask = psci_has_ext_power_state() ? @@ -145,6 +151,14 @@ static int psci_to_linux_errno(int errno) return -EINVAL; } +static int psci_set_cpu_suspend_mode(bool suspend_mode) +{ + int err; + + err = invoke_psci_fn(PSCI_FN_NATIVE(1_0, SUSPEND_MODE), + suspend_mode, 0, 0); + return psci_to_linux_errno(err); +} static u32 psci_get_version(void) { @@ -397,8 +411,12 @@ static void __init psci_init_cpu_suspend(void) { int feature = psci_features(psci_function_id[PSCI_FN_CPU_SUSPEND]); - if (feature != PSCI_RET_NOT_SUPPORTED) + if (feature != PSCI_RET_NOT_SUPPORTED) { psci_cpu_suspend_feature = feature; + if (psci_has_OS_initiated_mode_support()) + psci_ops.set_cpu_suspend_mode = + psci_set_cpu_suspend_mode; + } } /* diff --git a/include/linux/psci.h b/include/linux/psci.h index bdea1cb..c040502 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -33,6 +33,7 @@ struct psci_operations { int (*affinity_info)(unsigned long target_affinity, unsigned long lowest_affinity_level); int (*migrate_info_type)(void); + int (*set_cpu_suspend_mode)(bool); }; extern struct psci_operations psci_ops; diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h index 3d7a0fc..097c95e 100644 --- a/include/uapi/linux/psci.h +++ b/include/uapi/linux/psci.h @@ -50,6 +50,8 @@ #define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14) #define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) +#define PSCI_1_0_FN_SUSPEND_MODE PSCI_0_2_FN(0xF) +#define PSCI_1_0_FN64_SUSPEND_MODE PSCI_0_2_FN64(0xF) /* PSCI v0.2 power state encoding for CPU_SUSPEND function */ #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff @@ -90,8 +92,10 @@ /* PSCI features decoding (>=1.0) */ #define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT 1 +#define PSCI_1_0_FEATURES_CPU_SUSPEND_OS_INITIATED_MODE_MASK 1 #define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK \ - (0x1 << PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT) + ((0x1 << PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT)| \ + PSCI_1_0_FEATURES_CPU_SUSPEND_OS_INITIATED_MODE_MASK) /* PSCI return values (inclusive of all PSCI versions) */ #define PSCI_RET_SUCCESS 0