Skip to contentSkip to conversation

ARM: dts: mxs: Use 'regulator-fixed' for turning on LCD

PATCH New Fabio Estevam 2 participants 4 messages Apr 5, 2013

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v4 1/2 ARM: dts: mxs: Use 'regulator-fixed' for turning on LCD

From: Fabio Estevam <[email protected]>

Instead of using a custom binding for turning on a GPIO that activates the LCD, use the standard 'regulator-fixed'.

---
Changes since v3:
- Fix regulator bindings (use lcd-supply)
Changes since v2:
- Use regulator-fixed
Changes since v1:
- Adjust Subject, since the change is not specific to mx28evk

 Documentation/devicetree/bindings/fb/mxsfb.txt |    5 +----
 arch/arm/boot/dts/imx23-evk.dts                |   11 ++++++++++-
 arch/arm/boot/dts/imx28-evk.dts                |   11 ++++++++++-
 3 files changed, 21 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/fb/mxsfb.txt +1 -4
index 7ba3b76..b15230c 100644
@@ -8,9 +8,7 @@ Required properties:
 - display : phandle to display node (see below for details)
 
 Optional properties:
-- panel-enable-gpios : Should specify the gpio for panel enable
-
-* display node
+- display node
 
 Required properties:
 - bits-per-pixel : <16> for RGB565, <32> for RGB888/666.
@@ -25,7 +23,6 @@ lcdif at 80030000 {
 	compatible = "fsl,imx28-lcdif";
 	reg = <0x80030000 2000>;
 	interrupts = <38 86>;
-	panel-enable-gpios = <&gpio3 30 0>;
 
 	display: display {
 		bits-per-pixel = <32>;
arch/arm/boot/dts/imx23-evk.dts +10 -1
index 7880e17..da0588a 100644
@@ -59,7 +59,7 @@
 			lcdif at 80030000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <&lcdif_24bit_pins_a>;
-				panel-enable-gpios = <&gpio1 18 0>;
+				lcd-supply = <&reg_lcd_3v3>;
 				display = <&display>;
 				status = "okay";
 
@@ -120,6 +120,15 @@
 			regulator-max-microvolt = <3300000>;
 			gpio = <&gpio1 29 0>;
 		};
+
+		reg_lcd_3v3: lcd-3v3 {
+			compatible = "regulator-fixed";
+			regulator-name = "lcd-3v3";
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3300000>;
+			gpio = <&gpio1 18 0>;
+			enable-active-high;
+		};
 	};
 
 	backlight {
arch/arm/boot/dts/imx28-evk.dts +10 -1
index 2d4ea3b..3637bf3 100644
@@ -123,7 +123,7 @@
 				pinctrl-names = "default";
 				pinctrl-0 = <&lcdif_24bit_pins_a
 					     &lcdif_pins_evk>;
-				panel-enable-gpios = <&gpio3 30 0>;
+				lcd-supply = <&reg_lcd_3v3>;
 				display = <&display>;
 				status = "okay";
 
@@ -310,6 +310,15 @@
 			gpio = <&gpio3 8 0>;
 			enable-active-high;
 		};
+
+		reg_lcd_3v3: lcd-3v3 {
+			compatible = "regulator-fixed";
+			regulator-name = "lcd-3v3";
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3300000>;
+			gpio = <&gpio3 30 0>;
+			enable-active-high;
+		};
 	};
 
 	sound {
Signature · 1 line
1.7.9.5
author reviewer
#1 lore raw

PATCH v4 2/2 video: mxsfb: Use devm_regulator_get()

From: Fabio Estevam <[email protected]>

Instead of using a custom binding for retrieving the GPIO that activates the LCD from devicetree, use the standard devm_regulator_get().

This approach has the advantage to be more generic.

For example: in the case of a board that has a PMIC supplying the LCD voltage, the current approach would not work, as it only searches for a GPIO pin.

Cc Florian Tobias Schandinat <[email protected]>

---
Changes since v3:
- None
Changes since v2:
- Use devm_regulator_get()
Changes since v1:
- No changes

 drivers/video/mxsfb.c |   19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/video/mxsfb.c +6 -13
index eac7c1a..c536887 100644
@@ -42,7 +42,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/of_device.h>
-#include <linux/of_gpio.h>
 #include <video/of_display_timing.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
@@ -51,6 +50,7 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/fb.h>
 #include <video/videomode.h>
+#include <linux/regulator/consumer.h>
 
 #define REG_SET	4
 #define REG_CLR	8
@@ -859,9 +859,8 @@ static int mxsfb_probe(struct platform_device *pdev)
 	struct fb_info *fb_info;
 	struct fb_modelist *modelist;
 	struct pinctrl *pinctrl;
-	int panel_enable;
-	enum of_gpio_flags flags;
 	int ret;
+	struct regulator *reg_lcd;
 
 	if (of_id)
 		pdev->id_entry = of_id->data;
@@ -904,18 +903,12 @@ static int mxsfb_probe(struct platform_device *pdev)
 		goto fb_release;
 	}
 
