Skip to contentSkip to conversation

video: imxfb: Introduce regulator support.

PATCH Superseded Denis Carikli 2 participants 8 messages Nov 5, 2013

Subsystems (7)

v10 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

PATCH v10 1/7 video: imxfb: Introduce regulator support.

This commit is based on the following commit by Fabio Estevam:
4344429 video: mxsfb: Introduce regulator support

Cc Fabio Estevam <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc Jean-Christophe Plagniol-Villard <[email protected]>
Cc Tomi Valkeinen <[email protected]>
Cc linux-fbdev at vger.kernel.org
Cc Eric B?nard <[email protected]>

---
ChangeLog v9->v10:
- Added a return 0; at the end of imxfb_disable_controller.

ChangeLog v8->v9:
- return an error if regulator_{enable,disable} fails in imxfb_{enable,disable}_controller, and use it.

---
 drivers/video/imxfb.c |   55 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 43 insertions(+), 12 deletions(-)
drivers/video/imxfb.c +43 -12
index 38733ac..a2fe8bd 100644
@@ -28,6 +28,7 @@
 #include <linux/cpufreq.h>
 #include <linux/clk.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/math64.h>
@@ -145,6 +146,7 @@ struct imxfb_info {
 	struct clk		*clk_ipg;
 	struct clk		*clk_ahb;
 	struct clk		*clk_per;
+	struct regulator	*reg_lcd;
 	enum imxfb_type		devtype;
 	bool			enabled;
 
@@ -561,14 +563,25 @@ static void imxfb_exit_backlight(struct imxfb_info *fbi)
 }
 #endif
 
-static void imxfb_enable_controller(struct imxfb_info *fbi)
+static int imxfb_enable_controller(struct imxfb_info *fbi)
 {
+	int ret;
 
 	if (fbi->enabled)
-		return;
+		return 0;
 
 	pr_debug("Enabling LCD controller\n");
 
+	if (fbi->reg_lcd) {
+		ret = regulator_enable(fbi->reg_lcd);
+		if (ret) {
+			dev_err(&fbi->pdev->dev,
+				"lcd regulator enable failed with error: %d\n",
+				ret);
+			return ret;
+		}
+	}
+
 	writel(fbi->screen_dma, fbi->regs + LCDC_SSA);
 
 	/* panning offset 0 (0 pixel offset)        */
@@ -593,12 +606,16 @@ static void imxfb_enable_controller(struct imxfb_info *fbi)
 		fbi->backlight_power(1);
 	if (fbi->lcd_power)
 		fbi->lcd_power(1);
+
+	return 0;
 }
 
-static void imxfb_disable_controller(struct imxfb_info *fbi)
+static int imxfb_disable_controller(struct imxfb_info *fbi)
 {
+	int ret;
+
 	if (!fbi->enabled)
-		return;
+		return 0;
 
 	pr_debug("Disabling LCD controller\n");
 
@@ -613,6 +630,17 @@ static void imxfb_disable_controller(struct imxfb_info *fbi)
 	fbi->enabled = false;
 
 	writel(0, fbi->regs + LCDC_RMCR);
+
+	if (fbi->reg_lcd) {
+		ret = regulator_disable(fbi->reg_lcd);
+		if (ret)
+			dev_err(&fbi->pdev->dev,
+				"lcd regulator disable failed with error: %d\n",
+				ret);
+			return ret;
+	}
+
+	return 0;
 }
 
 static int imxfb_blank(int blank, struct fb_info *info)
@@ -626,13 +654,12 @@ static int imxfb_blank(int blank, struct fb_info *info)
 	case FB_BLANK_VSYNC_SUSPEND:
 	case FB_BLANK_HSYNC_SUSPEND:
 	case FB_BLANK_NORMAL:
-		imxfb_disable_controller(fbi);
-		break;
+		return imxfb_disable_controller(fbi);
 
 	case FB_BLANK_UNBLANK:
-		imxfb_enable_controller(fbi);
-		break;
+		return imxfb_enable_controller(fbi);
 	}
+
 	return 0;
 }
 
@@ -734,8 +761,7 @@ static int imxfb_suspend(struct platform_device *dev, pm_message_t state)
 
 	pr_debug("%s\n", __func__);
 
