Messages in this thread Patch in this message | | | From | Yann Sionneau <> | Subject | [RFC PATCH 19/25] kvx: power: scall poweroff driver | Date | Tue, 3 Jan 2023 17:43:53 +0100 |
| |
Add a driver to poweroff the Coolidge SoC when running under Qemu, ISS or when the debugger (jtag-runner) runs on PL0 to catch the scall.
CC: Sebastian Reichel <sre@kernel.org> CC: linux-kernel@vger.kernel.org CC: linux-pm@vger.kernel.org Co-developed-by: Clement Leger <clement.leger@bootlin.com> Signed-off-by: Clement Leger <clement.leger@bootlin.com> Co-developed-by: Julian Vetter <jvetter@kalray.eu> Signed-off-by: Julian Vetter <jvetter@kalray.eu> Signed-off-by: Yann Sionneau <ysionneau@kalray.eu> --- drivers/power/reset/kvx-scall-poweroff.c | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 drivers/power/reset/kvx-scall-poweroff.c
diff --git a/drivers/power/reset/kvx-scall-poweroff.c b/drivers/power/reset/kvx-scall-poweroff.c new file mode 100644 index 000000000000..586d93fbcaed --- /dev/null +++ b/drivers/power/reset/kvx-scall-poweroff.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2017 - 2022 Kalray Inc. + * Author(s): Clement Leger + */ + +#include <linux/pm.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> + +#define SCALL_NUM_EXIT "0xfff" + +static void kvx_scall_poweroff(void) +{ + register int status asm("r0") = 0; + + asm volatile ("scall " SCALL_NUM_EXIT "\n\t;;" + : /* out */ + : "r"(status)); + + unreachable(); +} + +static int kvx_scall_poweroff_probe(struct platform_device *pdev) +{ + pm_power_off = kvx_scall_poweroff; + + return 0; +} + +static int kvx_scall_poweroff_remove(struct platform_device *pdev) +{ + if (pm_power_off == kvx_scall_poweroff) + pm_power_off = NULL; + + return 0; +} + +static const struct of_device_id kvx_scall_poweroff_of_match[] = { + { .compatible = "kalray,kvx-scall-poweroff" }, + {} +}; + +static struct platform_driver kvx_scall_poweroff_driver = { + .probe = kvx_scall_poweroff_probe, + .remove = kvx_scall_poweroff_remove, + .driver = { + .name = "kvx-scall-poweroff", + .of_match_table = kvx_scall_poweroff_of_match, + }, +}; +module_platform_driver(kvx_scall_poweroff_driver); -- 2.37.2
| |