1 // SPDX-License-Identifier: GPL-2.0-only
3 * Power off by restarting and let u-boot keep hold of the machine
4 * until the user presses a button for example.
8 * Copyright (C) 2012 Andrew Lunn
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/of_platform.h>
14 #include <linux/module.h>
15 #include <linux/reboot.h>
17 static int restart_poweroff_do_poweroff(struct sys_off_data *data)
19 reboot_mode = REBOOT_HARD;
20 machine_restart(NULL);
24 static int restart_poweroff_probe(struct platform_device *pdev)
26 /* Set this handler to low priority to not override an existing handler */
27 return devm_register_sys_off_handler(&pdev->dev,
28 SYS_OFF_MODE_POWER_OFF,
30 restart_poweroff_do_poweroff,
34 static const struct of_device_id of_restart_poweroff_match[] = {
35 { .compatible = "restart-poweroff", },
38 MODULE_DEVICE_TABLE(of, of_restart_poweroff_match);
40 static struct platform_driver restart_poweroff_driver = {
41 .probe = restart_poweroff_probe,
43 .name = "poweroff-restart",
44 .of_match_table = of_restart_poweroff_match,
47 module_platform_driver(restart_poweroff_driver);
50 MODULE_DESCRIPTION("restart poweroff driver");
51 MODULE_ALIAS("platform:poweroff-restart");