-	imxfb_disable_controller(fbi);
-	return 0;
+	return imxfb_disable_controller(fbi);
 }
 
 static int imxfb_resume(struct platform_device *dev)
@@ -745,8 +771,7 @@ static int imxfb_resume(struct platform_device *dev)
 
 	pr_debug("%s\n", __func__);
 
-	imxfb_enable_controller(fbi);
-	return 0;
+	return imxfb_enable_controller(fbi);
 }
 #else
 #define imxfb_suspend	NULL
@@ -1020,6 +1045,12 @@ static int imxfb_probe(struct platform_device *pdev)
 		goto failed_register;
 	}
 
+	fbi->reg_lcd = devm_regulator_get(&pdev->dev, "lcd");
+	if (IS_ERR(fbi->reg_lcd)) {
+		dev_info(&pdev->dev, "No lcd regulator used.\n");
+		fbi->reg_lcd = NULL;
+	}
+
 	imxfb_enable_controller(fbi);
 	fbi->pdev = pdev;
 #ifdef PWMR_BACKLIGHT_AVAILABLE
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v10 2/7 video: imxfb: Also add pwmr for the device tree.

pwmr has to be set to get the imxfb backlight work, though pwmr was only configurable trough the platform data.

Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Ian Campbell <[email protected]>
Cc devicetree at vger.kernel.org
Cc Jean-Christophe Plagniol-Villard <[email protected]>
Cc Tomi Valkeinen <[email protected]>
Cc linux-fbdev at vger.kernel.org
Cc Sascha Hauer <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc Eric B?nard <[email protected]>
---
 .../devicetree/bindings/video/fsl,imx-fb.txt       |    3 +++
 drivers/video/imxfb.c                              |    2 ++
 2 files changed, 5 insertions(+)
Documentation/devicetree/bindings/video/fsl,imx-fb.txt +3 -0
index 46da08d..ac457ae 100644
@@ -17,6 +17,9 @@ Required nodes:
 Optional properties:
 - fsl,dmacr: DMA Control Register value. This is optional. By default, the
 	register is not modified as recommended by the datasheet.
+- fsl,pwmr:  LCDC PWM Contrast Control Register value. That property is
+	optional, but defining it is necessary to get the backlight working. If that
+	property is ommited, the register is zeroed.
 - fsl,lscr1: LCDC Sharp Configuration Register value.
 
 Example:
drivers/video/imxfb.c +2 -0
index a2fe8bd..d2447d2 100644
@@ -835,6 +835,8 @@ static int imxfb_init_fbinfo(struct platform_device *pdev)
 
 		of_property_read_u32(np, "fsl,dmacr", &fbi->dmacr);
 
+		of_property_read_u32(np, "fsl,pwmr", &fbi->pwmr);
+
 		/* These two function pointers could be used by some specific
 		 * platforms. */
 		fbi->lcd_power = NULL;
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v10 3/7 video: Kconfig: Allow more broad selection of the imxfb framebuffer driver.

In reply to Denis Carikli

Without that patch, a user can't select the imxfb driver when the i.MX25 and/or
the i.MX27 device tree board are selected and that no boards that selects IMX_HAVE_PLATFORM_IMX_FB are compiled in.

Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Ian Campbell <[email protected]>
Cc devicetree at vger.kernel.org
Cc Sascha Hauer <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc Russell King <[email protected]>
Cc Jean-Christophe Plagniol-Villard <[email protected]>
Cc Tomi Valkeinen <[email protected]>
Cc linux-fbdev at vger.kernel.org
Cc Eric B?nard <[email protected]>

---
ChangeLog v8->v9:
- Added Jean-Christophe PLAGNIOL-VILLARD's ACK.

---
 drivers/video/Kconfig |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/Kconfig +1 -1
index 84b685f..f65e577 100644
@@ -363,7 +363,7 @@ config FB_SA1100
 
 config FB_IMX
 	tristate "Freescale i.MX1/21/25/27 LCD support"
-	depends on FB && IMX_HAVE_PLATFORM_IMX_FB
+	depends on FB && ARCH_MXC
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v10 4/7 pinctrl: pinctrl-imx: add imx25 pinctrl driver

