Skip to contentSkip to conversation

ARM: Kirkwood: Use fixed regulators

PATCH New Andrew Lunn 1 participant 7 messages Nov 17, 2012

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

cover ARM: Kirkwood: Use fixed regulators

A few Kirkwood boards use a GPIO line to enable power to subsystems, eg USB or SATA devices. Use the regulator framework to control these GPIO lines, and describe them in DT rather than C code in the board files.

Posted before as part of the bigger patchset.

Andrew Lunn (5):
ARM: Kirkwood: Enable regulator and fixed regulators.
ARM: Kirkwood: Convert DNSKW to use regulators
ARM: Kirkwood: Convert Dockstar to use regulators
ARM: Kirkwood: Convert GoFlexNet to use regulators
ARM: Kirkwood: Convert LSXL to use regulators

 arch/arm/boot/dts/kirkwood-dnskw.dtsi    |   29 +++++++++++++++++++++++++++++
 arch/arm/boot/dts/kirkwood-dockstar.dts  |   17 +++++++++++++++++
 arch/arm/boot/dts/kirkwood-goflexnet.dts |   17 +++++++++++++++++
 arch/arm/boot/dts/kirkwood-lsxl.dtsi     |   29 +++++++++++++++++++++++++++++
 arch/arm/mach-kirkwood/Kconfig           |    3 ++-
 arch/arm/mach-kirkwood/board-dnskw.c     |    4 ----
 arch/arm/mach-kirkwood/board-dockstar.c  |    4 ----
 arch/arm/mach-kirkwood/board-goflexnet.c |    4 ----
 arch/arm/mach-kirkwood/board-lsxl.c      |    8 --------
 9 files changed, 94 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/5 ARM: Kirkwood: Enable regulator and fixed regulators.

A few boards use a GPIO line to enable power to subsystems, eg USB or SATA devices. Pull in the regulator framework as the first step to controlling these GPIO lines are regulators.

---
 arch/arm/mach-kirkwood/Kconfig |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-kirkwood/Kconfig +2 -1
index e0d26fe..b8e96f3 100644
@@ -49,8 +49,9 @@ config ARCH_KIRKWOOD_DT
 	select POWER_SUPPLY
 	select POWER_RESET
 	select POWER_RESET_GPIO
+	select REGULATOR
+	select REGULATOR_FIXED_VOLTAGE
 	select USE_OF
-
 	help
 	  Say 'Y' here if you want your kernel to support the
 	  Marvell Kirkwood using flattened device tree.
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/5 ARM: Kirkwood: Convert DNSKW to use regulators

In reply to Andrew Lunn

Control the power to SATA0 and SATA1 using a fixed regulator.

---
 arch/arm/boot/dts/kirkwood-dnskw.dtsi |   29 +++++++++++++++++++++++++++++
 arch/arm/mach-kirkwood/board-dnskw.c  |    4 ----
 2 files changed, 29 insertions(+), 4 deletions(-)
arch/arm/boot/dts/kirkwood-dnskw.dtsi +29 -0
index 22aa07a..b6aeb4f 100644
@@ -81,4 +81,33 @@
 			};
 		};
 	};
+
+	regulators {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		sata0_power: regulator at 1 {
+			compatible = "regulator-fixed";
+			reg = <1>;
+			regulator-name = "SATA0 Power";
+			regulator-min-microvolt = <5000000>;
+			regulator-max-microvolt = <5000000>;
+			enable-active-high;
+			regulator-always-on;
+			regulator-boot-on;
+			gpio = <&gpio1 7 0>;
+		};
+		sata1_power: regulator at 2 {
+			compatible = "regulator-fixed";
+			reg = <2>;
+			regulator-name = "SATA1 Power";
+			regulator-min-microvolt = <5000000>;
+			regulator-max-microvolt = <5000000>;
+			enable-active-high;
+			regulator-always-on;
+			regulator-boot-on;
+			gpio = <&gpio1 8 0>;
+		};
+	};
 };
arch/arm/mach-kirkwood/board-dnskw.c +0 -4
index 549369e..653bbbe 100644
@@ -76,10 +76,6 @@ void __init dnskw_init(void)
 	kirkwood_ehci_init();
 	kirkwood_ge00_init(&dnskw_ge00_data);
 
