public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Elliot Berman <eberman@codeaurora.org>
To: Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Sudeep Holla <sudeep.holla@arm.com>
Cc: Elliot Berman <eberman@codeaurora.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	tsoni@codeaurora.org, psodagud@codeaurora.org,
	linux-arm-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [RFC] drivers: firmware: psci: Add function to support SYSTEM_RESET2
Date: Fri, 10 Jan 2020 11:29:12 -0800	[thread overview]
Message-ID: <1578684552-15953-2-git-send-email-eberman@codeaurora.org> (raw)
In-Reply-To: <1578684552-15953-1-git-send-email-eberman@codeaurora.org>

Make SYSTEM_RESET2 command part of its own function which client drivers
may also invoke to support vendor-specific reset types.

Signed-off-by: Elliot Berman <eberman@codeaurora.org>
---
 drivers/firmware/psci/psci.c | 16 +++++++++++++++-
 include/linux/psci.h         |  3 +++
 include/uapi/linux/psci.h    |  8 ++++++++
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index b3b6c15..338e4be 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -220,6 +220,15 @@ static unsigned long psci_migrate_info_up_cpu(void)
 			      0, 0, 0);
 }
 
+int psci_system_reset2(const u32 reset_type, const unsigned long cookie)
+{
+	if (!psci_system_reset2_supported)
+		return -EOPNOTSUPP;
+	return invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), reset_type,
+			      cookie, 0);
+}
+EXPORT_SYMBOL_GPL(psci_system_reset2);
+
 static void set_conduit(enum arm_smccc_conduit conduit)
 {
 	switch (conduit) {
@@ -267,7 +276,12 @@ static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
 		 * reset_type[30:0] = 0 (SYSTEM_WARM_RESET)
 		 * cookie = 0 (ignored by the implementation)
 		 */
-		invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), 0, 0, 0);
+		psci_system_reset2(
+			PSCI_1_1_SYSTEM_RESET2_SYSTEM_WARM_RESET |
+			(PSCI_1_1_SYSTEM_RESET2_TYPE_ARCHITECTURE <<
+			PSCI_1_1_SYSTEM_RESET2_SHIFT),
+			0
+		);
 	} else {
 		invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
 	}
diff --git a/include/linux/psci.h b/include/linux/psci.h
index ebe0a88..9479952 100644
--- a/include/linux/psci.h
+++ b/include/linux/psci.h
@@ -41,8 +41,11 @@ extern struct psci_operations psci_ops;
 
 #if defined(CONFIG_ARM_PSCI_FW)
 int __init psci_dt_init(void);
+int psci_system_reset2(const u32 reset_type, const unsigned long cookie);
 #else
 static inline int psci_dt_init(void) { return 0; }
+static inline int psci_system_reset2(const u32 reset_type,
+	const unsigned long cookie) { return -ENODEV; }
 #endif
 
 #if defined(CONFIG_ARM_PSCI_FW) && defined(CONFIG_ACPI)
diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h
index 2fcad1d..42edbd7 100644
--- a/include/uapi/linux/psci.h
+++ b/include/uapi/linux/psci.h
@@ -72,6 +72,14 @@
 #define PSCI_1_0_EXT_POWER_STATE_TYPE_MASK	\
 				(0x1 << PSCI_1_0_EXT_POWER_STATE_TYPE_SHIFT)
 
+/* PSCI SYSTEM_RESET2 reset_type argument */
+#define PSCI_1_1_SYSTEM_RESET2_SYSTEM_WARM_RESET	0x0
+#define PSCI_1_1_SYSTEM_RESET2_TYPE_VENDOR		1
+#define PSCI_1_1_SYSTEM_RESET2_TYPE_ARCHITECTURE	0
+#define PSCI_1_1_SYSTEM_RESET2_TYPE_SHIFT		30
+#define PSCI_1_1_SYSTEM_RESET2_TYPE_MASK		\
+				(0x1 << PSCI_1_1_SYSTEM_RESET2_TYPE_SHIFT)
+
 /* PSCI v0.2 affinity level state returned by AFFINITY_INFO */
 #define PSCI_0_2_AFFINITY_LEVEL_ON		0
 #define PSCI_0_2_AFFINITY_LEVEL_OFF		1
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2020-01-10 19:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 19:29 [RFC] ARM PSCI: Add support for vendor-specific SYSTEM_RESET2 Elliot Berman
2020-01-10 19:29 ` Elliot Berman [this message]
2020-01-13 10:11 ` Sudeep Holla

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=1578684552-15953-2-git-send-email-eberman@codeaurora.org \
    --to=eberman@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-arm-kernel@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=psodagud@codeaurora.org \
    --cc=sudeep.holla@arm.com \
    --cc=tsoni@codeaurora.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