In reply to Denis Carikli

This is mostly cut and paste from the imx35 pinctrl driver. The data was generated using sed and awk on
arch/arm/plat-mxc/include/mach/iomux-mx25.h.

Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Ian Campbell <[email protected]>
Cc devicetree at vger.kernel.org
Cc Sascha Hauer <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc Russell King <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Eric B?nard <[email protected]>

---
ChangeLog v9->v10:
- Added a imx25-pingrp.h header.

ChangeLog v8->v9:
- Whitespace cleanup betwen the CC: and Signed-off-by.
- Kconfig: rebased to make it apply on the new HEAD.

---
 .../bindings/pinctrl/fsl,imx25-pinctrl.txt         |   33 ++
 arch/arm/boot/dts/imx25-pinfunc.h                  |  513 ++++++++++++++++++++
 arch/arm/boot/dts/imx25-pingrp.h                   |   79 +++
 arch/arm/boot/dts/imx25.dtsi                       |    1 +
 drivers/pinctrl/Kconfig                            |    9 +
 drivers/pinctrl/Makefile                           |    1 +
 drivers/pinctrl/pinctrl-imx25.c                    |  351 ++++++++++++++
 7 files changed, 987 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt
 create mode 100644 arch/arm/boot/dts/imx25-pinfunc.h
 create mode 100644 arch/arm/boot/dts/imx25-pingrp.h
 create mode 100644 drivers/pinctrl/pinctrl-imx25.c
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt new file +33 -0
new file mode 100644
index 0000000..64906ca
@@ -0,0 +1,33 @@
+* Freescale IMX25 IOMUX Controller
+
+Please refer to fsl,imx-pinctrl.txt in this directory for common binding part
+and usage.
+
+Required properties:
+- compatible: "fsl,imx25-iomuxc"
+- fsl,pins: two integers array, represents a group of pins mux and config
+  setting. The format is fsl,pins = <PIN_FUNC_ID CONFIG>, PIN_FUNC_ID is a
+  pin working on a specific function, CONFIG is the pad setting value like
+  pull-up for this pin. Please refer to imx25 datasheet for the valid pad
+  config settings.
+
+CONFIG bits definition:
+PAD_CTL_DRIVE_VOLAGAGE_18	(1 << 13)
+PAD_CTL_DRIVE_VOLAGAGE_33	(0 << 13)
+PAD_CTL_HYS			(1 << 8)
+PAD_CTL_PKE			(1 << 7)
+PAD_CTL_PUE			(1 << 6)
+PAD_CTL_PUS_100K_DOWN		(0 << 4)
+PAD_CTL_PUS_47K_UP		(1 << 4)
+PAD_CTL_PUS_100K_UP		(2 << 4)
+PAD_CTL_PUS_22K_UP		(3 << 4)
+PAD_CTL_ODE_CMOS		(0 << 3)
+PAD_CTL_ODE_OPENDRAIN		(1 << 3)
+PAD_CTL_DSE_NOMINAL		(0 << 1)
+PAD_CTL_DSE_HIGH		(1 << 1)
+PAD_CTL_DSE_MAX			(2 << 1)
+PAD_CTL_SRE_FAST		(1 << 0)
+PAD_CTL_SRE_SLOW		(0 << 0)
+
+Refer to imx25-pinfunc.h in device tree source folder for all available
+imx25 PIN_FUNC_ID.
arch/arm/boot/dts/imx25-pinfunc.h new file +513 -0

513 lines not on this page · raw message

arch/arm/boot/dts/imx25-pingrp.h new file +79 -0

79 lines not on this page · raw message

arch/arm/boot/dts/imx25.dtsi +1 -0
index 623ed55..1c19ad3 100644
@@ -10,6 +10,7 @@
  */
 
 #include "skeleton.dtsi"