-	/* Ensure power is supplied to both HDDs */
-	dnskw_gpio_register(39, "dnskw:power:sata0", 1);
-	dnskw_gpio_register(40, "dnskw:power:sata1", 1);
-
 	/* Set NAS to turn back on after a power failure */
 	dnskw_gpio_register(37, "dnskw:power:recover", 1);
 }
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 3/5 ARM: Kirkwood: Convert Dockstar to use regulators

In reply to Andrew Lunn

Control the power to USB using a fixed regulator.

---
 arch/arm/boot/dts/kirkwood-dockstar.dts |   17 +++++++++++++++++
 arch/arm/mach-kirkwood/board-dockstar.c |    4 ----
 2 files changed, 17 insertions(+), 4 deletions(-)
arch/arm/boot/dts/kirkwood-dockstar.dts +17 -0
index 08a5824..c0fbfdc 100644
@@ -54,4 +54,21 @@
 			gpios = <&gpio1 15 1>;
 		};
 	};
+	regulators {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		usb_power: regulator at 1 {
+			compatible = "regulator-fixed";
+			reg = <1>;
+			regulator-name = "USB Power";
+			regulator-min-microvolt = <5000000>;
+			regulator-max-microvolt = <5000000>;
+			enable-active-high;
+			regulator-always-on;
+			regulator-boot-on;
+			gpio = <&gpio0 29 0>;
+		};
+	};
 };
arch/arm/mach-kirkwood/board-dockstar.c +0 -4
index f2fbb02..5c60fa1 100644
@@ -24,7 +24,6 @@
 #include <linux/of_fdt.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
-#include <linux/gpio.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -52,9 +51,6 @@ void __init dockstar_dt_init(void)
 	 */
 	kirkwood_mpp_conf(dockstar_mpp_config);
 
-	if (gpio_request(29, "USB Power Enable") != 0 ||
-	    gpio_direction_output(29, 1) != 0)
-		pr_err("can't setup GPIO 29 (USB Power Enable)\n");
 	kirkwood_ehci_init();
 
 	kirkwood_ge00_init(&dockstar_ge00_data);
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 4/5 ARM: Kirkwood: Convert GoFlexNet to use regulators

In reply to Andrew Lunn

Control the power to USB using a fixed regulator.

---
 arch/arm/boot/dts/kirkwood-goflexnet.dts |   17 +++++++++++++++++
 arch/arm/mach-kirkwood/board-goflexnet.c |    4 ----
 2 files changed, 17 insertions(+), 4 deletions(-)
arch/arm/boot/dts/kirkwood-goflexnet.dts +17 -0
index 7c8238f..84de887 100644
@@ -96,4 +96,21 @@
 			gpios = <&gpio1 9 0>;
 		};
 	};
+	regulators {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		usb_power: regulator at 1 {
+			compatible = "regulator-fixed";
+			reg = <1>;
+			regulator-name = "USB Power";
+			regulator-min-microvolt = <5000000>;
+			regulator-max-microvolt = <5000000>;
+			enable-active-high;
+			regulator-always-on;
+			regulator-boot-on;
+			gpio = <&gpio0 29 0>;
+		};
+	};
 };
arch/arm/mach-kirkwood/board-goflexnet.c +0 -4
index 001ca8c..7257a35 100644
@@ -26,7 +26,6 @@
 #include <linux/of_fdt.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
-#include <linux/gpio.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -62,9 +61,6 @@ void __init goflexnet_init(void)
 	 */
 	kirkwood_mpp_conf(goflexnet_mpp_config);
 
-	if (gpio_request(29, "USB Power Enable") != 0 ||
-	    gpio_direction_output(29, 1) != 0)
-		pr_err("can't setup GPIO 29 (USB Power Enable)\n");
 	kirkwood_ehci_init();
 
 	kirkwood_ge00_init(&goflexnet_ge00_data);
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH 5/5 ARM: Kirkwood: Convert LSXL to use regulators

In reply to Andrew Lunn

Control the power to USB and HDD using a fixed regulator.

---
 arch/arm/boot/dts/kirkwood-lsxl.dtsi |   29 +++++++++++++++++++++++++++++
 arch/arm/mach-kirkwood/board-lsxl.c  |    8 --------
 2 files changed, 29 insertions(+), 8 deletions(-)