-	panel_enable = of_get_named_gpio_flags(pdev->dev.of_node,
-					       "panel-enable-gpios", 0, &flags);
-	if (gpio_is_valid(panel_enable)) {
-		unsigned long f = GPIOF_OUT_INIT_HIGH;
-		if (flags == OF_GPIO_ACTIVE_LOW)
-			f = GPIOF_OUT_INIT_LOW;
-		ret = devm_gpio_request_one(&pdev->dev, panel_enable,
-					    f, "panel-enable");
+	reg_lcd = devm_regulator_get(&pdev->dev, "lcd");
+	if (!IS_ERR(reg_lcd)) {
+		ret = regulator_enable(reg_lcd);
 		if (ret) {
 			dev_err(&pdev->dev,
-				"failed to request gpio %d: %d\n",
-				panel_enable, ret);
+				"Failed to enable lcd regulator: %d\n", ret);
 			goto fb_release;
 		}
 	}
Signature · 1 line
1.7.9.5
author reviewer
#2 lore raw

PATCH v4 2/2 video: mxsfb: Use devm_regulator_get()

Quoted 58 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Instead of using a custom binding for retrieving the GPIO that activates the LCD from devicetree, use the standard devm_regulator_get().

This approach has the advantage to be more generic.

For example: in the case of a board that has a PMIC supplying the LCD voltage, the current approach would not work, as it only searches for a GPIO pin.

Cc Florian Tobias Schandinat <[email protected]>

---
Changes since v3:
- None
Changes since v2:
- Use devm_regulator_get()
Changes since v1:
- No changes

 drivers/video/mxsfb.c |   19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/video/mxsfb.c +2 -4
index eac7c1a..c536887 100644
@@ -42,7 +42,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/of_device.h>
-#include <linux/of_gpio.h>
 #include <video/of_display_timing.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
@@ -51,6 +50,7 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/fb.h>
 #include <video/videomode.h>
+#include <linux/regulator/consumer.h>
 
 #define REG_SET        4
 #define REG_CLR        8
@@ -859,9 +859,8 @@ static int mxsfb_probe(struct platform_device *pdev)
        struct fb_info *fb_info;
        struct fb_modelist *modelist;
        struct pinctrl *pinctrl;
-       int panel_enable;
-       enum of_gpio_flags flags;
        int ret;
+       struct regulator *reg_lcd;
 
        if (of_id)
                pdev->id_entry = of_id->data;
@@ -904,18 +903,12 @@ static int mxsfb_probe(struct platform_device *pdev)
                goto fb_release;
        }
 
