[RFC] drivers: firmware: psci: Add function to support SYSTEM_RESET2
From: Elliot Berman
Date: Fri Jan 10 2020 - 14:29:23 EST
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@xxxxxxxxxxxxxx>
---
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