arch/arm/boot/dts/kirkwood-lsxl.dtsi +29 -0
index 8fea375..65a8c52 100644
@@ -94,4 +94,33 @@
 			gpios = <&gpio1 16 1>;
 		};
 	};
+
+	regulators {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		usb_power: regulator at 1 {
+			compatible = "regulator-fixed";
+			reg = <1>;
+			regulator-name = "USB Power";
+			regulator-min-microvolt = <5000000>;
+			regulator-max-microvolt = <5000000>;
+			enable-active-high;
+			regulator-always-on;
+			regulator-boot-on;
+			gpio = <&gpio0 11 0>;
+		};
+		hdd_power: regulator at 2 {
+			compatible = "regulator-fixed";
+			reg = <2>;
+			regulator-name = "HDD Power";
+			regulator-min-microvolt = <5000000>;
+			regulator-max-microvolt = <5000000>;
+			enable-active-high;
+			regulator-always-on;
+			regulator-boot-on;
+			gpio = <&gpio0 10 0>;
+		};
+	};
 };
arch/arm/mach-kirkwood/board-lsxl.c +0 -8
index 83d8975..b9845c0 100644
@@ -19,7 +19,6 @@
 #include <linux/spi/flash.h>
 #include <linux/spi/spi.h>
 #include <linux/mv643xx_eth.h>
-#include <linux/gpio.h>
 #include <linux/gpio-fan.h>
 #include <linux/input.h>
 #include <asm/mach-types.h>
@@ -111,9 +110,6 @@ static void lsxl_power_off(void)
 	kirkwood_restart('h', NULL);
 }
 
-#define LSXL_GPIO_HDD_POWER 10
-#define LSXL_GPIO_USB_POWER 11
-
 void __init lsxl_init(void)
 {
 	/*
@@ -121,10 +117,6 @@ void __init lsxl_init(void)
 	 */
 	kirkwood_mpp_conf(lsxl_mpp_config);
 
-	/* usb and sata power on */
-	gpio_set_value(LSXL_GPIO_USB_POWER, 1);
-	gpio_set_value(LSXL_GPIO_HDD_POWER, 1);
-
 	kirkwood_ehci_init();
 	kirkwood_ge00_init(&lsxl_ge00_data);
 	kirkwood_ge01_init(&lsxl_ge01_data);
Signature · 1 line
1.7.10.4
#6 lore raw

cover ARM: Kirkwood: Use fixed regulators

In reply to Andrew Lunn

Hi Folks

Forgot to mention, these patches apply on top of the gpio-poweroff patches, which has been ACKed by the appropriate maintainer.

Andrew

Quoted 28 lines · Andrew Lunn

A few Kirkwood boards use a GPIO line to enable power to subsystems, eg USB or SATA devices. Use the regulator framework to control these GPIO lines, and describe them in DT rather than C code in the board files.

Posted before as part of the bigger patchset.

Andrew Lunn (5):
ARM: Kirkwood: Enable regulator and fixed regulators.
ARM: Kirkwood: Convert DNSKW to use regulators
ARM: Kirkwood: Convert Dockstar to use regulators
ARM: Kirkwood: Convert GoFlexNet to use regulators
ARM: Kirkwood: Convert LSXL to use regulators

 arch/arm/boot/dts/kirkwood-dnskw.dtsi    |   29 +++++++++++++++++++++++++++++
 arch/arm/boot/dts/kirkwood-dockstar.dts  |   17 +++++++++++++++++
 arch/arm/boot/dts/kirkwood-goflexnet.dts |   17 +++++++++++++++++
 arch/arm/boot/dts/kirkwood-lsxl.dtsi     |   29 +++++++++++++++++++++++++++++
 arch/arm/mach-kirkwood/Kconfig           |    3 ++-
 arch/arm/mach-kirkwood/board-dnskw.c     |    4 ----
 arch/arm/mach-kirkwood/board-dockstar.c  |    4 ----
 arch/arm/mach-kirkwood/board-goflexnet.c |    4 ----
 arch/arm/mach-kirkwood/board-lsxl.c      |    8 --------
 9 files changed, 94 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.10.4