linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aaro Koskinen <aaro.koskinen@iki.fi>
To: Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: Aaro Koskinen <aaro.koskinen@nokia.com>
Subject: [PATCH] drivers: firmware: psci: add support for warm reset
Date: Mon,  1 Apr 2019 21:14:43 +0300	[thread overview]
Message-ID: <20190401181443.6459-1-aaro.koskinen@iki.fi> (raw)

From: Aaro Koskinen <aaro.koskinen@nokia.com>

Add support for warm reset using SYSTEM_RESET2 introduced in PSCI
1.1 specification.

Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
---
 drivers/firmware/psci.c   | 25 +++++++++++++++++++++++++
 include/uapi/linux/psci.h |  3 +++
 2 files changed, 28 insertions(+)

diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index c80ec1d03274..1d95b5f6d403 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -73,6 +73,7 @@ enum psci_function {
 	PSCI_FN_CPU_ON,
 	PSCI_FN_CPU_OFF,
 	PSCI_FN_MIGRATE,
+	PSCI_FN_SYSTEM_RESET2,
 	PSCI_FN_MAX,
 };
 
@@ -256,6 +257,14 @@ static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
 	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
 }
 
+static void psci_sys_reset2(enum reboot_mode reboot_mode, const char *cmd)
+{
+	if (reboot_mode == REBOOT_WARM)
+		invoke_psci_fn(psci_function_id[PSCI_FN_SYSTEM_RESET2], 0, 0, 0);
+	else
+		psci_sys_reset(reboot_mode, cmd);
+}
+
 static void psci_sys_poweroff(void)
 {
 	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
@@ -564,6 +573,20 @@ static void __init psci_0_2_set_functions(void)
 	pm_power_off = psci_sys_poweroff;
 }
 
+static void __init psci_1_1_set_functions(void)
+{
+	int sys_reset2;
+	int feature;
+
+	sys_reset2 = PSCI_FN_NATIVE(1_1, SYSTEM_RESET2);
+	feature	= psci_features(sys_reset2);
+
+	if (feature != PSCI_RET_NOT_SUPPORTED) {
+		psci_function_id[PSCI_FN_SYSTEM_RESET2] = sys_reset2;
+		arm_pm_restart = psci_sys_reset2;
+	}
+}
+
 /*
  * Probe function for PSCI firmware versions >= 0.2
  */
@@ -588,6 +611,8 @@ static int __init psci_probe(void)
 		psci_init_smccc();
 		psci_init_cpu_suspend();
 		psci_init_system_suspend();
+		if (PSCI_VERSION_MINOR(ver) >= 1)
+			psci_1_1_set_functions();
 	}
 
 	return 0;
diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h
index b3bcabe380da..f36e616c3b3f 100644
--- a/include/uapi/linux/psci.h
+++ b/include/uapi/linux/psci.h
@@ -52,6 +52,9 @@
 
 #define PSCI_1_0_FN64_SYSTEM_SUSPEND		PSCI_0_2_FN64(14)
 
+#define PSCI_1_1_FN_SYSTEM_RESET2		PSCI_0_2_FN(18)
+#define PSCI_1_1_FN64_SYSTEM_RESET2		PSCI_0_2_FN64(18)
+
 /* PSCI v0.2 power state encoding for CPU_SUSPEND function */
 #define PSCI_0_2_POWER_STATE_ID_MASK		0xffff
 #define PSCI_0_2_POWER_STATE_ID_SHIFT		0
-- 
2.17.0


             reply	other threads:[~2019-04-01 18:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 18:14 Aaro Koskinen [this message]
2019-04-03  3:33 ` [PATCH] drivers: firmware: psci: add support for warm reset Mark Rutland
2019-04-03 18:12   ` Aaro Koskinen

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=20190401181443.6459-1-aaro.koskinen@iki.fi \
    --to=aaro.koskinen@iki.fi \
    --cc=aaro.koskinen@nokia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    /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).