Skip to content

Commit

Permalink
power/reset: Add a new driver implementing 'power off by restarting'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andrew Lunn authored and Anton Vorontsov committed Jan 6, 2013
1 parent e8fc721 commit ffd8f9a
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* Restart Power Off

Buffalo Linkstation LS-XHL and LS-CHLv2, and other devices power off
by restarting and letting u-boot keep hold of the machine until the
user presses a button.

Required Properties:
- compatible: Should be "restart-poweroff"
8 changes: 8 additions & 0 deletions drivers/power/reset/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ config POWER_RESET_QNAP
commands to the microcontroller which controls the main power.

Say Y if you have a QNAP NAS.

config POWER_RESET_RESTART
bool "Restart power-off driver"
depends on ARM
help
Some boards don't actually have the ability to power off.
Instead they restart, and u-boot holds the SoC until the
user presses a key. u-boot then boots into Linux.
1 change: 1 addition & 0 deletions drivers/power/reset/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
65 changes: 65 additions & 0 deletions drivers/power/reset/restart-poweroff.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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 <asm/system_misc.h>

static void restart_poweroff_do_poweroff(void)
{
arm_pm_restart('h', NULL);
}

static int __devinit 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 __devexit 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 = __devexit_p(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("GPLv2");
MODULE_ALIAS("platform:poweroff-restart");

0 comments on commit ffd8f9a

Please sign in to comment.