diff mbox

[1/2] Convert power recovery pin to a fixed regulator

Message ID 1376231210-6484-2-git-send-email-jm@lentin.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Jamie Lentin Aug. 11, 2013, 2:26 p.m. UTC
dnskw_gpio_register() is broken, and probably has been for a while,
since dnskw_init() is called too early to register GPIOs. Instead use a
fixed regulator to turn the pin high, which knows to defer the
registration until later.

Signed-off-by: Jamie Lentin <jm@lentin.co.uk>
---
 arch/arm/boot/dts/kirkwood-dnskw.dtsi | 13 +++++++++++++
 arch/arm/mach-kirkwood/board-dnskw.c  | 15 ---------------
 2 files changed, 13 insertions(+), 15 deletions(-)

Comments

Mark Brown Aug. 11, 2013, 6:24 p.m. UTC | #1
On Sun, Aug 11, 2013 at 03:26:49PM +0100, Jamie Lentin wrote:
> dnskw_gpio_register() is broken, and probably has been for a while,
> since dnskw_init() is called too early to register GPIOs. Instead use a
> fixed regulator to turn the pin high, which knows to defer the
> registration until later.

So, this is really abuse of the regulator API since it knows how to set
a GPIO.  Perhaps the reset controller might be a better fit, or pinctrl
defaults?
Jason Cooper Aug. 12, 2013, 4:51 p.m. UTC | #2
On Sun, Aug 11, 2013 at 07:24:44PM +0100, Mark Brown wrote:
> On Sun, Aug 11, 2013 at 03:26:49PM +0100, Jamie Lentin wrote:
> > dnskw_gpio_register() is broken, and probably has been for a while,
> > since dnskw_init() is called too early to register GPIOs. Instead use a
> > fixed regulator to turn the pin high, which knows to defer the
> > registration until later.
> 
> So, this is really abuse of the regulator API since it knows how to set
> a GPIO.  Perhaps the reset controller might be a better fit, or pinctrl
> defaults?

I vote for the reset controller.

Jamie, I'm taking the deletion part of both of these patches since it
didn't work any way and it's the last holdout of DT platform code in
kirkwood.

Once you get the DT node nailed down for the reset pin, just submit it
by itself.

thx,

Jason.
Jamie Lentin Aug. 12, 2013, 5:03 p.m. UTC | #3
On Mon, 12 Aug 2013, Jason Cooper wrote:

> On Sun, Aug 11, 2013 at 07:24:44PM +0100, Mark Brown wrote:
>> On Sun, Aug 11, 2013 at 03:26:49PM +0100, Jamie Lentin wrote:
>>> dnskw_gpio_register() is broken, and probably has been for a while,
>>> since dnskw_init() is called too early to register GPIOs. Instead use a
>>> fixed regulator to turn the pin high, which knows to defer the
>>> registration until later.
>>
>> So, this is really abuse of the regulator API since it knows how to set
>> a GPIO.  Perhaps the reset controller might be a better fit, or pinctrl
>> defaults?
>
> I vote for the reset controller.

Okay, will rummage and come back with a separate patch. Thanks for your 
suggestions!

> Jamie, I'm taking the deletion part of both of these patches since it
> didn't work any way and it's the last holdout of DT platform code in
> kirkwood.
>
> Once you get the DT node nailed down for the reset pin, just submit it
> by itself.

Please do, the code isn't in any way useful.

> thx,
>
> Jason.
>
diff mbox

Patch

diff --git a/arch/arm/boot/dts/kirkwood-dnskw.dtsi b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
index d544f77..9e74127 100644
--- a/arch/arm/boot/dts/kirkwood-dnskw.dtsi
+++ b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
@@ -217,6 +217,19 @@ 
 			regulator-boot-on;
 			gpio = <&gpio1 8 0>;
 		};
+		power_back_on: regulator@3 {
+			/* Turning this pin high means the NAS will turn on
+			immediately after a power failure. */
+			compatible = "regulator-fixed";
+			reg = <3>;
+			regulator-name = "Recover after power failure";
+			regulator-min-microvolt = <5000000>;
+			regulator-max-microvolt = <5000000>;
+			regulator-always-on;
+			regulator-boot-on;
+			gpio = <&gpio1 5 0>;
+			enable-active-high;
+		};
 	};
 };
 
diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c
index 2af7a95..0b441b9 100644
--- a/arch/arm/mach-kirkwood/board-dnskw.c
+++ b/arch/arm/mach-kirkwood/board-dnskw.c
@@ -14,23 +14,8 @@ 
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/gpio.h>
 #include "common.h"
 
-/* Register any GPIO for output and set the value */
-static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)
-{
-	if (gpio_request(gpio, name) == 0 &&
-	    gpio_direction_output(gpio, 0) == 0) {
-		gpio_set_value(gpio, def);
-		if (gpio_export(gpio, 0) != 0)
-			pr_err("dnskw: Failed to export GPIO %s\n", name);
-	} else
-		pr_err("dnskw: Failed to register %s\n", name);
-}
-
 void __init dnskw_init(void)
 {
-	/* Set NAS to turn back on after a power failure */
-	dnskw_gpio_register(37, "dnskw:power:recover", 1);
 }