From patchwork Wed Oct 11 08:03:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 9999443 X-Patchwork-Delegate: geert@linux-m68k.org 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 8A35A602BF for ; Wed, 11 Oct 2017 11:52:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D946283CF for ; Wed, 11 Oct 2017 11:52:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 729AD289F0; Wed, 11 Oct 2017 11:52:04 +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=unavailable 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 05C0B283CF for ; Wed, 11 Oct 2017 11:52:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757333AbdJKLv1 (ORCPT ); Wed, 11 Oct 2017 07:51:27 -0400 Received: from xavier.telenet-ops.be ([195.130.132.52]:40512 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751910AbdJKLub (ORCPT ); Wed, 11 Oct 2017 07:50:31 -0400 Received: from ayla.of.borg ([84.195.106.246]) by xavier.telenet-ops.be with bizsmtp id LBqU1w00P5JzmfG01BqUzr; Wed, 11 Oct 2017 13:50:30 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1e2FWu-0004e7-8q; Wed, 11 Oct 2017 13:50:28 +0200 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1e2Bys-0003Dl-O1; Wed, 11 Oct 2017 10:03:06 +0200 From: Geert Uytterhoeven To: Mark Rutland , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/2] drivers: firmware: psci: Add psci_is_available() Date: Wed, 11 Oct 2017 10:03:01 +0200 Message-Id: <1507708982-12336-2-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507708982-12336-1-git-send-email-geert+renesas@glider.be> References: <1507708982-12336-1-git-send-email-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP PSCI support may be disabled at build time (by configuration) or at run-time (PSCI firmware not present). While CONFIG_ARM_PSCI_FW can be used to check for build time enablement, there is currently no simple way to check if PSCI is actually available and used. Hence add a helper function to check if PSCI is available. This is useful for e.g. drivers that are used on platforms with and without PSCI. Such drivers may need to take provisions for proper operation when PSCI is used, and/or to implement functionality that is usually provided by PSCI. Signed-off-by: Geert Uytterhoeven --- drivers/firmware/psci.c | 5 +++++ include/linux/psci.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index da469c972b503f83..a3a11e2d8ffffaaa 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -670,6 +670,11 @@ int __init psci_dt_init(void) return init_fn(np); } +bool psci_is_available(void) +{ + return psci_ops.cpu_off && psci_ops.cpu_on && psci_ops.cpu_suspend; +} + #ifdef CONFIG_ACPI /* * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's diff --git a/include/linux/psci.h b/include/linux/psci.h index bdea1cb5e1db142b..2bdee325aeb80cf6 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -39,8 +39,10 @@ extern struct psci_operations psci_ops; #if defined(CONFIG_ARM_PSCI_FW) int __init psci_dt_init(void); +bool psci_is_available(void); #else static inline int psci_dt_init(void) { return 0; } +static inline bool psci_is_available(void) { return false; } #endif #if defined(CONFIG_ARM_PSCI_FW) && defined(CONFIG_ACPI)