Skip to contentSkip to conversation

Power off drivers for QNAP and LSXL.

PATCH New Andrew Lunn 5 participants 26 messages Dec 28, 2012 – May 26, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Power off drivers for QNAP and LSXL.

This patchset contains two power off driver, moving existing code out of mach-kirkwood into drivers/power/reset.

QNAP NAS boards have a microcontroller connected to a UART. Sending the command to it turns the power off. There are Orion5x QNAP boards which can later use this driver, once they are converted to DT.

Kirkwood Buffalo Linkstation LSXL devices power off by restarting and letting the boot loader idle until the user hits a switch. There are again Orion5x devices which could use this driver in the future, once they are converted to DT. It also looks like some PXA devices could use it.

Patches #1 and #3 are the drivers, and #2 and #4 make use of the driver, removing C code and adding DT nodes.

The QNAP driver has been tested on a QNAP TS119+. The LSXL driver is currently untested.

git://github.com/lunn/linux.git v3.8-rc1-qnap-poweroff

Andrew Lunn (4):
Power: Reset: Driver to turn QNAP board power off.
ARM: Kirkwood: Make use of the QNAP Power off driver.
Power: Reset: Power off by restarting
ARM: Kirkwood: Convert LSXL to restart-poweroff driver.

 .../bindings/power_supply/qnap-poweroff.txt        |   14 +++
 .../bindings/power_supply/restart-poweroff.txt     |    9 ++
 arch/arm/boot/dts/kirkwood-lsxl.dtsi               |    4 +
 arch/arm/boot/dts/kirkwood-ts219.dtsi              |    5 +
 arch/arm/mach-kirkwood/Kconfig                     |    2 +
 arch/arm/mach-kirkwood/board-lsxl.c                |   16 ---
 arch/arm/mach-kirkwood/board-ts219.c               |    3 -
 drivers/power/reset/Kconfig                        |   17 +++
 drivers/power/reset/Makefile                       |    2 +
 drivers/power/reset/qnap-poweroff.c                |  124 ++++++++++++++++++++
 drivers/power/reset/restart-poweroff.c             |   67 +++++++++++
 11 files changed, 244 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt
 create mode 100644 Documentation/devicetree/bindings/power_supply/restart-poweroff.txt
 create mode 100644 drivers/power/reset/qnap-poweroff.c
 create mode 100644 drivers/power/reset/restart-poweroff.c
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/4 Power: Reset: Driver to turn QNAP board power off.

From: Andrew Lunn <[email protected]>

The QNAP NAS boxes have a microcontroller attached to the SoCs second serial port. By sending it a simple command, it will turn the power for the board off. This driver registers a function for pm_power_off to send such a command.

---
 .../bindings/power_supply/qnap-poweroff.txt        |   14 +++
 drivers/power/reset/Kconfig                        |    9 ++
 drivers/power/reset/Makefile                       |    1 +
 drivers/power/reset/qnap-poweroff.c                |  124 ++++++++++++++++++++
 4 files changed, 148 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt
 create mode 100644 drivers/power/reset/qnap-poweroff.c
Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt new file +14 -0
new file mode 100644
index 0000000..0951952
@@ -0,0 +1,14 @@
+* QNAP Power Off
+
+QNAP NAS devices have a microcontroller controlling the main power
+supply. This microcontroller is connected to UART1 of the Kirkwood and
+Orion5x SoCs. Sending the charactor 'A', at 19200 baud, tells the
+microcontroller to turn the power off. This driver adds a handler to
+pm_power_off which is called to turn the power off.
+
+Required Properties:
+- compatible: Should be "qnap,power-off"
+
+- reg: Address and length of the register set for UART1
+- clocks: tclk clock
+
drivers/power/reset/Kconfig +9 -0
index 6461b48..6453aac 100644
@@ -13,3 +13,12 @@ config POWER_RESET_GPIO
 	  This driver supports turning off your board via a GPIO line.
 	  If your board needs a GPIO high/low to power down, say Y and
 	  create a binding in your devicetree.
+
+config POWER_RESET_QNAP
+	bool "QNAP power-off driver"
+	depends on OF_GPIO && POWER_RESET && PLAT_ORION
+	help
+	  This driver supports turning off QNAP NAS devices by sending
+	  commands to the microcontroller which controls the main power.
+
+	  Say Y if you have a QNAP NAS.
drivers/power/reset/Makefile +1 -0
index 751488a..c4d3b2d 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
+obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
drivers/power/reset/qnap-poweroff.c new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 1/4 Power: Reset: Driver to turn QNAP board power off.

Quoted 9 lines · Andrew Lunn

From: Andrew Lunn <[email protected]>

The QNAP NAS boxes have a microcontroller attached to the SoCs second serial port. By sending it a simple command, it will turn the power for the board off. This driver registers a function for pm_power_off to send such a command.

---

[...]

Quoted 1 line

+MODULE_LICENSE("GPLv2+");

That doesn't make sense, and probably will result into a T (tainted) flag. The kernel is under GPLv2 license, no '+'. Anyone who touches the code assumes that it is "GPLv2 only". So, any changes on top of your code automatically turns it into "GPLv2 only". IANAL, but that's how I believe things work.

Anyway, fixed this warning:

CC drivers/power/reset/qnap-poweroff.o
drivers/power/reset/qnap-poweroff.c: In function ?qnap_power_off_probe?:
drivers/power/reset/qnap-poweroff.c:80:3: warning: passing argument 1 of ?lookup_symbol_name? makes integer from pointer without a cast [enabled by default] In file included from drivers/power/reset/qnap-poweroff.c:21:0:
include/linux/kallsyms.h:45:5: note: expected ?long unsigned int? but argument is of type ?void (*)(void)?

... and have made a few cosmetic changes (see below). But I didn't change the license string, you probably should send a patch for it.

Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt +0 -1
index 0951952..9a599d2 100644
@@ -11,4 +11,3 @@ Required Properties:
 
 - reg: Address and length of the register set for UART1
 - clocks: tclk clock
-
drivers/power/reset/qnap-poweroff.c +9 -17
index ca0b476..cecb317 100644
@@ -28,8 +28,7 @@
 static void __iomem *base;
 static unsigned long tclk;
 
-static void
-qnap_power_off(void)
+static void qnap_power_off(void)
 {
 	/* 19200 baud divisor */
 	const unsigned divisor = ((tclk + (8 * 19200)) / (16 * 19200));
@@ -49,28 +48,25 @@ qnap_power_off(void)
 	writel('A', UART1_REG(TX));
 }
 
-static int
-qnap_power_off_probe(struct platform_device *pdev)
+static int qnap_power_off_probe(struct platform_device *pdev)
 {
 	struct resource *res;
 	struct clk *clk;
 	char symname[KSYM_NAME_LEN];
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
+	if (!res) {
 		dev_err(&pdev->dev, "Missing resource");
 		return -EINVAL;
 	}
 
-	base = devm_ioremap(&pdev->dev, res->start,
-			    resource_size(res));
-	if (base == NULL) {
+	base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+	if (!base) {
 		dev_err(&pdev->dev, "Unable to map resource");
 		return -EINVAL;
 	}
 
-	/* We need to know tclk in order to calculate the UART
-	   divisor */
+	/* We need to know tclk in order to calculate the UART divisor */
 	clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "Clk missing");
@@ -80,8 +76,8 @@ qnap_power_off_probe(struct platform_device *pdev)
 	tclk = clk_get_rate(clk);
 
 	/* Check that nothing else has already setup a handler */
-	if (pm_power_off != NULL) {
-		lookup_symbol_name(pm_power_off, symname);
+	if (pm_power_off) {
+		lookup_symbol_name((ulong)pm_power_off, symname);
 		dev_err(&pdev->dev,
 			"pm_power_off already claimed %p %s",
 			pm_power_off, symname);
@@ -92,11 +88,9 @@ qnap_power_off_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int
-qnap_power_off_remove(struct platform_device *pdev)
+static int qnap_power_off_remove(struct platform_device *pdev)
 {
 	pm_power_off = NULL;
-
 	return 0;
 }
 
@@ -104,7 +98,6 @@ static const struct of_device_id qnap_power_off_of_match_table[] = {
 	{ .compatible = "qnap,power-off", },
 	{}
 };
-
 MODULE_DEVICE_TABLE(of, qnap_power_off_of_match_table);
 
 static struct platform_driver qnap_power_off_driver = {
@@ -116,7 +109,6 @@ static struct platform_driver qnap_power_off_driver = {
 		.of_match_table = of_match_ptr(qnap_power_off_of_match_table),
 	},
 };
-
 module_platform_driver(qnap_power_off_driver);
 
 MODULE_AUTHOR("Andrew Lunn <[email protected]>");
#3 lore raw

PATCH 1/1 power: reset: qnap-poweroff: Fix License String

GPLv2+ is not a valid license string. Replace it with one that is.

---
 drivers/power/reset/qnap-poweroff.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/reset/qnap-poweroff.c +1 -1
index ca0b476..8af772b 100644
@@ -121,4 +121,4 @@ module_platform_driver(qnap_power_off_driver);
 
 MODULE_AUTHOR("Andrew Lunn <[email protected]>");
 MODULE_DESCRIPTION("QNAP Power off driver");
-MODULE_LICENSE("GPLv2+");
+MODULE_LICENSE("GPL v2");
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 1/1 power: reset: qnap-poweroff: Fix License String

Quoted 4 lines · Andrew Lunn

GPLv2+ is not a valid license string. Replace it with one that is.

---

Applied, thanks a lot!

Quoted 15 lines
 drivers/power/reset/qnap-poweroff.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/reset/qnap-poweroff.c +1 -1
index ca0b476..8af772b 100644
@@ -121,4 +121,4 @@ module_platform_driver(qnap_power_off_driver);
 
 MODULE_AUTHOR("Andrew Lunn <[email protected]>");
 MODULE_DESCRIPTION("QNAP Power off driver");
-MODULE_LICENSE("GPLv2+");
+MODULE_LICENSE("GPL v2");
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH 1/1 power: reset: qnap-poweroff: Fix License String

In reply to Andrew Lunn
Quoted 12 lines · Andrew Lunn

GPLv2+ is not a valid license string. Replace it with one that is.

---
 drivers/power/reset/qnap-poweroff.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/reset/qnap-poweroff.c +0 -0
index ca0b476..8af772b 100644

drivers/power/reset/qnap-poweroff.c module_platform_driver(qnap_power_off_driver); · line 124

Quoted 5 lines
drivers/power/reset/qnap-poweroff.c +1 -1
@@ -121,4 +121,4 @@ module_platform_driver(qnap_power_off_driver);
 
 MODULE_AUTHOR("Andrew Lunn <[email protected]>");
 MODULE_DESCRIPTION("QNAP Power off driver");
-MODULE_LICENSE("GPLv2+");
+MODULE_LICENSE("GPL v2");

This change is wrong.

According to include/linux/module.h "GPL v2" means exactly that: version
2. As the file specifies v2 or later in the header you have to use "GPL" which means v2 or later.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#6 lore raw

Re: [PATCH] power: reset: qnap-poweroff: Fix License String

Quoted 20 lines · Uwe Kleine-K?nig
Quoted 12 lines · Andrew Lunn

GPLv2+ is not a valid license string. Replace it with one that is.

---
 drivers/power/reset/qnap-poweroff.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/reset/qnap-poweroff.c +0 -0
index ca0b476..8af772b 100644

drivers/power/reset/qnap-poweroff.c module_platform_driver(qnap_power_off_driver); · line 124

Quoted 5 lines
drivers/power/reset/qnap-poweroff.c +1 -1
@@ -121,4 +121,4 @@ module_platform_driver(qnap_power_off_driver);
 
 MODULE_AUTHOR("Andrew Lunn <[email protected]>");
 MODULE_DESCRIPTION("QNAP Power off driver");
-MODULE_LICENSE("GPLv2+");
+MODULE_LICENSE("GPL v2");

This change is wrong.

Quoted 3 lines

According to include/linux/module.h "GPL v2" means exactly that: version
2. As the file specifies v2 or later in the header you have to use "GPL" which means v2 or later.

Does it even make sense to have the two separate things ("GPL v2" and "GPL")?

Suppose there is a global change that modifies a bunch of drivers, some of them are GPLv2+. Now, the author of the global change is submitting it under "GPL v2 only" license, which, by definition, turns any GPLv2+ code into "GPL v2 only", right?

So, changing from GPLv2+ to "GPL v2 only" is OK, but not the other way around.

IANAL, tho.

Anton

p.s. Yes, in this particular driver it also makes sense to remove "or later" words from the header, just to be consistent.

#7 lore raw

Re: [PATCH] power: reset: qnap-poweroff: Fix License String

Hello Anton,

Quoted 21 lines · Anton Vorontsov
Quoted 20 lines · Uwe Kleine-K?nig
Quoted 12 lines · Andrew Lunn

GPLv2+ is not a valid license string. Replace it with one that is.

---
 drivers/power/reset/qnap-poweroff.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/reset/qnap-poweroff.c +0 -0
index ca0b476..8af772b 100644

drivers/power/reset/qnap-poweroff.c module_platform_driver(qnap_power_off_driver); · line 124

Quoted 5 lines
drivers/power/reset/qnap-poweroff.c +1 -1
@@ -121,4 +121,4 @@ module_platform_driver(qnap_power_off_driver);
 
 MODULE_AUTHOR("Andrew Lunn <[email protected]>");
 MODULE_DESCRIPTION("QNAP Power off driver");
-MODULE_LICENSE("GPLv2+");
+MODULE_LICENSE("GPL v2");

This change is wrong.

Quoted 6 lines
Quoted 3 lines

According to include/linux/module.h "GPL v2" means exactly that: version
2. As the file specifies v2 or later in the header you have to use "GPL" which means v2 or later.

Does it even make sense to have the two separate things ("GPL v2" and "GPL")?

Yeah. If you had another OS project that uses GPL-4 you can just copy over a GPL-2+ driver to it, not an GPL-2 driver. So assuming the kernel will stay at GPL-2 forever it doesn't make any difference for the kernel. But other projects might benefit. (And if in the future someone might want to change the kernel to GPL-4, she only needs to contact the GPL-2 authors and can legally change GPL-2+ to GPL-4+.)

Quoted 4 lines

Suppose there is a global change that modifies a bunch of drivers, some of them are GPLv2+. Now, the author of the global change is submitting it under "GPL v2 only" license, which, by definition, turns any GPLv2+ code into "GPL v2 only", right?

See http://yarchive.net/comp/linux/dual_license_bsd_gpl.html for Linus' POV. It's an old mail, but I think it still applies.

Quoted 2 lines

So, changing from GPLv2+ to "GPL v2 only" is OK, but not the other way around.

OK as in (probably) legal. OK as in fair is questionable.

Quoted 1 line

IANAL, tho.

ditto.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#8 lore raw

PATCH 2/4 ARM: Kirkwood: Make use of the QNAP Power off driver.

In reply to Andrew Lunn

Add a node into the DT binding and remove C code.

---
 arch/arm/boot/dts/kirkwood-ts219.dtsi |    5 +++++
 arch/arm/mach-kirkwood/Kconfig        |    1 +
 arch/arm/mach-kirkwood/board-ts219.c  |    3 ---
 3 files changed, 6 insertions(+), 3 deletions(-)
arch/arm/boot/dts/kirkwood-ts219.dtsi +5 -0
index 64ea27c..4e29460 100644
@@ -31,6 +31,11 @@
 			clock-frequency = <200000000>;
 			status = "okay";
 		};
+		poweroff at 12100 {
+			compatible = "qnap,power-off";
+			reg = <0x12000 0x100>;
+			clocks = <&gate_clk 7>;
+		};
 		spi at 10600 {
 			status = "okay";
 
arch/arm/mach-kirkwood/Kconfig +1 -0
index f91cdff..bb4de9c 100644
@@ -92,6 +92,7 @@ config MACH_TS219_DT
 	select ARCH_KIRKWOOD_DT
 	select ARM_APPENDED_DTB
 	select ARM_ATAG_DTB_COMPAT
+	select POWER_RESET_QNAP
 	help
 	  Say 'Y' here if you want your kernel to support the QNAP
 	  TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and
arch/arm/mach-kirkwood/board-ts219.c +0 -3
index acb0187..10fb397 100644
@@ -23,7 +23,6 @@
 #include <asm/mach/arch.h>
 #include <mach/kirkwood.h>
 #include "common.h"
-#include "tsx1x-common.h"
 
 static struct mv643xx_eth_platform_data qnap_ts219_ge00_data = {
 	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
@@ -38,8 +37,6 @@ void __init qnap_dt_ts219_init(void)
 		qnap_ts219_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
 
 	kirkwood_ge00_init(&qnap_ts219_ge00_data);
-
-	pm_power_off = qnap_tsx1x_power_off;
 }
 
 /* FIXME: Will not work with DT. Maybe use MPP40_GPIO? */
Signature · 1 line
1.7.10.4
#9 lore raw

PATCH 3/4 Power: Reset: Power off by restarting

In reply to Andrew Lunn

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.

---
 .../bindings/power_supply/restart-poweroff.txt     |    9 +++
 drivers/power/reset/Kconfig                        |    8 +++
 drivers/power/reset/Makefile                       |    1 +
 drivers/power/reset/restart-poweroff.c             |   67 ++++++++++++++++++++
 4 files changed, 85 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power_supply/restart-poweroff.txt
 create mode 100644 drivers/power/reset/restart-poweroff.c
Documentation/devicetree/bindings/power_supply/restart-poweroff.txt new file +9 -0
new file mode 100644
index 0000000..e4f1660
@@ -0,0 +1,9 @@
+* 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"
+
drivers/power/reset/Kconfig +8 -0
index 6453aac..1ae65b8 100644
@@ -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.
drivers/power/reset/Makefile +1 -0
index c4d3b2d..0f317f5 100644
@@ -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
\ No newline at end of file
drivers/power/reset/restart-poweroff.c new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#10 lore raw

PATCH 3/4 Power: Reset: Power off by restarting

Am Freitag 28 Dezember 2012, 13:25:11 schrieb Andrew Lunn:

Quoted 82 lines

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.

---
 .../bindings/power_supply/restart-poweroff.txt     |    9 +++
 drivers/power/reset/Kconfig                        |    8 +++
 drivers/power/reset/Makefile                       |    1 +
 drivers/power/reset/restart-poweroff.c             |   67
++++++++++++++++++++ 4 files changed, 85 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/power_supply/restart-poweroff.txt create mode 100644 drivers/power/reset/restart-poweroff.c

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 0000000..e4f1660

Documentation/devicetree/bindings/power_supply/restart-poweroff.txt new file +9 -0
@@ -0,0 +1,9 @@
+* 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"
+
drivers/power/reset/Kconfig +8 -0
index 6453aac..1ae65b8 100644
@@ -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.
drivers/power/reset/Makefile +1 -0
index c4d3b2d..0f317f5 100644
@@ -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
\ No newline at end of file
(quoted diff) +0 -0

b/drivers/power/reset/restart-poweroff.c new file mode 100644 index 0000000..79b1a2e

drivers/power/reset/restart-poweroff.c new file +18 -0
@@ -0,0 +1,67 @@
+/*
+ * Power off by restarting and let u-boot keep hold of the machine
+ * until the user presses a button for example.
+ *
+ * Andrew Lunn <[email protected]>
+ *
+ * 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 <asm/system_misc.h>
+#include <linux/of_platform.h>

drivers/power/reset/restart-poweroff.c line 28

Quoted 10 lines
drivers/power/reset/restart-poweroff.c new file +10 -0
+#include <linux/module.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 

*/

Quoted 29 lines
drivers/power/reset/restart-poweroff.c new file +29 -0
+	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,

drivers/power/reset/restart-poweroff.c line 67

Quoted 10 lines
drivers/power/reset/restart-poweroff.c new file +10 -0
+		   .of_match_table = of_restart_poweroff_match,
+		   },
+};
+
+module_platform_driver(restart_poweroff_driver);
+
+MODULE_AUTHOR("Andrew Lunn <[email protected]");
+MODULE_DESCRIPTION("restart poweroff driver");
+MODULE_LICENSE("GPLv2");
+MODULE_ALIAS("platform:poweroff-restart");
#11 lore raw

PATCH 3/4 Power: Reset: Power off by restarting

Quoted 7 lines · Michael Walle

Am Freitag 28 Dezember 2012, 13:25:11 schrieb Andrew Lunn:

Quoted 6 lines

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.

[...]

Quoted 1 line

Applied (with a small cosmetic cleanups), thanks a lot!

Note that I can also take the ARM patches together with the drivers (and it would make sense to keep things bisectable). Should I?

Thanks,
Anton

#12 lore raw

PATCH 3/4 Power: Reset: Power off by restarting

Quoted 7 lines · Anton Vorontsov
Quoted 6 lines · Michael Walle

Am Freitag 28 Dezember 2012, 13:25:11 schrieb Andrew Lunn:

Quoted 5 lines

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.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

[...]

Quoted 1 line

Applied (with a small cosmetic cleanups), thanks a lot!

Note that I can also take the ARM patches together with the drivers (and it would make sense to keep things bisectable). Should I?

Hi Anton

Do you have a stable branch containing these patches? There are likely to be some remove/remove conflicts with the ARM patches, which we can avoid if you have a stable branch we can merge.

Thanks
Andrew

#13 lore raw

PATCH 3/4 Power: Reset: Power off by restarting

Quoted 12 lines · Andrew Lunn
Quoted 11 lines · Anton Vorontsov
Quoted 7 lines · Michael Walle

Am Freitag 28 Dezember 2012, 13:25:11 schrieb Andrew Lunn:

Quoted 6 lines

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.

[...]

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

Applied (with a small cosmetic cleanups), thanks a lot!

Note that I can also take the ARM patches together with the drivers (and it would make sense to keep things bisectable). Should I?

Hi Anton

Do you have a stable branch containing these patches?

Stable as in 'I don't rebase it'? Yes, I tend to not rebase the battery tree. It is here:

git://git.infradead.org/battery-2.6.git master

You can find the applied patches there.

Thanks,
Anton

#14 lore raw

PATCH 3/4 Power: Reset: Power off by restarting

In reply to Anton Vorontsov
Quoted 7 lines · Anton Vorontsov
Quoted 6 lines · Michael Walle

Am Freitag 28 Dezember 2012, 13:25:11 schrieb Andrew Lunn:

Quoted 5 lines

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.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

[...]

Quoted 1 line

Applied (with a small cosmetic cleanups), thanks a lot!

Note that I can also take the ARM patches together with the drivers (and it would make sense to keep things bisectable). Should I?

Please take patches 1 and 3 of this series (which it looks like you have). I'll take 2 and 4 and list your stable tree as a dependency.

thx,

Jason.

#15 lore raw

PATCH 1/1 power/reset: restart: remove __dev{init,exit}

In reply to Anton Vorontsov
---
 drivers/power/reset/restart-poweroff.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/power/reset/restart-poweroff.c +3 -3
index b11b9e8..059cd15 100644
@@ -22,7 +22,7 @@ static void restart_poweroff_do_poweroff(void)
 	arm_pm_restart('h', NULL);
 }
 
-static int __devinit restart_poweroff_probe(struct platform_device *pdev)
+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) {
@@ -35,7 +35,7 @@ static int __devinit restart_poweroff_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __devexit restart_poweroff_remove(struct platform_device *pdev)
+static int restart_poweroff_remove(struct platform_device *pdev)
 {
 	if (pm_power_off == &restart_poweroff_do_poweroff)
 		pm_power_off = NULL;
@@ -50,7 +50,7 @@ static const struct of_device_id of_restart_poweroff_match[] = {
 
 static struct platform_driver restart_poweroff_driver = {
 	.probe = restart_poweroff_probe,
-	.remove = __devexit_p(restart_poweroff_remove),
+	.remove = restart_poweroff_remove,
 	.driver = {
 		.name = "poweroff-restart",
 		.owner = THIS_MODULE,
Signature · 1 line
1.8.1.1
#16 lore raw

PATCH 1/1 power/reset: restart: remove __dev{init,exit}

Anton,

I forgot to mention, this fixes a build breakage on battery/master.

thx,

Jason.

Quoted 39 lines · Jason Cooper
---
 drivers/power/reset/restart-poweroff.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/power/reset/restart-poweroff.c +3 -3
index b11b9e8..059cd15 100644
@@ -22,7 +22,7 @@ static void restart_poweroff_do_poweroff(void)
 	arm_pm_restart('h', NULL);
 }
 
-static int __devinit restart_poweroff_probe(struct platform_device *pdev)
+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) {
@@ -35,7 +35,7 @@ static int __devinit restart_poweroff_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __devexit restart_poweroff_remove(struct platform_device *pdev)
+static int restart_poweroff_remove(struct platform_device *pdev)
 {
 	if (pm_power_off == &restart_poweroff_do_poweroff)
 		pm_power_off = NULL;
@@ -50,7 +50,7 @@ static const struct of_device_id of_restart_poweroff_match[] = {
 
 static struct platform_driver restart_poweroff_driver = {
 	.probe = restart_poweroff_probe,
-	.remove = __devexit_p(restart_poweroff_remove),
+	.remove = restart_poweroff_remove,
 	.driver = {
 		.name = "poweroff-restart",
 		.owner = THIS_MODULE,
Signature · 1 line
1.8.1.1
#17 lore raw

PATCH 1/1 power/reset: restart: remove __dev{init,exit}

In reply to Jason Cooper
Quoted 1 line · Jason Cooper

Hi Jason

I Acked-by: a very similar patch to this yesterday....

https://lkml.org/lkml/2013/1/30/233

Andrew

Quoted 38 lines
---
 drivers/power/reset/restart-poweroff.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/power/reset/restart-poweroff.c +3 -3
index b11b9e8..059cd15 100644
@@ -22,7 +22,7 @@ static void restart_poweroff_do_poweroff(void)
 	arm_pm_restart('h', NULL);
 }
 
-static int __devinit restart_poweroff_probe(struct platform_device *pdev)
+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) {
@@ -35,7 +35,7 @@ static int __devinit restart_poweroff_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __devexit restart_poweroff_remove(struct platform_device *pdev)
+static int restart_poweroff_remove(struct platform_device *pdev)
 {
 	if (pm_power_off == &restart_poweroff_do_poweroff)
 		pm_power_off = NULL;
@@ -50,7 +50,7 @@ static const struct of_device_id of_restart_poweroff_match[] = {
 
 static struct platform_driver restart_poweroff_driver = {
 	.probe = restart_poweroff_probe,
-	.remove = __devexit_p(restart_poweroff_remove),
+	.remove = restart_poweroff_remove,
 	.driver = {
 		.name = "poweroff-restart",
 		.owner = THIS_MODULE,
Signature · 1 line
1.8.1.1
#18 lore raw

PATCH 1/1 power/reset: restart: remove __dev{init,exit}

Quoted 8 lines · Andrew Lunn
Quoted 1 line · Jason Cooper

Hi Jason

I Acked-by: a very similar patch to this yesterday....

https://lkml.org/lkml/2013/1/30/233

Hmm, I need to read more carefully. My auto-flagging script didn't catch it because it didn't have any of the mvebu/kirkwood/dove/orion keywords in it :-(

Sorry for the noise.

thx,

Jason.

#20 lore raw

PATCH 4/4 ARM: Kirkwood: Convert LSXL to restart-poweroff driver.

In reply to Andrew Lunn

Add a device tree node and remove the C code.

---
 arch/arm/boot/dts/kirkwood-lsxl.dtsi |    4 ++++
 arch/arm/mach-kirkwood/Kconfig       |    1 +
 arch/arm/mach-kirkwood/board-lsxl.c  |   16 ----------------
 3 files changed, 5 insertions(+), 16 deletions(-)
arch/arm/boot/dts/kirkwood-lsxl.dtsi +4 -0
index 37d45c4..996c7fe 100644
@@ -172,6 +172,10 @@
 		alarm-gpios = <&gpio1 8 0>;
 	};
 
+	restart_poweroff {
+		compatible = "restart-poweroff";
+	};
+
 	regulators {
 		compatible = "simple-bus";
 		#address-cells = <1>;
arch/arm/mach-kirkwood/Kconfig +1 -0
index bb4de9c..432bee0 100644
@@ -119,6 +119,7 @@ config MACH_GOFLEXNET_DT
 config MACH_LSXL_DT
 	bool "Buffalo Linkstation LS-XHL, LS-CHLv2 (Flattened Device Tree)"
 	select ARCH_KIRKWOOD_DT
+	select POWER_RESET_RESTART
 	help
 	  Say 'Y' here if you want your kernel to support the
 	  Buffalo Linkstation LS-XHL & LS-CHLv2 devices, using
arch/arm/mach-kirkwood/board-lsxl.c +0 -16
index 4ec8b7a..3483952 100644
@@ -25,19 +25,6 @@ static struct mv643xx_eth_platform_data lsxl_ge01_data = {
 	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
 };
 
-/*
- * On the LS-XHL/LS-CHLv2, the shutdown process is following:
- * - Userland monitors key events until the power switch goes to off position
- * - The board reboots
- * - U-boot starts and goes into an idle mode waiting for the user
- *   to move the switch to ON position
- *
- */
-static void lsxl_power_off(void)
-{
-	kirkwood_restart('h', NULL);
-}
-
 void __init lsxl_init(void)
 {
 	/*
@@ -46,7 +33,4 @@ void __init lsxl_init(void)
 
 	kirkwood_ge00_init(&lsxl_ge00_data);
 	kirkwood_ge01_init(&lsxl_ge01_data);
-
-	/* register power-off method */
-	pm_power_off = lsxl_power_off;
 }
Signature · 1 line
1.7.10.4
#21 lore raw

PATCH 4/4 ARM: Kirkwood: Convert LSXL to restart-poweroff driver.

Am Freitag 28 Dezember 2012, 13:25:12 schrieb Andrew Lunn:

Quoted 61 lines

Add a device tree node and remove the C code.

---
 arch/arm/boot/dts/kirkwood-lsxl.dtsi |    4 ++++
 arch/arm/mach-kirkwood/Kconfig       |    1 +
 arch/arm/mach-kirkwood/board-lsxl.c  |   16 ----------------
 3 files changed, 5 insertions(+), 16 deletions(-)
(quoted diff) +0 -0

b/arch/arm/boot/dts/kirkwood-lsxl.dtsi index 37d45c4..996c7fe 100644

arch/arm/boot/dts/kirkwood-lsxl.dtsi +4 -0
@@ -172,6 +172,10 @@
 		alarm-gpios = <&gpio1 8 0>;
 	};
 
+	restart_poweroff {
+		compatible = "restart-poweroff";
+	};
+
 	regulators {
 		compatible = "simple-bus";
 		#address-cells = <1>;
(quoted diff) +0 -0

b/arch/arm/mach-kirkwood/Kconfig index bb4de9c..432bee0 100644

arch/arm/mach-kirkwood/Kconfig +1 -0
@@ -119,6 +119,7 @@ config MACH_GOFLEXNET_DT
 config MACH_LSXL_DT
 	bool "Buffalo Linkstation LS-XHL, LS-CHLv2 (Flattened Device Tree)"
 	select ARCH_KIRKWOOD_DT
+	select POWER_RESET_RESTART
 	help
 	  Say 'Y' here if you want your kernel to support the
 	  Buffalo Linkstation LS-XHL & LS-CHLv2 devices, using
(quoted diff) +0 -0

b/arch/arm/mach-kirkwood/board-lsxl.c index 4ec8b7a..3483952 100644

arch/arm/mach-kirkwood/board-lsxl.c +0 -3
@@ -25,19 +25,6 @@ static struct mv643xx_eth_platform_data lsxl_ge01_data =
 { .phy_addr	= MV643XX_ETH_PHY_ADDR(8),
 };
 
-/*
- * On the LS-XHL/LS-CHLv2, the shutdown process is following:
- * - Userland monitors key events until the power switch goes to off

position - * - The board reboots
- * - U-boot starts and goes into an idle mode waiting for the user
- * to move the switch to ON position
- *
- */

arch/arm/mach-kirkwood/board-lsxl.c +0 -5
-static void lsxl_power_off(void)
-{
-	kirkwood_restart('h', NULL);
-}
-
 void __init lsxl_init(void)
 {
 	/*

arch/arm/mach-kirkwood/board-lsxl.c void __init lsxl_init(void) · line 36

Quoted 7 lines
arch/arm/mach-kirkwood/board-lsxl.c +0 -3
@@ -46,7 +33,4 @@ void __init lsxl_init(void)
 
 	kirkwood_ge00_init(&lsxl_ge00_data);
 	kirkwood_ge01_init(&lsxl_ge01_data);
-
-	/* register power-off method */
-	pm_power_off = lsxl_power_off;
 }

Sort of, device_shutdown() is blocking on my board (seems to be some kind of issue with orion-ehci), but that has nothing to do with this patch :)

#23 lore raw

PATCH 4/4 ARM: Kirkwood: Convert LSXL to restart-poweroff driver.

Am Freitag 28 Dezember 2012, 20:39:05 schrieb Andrew Lunn:

Quoted 6 lines
Quoted 1 line

Hi Michael

Thanks for testing.

Quoted 8 lines
Quoted 2 lines

Sort of, device_shutdown() is blocking on my board (seems to be some kind of issue with orion-ehci), but that has nothing to do with this patch :)

Have you tried the USB clock fix:

http://www.spinics.net/lists/arm-kernel/msg213741.html

Andrew

ah thanks, that fixed it.

Signature · 1 line
Michael
#24 lore raw

cover Power off drivers for QNAP and LSXL.

In reply to Andrew Lunn
Quoted 27 lines · Andrew Lunn

This patchset contains two power off driver, moving existing code out of mach-kirkwood into drivers/power/reset.

QNAP NAS boards have a microcontroller connected to a UART. Sending the command to it turns the power off. There are Orion5x QNAP boards which can later use this driver, once they are converted to DT.

Kirkwood Buffalo Linkstation LSXL devices power off by restarting and letting the boot loader idle until the user hits a switch. There are again Orion5x devices which could use this driver in the future, once they are converted to DT. It also looks like some PXA devices could use it.

Patches #1 and #3 are the drivers, and #2 and #4 make use of the driver, removing C code and adding DT nodes.

The QNAP driver has been tested on a QNAP TS119+. The LSXL driver is currently untested.

git://github.com/lunn/linux.git v3.8-rc1-qnap-poweroff

Andrew Lunn (4):
Power: Reset: Driver to turn QNAP board power off.
ARM: Kirkwood: Make use of the QNAP Power off driver.
Power: Reset: Power off by restarting
ARM: Kirkwood: Convert LSXL to restart-poweroff driver.

Quoted 16 lines
 .../bindings/power_supply/qnap-poweroff.txt        |   14 +++
 .../bindings/power_supply/restart-poweroff.txt     |    9 ++
 arch/arm/boot/dts/kirkwood-lsxl.dtsi               |    4 +
 arch/arm/boot/dts/kirkwood-ts219.dtsi              |    5 +
 arch/arm/mach-kirkwood/Kconfig                     |    2 +
 arch/arm/mach-kirkwood/board-lsxl.c                |   16 ---
 arch/arm/mach-kirkwood/board-ts219.c               |    3 -
 drivers/power/reset/Kconfig                        |   17 +++
 drivers/power/reset/Makefile                       |    2 +
 drivers/power/reset/qnap-poweroff.c                |  124 ++++++++++++++++++++
 drivers/power/reset/restart-poweroff.c             |   67 +++++++++++
 11 files changed, 244 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt
 create mode 100644 Documentation/devicetree/bindings/power_supply/restart-poweroff.txt
 create mode 100644 drivers/power/reset/qnap-poweroff.c
 create mode 100644 drivers/power/reset/restart-poweroff.c

patches 2 and 4 applied to mvebu/dt with a dependency on:

git://git.infradead.org/battery-2.6.git master

up to:

ffd8f9a power/reset: Add a new driver implementing 'power off by restarting'

in order to pull in patches 1 and 3:

ffd8f9a power/reset: Add a new driver implementing 'power off by restarting' e8fc721 power/reset: Add a new driver to turn QNAP board power off

thx,

Jason.

#25 lore raw

cover Power off drivers for QNAP and LSXL.

Quoted 49 lines · Jason Cooper
Quoted 27 lines · Andrew Lunn

This patchset contains two power off driver, moving existing code out of mach-kirkwood into drivers/power/reset.

QNAP NAS boards have a microcontroller connected to a UART. Sending the command to it turns the power off. There are Orion5x QNAP boards which can later use this driver, once they are converted to DT.

Kirkwood Buffalo Linkstation LSXL devices power off by restarting and letting the boot loader idle until the user hits a switch. There are again Orion5x devices which could use this driver in the future, once they are converted to DT. It also looks like some PXA devices could use it.

Patches #1 and #3 are the drivers, and #2 and #4 make use of the driver, removing C code and adding DT nodes.

The QNAP driver has been tested on a QNAP TS119+. The LSXL driver is currently untested.

git://github.com/lunn/linux.git v3.8-rc1-qnap-poweroff

Andrew Lunn (4):
Power: Reset: Driver to turn QNAP board power off.
ARM: Kirkwood: Make use of the QNAP Power off driver.
Power: Reset: Power off by restarting
ARM: Kirkwood: Convert LSXL to restart-poweroff driver.

Quoted 16 lines
 .../bindings/power_supply/qnap-poweroff.txt        |   14 +++
 .../bindings/power_supply/restart-poweroff.txt     |    9 ++
 arch/arm/boot/dts/kirkwood-lsxl.dtsi               |    4 +
 arch/arm/boot/dts/kirkwood-ts219.dtsi              |    5 +
 arch/arm/mach-kirkwood/Kconfig                     |    2 +
 arch/arm/mach-kirkwood/board-lsxl.c                |   16 ---
 arch/arm/mach-kirkwood/board-ts219.c               |    3 -
 drivers/power/reset/Kconfig                        |   17 +++
 drivers/power/reset/Makefile                       |    2 +
 drivers/power/reset/qnap-poweroff.c                |  124 ++++++++++++++++++++
 drivers/power/reset/restart-poweroff.c             |   67 +++++++++++
 11 files changed, 244 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt
 create mode 100644 Documentation/devicetree/bindings/power_supply/restart-poweroff.txt
 create mode 100644 drivers/power/reset/qnap-poweroff.c
 create mode 100644 drivers/power/reset/restart-poweroff.c

patches 2 and 4 applied to mvebu/dt with a dependency on:

git://git.infradead.org/battery-2.6.git master

Quoted 8 lines

up to:

ffd8f9a power/reset: Add a new driver implementing 'power off by restarting'

in order to pull in patches 1 and 3:

ffd8f9a power/reset: Add a new driver implementing 'power off by restarting' e8fc721 power/reset: Add a new driver to turn QNAP board power off

Yeah.... So thanks to Andrew for bringing this to my attention. Somewhere along the line, I must've dropped patches 2 and 4.

Thankfully, patches 1 and 3 made it in, so I've just applied 2 and 4 to mvebu/boards.

thx, and sorry for the delay.

Jason.