+#include "imx25-pinfunc.h"
 
 / {
 	aliases {
drivers/pinctrl/Kconfig +9 -0
index b6e864e..6716be9 100644
@@ -80,6 +80,15 @@ config PINCTRL_IMX
 	select PINMUX
 	select PINCONF
 
+
+config PINCTRL_IMX25
+        bool "IMX25 pinctrl driver"
+        depends on OF
+        depends on SOC_IMX25
+        select PINCTRL_IMX
+        help
+          Say Y here to enable the imx25 pinctrl driver
+
 config PINCTRL_IMX35
 	bool "IMX35 pinctrl driver"
 	depends on OF
drivers/pinctrl/Makefile +1 -0
index 496d9bf..9bf4b16 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_PINCTRL_IMX6SL)	+= pinctrl-imx6sl.o
 obj-$(CONFIG_PINCTRL_FALCON)	+= pinctrl-falcon.o
 obj-$(CONFIG_PINCTRL_MXS)	+= pinctrl-mxs.o
 obj-$(CONFIG_PINCTRL_IMX23)	+= pinctrl-imx23.o
+obj-$(CONFIG_PINCTRL_IMX25)	+= pinctrl-imx25.o
 obj-$(CONFIG_PINCTRL_IMX28)	+= pinctrl-imx28.o
 obj-$(CONFIG_PINCTRL_NOMADIK)	+= pinctrl-nomadik.o
 obj-$(CONFIG_PINCTRL_STN8815)	+= pinctrl-nomadik-stn8815.o
drivers/pinctrl/pinctrl-imx25.c new file +351 -0

351 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v10 5/7 ARM: dts: imx25.dtsi: Permit to use the iomuxc in the dts.

In reply to Denis Carikli

An iomuxc label was added, and imx25-pingrp.h was included.

Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Ian Campbell <[email protected]>
Cc devicetree at vger.kernel.org
Cc Sascha Hauer <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc Eric B?nard <[email protected]>

---
ChangeLog v9->v10:
- New patch made from the remaining parts of the "ARM: dts: imx25.dtsi: Add some pinmux pins." patch in the old serie.

---
 arch/arm/boot/dts/imx25.dtsi |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/boot/dts/imx25.dtsi +2 -1
index 1c19ad3..1a86eab 100644
@@ -11,6 +11,7 @@
 
 #include "skeleton.dtsi"
 #include "imx25-pinfunc.h"
+#include "imx25-pingrp.h"
 
 / {
 	aliases {
@@ -174,7 +175,7 @@
 				status = "disabled";
 			};
 
-			iomuxc at 43fac000{
+			iomuxc: iomuxc at 43fac000 {
 				compatible = "fsl,imx25-iomuxc";
 				reg = <0x43fac000 0x4000>;
 			};
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v10 6/7 ARM i.MX25: build in pinctrl support.

In reply to Denis Carikli
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Ian Campbell <[email protected]>
Cc devicetree at vger.kernel.org
Cc Sascha Hauer <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc Russell King <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Eric B?nard <[email protected]>

---
ChangeLog v9->v10:
- Splitted to make the automatic enabling of the functionality separate.

---
 arch/arm/mach-imx/Kconfig |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-imx/Kconfig +2 -0
index 2b90984..4df7305 100644
@@ -102,6 +102,8 @@ config SOC_IMX25
 	select COMMON_CLK
 	select CPU_ARM926T
 	select MXC_AVIC
+	select PINCTRL
+	select PINCTRL_IMX25
 
 config SOC_IMX27
 	bool
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v10 7/7 ARM: dts: Add support for the cpuimx25 board from Eukrea and its baseboard.

In reply to Denis Carikli

The following devices/functionalities were added:
* Main and secondary UARTs.
* i2c and the pcf8563 device.
* CMO-QVGA(With backlight), DVI-VGA and DVI-SVGA displays
* Ethernet.
* NAND.
* The BP1 button.
* The LED.
* Watchdog
* SD.

Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Ian Campbell <[email protected]>
Cc devicetree at vger.kernel.org
Cc Sascha Hauer <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc Eric B?nard <[email protected]>

---
ChangeLog v9->v10:
- Adapted to the new pingrp patches.

ChangeLog v8->v9:
- Licenses were shortened.

---
 arch/arm/boot/dts/imx25-eukrea-cpuimx25.dtsi       |   60 ++++++++++
 .../imx25-eukrea-mbimxsd25-baseboard-cmo-qvga.dts  |   66 +++++++++++
 .../imx25-eukrea-mbimxsd25-baseboard-dvi-svga.dts  |   45 ++++++++
 .../imx25-eukrea-mbimxsd25-baseboard-dvi-vga.dts   |   45 ++++++++
 .../boot/dts/imx25-eukrea-mbimxsd25-baseboard.dts  |  117 ++++++++++++++++++++
 5 files changed, 333 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx25-eukrea-cpuimx25.dtsi
 create mode 100644 arch/arm/boot/dts/imx25-eukrea-mbimxsd25-baseboard-cmo-qvga.dts
 create mode 100644 arch/arm/boot/dts/imx25-eukrea-mbimxsd25-baseboard-dvi-svga.dts
 create mode 100644 arch/arm/boot/dts/imx25-eukrea-mbimxsd25-baseboard-dvi-vga.dts
 create mode 100644 arch/arm/boot/dts/imx25-eukrea-mbimxsd25-baseboard.dts
arch/arm/boot/dts/imx25-eukrea-cpuimx25.dtsi new file +60 -0
new file mode 100644
index 0000000..8abd45a
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2013 Eukr?a Electromatique <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "imx25.dtsi"
+
+/ {
+	model = "Eukrea CPUIMX25";
+	compatible = "eukrea,cpuimx25", "fsl,imx25";
+
+	memory {
+		reg = <0x80000000 0x4000000>; /* 64M */
+	};
+};
+
+&fec {
+	phy-mode = "rmii";
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_fec>;
+	status = "okay";
+};
+
+&i2c1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c1>;
+	status = "okay";
+
+	pcf8563 at 51 {
+		compatible = "nxp,pcf8563";
+		reg = <0x51>;
+	};
+};
+
+&iomuxc {
+	imx25-eukrea-cpuimx25 {
+		pinctrl_fec: fecgrp {
+			fsl,pins = <MX25_FEC_PINGRP1>;
+		};
+
+		pinctrl_i2c1: i2c1grp {
+			fsl,pins = <MX25_I2C1_PINGRP1>;
+		};
+	};
+};
+
+&nfc {
+	nand-bus-width = <8>;
+	nand-ecc-mode = "hw";
+	nand-on-flash-bbt;
+	status = "okay";
+};
arch/arm/boot/dts/imx25-eukrea-mbimxsd25-baseboard-cmo-qvga.dts new file +66 -0

66 lines not on this page · raw message

arch/arm/boot/dts/imx25-eukrea-mbimxsd25-baseboard-dvi-svga.dts new file +45 -0

45 lines not on this page · raw message

arch/arm/boot/dts/imx25-eukrea-mbimxsd25-baseboard-dvi-vga.dts new file +45 -0

45 lines not on this page · raw message

arch/arm/boot/dts/imx25-eukrea-mbimxsd25-baseboard.dts new file +117 -0

117 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v10 4/7 pinctrl: pinctrl-imx: add imx25 pinctrl driver

In reply to Denis Carikli
Quoted 5 lines · Denis Carikli
 .../bindings/pinctrl/fsl,imx25-pinctrl.txt         |   33 ++
 arch/arm/boot/dts/imx25-pinfunc.h                  |  513 ++++++++++++++++++++
 arch/arm/boot/dts/imx25-pingrp.h                   |   79 +++
 arch/arm/boot/dts/imx25.dtsi                       |    1 +

Unless Linus gives his ACK on the patch to have it go via IMX tree, we need to split above 3 files into another patch that we can apply on IMX tree, because other patches e.g. the last one in the series depends on them.

BTW, it seems that you missed the comments that Sascha and Markus put on the v9 of the patch.

Shawn

Quoted 8 lines
 drivers/pinctrl/Kconfig                            |    9 +
 drivers/pinctrl/Makefile                           |    1 +
 drivers/pinctrl/pinctrl-imx25.c                    |  351 ++++++++++++++
 7 files changed, 987 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt
 create mode 100644 arch/arm/boot/dts/imx25-pinfunc.h
 create mode 100644 arch/arm/boot/dts/imx25-pingrp.h
 create mode 100644 drivers/pinctrl/pinctrl-imx25.c