mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 16:49:22 +00:00
video: mxsfb: Introduce regulator support
Instead of using a custom binding for retrieving the GPIO that activates the LCD from devicetree, use a standard regulator. 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. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
This commit is contained in:
parent
ac77bc227e
commit
4344429d3d
4 changed files with 43 additions and 24 deletions
|
@ -7,9 +7,6 @@ Required properties:
|
||||||
- interrupts: Should contain lcdif interrupts
|
- interrupts: Should contain lcdif interrupts
|
||||||
- display : phandle to display node (see below for details)
|
- 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:
|
Required properties:
|
||||||
|
@ -25,7 +22,6 @@ lcdif@80030000 {
|
||||||
compatible = "fsl,imx28-lcdif";
|
compatible = "fsl,imx28-lcdif";
|
||||||
reg = <0x80030000 2000>;
|
reg = <0x80030000 2000>;
|
||||||
interrupts = <38 86>;
|
interrupts = <38 86>;
|
||||||
panel-enable-gpios = <&gpio3 30 0>;
|
|
||||||
|
|
||||||
display: display {
|
display: display {
|
||||||
bits-per-pixel = <32>;
|
bits-per-pixel = <32>;
|
||||||
|
|
|
@ -59,7 +59,7 @@ hog_pins_a: hog@0 {
|
||||||
lcdif@80030000 {
|
lcdif@80030000 {
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
pinctrl-0 = <&lcdif_24bit_pins_a>;
|
pinctrl-0 = <&lcdif_24bit_pins_a>;
|
||||||
panel-enable-gpios = <&gpio1 18 0>;
|
lcd-supply = <®_lcd_3v3>;
|
||||||
display = <&display>;
|
display = <&display>;
|
||||||
status = "okay";
|
status = "okay";
|
||||||
|
|
||||||
|
@ -120,6 +120,15 @@ reg_vddio_sd0: vddio-sd0 {
|
||||||
regulator-max-microvolt = <3300000>;
|
regulator-max-microvolt = <3300000>;
|
||||||
gpio = <&gpio1 29 0>;
|
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 {
|
backlight {
|
||||||
|
|
|
@ -123,7 +123,7 @@ lcdif@80030000 {
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
pinctrl-0 = <&lcdif_24bit_pins_a
|
pinctrl-0 = <&lcdif_24bit_pins_a
|
||||||
&lcdif_pins_evk>;
|
&lcdif_pins_evk>;
|
||||||
panel-enable-gpios = <&gpio3 30 0>;
|
lcd-supply = <®_lcd_3v3>;
|
||||||
display = <&display>;
|
display = <&display>;
|
||||||
status = "okay";
|
status = "okay";
|
||||||
|
|
||||||
|
@ -310,6 +310,15 @@ reg_usb1_vbus: usb1_vbus {
|
||||||
gpio = <&gpio3 8 0>;
|
gpio = <&gpio3 8 0>;
|
||||||
enable-active-high;
|
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 {
|
sound {
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of_device.h>
|
||||||
#include <linux/of_gpio.h>
|
|
||||||
#include <video/of_display_timing.h>
|
#include <video/of_display_timing.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
|
@ -50,6 +49,7 @@
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/pinctrl/consumer.h>
|
#include <linux/pinctrl/consumer.h>
|
||||||
#include <linux/fb.h>
|
#include <linux/fb.h>
|
||||||
|
#include <linux/regulator/consumer.h>
|
||||||
#include <video/videomode.h>
|
#include <video/videomode.h>
|
||||||
|
|
||||||
#define REG_SET 4
|
#define REG_SET 4
|
||||||
|
@ -179,6 +179,7 @@ struct mxsfb_info {
|
||||||
unsigned dotclk_delay;
|
unsigned dotclk_delay;
|
||||||
const struct mxsfb_devdata *devdata;
|
const struct mxsfb_devdata *devdata;
|
||||||
u32 sync;
|
u32 sync;
|
||||||
|
struct regulator *reg_lcd;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define mxsfb_is_v3(host) (host->devdata->ipversion == 3)
|
#define mxsfb_is_v3(host) (host->devdata->ipversion == 3)
|
||||||
|
@ -338,9 +339,19 @@ static void mxsfb_enable_controller(struct fb_info *fb_info)
|
||||||
{
|
{
|
||||||
struct mxsfb_info *host = to_imxfb_host(fb_info);
|
struct mxsfb_info *host = to_imxfb_host(fb_info);
|
||||||
u32 reg;
|
u32 reg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
dev_dbg(&host->pdev->dev, "%s\n", __func__);
|
dev_dbg(&host->pdev->dev, "%s\n", __func__);
|
||||||
|
|
||||||
|
if (host->reg_lcd) {
|
||||||
|
ret = regulator_enable(host->reg_lcd);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(&host->pdev->dev,
|
||||||
|
"lcd regulator enable failed: %d\n", ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clk_prepare_enable(host->clk);
|
clk_prepare_enable(host->clk);
|
||||||
clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U);
|
clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U);
|
||||||
|
|
||||||
|
@ -362,6 +373,7 @@ static void mxsfb_disable_controller(struct fb_info *fb_info)
|
||||||
struct mxsfb_info *host = to_imxfb_host(fb_info);
|
struct mxsfb_info *host = to_imxfb_host(fb_info);
|
||||||
unsigned loop;
|
unsigned loop;
|
||||||
u32 reg;
|
u32 reg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
dev_dbg(&host->pdev->dev, "%s\n", __func__);
|
dev_dbg(&host->pdev->dev, "%s\n", __func__);
|
||||||
|
|
||||||
|
@ -385,6 +397,13 @@ static void mxsfb_disable_controller(struct fb_info *fb_info)
|
||||||
clk_disable_unprepare(host->clk);
|
clk_disable_unprepare(host->clk);
|
||||||
|
|
||||||
host->enabled = 0;
|
host->enabled = 0;
|
||||||
|
|
||||||
|
if (host->reg_lcd) {
|
||||||
|
ret = regulator_disable(host->reg_lcd);
|
||||||
|
if (ret)
|
||||||
|
dev_err(&host->pdev->dev,
|
||||||
|
"lcd regulator disable failed: %d\n", ret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mxsfb_set_par(struct fb_info *fb_info)
|
static int mxsfb_set_par(struct fb_info *fb_info)
|
||||||
|
@ -859,8 +878,6 @@ static int mxsfb_probe(struct platform_device *pdev)
|
||||||
struct fb_info *fb_info;
|
struct fb_info *fb_info;
|
||||||
struct fb_modelist *modelist;
|
struct fb_modelist *modelist;
|
||||||
struct pinctrl *pinctrl;
|
struct pinctrl *pinctrl;
|
||||||
int panel_enable;
|
|
||||||
enum of_gpio_flags flags;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (of_id)
|
if (of_id)
|
||||||
|
@ -904,21 +921,9 @@ static int mxsfb_probe(struct platform_device *pdev)
|
||||||
goto fb_release;
|
goto fb_release;
|
||||||
}
|
}
|
||||||
|
|
||||||
panel_enable = of_get_named_gpio_flags(pdev->dev.of_node,
|
host->reg_lcd = devm_regulator_get(&pdev->dev, "lcd");
|
||||||
"panel-enable-gpios", 0, &flags);
|
if (IS_ERR(host->reg_lcd))
|
||||||
if (gpio_is_valid(panel_enable)) {
|
host->reg_lcd = NULL;
|
||||||
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");
|
|
||||||
if (ret) {
|
|
||||||
dev_err(&pdev->dev,
|
|
||||||
"failed to request gpio %d: %d\n",
|
|
||||||
panel_enable, ret);
|
|
||||||
goto fb_release;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fb_info->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16,
|
fb_info->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
|
Loading…
Reference in a new issue