* [PATCH v2 0/6] ARM: psci: add PSCI client driver
@ 2019-11-06 10:21 Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 1/6] ARM: psci: translate PSCI error codes in smc command Ahmad Fatoum
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Ahmad Fatoum @ 2019-11-06 10:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
On platforms like the ARM STM32MP and the ARM64 Layerscape, firmware
(i.e. barebox) is expected to fixup the correct PSCI version into the
Linux device tree, so functionality like system reset via PSCI works.
Add a generic client driver that handles this and enable its usage for
the STM32MP.
v1 -> v2:
- changed some erroneous commit message headers
- squashed PSCI system reset driver into PSCI client code (Sascha)
- Made the new CONFIG_ARM_PSCI_CLIENT selectable (Sascha)
- Added help text for CONFIG_ARM_PSCI_CLIENT
- Added -ENOSYS returning stubs for when barebox is compiled without
CONFIG_ARM_PSCI_CLIENT
- treat failure to register reset and/or poweroff handler in barebox
as warnings not errors
Ahmad Fatoum (6):
ARM: psci: translate PSCI error codes in smc command
ARM: psci: use CONFIG_ARM_PSCI_DEBUG for smc command
ARM: psci: wire in smc command help
ARM: psci: implement PSCI client driver
ARM: stm32mp: select ARM_USE_COMPRESSED_DTB for the whole arch
ARM: dts: stm32mp: report psci v0.2 at least
arch/arm/Kconfig | 10 ++
arch/arm/cpu/Makefile | 1 +
arch/arm/cpu/psci-client.c | 190 ++++++++++++++++++++++++++++++++++
arch/arm/cpu/psci.c | 46 +++++++-
arch/arm/dts/stm32mp157c.dtsi | 4 +
arch/arm/include/asm/psci.h | 23 +++-
arch/arm/mach-stm32mp/Kconfig | 2 +-
7 files changed, 269 insertions(+), 7 deletions(-)
create mode 100644 arch/arm/cpu/psci-client.c
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/6] ARM: psci: translate PSCI error codes in smc command
2019-11-06 10:21 [PATCH v2 0/6] ARM: psci: add PSCI client driver Ahmad Fatoum
@ 2019-11-06 10:21 ` Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 2/6] ARM: psci: use CONFIG_ARM_PSCI_DEBUG for " Ahmad Fatoum
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Ahmad Fatoum @ 2019-11-06 10:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
For more usability, translate CPU_ON error codes into the error
descriptions found in the PSCI Platform Design Document[1].
[1]: http://infocenter.arm.com/help/topic/com.arm.doc.den0022d/Power_State_Coordination_Interface_PDD_v1_1_DEN0022D.pdf
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/cpu/psci.c | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/psci.c b/arch/arm/cpu/psci.c
index a976ddbb5c65..b02e83986af8 100644
--- a/arch/arm/cpu/psci.c
+++ b/arch/arm/cpu/psci.c
@@ -248,8 +248,41 @@ void second_entry(void)
while (1);
}
+static const char *psci_xlate_str(long err)
+{
+ static char errno_string[sizeof "error 0x123456789ABCDEF0"];
+
+ switch(err)
+ {
+ case ARM_PSCI_RET_SUCCESS:
+ return "Success";
+ case ARM_PSCI_RET_NOT_SUPPORTED:
+ return "Operation not supported";
+ case ARM_PSCI_RET_INVAL:
+ return "Invalid argument";
+ case ARM_PSCI_RET_DENIED:
+ return "Operation not permitted";
+ case ARM_PSCI_RET_ALREADY_ON:
+ return "CPU already on";
+ case ARM_PSCI_RET_ON_PENDING:
+ return "CPU_ON in progress";
+ case ARM_PSCI_RET_INTERNAL_FAILURE:
+ return "Internal failure";
+ case ARM_PSCI_RET_NOT_PRESENT:
+ return "Trusted OS not present on core";
+ case ARM_PSCI_RET_DISABLED:
+ return "CPU is disabled";
+ case ARM_PSCI_RET_INVALID_ADDRESS:
+ return "Bad address";
+ }
+
+ sprintf(errno_string, "error 0x%lx", err);
+ return errno_string;
+}
+
static int do_smc(int argc, char *argv[])
{
+ long ret;
int opt;
struct arm_smccc_res res = {
.a0 = 0xdeadbee0,
@@ -271,7 +304,10 @@ static int do_smc(int argc, char *argv[])
case 'c':
arm_smccc_smc(ARM_PSCI_0_2_FN_CPU_ON,
1, (unsigned long)second_entry, 0, 0, 0, 0, 0, &res);
- break;
+ ret = (long)res.a0;
+ printf("CPU_ON returns with: %s\n", psci_xlate_str(ret));
+ if (ret)
+ return COMMAND_ERROR;
}
}
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/6] ARM: psci: use CONFIG_ARM_PSCI_DEBUG for smc command
2019-11-06 10:21 [PATCH v2 0/6] ARM: psci: add PSCI client driver Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 1/6] ARM: psci: translate PSCI error codes in smc command Ahmad Fatoum
@ 2019-11-06 10:21 ` Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 3/6] ARM: psci: wire in smc command help Ahmad Fatoum
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Ahmad Fatoum @ 2019-11-06 10:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
There's already an option to use when debugging PSCI. Instead of
requiring users to #define DEBUG 1 as well, have the smc command be
usable when CONFIG_ARM_PSCI_DEBUG, not DEBUG is defined.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/cpu/psci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/cpu/psci.c b/arch/arm/cpu/psci.c
index b02e83986af8..8c5043d83c8c 100644
--- a/arch/arm/cpu/psci.c
+++ b/arch/arm/cpu/psci.c
@@ -228,7 +228,7 @@ static int armv7_psci_init(void)
}
device_initcall(armv7_psci_init);
-#ifdef DEBUG
+#ifdef CONFIG_ARM_PSCI_DEBUG
#include <command.h>
#include <getopt.h>
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 3/6] ARM: psci: wire in smc command help
2019-11-06 10:21 [PATCH v2 0/6] ARM: psci: add PSCI client driver Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 1/6] ARM: psci: translate PSCI error codes in smc command Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 2/6] ARM: psci: use CONFIG_ARM_PSCI_DEBUG for " Ahmad Fatoum
@ 2019-11-06 10:21 ` Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 4/6] ARM: psci: implement PSCI client driver Ahmad Fatoum
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Ahmad Fatoum @ 2019-11-06 10:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The smc command has a help defined, but unused. Wire it in, so
help smc and smc -invalidoption work as expected.
While at it, remove the unimplemented -z option. It's unneeded,
because -c turns off the CPU after starting it again already.
Also it seems it's not implementable without interprocessor communication,
which is probably overkill here.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/cpu/psci.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/arm/cpu/psci.c b/arch/arm/cpu/psci.c
index 8c5043d83c8c..22ce1dfd0e84 100644
--- a/arch/arm/cpu/psci.c
+++ b/arch/arm/cpu/psci.c
@@ -291,7 +291,10 @@ static int do_smc(int argc, char *argv[])
.a3 = 0xdeadbee3,
};
- while ((opt = getopt(argc, argv, "nicz")) > 0) {
+ if (argc < 2)
+ return COMMAND_ERROR_USAGE;
+
+ while ((opt = getopt(argc, argv, "nic")) > 0) {
switch (opt) {
case 'n':
armv7_secure_monitor_install();
@@ -321,7 +324,6 @@ BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT ("-n", "Install secure monitor and switch to nonsecure mode")
BAREBOX_CMD_HELP_OPT ("-i", "Show information about installed PSCI version")
BAREBOX_CMD_HELP_OPT ("-c", "Start secondary CPU core")
-BAREBOX_CMD_HELP_OPT ("-z", "Turn off secondary CPU core")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(smc)
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 4/6] ARM: psci: implement PSCI client driver
2019-11-06 10:21 [PATCH v2 0/6] ARM: psci: add PSCI client driver Ahmad Fatoum
` (2 preceding siblings ...)
2019-11-06 10:21 ` [PATCH v2 3/6] ARM: psci: wire in smc command help Ahmad Fatoum
@ 2019-11-06 10:21 ` Ahmad Fatoum
2019-11-07 11:33 ` Sascha Hauer
2019-11-06 10:21 ` [PATCH v2 5/6] ARM: stm32mp: select ARM_USE_COMPRESSED_DTB for the whole arch Ahmad Fatoum
` (2 subsequent siblings)
6 siblings, 1 reply; 10+ messages in thread
From: Ahmad Fatoum @ 2019-11-06 10:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
System reset on the STM32MP may be done via PSCI when running TF-A
as first-stage boot loader. Provide a PSCI driver to simplify using it:
- A psci_invoke function is exported, so other code can use it
- A fixup for the PSCI device tree node is registered
- A reset and poweroff handler via PSCI is registered for PSCI >= v0.2
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/Kconfig | 9 ++
arch/arm/cpu/Makefile | 1 +
arch/arm/cpu/psci-client.c | 190 ++++++++++++++++++++++++++++++++++++
arch/arm/include/asm/psci.h | 23 ++++-
4 files changed, 221 insertions(+), 2 deletions(-)
create mode 100644 arch/arm/cpu/psci-client.c
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f82844a83a5e..1346f70f4f5f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -449,6 +449,15 @@ config ARM_PSCI
PSCI is used for controlling secondary CPU cores on some systems. Say
yes here if you want barebox to service PSCI calls on such systems.
+config ARM_PSCI_CLIENT
+ bool "Enable barebox PSCI client support"
+ select ARM_SMCCC
+ select ARM_PSCI_OF
+ help
+ Say yes here if you want barebox to communicate with a secure monitor
+ for resetting/powering off the system over PSCI. barebox' PSCI version
+ information will also be shared with Linux via device tree fixups.
+
config ARM_PSCI_DEBUG
bool "Enable PSCI debugging"
depends on ARM_PSCI
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index e0b16747ad66..09b3bc2eeab9 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -16,6 +16,7 @@ pbl-$(CONFIG_BOARD_ARM_GENERIC_DT_AARCH64) += board-dt-2nd-aarch64.o
obj-pbl-y += setupc$(S64).o cache$(S64).o
obj-$(CONFIG_BOOTM_OPTEE) += start-kernel-optee.o
+obj-$(CONFIG_ARM_PSCI_CLIENT) += psci-client.o
#
# Any variants can be called as start-armxyz.S
diff --git a/arch/arm/cpu/psci-client.c b/arch/arm/cpu/psci-client.c
new file mode 100644
index 000000000000..b5d0d3749702
--- /dev/null
+++ b/arch/arm/cpu/psci-client.c
@@ -0,0 +1,190 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com>
+ * Copyright (C) 2019 Ahmad Fatoum, Pengutronix
+ */
+
+#include <common.h>
+#include <init.h>
+#include <driver.h>
+#include <asm/psci.h>
+#include <asm/secure.h>
+#include <poweroff.h>
+#include <restart.h>
+#include <linux/arm-smccc.h>
+
+static struct restart_handler restart;
+
+static void __noreturn psci_invoke_noreturn(int function)
+{
+ int ret;
+
+ ret = psci_invoke(function, 0, 0, 0, NULL);
+
+ pr_err("psci command failed: %s\n", strerror(-ret));
+ hang();
+}
+
+static void __noreturn psci_poweroff(struct poweroff_handler *handler)
+{
+ psci_invoke_noreturn(ARM_PSCI_0_2_FN_SYSTEM_OFF);
+}
+
+static void __noreturn psci_restart(struct restart_handler *rst)
+{
+ psci_invoke_noreturn(ARM_PSCI_0_2_FN_SYSTEM_RESET);
+}
+
+static u32 version;
+int psci_get_version(void)
+{
+ if (!version)
+ return -EPROBE_DEFER;
+
+ return version;
+}
+
+static u32 (*psci_invoke_fn)(ulong, ulong, ulong, ulong);
+
+static int psci_xlate_error(s32 errnum)
+{
+ switch (errnum) {
+ case ARM_PSCI_RET_NOT_SUPPORTED:
+ return -ENOTSUPP; // Operation not supported
+ case ARM_PSCI_RET_INVAL:
+ return -EINVAL; // Invalid argument
+ case ARM_PSCI_RET_DENIED:
+ return -EPERM; // Operation not permitted
+ case ARM_PSCI_RET_ALREADY_ON:
+ return -EBUSY; // CPU already on
+ case ARM_PSCI_RET_ON_PENDING:
+ return -EALREADY; // CPU_ON in progress
+ case ARM_PSCI_RET_INTERNAL_FAILURE:
+ return -EIO; // Internal failure
+ case ARM_PSCI_RET_NOT_PRESENT:
+ return -ESRCH; // Trusted OS not present on core
+ case ARM_PSCI_RET_DISABLED:
+ return -ENODEV; // CPU is disabled
+ case ARM_PSCI_RET_INVALID_ADDRESS:
+ return -EACCES; // Bad address
+ default:
+ return errnum;
+ };
+}
+
+int psci_invoke(ulong function, ulong arg0, ulong arg1, ulong arg2,
+ ulong *result)
+{
+ ulong ret;
+ if (!psci_invoke_fn)
+ return -EPROBE_DEFER;
+
+ ret = psci_invoke_fn(function, arg0, arg1, arg2);
+ if (result)
+ *result = ret;
+
+ switch (function) {
+ case ARM_PSCI_0_2_FN_PSCI_VERSION:
+ case ARM_PSCI_1_0_FN64_STAT_RESIDENCY:
+ case ARM_PSCI_1_0_FN64_STAT_COUNT:
+ /* These don't return an error code */
+ return 0;
+ }
+
+ return psci_xlate_error(ret);
+}
+
+static u32 invoke_psci_fn_hvc(ulong function, ulong arg0, ulong arg1, ulong arg2)
+{
+ struct arm_smccc_res res;
+ arm_smccc_hvc(function, arg0, arg1, arg2, 0, 0, 0, 0, &res);
+ return res.a0;
+}
+
+static u32 invoke_psci_fn_smc(ulong function, ulong arg0, ulong arg1, ulong arg2)
+{
+ struct arm_smccc_res res;
+ arm_smccc_smc(function, arg0, arg1, arg2, 0, 0, 0, 0, &res);
+ return res.a0;
+}
+
+static int of_psci_do_fixup(struct device_node *root, void *context)
+{
+ return of_psci_fixup(root, *(u32 *)context);
+}
+
+static int __init psci_probe(struct device_d *dev)
+{
+ const char *method;
+ ulong of_version, actual_version;
+ int ret;
+
+ ret = dev_get_drvdata(dev, (const void **)&of_version);
+ if (ret)
+ return -ENODEV;
+
+ ret = of_property_read_string(dev->device_node, "method", &method);
+ if (ret) {
+ dev_warn(dev, "missing \"method\" property\n");
+ return -ENXIO;
+ }
+
+ if (!strcmp(method, "hvc")) {
+ psci_invoke_fn = invoke_psci_fn_hvc;
+ } else if (!strcmp(method, "smc")) {
+ psci_invoke_fn = invoke_psci_fn_smc;
+ } else {
+ pr_warn("invalid \"method\" property: %s\n", method);
+ return -EINVAL;
+ }
+
+
+ if (of_version < ARM_PSCI_VER(0,2)) {
+ version = of_version;
+
+ dev_info(dev, "assuming version %u.%u\n",
+ version >> 16, version & 0xffff);
+ dev_dbg(dev, "Not registering reset handler due to PSCI version\n");
+
+ return 0;
+ }
+
+ psci_invoke(ARM_PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0, &actual_version);
+ version = actual_version;
+
+ dev_info(dev, "detected version %u.%u\n",
+ version >> 16, version & 0xffff);
+
+ if (actual_version != of_version)
+ of_register_fixup(of_psci_do_fixup, &version);
+
+ ret = poweroff_handler_register_fn(psci_poweroff);
+ if (ret)
+ dev_warn(dev, "error registering poweroff handler: %s\n",
+ strerror(-ret));
+
+ restart.name = "psci";
+ restart.restart = psci_restart;
+ restart.priority = 400;
+
+ ret = restart_handler_register(&restart);
+ if (ret)
+ dev_warn(dev, "error registering restart handler: %s\n",
+ strerror(-ret));
+
+ return ret;
+}
+
+static __maybe_unused struct of_device_id psci_dt_ids[] = {
+ { .compatible = "arm,psci", .data = (void*)ARM_PSCI_VER(0,1) },
+ { .compatible = "arm,psci-0.2", .data = (void*)ARM_PSCI_VER(0,2) },
+ { .compatible = "arm,psci-1.0", .data = (void*)ARM_PSCI_VER(1,0) },
+ { /* sentinel */ },
+};
+
+static struct driver_d psci_driver = {
+ .name = "psci",
+ .probe = psci_probe,
+ .of_compatible = DRV_OF_COMPAT(psci_dt_ids),
+};
+coredevice_platform_driver(psci_driver);
diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
index f2db967f3a63..8f76ffcb2dbb 100644
--- a/arch/arm/include/asm/psci.h
+++ b/arch/arm/include/asm/psci.h
@@ -18,8 +18,9 @@
#ifndef __ARM_PSCI_H__
#define __ARM_PSCI_H__
-#define ARM_PSCI_VER_1_0 (0x00010000)
-#define ARM_PSCI_VER_0_2 (0x00000002)
+#define ARM_PSCI_VER(major, minor) (((major) << 16) | (minor))
+#define ARM_PSCI_VER_1_0 ARM_PSCI_VER(1,0)
+#define ARM_PSCI_VER_0_2 ARM_PSCI_VER(0,2)
/* PSCI 0.1 interface */
#define ARM_PSCI_FN_BASE 0x95c1ba5e
@@ -106,6 +107,24 @@ static inline void psci_set_ops(struct psci_ops *ops)
}
#endif
+#ifdef CONFIG_ARM_PSCI_CLIENT
+int psci_invoke(ulong function, ulong arg0, ulong arg1, ulong arg2,
+ ulong *result);
+
+int psci_get_version(void);
+#else
+int psci_invoke(ulong function, ulong arg0, ulong arg1, ulong arg2,
+ ulong *result)
+{
+ return -ENOSYS;
+}
+
+int psci_get_version(void)
+{
+ return -ENOSYS;
+}
+#endif
+
void psci_cpu_entry(void);
#ifdef CONFIG_ARM_PSCI_DEBUG
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 5/6] ARM: stm32mp: select ARM_USE_COMPRESSED_DTB for the whole arch
2019-11-06 10:21 [PATCH v2 0/6] ARM: psci: add PSCI client driver Ahmad Fatoum
` (3 preceding siblings ...)
2019-11-06 10:21 ` [PATCH v2 4/6] ARM: psci: implement PSCI client driver Ahmad Fatoum
@ 2019-11-06 10:21 ` Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 6/6] ARM: dts: stm32mp: report psci v0.2 at least Ahmad Fatoum
2019-11-07 7:09 ` [PATCH v2 0/6] ARM: psci: add PSCI client driver Sascha Hauer
6 siblings, 0 replies; 10+ messages in thread
From: Ahmad Fatoum @ 2019-11-06 10:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
We'll probably be using compressed DTBs for all new boards as well, thus
move the ARM_USE_COMPRESSED_DTB, so it's always selected for STM32MP.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/Kconfig | 1 +
arch/arm/mach-stm32mp/Kconfig | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1346f70f4f5f..9589a6a511e4 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -202,6 +202,7 @@ config ARCH_STM32MP
select ARCH_HAS_RESET_CONTROLLER
select ARM_AMBA
select ARM_SMCCC
+ select ARM_USE_COMPRESSED_DTB
config ARCH_VERSATILE
bool "ARM Versatile boards (ARM926EJ-S)"
diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
index 6bf950b23f0f..b30439735e17 100644
--- a/arch/arm/mach-stm32mp/Kconfig
+++ b/arch/arm/mach-stm32mp/Kconfig
@@ -9,7 +9,6 @@ config ARCH_STM32MP157
config MACH_STM32MP157C_DK2
select ARCH_STM32MP157
- select ARM_USE_COMPRESSED_DTB
bool "STM32MP157C-DK2 board"
endif
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 6/6] ARM: dts: stm32mp: report psci v0.2 at least
2019-11-06 10:21 [PATCH v2 0/6] ARM: psci: add PSCI client driver Ahmad Fatoum
` (4 preceding siblings ...)
2019-11-06 10:21 ` [PATCH v2 5/6] ARM: stm32mp: select ARM_USE_COMPRESSED_DTB for the whole arch Ahmad Fatoum
@ 2019-11-06 10:21 ` Ahmad Fatoum
2019-11-06 10:26 ` [PATCH] fixup! " Ahmad Fatoum
2019-11-07 7:09 ` [PATCH v2 0/6] ARM: psci: add PSCI client driver Sascha Hauer
6 siblings, 1 reply; 10+ messages in thread
From: Ahmad Fatoum @ 2019-11-06 10:21 UTC (permalink / raw)
To: barebox; +Cc: Michael Olbrich, Ahmad Fatoum
ARM TF-A reports compatibility with PSCI v1.1 since v1.5. Upstream
ARM TF-A support for STM32MP was introduced with v1.6.
It's thus safe to assume that the STM32MP barebox will never have to
interact with a secure monitor implementing PSCI v0.1.
Overwrite the psci device tree compatible to specify v0.2. This is the
first version that implements PSCI_VERSION, which allows the barebox
psci client driver selected in this commit to query the actual PSCI
version and fix it up into the device tree.
This fixes an issue where resetting via PSCI fails in Linux because the
upstream device tree compatible:
reboot: Restarting system
Reboot failed -- System halted
Reported-by: Michael Olbrich <mol@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/dts/stm32mp157c.dtsi | 4 ++++
arch/arm/mach-stm32mp/Kconfig | 1 +
2 files changed, 5 insertions(+)
diff --git a/arch/arm/dts/stm32mp157c.dtsi b/arch/arm/dts/stm32mp157c.dtsi
index 771139c28af0..97c075a020f8 100644
--- a/arch/arm/dts/stm32mp157c.dtsi
+++ b/arch/arm/dts/stm32mp157c.dtsi
@@ -19,6 +19,10 @@
gpio10 = &gpiok;
gpio25 = &gpioz;
};
+
+ psci {
+ compatible = "arm,psci-0.2";
+ };
};
&bsec {
diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
index b30439735e17..e74029158223 100644
--- a/arch/arm/mach-stm32mp/Kconfig
+++ b/arch/arm/mach-stm32mp/Kconfig
@@ -5,6 +5,7 @@ config ARCH_NR_GPIO
default 416
config ARCH_STM32MP157
+ select PSCI_CLIENT
bool
config MACH_STM32MP157C_DK2
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] fixup! ARM: dts: stm32mp: report psci v0.2 at least
2019-11-06 10:21 ` [PATCH v2 6/6] ARM: dts: stm32mp: report psci v0.2 at least Ahmad Fatoum
@ 2019-11-06 10:26 ` Ahmad Fatoum
0 siblings, 0 replies; 10+ messages in thread
From: Ahmad Fatoum @ 2019-11-06 10:26 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Typo...
---
arch/arm/mach-stm32mp/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
index e74029158223..9b55a3d21843 100644
--- a/arch/arm/mach-stm32mp/Kconfig
+++ b/arch/arm/mach-stm32mp/Kconfig
@@ -5,7 +5,7 @@ config ARCH_NR_GPIO
default 416
config ARCH_STM32MP157
- select PSCI_CLIENT
+ select ARM_PSCI_CLIENT
bool
config MACH_STM32MP157C_DK2
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/6] ARM: psci: add PSCI client driver
2019-11-06 10:21 [PATCH v2 0/6] ARM: psci: add PSCI client driver Ahmad Fatoum
` (5 preceding siblings ...)
2019-11-06 10:21 ` [PATCH v2 6/6] ARM: dts: stm32mp: report psci v0.2 at least Ahmad Fatoum
@ 2019-11-07 7:09 ` Sascha Hauer
6 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2019-11-07 7:09 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, Nov 06, 2019 at 11:21:43AM +0100, Ahmad Fatoum wrote:
> On platforms like the ARM STM32MP and the ARM64 Layerscape, firmware
> (i.e. barebox) is expected to fixup the correct PSCI version into the
> Linux device tree, so functionality like system reset via PSCI works.
>
> Add a generic client driver that handles this and enable its usage for
> the STM32MP.
>
> v1 -> v2:
> - changed some erroneous commit message headers
> - squashed PSCI system reset driver into PSCI client code (Sascha)
> - Made the new CONFIG_ARM_PSCI_CLIENT selectable (Sascha)
> - Added help text for CONFIG_ARM_PSCI_CLIENT
> - Added -ENOSYS returning stubs for when barebox is compiled without
> CONFIG_ARM_PSCI_CLIENT
> - treat failure to register reset and/or poweroff handler in barebox
> as warnings not errors
>
> Ahmad Fatoum (6):
> ARM: psci: translate PSCI error codes in smc command
> ARM: psci: use CONFIG_ARM_PSCI_DEBUG for smc command
> ARM: psci: wire in smc command help
> ARM: psci: implement PSCI client driver
> ARM: stm32mp: select ARM_USE_COMPRESSED_DTB for the whole arch
> ARM: dts: stm32mp: report psci v0.2 at least
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 4/6] ARM: psci: implement PSCI client driver
2019-11-06 10:21 ` [PATCH v2 4/6] ARM: psci: implement PSCI client driver Ahmad Fatoum
@ 2019-11-07 11:33 ` Sascha Hauer
0 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2019-11-07 11:33 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, Nov 06, 2019 at 11:21:47AM +0100, Ahmad Fatoum wrote:
>
> +#ifdef CONFIG_ARM_PSCI_CLIENT
> +int psci_invoke(ulong function, ulong arg0, ulong arg1, ulong arg2,
> + ulong *result);
> +
> +int psci_get_version(void);
> +#else
> +int psci_invoke(ulong function, ulong arg0, ulong arg1, ulong arg2,
> + ulong *result)
> +{
> + return -ENOSYS;
> +}
Added missing "static inline" here
> +
> +int psci_get_version(void)
> +{
> + return -ENOSYS;
> +}
and here.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-11-07 11:33 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 10:21 [PATCH v2 0/6] ARM: psci: add PSCI client driver Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 1/6] ARM: psci: translate PSCI error codes in smc command Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 2/6] ARM: psci: use CONFIG_ARM_PSCI_DEBUG for " Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 3/6] ARM: psci: wire in smc command help Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 4/6] ARM: psci: implement PSCI client driver Ahmad Fatoum
2019-11-07 11:33 ` Sascha Hauer
2019-11-06 10:21 ` [PATCH v2 5/6] ARM: stm32mp: select ARM_USE_COMPRESSED_DTB for the whole arch Ahmad Fatoum
2019-11-06 10:21 ` [PATCH v2 6/6] ARM: dts: stm32mp: report psci v0.2 at least Ahmad Fatoum
2019-11-06 10:26 ` [PATCH] fixup! " Ahmad Fatoum
2019-11-07 7:09 ` [PATCH v2 0/6] ARM: psci: add PSCI client driver Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox