All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] GPIO driver to turn power off
@ 2012-11-13 15:44 ` Andrew Lunn
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-13 15:44 UTC (permalink / raw)
  To: anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A
  Cc: Andrew Lunn, gmbnomis-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM, Jason Cooper

A few of the Kirkwood systems use a GPIO line to turn the power off on
shutdown. They request the GPIO line in the board setup code,
optionally setting it as an output and driving it inactive. They then
register a function for pm_power_off. At the end of the shutdown, this
function is called. The GPIO line is configured as an output, if not
already so, and then driven active. In order to cover the use case of
edges rather then levels, triggering power off, the GPIO line is then
toggled active and later inactive. This should allow the driver to be
used by PXA which also has boards using the same scheme.

The driver code was initially developed by Jamie Lentin and extended
to cover the PXA case by Andrew Lunn.

v1 -> v2: Moved to drivers/power/reset

Andrew Lunn (2):
  ARM: Kirkwood: Convert DNSKW to use gpio-poweroff.
  ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.

Jamie Lentin (1):
  power: Add simple poweroff-gpio driver

 .../devicetree/bindings/gpio/gpio-poweroff.txt     |   22 ++++
 arch/arm/boot/dts/kirkwood-dnskw.dtsi              |    5 +
 arch/arm/boot/dts/kirkwood-ib62x0.dts              |    6 +
 arch/arm/mach-kirkwood/Kconfig                     |    4 +
 arch/arm/mach-kirkwood/board-dnskw.c               |   12 --
 arch/arm/mach-kirkwood/board-ib62x0.c              |   13 --
 drivers/power/Kconfig                              |    3 +
 drivers/power/Makefile                             |    1 +
 drivers/power/reset/Kconfig                        |   15 +++
 drivers/power/reset/Makefile                       |    1 +
 drivers/power/reset/gpio-poweroff.c                |  129 ++++++++++++++++++++
 11 files changed, 186 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
 create mode 100644 drivers/power/reset/Kconfig
 create mode 100644 drivers/power/reset/Makefile
 create mode 100644 drivers/power/reset/gpio-poweroff.c

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 0/3] GPIO driver to turn power off
@ 2012-11-13 15:44 ` Andrew Lunn
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-13 15:44 UTC (permalink / raw)
  To: linux-arm-kernel

A few of the Kirkwood systems use a GPIO line to turn the power off on
shutdown. They request the GPIO line in the board setup code,
optionally setting it as an output and driving it inactive. They then
register a function for pm_power_off. At the end of the shutdown, this
function is called. The GPIO line is configured as an output, if not
already so, and then driven active. In order to cover the use case of
edges rather then levels, triggering power off, the GPIO line is then
toggled active and later inactive. This should allow the driver to be
used by PXA which also has boards using the same scheme.

The driver code was initially developed by Jamie Lentin and extended
to cover the PXA case by Andrew Lunn.

v1 -> v2: Moved to drivers/power/reset

Andrew Lunn (2):
  ARM: Kirkwood: Convert DNSKW to use gpio-poweroff.
  ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.

Jamie Lentin (1):
  power: Add simple poweroff-gpio driver

 .../devicetree/bindings/gpio/gpio-poweroff.txt     |   22 ++++
 arch/arm/boot/dts/kirkwood-dnskw.dtsi              |    5 +
 arch/arm/boot/dts/kirkwood-ib62x0.dts              |    6 +
 arch/arm/mach-kirkwood/Kconfig                     |    4 +
 arch/arm/mach-kirkwood/board-dnskw.c               |   12 --
 arch/arm/mach-kirkwood/board-ib62x0.c              |   13 --
 drivers/power/Kconfig                              |    3 +
 drivers/power/Makefile                             |    1 +
 drivers/power/reset/Kconfig                        |   15 +++
 drivers/power/reset/Makefile                       |    1 +
 drivers/power/reset/gpio-poweroff.c                |  129 ++++++++++++++++++++
 11 files changed, 186 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
 create mode 100644 drivers/power/reset/Kconfig
 create mode 100644 drivers/power/reset/Makefile
 create mode 100644 drivers/power/reset/gpio-poweroff.c

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 1/3] power: Add simple poweroff-gpio driver
  2012-11-13 15:44 ` Andrew Lunn
@ 2012-11-13 15:44     ` Andrew Lunn
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-13 15:44 UTC (permalink / raw)
  To: anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A
  Cc: Andrew Lunn, gmbnomis-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM, Jason Cooper

From: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>

Given appropriate devicetree bindings, this driver registers a
pm_power_off function to set a GPIO line high/low to power down
your board.

Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
Signed-off-by: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
---
 .../devicetree/bindings/gpio/gpio-poweroff.txt     |   22 ++++
 drivers/power/Kconfig                              |    3 +
 drivers/power/Makefile                             |    1 +
 drivers/power/reset/Kconfig                        |   15 +++
 drivers/power/reset/Makefile                       |    1 +
 drivers/power/reset/gpio-poweroff.c                |  129 ++++++++++++++++++++
 6 files changed, 171 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
 create mode 100644 drivers/power/reset/Kconfig
 create mode 100644 drivers/power/reset/Makefile
 create mode 100644 drivers/power/reset/gpio-poweroff.c

diff --git a/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt b/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
new file mode 100644
index 0000000..558cdf3
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
@@ -0,0 +1,22 @@
+GPIO line that should be set high/low to power off a device
+
+Required properties:
+- compatible : should be "gpio-poweroff".
+- gpios : The GPIO to set high/low, see "gpios property" in
+  Documentation/devicetree/bindings/gpio/gpio.txt. If the pin should be
+  low to power down the board set it to "Active Low", otherwise set
+  gpio to "Active High".
+
+Optional properties:
+- input : Initially configure the GPIO line as an input. Only reconfigure
+  it to an output when the pm_power_off function is called. If this optional
+  property is not specified, the GPIO is initialized as an output in its
+  inactive state.
+
+
+Examples:
+
+gpio-poweroff {
+	compatible = "gpio-poweroff";
+	gpios = <&gpio 4 0>; /* GPIO 4 Active Low */
+};
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 49a8939..b1d956d 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -335,6 +335,9 @@ config AB8500_BATTERY_THERM_ON_BATCTRL
 	help
 	  Say Y to enable battery temperature measurements using
 	  thermistor connected on BATCTRL ADC.
+
+source "drivers/power/reset/Kconfig"
+
 endif # POWER_SUPPLY
 
 source "drivers/power/avs/Kconfig"
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b949cf8..f1d99f4 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -49,3 +49,4 @@ obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
 obj-$(CONFIG_POWER_AVS)		+= avs/
 obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
+obj-$(CONFIG_POWER_RESET)	+= reset/
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
new file mode 100644
index 0000000..6461b48
--- /dev/null
+++ b/drivers/power/reset/Kconfig
@@ -0,0 +1,15 @@
+menuconfig POWER_RESET
+	bool "Board level reset or power off"
+	help
+	  Provides a number of drivers which either reset a complete board
+	  or shut it down, by manipulating the main power supply on the board.
+
+	  Say Y here to enable board reset and power off
+
+config POWER_RESET_GPIO
+	bool "GPIO power-off driver"
+	depends on OF_GPIO && POWER_RESET
+	help
+	  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.
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
new file mode 100644
index 0000000..751488a
--- /dev/null
+++ b/drivers/power/reset/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
new file mode 100644
index 0000000..101ad57
--- /dev/null
+++ b/drivers/power/reset/gpio-poweroff.c
@@ -0,0 +1,129 @@
+/*
+ * Toggles a GPIO pin to power down a device
+ *
+ * Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
+ * Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
+ *
+ * Copyright (C) 2012 Jamie Lentin
+ *
+ * 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/delay.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/of_platform.h>
+#include <linux/of_gpio.h>
+#include <linux/module.h>
+
+/*
+ * Hold configuration here, cannot be more than one instance of the driver
+ * since pm_power_off itself is global.
+ */
+static int gpio_num = -1;
+static int gpio_active_low;
+
+static void gpio_poweroff_do_poweroff(void)
+{
+	BUG_ON(gpio_num == -1);
+
+	/* drive it active */
+	gpio_direction_output(gpio_num, !gpio_active_low);
+	mdelay(100);
+	/* rising edge or drive inactive */
+	gpio_set_value(gpio_num, gpio_active_low);
+	mdelay(100);
+	/* falling edge */
+	gpio_set_value(gpio_num, !gpio_active_low);
+
+	/* give it some time */
+	mdelay(100);
+
+	WARN_ON(1);
+}
+
+static int __devinit gpio_poweroff_probe(struct platform_device *pdev)
+{
+	enum of_gpio_flags flags;
+	bool input = false;
+	int ret;
+
+	/* If a pm_power_off function has already been added, leave it alone */
+	if (pm_power_off != NULL) {
+		pr_err("%s: pm_power_off function already registered",
+		       __func__);
+		return -EBUSY;
+	}
+
+	gpio_num = of_get_gpio_flags(pdev->dev.of_node, 0, &flags);
+	if (gpio_num < 0) {
+		pr_err("%s: Could not get GPIO configuration: %d",
+		       __func__, gpio_num);
+		return -ENODEV;
+	}
+	gpio_active_low = flags & OF_GPIO_ACTIVE_LOW;
+
+	if (of_get_property(pdev->dev.of_node, "input", NULL))
+		input = true;
+
+	ret = gpio_request(gpio_num, "poweroff-gpio");
+	if (ret) {
+		pr_err("%s: Could not get GPIO %d", __func__, gpio_num);
+		return ret;
+	}
+	if (input) {
+		if (gpio_direction_input(gpio_num)) {
+			pr_err("Could not set direction of GPIO %d to input",
+			       gpio_num);
+			goto err;
+		}
+	} else {
+		if (gpio_direction_output(gpio_num, gpio_active_low)) {
+			pr_err("Could not set direction of GPIO %d", gpio_num);
+			goto err;
+		}
+	}
+
+	pm_power_off = &gpio_poweroff_do_poweroff;
+	return 0;
+
+err:
+	gpio_free(gpio_num);
+	return -ENODEV;
+}
+
+static int __devexit gpio_poweroff_remove(struct platform_device *pdev)
+{
+	if (gpio_num != -1)
+		gpio_free(gpio_num);
+	if (pm_power_off == &gpio_poweroff_do_poweroff)
+		pm_power_off = NULL;
+
+	return 0;
+}
+
+static const struct of_device_id of_gpio_poweroff_match[] = {
+	{ .compatible = "gpio-poweroff", },
+	{},
+};
+
+static struct platform_driver gpio_poweroff_driver = {
+	.probe = gpio_poweroff_probe,
+	.remove = __devexit_p(gpio_poweroff_remove),
+	.driver = {
+		   .name = "poweroff-gpio",
+		   .owner = THIS_MODULE,
+		   .of_match_table = of_gpio_poweroff_match,
+		   },
+};
+
+module_platform_driver(gpio_poweroff_driver);
+
+MODULE_AUTHOR("Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>");
+MODULE_DESCRIPTION("GPIO poweroff driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:poweroff-gpio");
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 1/3] power: Add simple poweroff-gpio driver
@ 2012-11-13 15:44     ` Andrew Lunn
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-13 15:44 UTC (permalink / raw)
  To: linux-arm-kernel

From: Jamie Lentin <jm@lentin.co.uk>

Given appropriate devicetree bindings, this driver registers a
pm_power_off function to set a GPIO line high/low to power down
your board.

Signed-off-by: Jamie Lentin <jm@lentin.co.uk>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 .../devicetree/bindings/gpio/gpio-poweroff.txt     |   22 ++++
 drivers/power/Kconfig                              |    3 +
 drivers/power/Makefile                             |    1 +
 drivers/power/reset/Kconfig                        |   15 +++
 drivers/power/reset/Makefile                       |    1 +
 drivers/power/reset/gpio-poweroff.c                |  129 ++++++++++++++++++++
 6 files changed, 171 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
 create mode 100644 drivers/power/reset/Kconfig
 create mode 100644 drivers/power/reset/Makefile
 create mode 100644 drivers/power/reset/gpio-poweroff.c

diff --git a/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt b/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
new file mode 100644
index 0000000..558cdf3
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
@@ -0,0 +1,22 @@
+GPIO line that should be set high/low to power off a device
+
+Required properties:
+- compatible : should be "gpio-poweroff".
+- gpios : The GPIO to set high/low, see "gpios property" in
+  Documentation/devicetree/bindings/gpio/gpio.txt. If the pin should be
+  low to power down the board set it to "Active Low", otherwise set
+  gpio to "Active High".
+
+Optional properties:
+- input : Initially configure the GPIO line as an input. Only reconfigure
+  it to an output when the pm_power_off function is called. If this optional
+  property is not specified, the GPIO is initialized as an output in its
+  inactive state.
+
+
+Examples:
+
+gpio-poweroff {
+	compatible = "gpio-poweroff";
+	gpios = <&gpio 4 0>; /* GPIO 4 Active Low */
+};
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 49a8939..b1d956d 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -335,6 +335,9 @@ config AB8500_BATTERY_THERM_ON_BATCTRL
 	help
 	  Say Y to enable battery temperature measurements using
 	  thermistor connected on BATCTRL ADC.
+
+source "drivers/power/reset/Kconfig"
+
 endif # POWER_SUPPLY
 
 source "drivers/power/avs/Kconfig"
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b949cf8..f1d99f4 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -49,3 +49,4 @@ obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
 obj-$(CONFIG_POWER_AVS)		+= avs/
 obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
+obj-$(CONFIG_POWER_RESET)	+= reset/
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
new file mode 100644
index 0000000..6461b48
--- /dev/null
+++ b/drivers/power/reset/Kconfig
@@ -0,0 +1,15 @@
+menuconfig POWER_RESET
+	bool "Board level reset or power off"
+	help
+	  Provides a number of drivers which either reset a complete board
+	  or shut it down, by manipulating the main power supply on the board.
+
+	  Say Y here to enable board reset and power off
+
+config POWER_RESET_GPIO
+	bool "GPIO power-off driver"
+	depends on OF_GPIO && POWER_RESET
+	help
+	  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.
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
new file mode 100644
index 0000000..751488a
--- /dev/null
+++ b/drivers/power/reset/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
new file mode 100644
index 0000000..101ad57
--- /dev/null
+++ b/drivers/power/reset/gpio-poweroff.c
@@ -0,0 +1,129 @@
+/*
+ * Toggles a GPIO pin to power down a device
+ *
+ * Jamie Lentin <jm@lentin.co.uk>
+ * Andrew Lunn <andrew@lunn.ch>
+ *
+ * Copyright (C) 2012 Jamie Lentin
+ *
+ * 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/delay.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/of_platform.h>
+#include <linux/of_gpio.h>
+#include <linux/module.h>
+
+/*
+ * Hold configuration here, cannot be more than one instance of the driver
+ * since pm_power_off itself is global.
+ */
+static int gpio_num = -1;
+static int gpio_active_low;
+
+static void gpio_poweroff_do_poweroff(void)
+{
+	BUG_ON(gpio_num == -1);
+
+	/* drive it active */
+	gpio_direction_output(gpio_num, !gpio_active_low);
+	mdelay(100);
+	/* rising edge or drive inactive */
+	gpio_set_value(gpio_num, gpio_active_low);
+	mdelay(100);
+	/* falling edge */
+	gpio_set_value(gpio_num, !gpio_active_low);
+
+	/* give it some time */
+	mdelay(100);
+
+	WARN_ON(1);
+}
+
+static int __devinit gpio_poweroff_probe(struct platform_device *pdev)
+{
+	enum of_gpio_flags flags;
+	bool input = false;
+	int ret;
+
+	/* If a pm_power_off function has already been added, leave it alone */
+	if (pm_power_off != NULL) {
+		pr_err("%s: pm_power_off function already registered",
+		       __func__);
+		return -EBUSY;
+	}
+
+	gpio_num = of_get_gpio_flags(pdev->dev.of_node, 0, &flags);
+	if (gpio_num < 0) {
+		pr_err("%s: Could not get GPIO configuration: %d",
+		       __func__, gpio_num);
+		return -ENODEV;
+	}
+	gpio_active_low = flags & OF_GPIO_ACTIVE_LOW;
+
+	if (of_get_property(pdev->dev.of_node, "input", NULL))
+		input = true;
+
+	ret = gpio_request(gpio_num, "poweroff-gpio");
+	if (ret) {
+		pr_err("%s: Could not get GPIO %d", __func__, gpio_num);
+		return ret;
+	}
+	if (input) {
+		if (gpio_direction_input(gpio_num)) {
+			pr_err("Could not set direction of GPIO %d to input",
+			       gpio_num);
+			goto err;
+		}
+	} else {
+		if (gpio_direction_output(gpio_num, gpio_active_low)) {
+			pr_err("Could not set direction of GPIO %d", gpio_num);
+			goto err;
+		}
+	}
+
+	pm_power_off = &gpio_poweroff_do_poweroff;
+	return 0;
+
+err:
+	gpio_free(gpio_num);
+	return -ENODEV;
+}
+
+static int __devexit gpio_poweroff_remove(struct platform_device *pdev)
+{
+	if (gpio_num != -1)
+		gpio_free(gpio_num);
+	if (pm_power_off == &gpio_poweroff_do_poweroff)
+		pm_power_off = NULL;
+
+	return 0;
+}
+
+static const struct of_device_id of_gpio_poweroff_match[] = {
+	{ .compatible = "gpio-poweroff", },
+	{},
+};
+
+static struct platform_driver gpio_poweroff_driver = {
+	.probe = gpio_poweroff_probe,
+	.remove = __devexit_p(gpio_poweroff_remove),
+	.driver = {
+		   .name = "poweroff-gpio",
+		   .owner = THIS_MODULE,
+		   .of_match_table = of_gpio_poweroff_match,
+		   },
+};
+
+module_platform_driver(gpio_poweroff_driver);
+
+MODULE_AUTHOR("Jamie Lentin <jm@lentin.co.uk>");
+MODULE_DESCRIPTION("GPIO poweroff driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:poweroff-gpio");
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 2/3] ARM: Kirkwood: Convert DNSKW to use gpio-poweroff.
  2012-11-13 15:44 ` Andrew Lunn
@ 2012-11-13 15:44     ` Andrew Lunn
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-13 15:44 UTC (permalink / raw)
  To: anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A
  Cc: Andrew Lunn, gmbnomis-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM, Jason Cooper

Also enable the gpio-poweroff driver when DT is used.

Signed-off-by: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
Tested-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
---
 arch/arm/boot/dts/kirkwood-dnskw.dtsi |    5 +++++
 arch/arm/mach-kirkwood/Kconfig        |    4 ++++
 arch/arm/mach-kirkwood/board-dnskw.c  |   12 ------------
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-dnskw.dtsi b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
index 9b32d02..22aa07a 100644
--- a/arch/arm/boot/dts/kirkwood-dnskw.dtsi
+++ b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
@@ -35,6 +35,11 @@
 				      6000 2>;
 	};
 
+	gpio_poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&gpio1 4 0>;
+	};
+
 	ocp@f1000000 {
 		sata@80000 {
 			status = "okay";
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 50bca50..e0d26fe 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -46,7 +46,11 @@ config MACH_GURUPLUG
 
 config ARCH_KIRKWOOD_DT
 	bool "Marvell Kirkwood Flattened Device Tree"
+	select POWER_SUPPLY
+	select POWER_RESET
+	select POWER_RESET_GPIO
 	select USE_OF
+
 	help
 	  Say 'Y' here if you want your kernel to support the
 	  Marvell Kirkwood using flattened device tree.
diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c
index 43d16d6..549369e 100644
--- a/arch/arm/mach-kirkwood/board-dnskw.c
+++ b/arch/arm/mach-kirkwood/board-dnskw.c
@@ -57,11 +57,6 @@ static unsigned int dnskw_mpp_config[] __initdata = {
 	0
 };
 
-static void dnskw_power_off(void)
-{
-	gpio_set_value(36, 1);
-}
-
 /* Register any GPIO for output and set the value */
 static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)
 {
@@ -81,13 +76,6 @@ void __init dnskw_init(void)
 	kirkwood_ehci_init();
 	kirkwood_ge00_init(&dnskw_ge00_data);
 
-	/* Register power-off GPIO. */
-	if (gpio_request(36, "dnskw:power:off") == 0
-	    && gpio_direction_output(36, 0) == 0)
-		pm_power_off = dnskw_power_off;
-	else
-		pr_err("dnskw: failed to configure power-off GPIO\n");
-
 	/* Ensure power is supplied to both HDDs */
 	dnskw_gpio_register(39, "dnskw:power:sata0", 1);
 	dnskw_gpio_register(40, "dnskw:power:sata1", 1);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 2/3] ARM: Kirkwood: Convert DNSKW to use gpio-poweroff.
@ 2012-11-13 15:44     ` Andrew Lunn
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-13 15:44 UTC (permalink / raw)
  To: linux-arm-kernel

Also enable the gpio-poweroff driver when DT is used.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Jamie Lentin <jm@lentin.co.uk>
---
 arch/arm/boot/dts/kirkwood-dnskw.dtsi |    5 +++++
 arch/arm/mach-kirkwood/Kconfig        |    4 ++++
 arch/arm/mach-kirkwood/board-dnskw.c  |   12 ------------
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-dnskw.dtsi b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
index 9b32d02..22aa07a 100644
--- a/arch/arm/boot/dts/kirkwood-dnskw.dtsi
+++ b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
@@ -35,6 +35,11 @@
 				      6000 2>;
 	};
 
+	gpio_poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&gpio1 4 0>;
+	};
+
 	ocp at f1000000 {
 		sata at 80000 {
 			status = "okay";
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 50bca50..e0d26fe 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -46,7 +46,11 @@ config MACH_GURUPLUG
 
 config ARCH_KIRKWOOD_DT
 	bool "Marvell Kirkwood Flattened Device Tree"
+	select POWER_SUPPLY
+	select POWER_RESET
+	select POWER_RESET_GPIO
 	select USE_OF
+
 	help
 	  Say 'Y' here if you want your kernel to support the
 	  Marvell Kirkwood using flattened device tree.
diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c
index 43d16d6..549369e 100644
--- a/arch/arm/mach-kirkwood/board-dnskw.c
+++ b/arch/arm/mach-kirkwood/board-dnskw.c
@@ -57,11 +57,6 @@ static unsigned int dnskw_mpp_config[] __initdata = {
 	0
 };
 
-static void dnskw_power_off(void)
-{
-	gpio_set_value(36, 1);
-}
-
 /* Register any GPIO for output and set the value */
 static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)
 {
@@ -81,13 +76,6 @@ void __init dnskw_init(void)
 	kirkwood_ehci_init();
 	kirkwood_ge00_init(&dnskw_ge00_data);
 
-	/* Register power-off GPIO. */
-	if (gpio_request(36, "dnskw:power:off") == 0
-	    && gpio_direction_output(36, 0) == 0)
-		pm_power_off = dnskw_power_off;
-	else
-		pr_err("dnskw: failed to configure power-off GPIO\n");
-
 	/* Ensure power is supplied to both HDDs */
 	dnskw_gpio_register(39, "dnskw:power:sata0", 1);
 	dnskw_gpio_register(40, "dnskw:power:sata1", 1);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 3/3] ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.
  2012-11-13 15:44 ` Andrew Lunn
@ 2012-11-13 15:44     ` Andrew Lunn
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-13 15:44 UTC (permalink / raw)
  To: anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A
  Cc: Andrew Lunn, gmbnomis-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM, Jason Cooper

Signed-off-by: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
---
 arch/arm/boot/dts/kirkwood-ib62x0.dts |    6 ++++++
 arch/arm/mach-kirkwood/board-ib62x0.c |   13 -------------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
index 66794ed..9b0e2e3 100644
--- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
+++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
@@ -79,4 +79,10 @@
 			gpios = <&gpio0 27 0>;
 		};
 	};
+	gpio_poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&gpio0 24 1>;
+	};
+
+
 };
diff --git a/arch/arm/mach-kirkwood/board-ib62x0.c b/arch/arm/mach-kirkwood/board-ib62x0.c
index cfc47f8..7b8adf5 100644
--- a/arch/arm/mach-kirkwood/board-ib62x0.c
+++ b/arch/arm/mach-kirkwood/board-ib62x0.c
@@ -17,7 +17,6 @@
 #include <linux/mtd/partitions.h>
 #include <linux/ata_platform.h>
 #include <linux/mv643xx_eth.h>
-#include <linux/gpio.h>
 #include <linux/input.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -25,8 +24,6 @@
 #include "common.h"
 #include "mpp.h"
 
-#define IB62X0_GPIO_POWER_OFF	24
-
 static struct mv643xx_eth_platform_data ib62x0_ge00_data = {
 	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
 };
@@ -49,11 +46,6 @@ static unsigned int ib62x0_mpp_config[] __initdata = {
 	0
 };
 
-static void ib62x0_power_off(void)
-{
-	gpio_set_value(IB62X0_GPIO_POWER_OFF, 1);
-}
-
 void __init ib62x0_init(void)
 {
 	/*
@@ -63,9 +55,4 @@ void __init ib62x0_init(void)
 
 	kirkwood_ehci_init();
 	kirkwood_ge00_init(&ib62x0_ge00_data);
-	if (gpio_request(IB62X0_GPIO_POWER_OFF, "ib62x0:power:off") == 0 &&
-	    gpio_direction_output(IB62X0_GPIO_POWER_OFF, 0) == 0)
-		pm_power_off = ib62x0_power_off;
-	else
-		pr_err("board-ib62x0: failed to configure power-off GPIO\n");
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 3/3] ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.
@ 2012-11-13 15:44     ` Andrew Lunn
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-13 15:44 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 arch/arm/boot/dts/kirkwood-ib62x0.dts |    6 ++++++
 arch/arm/mach-kirkwood/board-ib62x0.c |   13 -------------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
index 66794ed..9b0e2e3 100644
--- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
+++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
@@ -79,4 +79,10 @@
 			gpios = <&gpio0 27 0>;
 		};
 	};
+	gpio_poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&gpio0 24 1>;
+	};
+
+
 };
diff --git a/arch/arm/mach-kirkwood/board-ib62x0.c b/arch/arm/mach-kirkwood/board-ib62x0.c
index cfc47f8..7b8adf5 100644
--- a/arch/arm/mach-kirkwood/board-ib62x0.c
+++ b/arch/arm/mach-kirkwood/board-ib62x0.c
@@ -17,7 +17,6 @@
 #include <linux/mtd/partitions.h>
 #include <linux/ata_platform.h>
 #include <linux/mv643xx_eth.h>
-#include <linux/gpio.h>
 #include <linux/input.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -25,8 +24,6 @@
 #include "common.h"
 #include "mpp.h"
 
-#define IB62X0_GPIO_POWER_OFF	24
-
 static struct mv643xx_eth_platform_data ib62x0_ge00_data = {
 	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
 };
@@ -49,11 +46,6 @@ static unsigned int ib62x0_mpp_config[] __initdata = {
 	0
 };
 
-static void ib62x0_power_off(void)
-{
-	gpio_set_value(IB62X0_GPIO_POWER_OFF, 1);
-}
-
 void __init ib62x0_init(void)
 {
 	/*
@@ -63,9 +55,4 @@ void __init ib62x0_init(void)
 
 	kirkwood_ehci_init();
 	kirkwood_ge00_init(&ib62x0_ge00_data);
-	if (gpio_request(IB62X0_GPIO_POWER_OFF, "ib62x0:power:off") == 0 &&
-	    gpio_direction_output(IB62X0_GPIO_POWER_OFF, 0) == 0)
-		pm_power_off = ib62x0_power_off;
-	else
-		pr_err("board-ib62x0: failed to configure power-off GPIO\n");
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 1/3] power: Add simple poweroff-gpio driver
  2012-11-13 15:44     ` Andrew Lunn
@ 2012-11-15 11:08         ` Linus Walleij
  -1 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2012-11-15 11:08 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: gmbnomis-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM, Jason Cooper

On Tue, Nov 13, 2012 at 4:44 PM, Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org> wrote:

> From: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
>
> Given appropriate devicetree bindings, this driver registers a
> pm_power_off function to set a GPIO line high/low to power down
> your board.
>
> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
> Signed-off-by: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>

This looks good to me!
Acked-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 1/3] power: Add simple poweroff-gpio driver
@ 2012-11-15 11:08         ` Linus Walleij
  0 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2012-11-15 11:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Nov 13, 2012 at 4:44 PM, Andrew Lunn <andrew@lunn.ch> wrote:

> From: Jamie Lentin <jm@lentin.co.uk>
>
> Given appropriate devicetree bindings, this driver registers a
> pm_power_off function to set a GPIO line high/low to power down
> your board.
>
> Signed-off-by: Jamie Lentin <jm@lentin.co.uk>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

This looks good to me!
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 0/3] GPIO driver to turn power off
  2012-11-13 15:44 ` Andrew Lunn
@ 2012-11-16 14:19     ` Jason Cooper
  -1 siblings, 0 replies; 24+ messages in thread
From: Jason Cooper @ 2012-11-16 14:19 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: gmbnomis-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM

On Tue, Nov 13, 2012 at 04:44:42PM +0100, Andrew Lunn wrote:
> A few of the Kirkwood systems use a GPIO line to turn the power off on
> shutdown. They request the GPIO line in the board setup code,
> optionally setting it as an output and driving it inactive. They then
> register a function for pm_power_off. At the end of the shutdown, this
> function is called. The GPIO line is configured as an output, if not
> already so, and then driven active. In order to cover the use case of
> edges rather then levels, triggering power off, the GPIO line is then
> toggled active and later inactive. This should allow the driver to be
> used by PXA which also has boards using the same scheme.
> 
> The driver code was initially developed by Jamie Lentin and extended
> to cover the PXA case by Andrew Lunn.
> 
> v1 -> v2: Moved to drivers/power/reset
> 
> Andrew Lunn (2):
>   ARM: Kirkwood: Convert DNSKW to use gpio-poweroff.
>   ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.
> 
> Jamie Lentin (1):
>   power: Add simple poweroff-gpio driver
> 
>  .../devicetree/bindings/gpio/gpio-poweroff.txt     |   22 ++++
>  arch/arm/boot/dts/kirkwood-dnskw.dtsi              |    5 +
>  arch/arm/boot/dts/kirkwood-ib62x0.dts              |    6 +
>  arch/arm/mach-kirkwood/Kconfig                     |    4 +
>  arch/arm/mach-kirkwood/board-dnskw.c               |   12 --
>  arch/arm/mach-kirkwood/board-ib62x0.c              |   13 --
>  drivers/power/Kconfig                              |    3 +
>  drivers/power/Makefile                             |    1 +
>  drivers/power/reset/Kconfig                        |   15 +++
>  drivers/power/reset/Makefile                       |    1 +
>  drivers/power/reset/gpio-poweroff.c                |  129 ++++++++++++++++++++
>  11 files changed, 186 insertions(+), 25 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
>  create mode 100644 drivers/power/reset/Kconfig
>  create mode 100644 drivers/power/reset/Makefile
>  create mode 100644 drivers/power/reset/gpio-poweroff.c

Anton,

Is it ok if we take this through the arm-soc tree with your Ack?

thx,

Jason.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 0/3] GPIO driver to turn power off
@ 2012-11-16 14:19     ` Jason Cooper
  0 siblings, 0 replies; 24+ messages in thread
From: Jason Cooper @ 2012-11-16 14:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Nov 13, 2012 at 04:44:42PM +0100, Andrew Lunn wrote:
> A few of the Kirkwood systems use a GPIO line to turn the power off on
> shutdown. They request the GPIO line in the board setup code,
> optionally setting it as an output and driving it inactive. They then
> register a function for pm_power_off. At the end of the shutdown, this
> function is called. The GPIO line is configured as an output, if not
> already so, and then driven active. In order to cover the use case of
> edges rather then levels, triggering power off, the GPIO line is then
> toggled active and later inactive. This should allow the driver to be
> used by PXA which also has boards using the same scheme.
> 
> The driver code was initially developed by Jamie Lentin and extended
> to cover the PXA case by Andrew Lunn.
> 
> v1 -> v2: Moved to drivers/power/reset
> 
> Andrew Lunn (2):
>   ARM: Kirkwood: Convert DNSKW to use gpio-poweroff.
>   ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.
> 
> Jamie Lentin (1):
>   power: Add simple poweroff-gpio driver
> 
>  .../devicetree/bindings/gpio/gpio-poweroff.txt     |   22 ++++
>  arch/arm/boot/dts/kirkwood-dnskw.dtsi              |    5 +
>  arch/arm/boot/dts/kirkwood-ib62x0.dts              |    6 +
>  arch/arm/mach-kirkwood/Kconfig                     |    4 +
>  arch/arm/mach-kirkwood/board-dnskw.c               |   12 --
>  arch/arm/mach-kirkwood/board-ib62x0.c              |   13 --
>  drivers/power/Kconfig                              |    3 +
>  drivers/power/Makefile                             |    1 +
>  drivers/power/reset/Kconfig                        |   15 +++
>  drivers/power/reset/Makefile                       |    1 +
>  drivers/power/reset/gpio-poweroff.c                |  129 ++++++++++++++++++++
>  11 files changed, 186 insertions(+), 25 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
>  create mode 100644 drivers/power/reset/Kconfig
>  create mode 100644 drivers/power/reset/Makefile
>  create mode 100644 drivers/power/reset/gpio-poweroff.c

Anton,

Is it ok if we take this through the arm-soc tree with your Ack?

thx,

Jason.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 0/3] GPIO driver to turn power off
  2012-11-16 14:19     ` Jason Cooper
@ 2012-11-16 19:23         ` Anton Vorontsov
  -1 siblings, 0 replies; 24+ messages in thread
From: Anton Vorontsov @ 2012-11-16 19:23 UTC (permalink / raw)
  To: Jason Cooper
  Cc: Andrew Lunn, gmbnomis-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM

On Fri, Nov 16, 2012 at 09:19:47AM -0500, Jason Cooper wrote:
[...]
> Is it ok if we take this through the arm-soc tree with your Ack?

Yup. The driver looks good.

Acked-by: Anton Vorontsov <cbouatmailru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Thanks.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 0/3] GPIO driver to turn power off
@ 2012-11-16 19:23         ` Anton Vorontsov
  0 siblings, 0 replies; 24+ messages in thread
From: Anton Vorontsov @ 2012-11-16 19:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Nov 16, 2012 at 09:19:47AM -0500, Jason Cooper wrote:
[...]
> Is it ok if we take this through the arm-soc tree with your Ack?

Yup. The driver looks good.

Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>

Thanks.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 1/3] power: Add simple poweroff-gpio driver
  2012-11-13 15:44     ` Andrew Lunn
@ 2012-11-16 19:25       ` Simon Baatz
  -1 siblings, 0 replies; 24+ messages in thread
From: Simon Baatz @ 2012-11-16 19:25 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Jason Cooper, devicetree-discuss, anton.vorontsov, jm,
	Linus Walleij, linux ARM

Hi Andrew,

On Tue, Nov 13, 2012 at 04:44:43PM +0100, Andrew Lunn wrote:
> From: Jamie Lentin <jm@lentin.co.uk>
> 
> Given appropriate devicetree bindings, this driver registers a
> pm_power_off function to set a GPIO line high/low to power down
> your board.
> 
> Signed-off-by: Jamie Lentin <jm@lentin.co.uk>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  .../devicetree/bindings/gpio/gpio-poweroff.txt     |   22 ++++
>  drivers/power/Kconfig                              |    3 +
>  drivers/power/Makefile                             |    1 +
>  drivers/power/reset/Kconfig                        |   15 +++
>  drivers/power/reset/Makefile                       |    1 +
>  drivers/power/reset/gpio-poweroff.c                |  129 ++++++++++++++++++++
>  6 files changed, 171 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
>  create mode 100644 drivers/power/reset/Kconfig
>  create mode 100644 drivers/power/reset/Makefile
>  create mode 100644 drivers/power/reset/gpio-poweroff.c
> 
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt b/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
> new file mode 100644
> index 0000000..558cdf3
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
> @@ -0,0 +1,22 @@
> +GPIO line that should be set high/low to power off a device
> +
> +Required properties:
> +- compatible : should be "gpio-poweroff".
> +- gpios : The GPIO to set high/low, see "gpios property" in
> +  Documentation/devicetree/bindings/gpio/gpio.txt. If the pin should be
> +  low to power down the board set it to "Active Low", otherwise set
> +  gpio to "Active High".
> +
> +Optional properties:
> +- input : Initially configure the GPIO line as an input. Only reconfigure
> +  it to an output when the pm_power_off function is called. If this optional
> +  property is not specified, the GPIO is initialized as an output in its
> +  inactive state.
> +
> +
> +Examples:
> +
> +gpio-poweroff {
> +	compatible = "gpio-poweroff";
> +	gpios = <&gpio 4 0>; /* GPIO 4 Active Low */
> +};
> diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
> index 49a8939..b1d956d 100644
> --- a/drivers/power/Kconfig
> +++ b/drivers/power/Kconfig
> @@ -335,6 +335,9 @@ config AB8500_BATTERY_THERM_ON_BATCTRL
>  	help
>  	  Say Y to enable battery temperature measurements using
>  	  thermistor connected on BATCTRL ADC.
> +
> +source "drivers/power/reset/Kconfig"
> +
>  endif # POWER_SUPPLY
>  
>  source "drivers/power/avs/Kconfig"
> diff --git a/drivers/power/Makefile b/drivers/power/Makefile
> index b949cf8..f1d99f4 100644
> --- a/drivers/power/Makefile
> +++ b/drivers/power/Makefile
> @@ -49,3 +49,4 @@ obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
>  obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
>  obj-$(CONFIG_POWER_AVS)		+= avs/
>  obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
> +obj-$(CONFIG_POWER_RESET)	+= reset/
> diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
> new file mode 100644
> index 0000000..6461b48
> --- /dev/null
> +++ b/drivers/power/reset/Kconfig
> @@ -0,0 +1,15 @@
> +menuconfig POWER_RESET
> +	bool "Board level reset or power off"
> +	help
> +	  Provides a number of drivers which either reset a complete board
> +	  or shut it down, by manipulating the main power supply on the board.
> +
> +	  Say Y here to enable board reset and power off
> +
> +config POWER_RESET_GPIO
> +	bool "GPIO power-off driver"
> +	depends on OF_GPIO && POWER_RESET
> +	help
> +	  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.
> diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
> new file mode 100644
> index 0000000..751488a
> --- /dev/null
> +++ b/drivers/power/reset/Makefile
> @@ -0,0 +1 @@
> +obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
> diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
> new file mode 100644
> index 0000000..101ad57
> --- /dev/null
> +++ b/drivers/power/reset/gpio-poweroff.c
> @@ -0,0 +1,129 @@
> +/*
> + * Toggles a GPIO pin to power down a device
> + *
> + * Jamie Lentin <jm@lentin.co.uk>
> + * Andrew Lunn <andrew@lunn.ch>
> + *
> + * Copyright (C) 2012 Jamie Lentin
> + *
> + * 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/delay.h>
> +#include <linux/platform_device.h>
> +#include <linux/gpio.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_gpio.h>
> +#include <linux/module.h>
> +
> +/*
> + * Hold configuration here, cannot be more than one instance of the driver
> + * since pm_power_off itself is global.
> + */
> +static int gpio_num = -1;
> +static int gpio_active_low;
> +
> +static void gpio_poweroff_do_poweroff(void)
> +{
> +	BUG_ON(gpio_num == -1);
> +
> +	/* drive it active */
> +	gpio_direction_output(gpio_num, !gpio_active_low);
> +	mdelay(100);
> +	/* rising edge or drive inactive */
> +	gpio_set_value(gpio_num, gpio_active_low);
> +	mdelay(100);
> +	/* falling edge */
> +	gpio_set_value(gpio_num, !gpio_active_low);
> +
> +	/* give it some time */
> +	mdelay(100);

On the IB-NAS 6210 I need to increase this delay to a whopping 3000
milliseconds to suppress the warning (2000 is not enough).  Is it
acceptable to increase this to such a high value or do we need
another solution?

> +
> +	WARN_ON(1);
> ...

- Simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 1/3] power: Add simple poweroff-gpio driver
@ 2012-11-16 19:25       ` Simon Baatz
  0 siblings, 0 replies; 24+ messages in thread
From: Simon Baatz @ 2012-11-16 19:25 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew,

On Tue, Nov 13, 2012 at 04:44:43PM +0100, Andrew Lunn wrote:
> From: Jamie Lentin <jm@lentin.co.uk>
> 
> Given appropriate devicetree bindings, this driver registers a
> pm_power_off function to set a GPIO line high/low to power down
> your board.
> 
> Signed-off-by: Jamie Lentin <jm@lentin.co.uk>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  .../devicetree/bindings/gpio/gpio-poweroff.txt     |   22 ++++
>  drivers/power/Kconfig                              |    3 +
>  drivers/power/Makefile                             |    1 +
>  drivers/power/reset/Kconfig                        |   15 +++
>  drivers/power/reset/Makefile                       |    1 +
>  drivers/power/reset/gpio-poweroff.c                |  129 ++++++++++++++++++++
>  6 files changed, 171 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
>  create mode 100644 drivers/power/reset/Kconfig
>  create mode 100644 drivers/power/reset/Makefile
>  create mode 100644 drivers/power/reset/gpio-poweroff.c
> 
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt b/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
> new file mode 100644
> index 0000000..558cdf3
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
> @@ -0,0 +1,22 @@
> +GPIO line that should be set high/low to power off a device
> +
> +Required properties:
> +- compatible : should be "gpio-poweroff".
> +- gpios : The GPIO to set high/low, see "gpios property" in
> +  Documentation/devicetree/bindings/gpio/gpio.txt. If the pin should be
> +  low to power down the board set it to "Active Low", otherwise set
> +  gpio to "Active High".
> +
> +Optional properties:
> +- input : Initially configure the GPIO line as an input. Only reconfigure
> +  it to an output when the pm_power_off function is called. If this optional
> +  property is not specified, the GPIO is initialized as an output in its
> +  inactive state.
> +
> +
> +Examples:
> +
> +gpio-poweroff {
> +	compatible = "gpio-poweroff";
> +	gpios = <&gpio 4 0>; /* GPIO 4 Active Low */
> +};
> diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
> index 49a8939..b1d956d 100644
> --- a/drivers/power/Kconfig
> +++ b/drivers/power/Kconfig
> @@ -335,6 +335,9 @@ config AB8500_BATTERY_THERM_ON_BATCTRL
>  	help
>  	  Say Y to enable battery temperature measurements using
>  	  thermistor connected on BATCTRL ADC.
> +
> +source "drivers/power/reset/Kconfig"
> +
>  endif # POWER_SUPPLY
>  
>  source "drivers/power/avs/Kconfig"
> diff --git a/drivers/power/Makefile b/drivers/power/Makefile
> index b949cf8..f1d99f4 100644
> --- a/drivers/power/Makefile
> +++ b/drivers/power/Makefile
> @@ -49,3 +49,4 @@ obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
>  obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
>  obj-$(CONFIG_POWER_AVS)		+= avs/
>  obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
> +obj-$(CONFIG_POWER_RESET)	+= reset/
> diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
> new file mode 100644
> index 0000000..6461b48
> --- /dev/null
> +++ b/drivers/power/reset/Kconfig
> @@ -0,0 +1,15 @@
> +menuconfig POWER_RESET
> +	bool "Board level reset or power off"
> +	help
> +	  Provides a number of drivers which either reset a complete board
> +	  or shut it down, by manipulating the main power supply on the board.
> +
> +	  Say Y here to enable board reset and power off
> +
> +config POWER_RESET_GPIO
> +	bool "GPIO power-off driver"
> +	depends on OF_GPIO && POWER_RESET
> +	help
> +	  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.
> diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
> new file mode 100644
> index 0000000..751488a
> --- /dev/null
> +++ b/drivers/power/reset/Makefile
> @@ -0,0 +1 @@
> +obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
> diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
> new file mode 100644
> index 0000000..101ad57
> --- /dev/null
> +++ b/drivers/power/reset/gpio-poweroff.c
> @@ -0,0 +1,129 @@
> +/*
> + * Toggles a GPIO pin to power down a device
> + *
> + * Jamie Lentin <jm@lentin.co.uk>
> + * Andrew Lunn <andrew@lunn.ch>
> + *
> + * Copyright (C) 2012 Jamie Lentin
> + *
> + * 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/delay.h>
> +#include <linux/platform_device.h>
> +#include <linux/gpio.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_gpio.h>
> +#include <linux/module.h>
> +
> +/*
> + * Hold configuration here, cannot be more than one instance of the driver
> + * since pm_power_off itself is global.
> + */
> +static int gpio_num = -1;
> +static int gpio_active_low;
> +
> +static void gpio_poweroff_do_poweroff(void)
> +{
> +	BUG_ON(gpio_num == -1);
> +
> +	/* drive it active */
> +	gpio_direction_output(gpio_num, !gpio_active_low);
> +	mdelay(100);
> +	/* rising edge or drive inactive */
> +	gpio_set_value(gpio_num, gpio_active_low);
> +	mdelay(100);
> +	/* falling edge */
> +	gpio_set_value(gpio_num, !gpio_active_low);
> +
> +	/* give it some time */
> +	mdelay(100);

On the IB-NAS 6210 I need to increase this delay to a whopping 3000
milliseconds to suppress the warning (2000 is not enough).  Is it
acceptable to increase this to such a high value or do we need
another solution?

> +
> +	WARN_ON(1);
> ...

- Simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 3/3] ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.
  2012-11-13 15:44     ` Andrew Lunn
@ 2012-11-16 19:32       ` Simon Baatz
  -1 siblings, 0 replies; 24+ messages in thread
From: Simon Baatz @ 2012-11-16 19:32 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Jason Cooper, devicetree-discuss, anton.vorontsov, jm,
	Linus Walleij, linux ARM

Hi Andrew,

On Tue, Nov 13, 2012 at 04:44:45PM +0100, Andrew Lunn wrote:
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  arch/arm/boot/dts/kirkwood-ib62x0.dts |    6 ++++++
>  arch/arm/mach-kirkwood/board-ib62x0.c |   13 -------------
>  2 files changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
> index 66794ed..9b0e2e3 100644
> --- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
> +++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
> @@ -79,4 +79,10 @@
>  			gpios = <&gpio0 27 0>;
>  		};
>  	};
> +	gpio_poweroff {
> +		compatible = "gpio-poweroff";
> +		gpios = <&gpio0 24 1>;

This needs to be:
		gpios = <&gpio0 24 0>;

If the GPIO is configured as an input, the box shuts down when
initializing the driver.

With this change:

Tested-by: Simon Baatz <gmbnomis@gmail.com>

Btw., I also tested it on top of your pinctrl changes, which works
like a charm as well.

- Simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 3/3] ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.
@ 2012-11-16 19:32       ` Simon Baatz
  0 siblings, 0 replies; 24+ messages in thread
From: Simon Baatz @ 2012-11-16 19:32 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew,

On Tue, Nov 13, 2012 at 04:44:45PM +0100, Andrew Lunn wrote:
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  arch/arm/boot/dts/kirkwood-ib62x0.dts |    6 ++++++
>  arch/arm/mach-kirkwood/board-ib62x0.c |   13 -------------
>  2 files changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
> index 66794ed..9b0e2e3 100644
> --- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
> +++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
> @@ -79,4 +79,10 @@
>  			gpios = <&gpio0 27 0>;
>  		};
>  	};
> +	gpio_poweroff {
> +		compatible = "gpio-poweroff";
> +		gpios = <&gpio0 24 1>;

This needs to be:
		gpios = <&gpio0 24 0>;

If the GPIO is configured as an input, the box shuts down when
initializing the driver.

With this change:

Tested-by: Simon Baatz <gmbnomis@gmail.com>

Btw., I also tested it on top of your pinctrl changes, which works
like a charm as well.

- Simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 0/3] GPIO driver to turn power off
  2012-11-16 19:23         ` Anton Vorontsov
@ 2012-11-17  8:29           ` Andrew Lunn
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-17  8:29 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Andrew Lunn, Jason Cooper,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM,
	gmbnomis-Re5JQEeQqe8AvxtiuMwx3w

On Fri, Nov 16, 2012 at 11:23:35AM -0800, Anton Vorontsov wrote:
> On Fri, Nov 16, 2012 at 09:19:47AM -0500, Jason Cooper wrote:
> [...]
> > Is it ok if we take this through the arm-soc tree with your Ack?
> 
> Yup. The driver looks good.
> 
> Acked-by: Anton Vorontsov <cbouatmailru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Hi Anton

Thanks for the ACK.

I will respin another version, with the delay before WARN() increased,
and fix the polarity of the GPIO i got wrong.

    Andrew

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 0/3] GPIO driver to turn power off
@ 2012-11-17  8:29           ` Andrew Lunn
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-17  8:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Nov 16, 2012 at 11:23:35AM -0800, Anton Vorontsov wrote:
> On Fri, Nov 16, 2012 at 09:19:47AM -0500, Jason Cooper wrote:
> [...]
> > Is it ok if we take this through the arm-soc tree with your Ack?
> 
> Yup. The driver looks good.
> 
> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>

Hi Anton

Thanks for the ACK.

I will respin another version, with the delay before WARN() increased,
and fix the polarity of the GPIO i got wrong.

    Andrew

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 3/3] ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.
  2012-11-16 19:32       ` Simon Baatz
