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 void restart_poweroff_do_poweroff(void)
19 reboot_mode = REBOOT_HARD;
20 machine_restart(NULL);
23 static int restart_poweroff_probe(struct platform_device *pdev)
25 /* If a pm_power_off function has already been added, leave it alone */
26 if (pm_power_off != NULL) {
28 "pm_power_off function already registered");
32 pm_power_off = &restart_poweroff_do_poweroff;
36 static int restart_poweroff_remove(struct platform_device *pdev)
38 if (pm_power_off == &restart_poweroff_do_poweroff)
44 static const struct of_device_id of_restart_poweroff_match[] = {
45 { .compatible = "restart-poweroff", },
48 MODULE_DEVICE_TABLE(of, of_restart_poweroff_match);
50 static struct platform_driver restart_poweroff_driver = {
51 .probe = restart_poweroff_probe,
52 .remove = restart_poweroff_remove,
54 .name = "poweroff-restart",
55 .of_match_table = of_restart_poweroff_match,
58 module_platform_driver(restart_poweroff_driver);
61 MODULE_DESCRIPTION("restart poweroff driver");
62 MODULE_ALIAS("platform:poweroff-restart");