0713e143c9
machine_restart is supported on non-ARM platforms, and and ultimately calls arm_pm_restart, so dont call arm_pm_restart directly but use the more generic function. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Heiko Stuebner <heiko@sntech.de> Cc: Russell King <linux@arm.linux.org.uk> Cc: Arnd Bergmann <arnd@arndb.de> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jonas Jensen <jonas.jensen@gmail.com> Cc: Maxime Ripard <maxime.ripard@free-electrons.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Tomasz Figa <t.figa@samsung.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Wim Van Sebroeck <wim@iguana.be> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
68 lines
1.7 KiB
C
68 lines
1.7 KiB
C
/*
|
|
* Power off by restarting and let u-boot keep hold of the machine
|
|
* until the user presses a button for example.
|
|
*
|
|
* Andrew Lunn <andrew@lunn.ch>
|
|
*
|
|
* Copyright (C) 2012 Andrew Lunn
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/module.h>
|
|
#include <linux/reboot.h>
|
|
#include <asm/system_misc.h>
|
|
|
|
static void restart_poweroff_do_poweroff(void)
|
|
{
|
|
reboot_mode = REBOOT_HARD;
|
|
machine_restart(NULL);
|
|
}
|
|
|
|
static int restart_poweroff_probe(struct platform_device *pdev)
|
|
{
|
|
/* If a pm_power_off function has already been added, leave it alone */
|
|
if (pm_power_off != NULL) {
|
|
dev_err(&pdev->dev,
|
|
"pm_power_off function already registered");
|
|
return -EBUSY;
|
|
}
|
|
|
|
pm_power_off = &restart_poweroff_do_poweroff;
|
|
return 0;
|
|
}
|
|
|
|
static int restart_poweroff_remove(struct platform_device *pdev)
|
|
{
|
|
if (pm_power_off == &restart_poweroff_do_poweroff)
|
|
pm_power_off = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id of_restart_poweroff_match[] = {
|
|
{ .compatible = "restart-poweroff", },
|
|
{},
|
|
};
|
|
|
|
static struct platform_driver restart_poweroff_driver = {
|
|
.probe = restart_poweroff_probe,
|
|
.remove = restart_poweroff_remove,
|
|
.driver = {
|
|
.name = "poweroff-restart",
|
|
.owner = THIS_MODULE,
|
|
.of_match_table = of_restart_poweroff_match,
|
|
},
|
|
};
|
|
module_platform_driver(restart_poweroff_driver);
|
|
|
|
MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch");
|
|
MODULE_DESCRIPTION("restart poweroff driver");
|
|
MODULE_LICENSE("GPL v2");
|
|
MODULE_ALIAS("platform:poweroff-restart");
|