Skip to contentSkip to conversation

ARM: Kirkwood: Convert NS2 to gpio-poweroff.

PATCH New Andrew Lunn 3 participants 7 messages Dec 28, 2012 – Jan 23, 2013

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

PATCH 1/5 ARM: Kirkwood: Convert NS2 to gpio-poweroff.

Remove C code and add a Device Tree node in its place.

---

This is untested. I've been known to get the active hi/low the wrong way around so that the board powers off as the driver loads at boot time. So it would be very good to have a tested-by: sign off.

 arch/arm/boot/dts/kirkwood-ns2-common.dtsi |    6 ++++++
 arch/arm/mach-kirkwood/board-ns2.c         |   14 --------------
 2 files changed, 6 insertions(+), 14 deletions(-)
arch/arm/boot/dts/kirkwood-ns2-common.dtsi +6 -0
index 9bc6785..58c4103 100644
@@ -60,4 +60,10 @@
 			gpios = <&gpio0 12 0>;
 		};
 	};
+
+	gpio_poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&gpio0 31 0>;
+	};
+
 };
arch/arm/mach-kirkwood/board-ns2.c +0 -14
index 8821720..f263449 100644
@@ -15,7 +15,6 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/mv643xx_eth.h>
-#include <linux/gpio.h>
 #include <linux/of.h>
 #include "common.h"
 #include "mpp.h"
@@ -59,13 +58,6 @@ static unsigned int ns2_mpp_config[] __initdata = {
 	0
 };
 
-#define NS2_GPIO_POWER_OFF	31
-
-static void ns2_power_off(void)
-{
-	gpio_set_value(NS2_GPIO_POWER_OFF, 1);
-}
-
 void __init ns2_init(void)
 {
 	/*
@@ -77,10 +69,4 @@ void __init ns2_init(void)
 	    of_machine_is_compatible("lacie,netspace_mini_v2"))
 		ns2_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
 	kirkwood_ge00_init(&ns2_ge00_data);
-
-	if (gpio_request(NS2_GPIO_POWER_OFF, "power-off") == 0 &&
-	    gpio_direction_output(NS2_GPIO_POWER_OFF, 0) == 0)
-		pm_power_off = ns2_power_off;
-	else
-		pr_err("ns2: failed to configure power-off GPIO\n");
 }
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/5 ARM: Kirkwood: Convert NS2 to gpio-poweroff.

Quoted 8 lines · Andrew Lunn

Remove C code and add a Device Tree node in its place.

---

This is untested. I've been known to get the active hi/low the wrong way around so that the board powers off as the driver loads at boot time. So it would be very good to have a tested-by: sign off.

Hi Andrew,

I think that GPIOs are currently broken for LaCie DT boards, due to commit f9e75922: "ARM: Kirkwood: Make use of mvebu pincltl and gpio drivers".

As mvbu_gpio is now used (instead of orion_gpio), pinctrl must also be used. I think that the pinctrl conversion is a preliminary work to the gpio_poweroff conversion. I realized this some weeks ago while working on the exactly same patch. Unfortunately, I failed to find enough time to fix it.

If you can afford a few days delay, let's say until the end of the next week, I should be able to add the pinctrl conversion patch and then also to test your patch on the top of that.

Thanks,

Simon

Quoted 60 lines

 arch/arm/boot/dts/kirkwood-ns2-common.dtsi |    6 ++++++
 arch/arm/mach-kirkwood/board-ns2.c         |   14 --------------
 2 files changed, 6 insertions(+), 14 deletions(-)
arch/arm/boot/dts/kirkwood-ns2-common.dtsi +6 -0
index 9bc6785..58c4103 100644
@@ -60,4 +60,10 @@
 			gpios = <&gpio0 12 0>;
 		};
 	};
+
+	gpio_poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&gpio0 31 0>;
+	};
+
 };
arch/arm/mach-kirkwood/board-ns2.c +0 -14
index 8821720..f263449 100644
@@ -15,7 +15,6 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/mv643xx_eth.h>
-#include <linux/gpio.h>
 #include <linux/of.h>
 #include "common.h"
 #include "mpp.h"
@@ -59,13 +58,6 @@ static unsigned int ns2_mpp_config[] __initdata = {
 	0
 };
 
-#define NS2_GPIO_POWER_OFF	31
-
-static void ns2_power_off(void)
-{
-	gpio_set_value(NS2_GPIO_POWER_OFF, 1);
-}
-
 void __init ns2_init(void)
 {
 	/*
@@ -77,10 +69,4 @@ void __init ns2_init(void)
 	    of_machine_is_compatible("lacie,netspace_mini_v2"))
 		ns2_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
 	kirkwood_ge00_init(&ns2_ge00_data);
-
-	if (gpio_request(NS2_GPIO_POWER_OFF, "power-off") == 0 &&
-	    gpio_direction_output(NS2_GPIO_POWER_OFF, 0) == 0)
-		pm_power_off = ns2_power_off;
-	else
-		pr_err("ns2: failed to configure power-off GPIO\n");
 }
Signature · 1 line
1.7.10.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121229/bab14b63/attachment-0001.sig>

#2 lore raw

PATCH 1/5 ARM: Kirkwood: Convert NS2 to gpio-poweroff.

Quoted 10 lines · Simon Guinot
Quoted 8 lines · Andrew Lunn

Remove C code and add a Device Tree node in its place.

---

This is untested. I've been known to get the active hi/low the wrong way around so that the board powers off as the driver loads at boot time. So it would be very good to have a tested-by: sign off.

Quoted 5 lines

Hi Andrew,

I think that GPIOs are currently broken for LaCie DT boards, due to commit f9e75922: "ARM: Kirkwood: Make use of mvebu pincltl and gpio drivers".

Hi Simon

gpio-power-off should work with either the old or the new driver.

What might not work with the old code gpio power off code with the new new driver. So it is worth giving it a try.

Quoted 9 lines

As mvbu_gpio is now used (instead of orion_gpio), pinctrl must also be used. I think that the pinctrl conversion is a preliminary work to the gpio_poweroff conversion. I realized this some weeks ago while working on the exactly same patch. Unfortunately, I failed to find enough time to fix it.

If you can afford a few days delay, let's say until the end of the next week, I should be able to add the pinctrl conversion patch and then also to test your patch on the top of that.

No rush. We have maybe another 4 weeks before we need to submit code upstream for the next merge window.

Andrew

#3 lore raw

PATCH 1/5 ARM: Kirkwood: Convert NS2 to gpio-poweroff.

Quoted 13 lines · Andrew Lunn
Quoted 12 lines · Simon Guinot
Quoted 8 lines · Andrew Lunn

Remove C code and add a Device Tree node in its place.

---

This is untested. I've been known to get the active hi/low the wrong way around so that the board powers off as the driver loads at boot time. So it would be very good to have a tested-by: sign off.

Hi Andrew,

Quoted 7 lines
Quoted 3 lines

I think that GPIOs are currently broken for LaCie DT boards, due to commit f9e75922: "ARM: Kirkwood: Make use of mvebu pincltl and gpio drivers".

Hi Simon

gpio-power-off should work with either the old or the new driver.

gpio_request fails because mvebu-gpio relies on pinctrl which is not available on the ns2 DT board. The mpp registration is still done in the old fashion way for the ns2 (with kirkwood_mpp_conf()).

Look at the orion_gpio_of_init() call removal in f9e75922.

Quoted 3 lines

What might not work with the old code gpio power off code with the new new driver. So it is worth giving it a try.

I have but gpio_request fails. It is the same with all the drivers trying to get GPIOs...

Quoted 7 lines
Quoted 7 lines

As mvbu_gpio is now used (instead of orion_gpio), pinctrl must also be used. I think that the pinctrl conversion is a preliminary work to the gpio_poweroff conversion. I realized this some weeks ago while working on the exactly same patch. Unfortunately, I failed to find enough time to fix it.

Quoted 6 lines
Quoted 3 lines

If you can afford a few days delay, let's say until the end of the next week, I should be able to add the pinctrl conversion patch and then also to test your patch on the top of that.

No rush. We have maybe another 4 weeks before we need to submit code upstream for the next merge window.

OK fine. I'll do that next week.

Simon

Quoted 2 lines

Andrew

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121229/980a929b/attachment-0001.sig>

#4 lore raw

PATCH 1/5 ARM: Kirkwood: Convert NS2 to gpio-poweroff.

In reply to Andrew Lunn
Quoted 5 lines · Andrew Lunn

Remove C code and add a Device Tree node in its place.

---

Quoted 8 lines

This is untested. I've been known to get the active hi/low the wrong way around so that the board powers off as the driver loads at boot time. So it would be very good to have a tested-by: sign off.

 arch/arm/boot/dts/kirkwood-ns2-common.dtsi |    6 ++++++
 arch/arm/mach-kirkwood/board-ns2.c         |   14 --------------
 2 files changed, 6 insertions(+), 14 deletions(-)

Andrew, do you want me to rebase your patch on the top of the pinctrl conversion one ?

Simon

Quoted 55 lines
arch/arm/boot/dts/kirkwood-ns2-common.dtsi +6 -0
index 9bc6785..58c4103 100644
@@ -60,4 +60,10 @@
 			gpios = <&gpio0 12 0>;
 		};
 	};
+
+	gpio_poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&gpio0 31 0>;
+	};
+
 };
arch/arm/mach-kirkwood/board-ns2.c +0 -14
index 8821720..f263449 100644
@@ -15,7 +15,6 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/mv643xx_eth.h>
-#include <linux/gpio.h>
 #include <linux/of.h>
 #include "common.h"
 #include "mpp.h"
@@ -59,13 +58,6 @@ static unsigned int ns2_mpp_config[] __initdata = {
 	0
 };
 
-#define NS2_GPIO_POWER_OFF	31
-
-static void ns2_power_off(void)
-{
-	gpio_set_value(NS2_GPIO_POWER_OFF, 1);
-}
-
 void __init ns2_init(void)
 {
 	/*
@@ -77,10 +69,4 @@ void __init ns2_init(void)
 	    of_machine_is_compatible("lacie,netspace_mini_v2"))
 		ns2_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
 	kirkwood_ge00_init(&ns2_ge00_data);
-
-	if (gpio_request(NS2_GPIO_POWER_OFF, "power-off") == 0 &&
-	    gpio_direction_output(NS2_GPIO_POWER_OFF, 0) == 0)
-		pm_power_off = ns2_power_off;
-	else
-		pr_err("ns2: failed to configure power-off GPIO\n");
 }
Signature · 1 line
1.7.10.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130109/4287e2b0/attachment.sig>

#5 lore raw

PATCH 1/5 ARM: Kirkwood: Convert NS2 to gpio-poweroff.

Quoted 11 lines · Simon Guinot
Quoted 10 lines · Andrew Lunn

Remove C code and add a Device Tree node in its place.

---

This is untested. I've been known to get the active hi/low the wrong way around so that the board powers off as the driver loads at boot time. So it would be very good to have a tested-by: sign off.

Quoted 8 lines
Quoted 3 lines
 arch/arm/boot/dts/kirkwood-ns2-common.dtsi |    6 ++++++
 arch/arm/mach-kirkwood/board-ns2.c         |   14 --------------
 2 files changed, 6 insertions(+), 14 deletions(-)

Andrew, do you want me to rebase your patch on the top of the pinctrl conversion one ?

Hi Simon

Thanks for testing.

What will probably be best is to wait until the next -rc comes out containing the pinctrl fixes and then rebase on top of that.

Thanks
Andrew

Applied
#6 lore raw

PATCH 1/5 ARM: Kirkwood: Convert NS2 to gpio-poweroff.

In reply to Andrew Lunn
Quoted 5 lines · Andrew Lunn

Remove C code and add a Device Tree node in its place.

---

Quoted 8 lines

This is untested. I've been known to get the active hi/low the wrong way around so that the board powers off as the driver loads at boot time. So it would be very good to have a tested-by: sign off.

 arch/arm/boot/dts/kirkwood-ns2-common.dtsi |    6 ++++++
 arch/arm/mach-kirkwood/board-ns2.c         |   14 --------------
 2 files changed, 6 insertions(+), 14 deletions(-)

Applied to mvebu/dt with a remove/remove resolution against Simon Guinot's patch in mvebu/fixes:

4ea931e ARM: Kirkwood: fix ns2 gpios by converting to pinctrl

thx,

Jason.