linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: geert+renesas@glider.be (Geert Uytterhoeven)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] drivers: firmware: psci: Add psci_is_available()
Date: Wed, 11 Oct 2017 10:03:01 +0200	[thread overview]
Message-ID: <1507708982-12336-2-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1507708982-12336-1-git-send-email-geert+renesas@glider.be>

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 <geert+renesas@glider.be>
---
 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)
-- 
2.7.4

  reply	other threads:[~2017-10-11  8:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  8:03 [PATCH 0/2] drivers: firmware: psci: Extract psci_is_available() helper Geert Uytterhoeven
2017-10-11  8:03 ` Geert Uytterhoeven [this message]
2017-10-12  2:58   ` [PATCH 1/2] drivers: firmware: psci: Add psci_is_available() Jisheng Zhang
2017-10-12  6:58     ` Geert Uytterhoeven
2017-10-25 15:45   ` [1/2] " Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1507708982-12336-2-git-send-email-geert+renesas@glider.be \
    --to=geert+renesas@glider.be \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).