@ 2012-11-17  8:30           ` Andrew Lunn
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-17  8:30 UTC (permalink / raw)
  To: Simon Baatz
  Cc: Andrew Lunn, Jason Cooper,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM

On Fri, Nov 16, 2012 at 08:32:50PM +0100, Simon Baatz wrote:
> Hi Andrew,
> 
> On Tue, Nov 13, 2012 at 04:44:45PM +0100, Andrew Lunn wrote:
> > Signed-off-by: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
> > ---
> >  arch/arm/boot/dts/kirkwood-ib62x0.dts |    6 ++++++
> >  arch/arm/mach-kirkwood/board-ib62x0.c |   13 -------------
> >  2 files changed, 6 insertions(+), 13 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
> > index 66794ed..9b0e2e3 100644
> > --- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
> > +++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
> > @@ -79,4 +79,10 @@
> >  			gpios = <&gpio0 27 0>;
> >  		};
> >  	};
> > +	gpio_poweroff {
> > +		compatible = "gpio-poweroff";
> > +		gpios = <&gpio0 24 1>;
> 
> This needs to be:
> 		gpios = <&gpio0 24 0>;

I also got it wrong on Jamie's board!

> 
> If the GPIO is configured as an input, the box shuts down when
> initializing the driver.
> 
> With this change:
> 
> Tested-by: Simon Baatz <gmbnomis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> Btw., I also tested it on top of your pinctrl changes, which works
> like a charm as well.

Thanks for testing that.

       Andrew

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 3/3] ARM: Kirkwood: Convert IB62x0 to use gpio-poweroff.
@ 2012-11-17  8:30           ` Andrew Lunn
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-17  8:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Nov 16, 2012 at 08:32:50PM +0100, Simon Baatz wrote:
> Hi Andrew,
> 
> On Tue, Nov 13, 2012 at 04:44:45PM +0100, Andrew Lunn wrote:
> > Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> > ---
> >  arch/arm/boot/dts/kirkwood-ib62x0.dts |    6 ++++++
> >  arch/arm/mach-kirkwood/board-ib62x0.c |   13 -------------
> >  2 files changed, 6 insertions(+), 13 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
> > index 66794ed..9b0e2e3 100644
> > --- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
> > +++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
> > @@ -79,4 +79,10 @@
> >  			gpios = <&gpio0 27 0>;
> >  		};
> >  	};
> > +	gpio_poweroff {
> > +		compatible = "gpio-poweroff";
> > +		gpios = <&gpio0 24 1>;
> 
> This needs to be:
> 		gpios = <&gpio0 24 0>;

I also got it wrong on Jamie's board!

> 
> If the GPIO is configured as an input, the box shuts down when
> initializing the driver.
> 
> With this change:
> 
> Tested-by: Simon Baatz <gmbnomis@gmail.com>
> 
> Btw., I also tested it on top of your pinctrl changes, which works
> like a charm as well.

Thanks for testing that.

       Andrew

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 1/3] power: Add simple poweroff-gpio driver
  2012-11-16 19:25       ` Simon Baatz
@ 2012-11-17  8:34           ` Andrew Lunn
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-17  8:34 UTC (permalink / raw)
  To: Simon Baatz
  Cc: Andrew Lunn, Jason Cooper,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A,
	jm-Pj/HzkgeCk7QXOPxS62xeg, linux ARM

> > + * Hold configuration here, cannot be more than one instance of the driver
> > + * since pm_power_off itself is global.
> > + */
> > +static int gpio_num = -1;
> > +static int gpio_active_low;
> > +
> > +static void gpio_poweroff_do_poweroff(void)
> > +{
> > +	BUG_ON(gpio_num == -1);
> > +
> > +	/* drive it active */
> > +	gpio_direction_output(gpio_num, !gpio_active_low);
> > +	mdelay(100);
> > +	/* rising edge or drive inactive */
> > +	gpio_set_value(gpio_num, gpio_active_low);
> > +	mdelay(100);
> > +	/* falling edge */
> > +	gpio_set_value(gpio_num, !gpio_active_low);
> > +
> > +	/* give it some time */
> > +	mdelay(100);
> 
> On the IB-NAS 6210 I need to increase this delay to a whopping 3000
> milliseconds to suppress the warning (2000 is not enough).  Is it
> acceptable to increase this to such a high value or do we need
> another solution?

Hi Simon

It is interesting how slow these things are at turning off. I already
had to increase it once from 10ms for the DNSKW.

So i will increase it to 3000 in the next spin of the patches.

Thanks

	Andrew

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 1/3] power: Add simple poweroff-gpio driver
@ 2012-11-17  8:34           ` Andrew Lunn
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2012-11-17  8:34 UTC (permalink / raw)
  To: linux-arm-kernel

> > + * Hold configuration here, cannot be more than one instance of the driver
> > + * since pm_power_off itself is global.
> > + */
> > +static int gpio_num = -1;
> > +static int gpio_active_low;
> > +
> > +static void gpio_poweroff_do_poweroff(void)
> > +{
> > +	BUG_ON(gpio_num == -1);
> > +
> > +	/* drive it active */
> > +	gpio_direction_output(gpio_num, !gpio_active_low);
> > +	mdelay(100);
> > +	/* rising edge or drive inactive */
> > +	gpio_set_value(gpio_num, gpio_active_low);
> > +	mdelay(100);
> > +	/* falling edge */
> > +	gpio_set_value(gpio_num, !gpio_active_low);
> > +
> > +	/* give it some time */
> > +	mdelay(100);
> 
> On the IB-NAS 6210 I need to increase this delay to a whopping 3000
> milliseconds to suppress the warning (2000 is not enough).  Is it
> acceptable to increase this to such a high value or do we need
> another solution?

Hi Simon

It is interesting how slow these things are at turning off. I already
had to increase it once from 10ms for the DNSKW.

So i will increase it to 3000 in the next spin of the patches.

Thanks

	Andrew

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-11-17  8:34 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-13 15:44 [PATCH v2 0/3] GPIO driver to turn power off Andrew Lunn
2012-11-13 15:44 ` Andrew Lunn
     [not found] ` <1352821485-10032-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2012-11-13 15:44   ` [PATCH v2 1/3] power: Add simple poweroff-gpio driver Andrew Lunn
2012-11-13 15:44     ` Andrew Lunn
     [not found]     ` <1352821485-10032-2-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2012-11-15 11:08       ` Linus Walleij
2012-11-15 11:08         ` Linus Walleij
2012-11-16 19:25     ` Simon Baatz
2012-11-16 19:25       ` Simon Baatz
     [not found]       ` <20121116192525.GA25838-2BA9cf72eNkOIzVOb1FTxg@public.gmane.org>
2012-11-17  8:34         ` Andrew Lunn
2012-11-17  8:34           ` Andrew Lunn
2012-11-13 15:44   ` [PATCH v2 2/3] ARM: Kirkwood: Convert DNSKW to use gpio-poweroff Andrew Lunn
2012-11-13 15:44     ` Andrew Lunn
2012-11-13 15:44   ` [PATCH v2 3/3] ARM: Kirkwood: Convert IB62x0 " Andrew Lunn
2012-11-13 15:44     ` Andrew Lunn
2012-11-16 19:32     ` Simon Baatz
2012-11-16 19:32       ` Simon Baatz
     [not found]       ` <20121116193250.GB25838-2BA9cf72eNkOIzVOb1FTxg@public.gmane.org>
2012-11-17  8:30         ` Andrew Lunn
2012-11-17  8:30           ` Andrew Lunn
2012-11-16 14:19   ` [PATCH v2 0/3] GPIO driver to turn power off Jason Cooper
2012-11-16 14:19     ` Jason Cooper
     [not found]     ` <20121116141947.GN22106-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-11-16 19:23       ` Anton Vorontsov
2012-11-16 19:23         ` Anton Vorontsov
2012-11-17  8:29         ` Andrew Lunn
2012-11-17  8:29           ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.