-       panel_enable = of_get_named_gpio_flags(pdev->dev.of_node,

drivers/video/mxsfb.c static int mxsfb_probe(struct platform_device *pdev) · line 908

Quoted 10 lines
drivers/video/mxsfb.c +3 -7
-                                              "panel-enable-gpios", 0, &flags);
-       if (gpio_is_valid(panel_enable)) {
-               unsigned long f = GPIOF_OUT_INIT_HIGH;
-               if (flags == OF_GPIO_ACTIVE_LOW)
-                       f = GPIOF_OUT_INIT_LOW;
-               ret = devm_gpio_request_one(&pdev->dev, panel_enable,
-                                           f, "panel-enable");
+       reg_lcd = devm_regulator_get(&pdev->dev, "lcd");
+       if (!IS_ERR(reg_lcd)) {
+               ret = regulator_enable(reg_lcd);

I missed a regulator_disable() call. Will send a new version tomorrow.

#3 lore raw

PATCH v4 1/2 ARM: dts: mxs: Use 'regulator-fixed' for turning on LCD

In reply to Fabio Estevam
Quoted 6 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Instead of using a custom binding for turning on a GPIO that activates the LCD, use the standard 'regulator-fixed'.

For sake of git bisect, I think you need to have these two patches be one?

Quoted 17 lines

---
Changes since v3:
- Fix regulator bindings (use lcd-supply)
Changes since v2:
- Use regulator-fixed
Changes since v1:
- Adjust Subject, since the change is not specific to mx28evk

 Documentation/devicetree/bindings/fb/mxsfb.txt |    5 +----
 arch/arm/boot/dts/imx23-evk.dts                |   11 ++++++++++-
 arch/arm/boot/dts/imx28-evk.dts                |   11 ++++++++++-
 3 files changed, 21 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/fb/mxsfb.txt +0 -0
index 7ba3b76..b15230c 100644

Documentation/devicetree/bindings/fb/mxsfb.txt Required properties: · line 12

Quoted 8 lines
Documentation/devicetree/bindings/fb/mxsfb.txt +1 -3
@@ -8,9 +8,7 @@ Required properties:
 - display : phandle to display node (see below for details)
 
 Optional properties:
-- panel-enable-gpios : Should specify the gpio for panel enable
-
-* display node
+- display node
 

Is this change related? You are turning a sub-node into a optional property. It does not look right.

Shawn

Quoted 71 lines
Documentation/devicetree/bindings/fb/mxsfb.txt +0 -1
 Required properties:
 - bits-per-pixel : <16> for RGB565, <32> for RGB888/666.
@@ -25,7 +23,6 @@ lcdif at 80030000 {
 	compatible = "fsl,imx28-lcdif";
 	reg = <0x80030000 2000>;
 	interrupts = <38 86>;
-	panel-enable-gpios = <&gpio3 30 0>;
 
 	display: display {
 		bits-per-pixel = <32>;
arch/arm/boot/dts/imx23-evk.dts +10 -1
index 7880e17..da0588a 100644
@@ -59,7 +59,7 @@
 			lcdif at 80030000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <&lcdif_24bit_pins_a>;
-				panel-enable-gpios = <&gpio1 18 0>;
+				lcd-supply = <&reg_lcd_3v3>;
 				display = <&display>;
 				status = "okay";
 
@@ -120,6 +120,15 @@
 			regulator-max-microvolt = <3300000>;
 			gpio = <&gpio1 29 0>;
 		};
+
+		reg_lcd_3v3: lcd-3v3 {
+			compatible = "regulator-fixed";
+			regulator-name = "lcd-3v3";
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3300000>;
+			gpio = <&gpio1 18 0>;
+			enable-active-high;
+		};
 	};
 
 	backlight {
arch/arm/boot/dts/imx28-evk.dts +10 -1
index 2d4ea3b..3637bf3 100644
@@ -123,7 +123,7 @@
 				pinctrl-names = "default";
 				pinctrl-0 = <&lcdif_24bit_pins_a
 					     &lcdif_pins_evk>;
-				panel-enable-gpios = <&gpio3 30 0>;
+				lcd-supply = <&reg_lcd_3v3>;
 				display = <&display>;
 				status = "okay";
 
@@ -310,6 +310,15 @@
 			gpio = <&gpio3 8 0>;
 			enable-active-high;
 		};
+
+		reg_lcd_3v3: lcd-3v3 {
+			compatible = "regulator-fixed";
+			regulator-name = "lcd-3v3";
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3300000>;
+			gpio = <&gpio3 30 0>;
+			enable-active-high;
+		};
 	};
 
 	sound {
Signature · 1 line
1.7.9.5