aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2012-12-28 07:25:11 -0500
committerAnton Vorontsov <anton@enomsg.org>2013-01-06 17:00:31 -0500
commitffd8f9a727f27270584c7472ca56cce1e4736888 (patch)
treee12dbb3f62ace5eb65251bc646f3da5a47a193ad
parente8fc721a9ab8dd6723063a92f5c5fdb5eaffbd6e (diff)
power/reset: Add a new driver implementing 'power off by restarting'
Some devices, Buffalo Linkstation LS-XHL and LS-CHLv2 for example, power-off by restarting to letting u-boot hold the SoC until the user presses a key. Add a generic driver to implement this. It binds a function to pm_power_off, which calls arm_pm_restart. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Michael Walle <michael@walle.cc> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
-rw-r--r--Documentation/devicetree/bindings/power_supply/restart-poweroff.txt8
-rw-r--r--drivers/power/reset/Kconfig8
-rw-r--r--drivers/power/reset/Makefile1
-rw-r--r--drivers/power/reset/restart-poweroff.c65
4 files changed, 82 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/power_supply/restart-poweroff.txt b/Documentation/devicetree/bindings/power_supply/restart-poweroff.txt
new file mode 100644
index 000000000000..5776e684afda
--- /dev/null
+++ b/Documentation/devicetree/bindings/power_supply/restart-poweroff.txt
@@ -0,0 +1,8 @@
1* Restart Power Off
2
3Buffalo Linkstation LS-XHL and LS-CHLv2, and other devices power off
4by restarting and letting u-boot keep hold of the machine until the
5user presses a button.
6
7Required Properties:
8- compatible: Should be "restart-poweroff"
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 6453aac701c0..1ae65b822864 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -22,3 +22,11 @@ config POWER_RESET_QNAP
22 commands to the microcontroller which controls the main power. 22 commands to the microcontroller which controls the main power.
23 23
24 Say Y if you have a QNAP NAS. 24 Say Y if you have a QNAP NAS.
25
26config POWER_RESET_RESTART
27 bool "Restart power-off driver"
28 depends on ARM
29 help
30 Some boards don't actually have the ability to power off.
31 Instead they restart, and u-boot holds the SoC until the
32 user presses a key. u-boot then boots into Linux.
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index c4d3b2d11b9e..0f317f50c56f 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -1,2 +1,3 @@
1obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o 1obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
2obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o 2obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
3obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o \ No newline at end of file
diff --git a/drivers/power/reset/restart-poweroff.c b/drivers/power/reset/restart-poweroff.c
new file mode 100644
index 000000000000..b11b9e887174
--- /dev/null
+++ b/drivers/power/reset/restart-poweroff.c
@@ -0,0 +1,65 @@
1/*
2 * Power off by restarting and let u-boot keep hold of the machine
3 * until the user presses a button for example.
4 *
5 * Andrew Lunn <andrew@lunn.ch>
6 *
7 * Copyright (C) 2012 Andrew Lunn
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/of_platform.h>
17#include <linux/module.h>
18#include <asm/system_misc.h>
19
20static void restart_poweroff_do_poweroff(void)
21{
22 arm_pm_restart('h', NULL);
23}
24
25static int __devinit restart_poweroff_probe(struct platform_device *pdev)
26{
27 /* If a pm_power_off function has already been added, leave it alone */
28 if (pm_power_off != NULL) {
29 dev_err(&pdev->dev,
30 "pm_power_off function already registered");
31 return -EBUSY;
32 }
33
34 pm_power_off = &restart_poweroff_do_poweroff;
35 return 0;
36}
37
38static int __devexit restart_poweroff_remove(struct platform_device *pdev)
39{
40 if (pm_power_off == &restart_poweroff_do_poweroff)
41 pm_power_off = NULL;
42
43 return 0;
44}
45
46static const struct of_device_id of_restart_poweroff_match[] = {
47 { .compatible = "restart-poweroff", },
48 {},
49};
50
51static struct platform_driver restart_poweroff_driver = {
52 .probe = restart_poweroff_probe,
53 .remove = __devexit_p(restart_poweroff_remove),
54 .driver = {
55 .name = "poweroff-restart",
56 .owner = THIS_MODULE,
57 .of_match_table = of_restart_poweroff_match,
58 },
59};
60module_platform_driver(restart_poweroff_driver);
61
62MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch");
63MODULE_DESCRIPTION("restart poweroff driver");
64MODULE_LICENSE("GPLv2");
65MODULE_ALIAS("platform:poweroff-restart");