diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2017-12-21 06:02:28 -0500 |
---|---|---|
committer | Maxime Ripard <maxime.ripard@free-electrons.com> | 2018-01-05 04:00:14 -0500 |
commit | a1c55bccf6004ec9fbcf892328f9658767aa22bb (patch) | |
tree | 896798b2ffec527af77be4dba6e28902dbeb9de0 | |
parent | 2e7e2ebc68979d984c99c29be0e1af390a49b48c (diff) |
drm/panel: lvds: Add support for the power-supply property
A significant number of panels need to power up a regulator in order to
operate properly. Add support for the power-supply property to enable and
disable such a regulator whenever needed.
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Link: https://patchwork.freedesktop.org/patch/msgid/0c0819bdf88fa948188df95e57a10820a8a4548d.1513854122.git-series.maxime.ripard@free-electrons.com
-rw-r--r-- | drivers/gpu/drm/panel/panel-lvds.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c index e2d57c01200b..57e38a9e7ab4 100644 --- a/drivers/gpu/drm/panel/panel-lvds.c +++ b/drivers/gpu/drm/panel/panel-lvds.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/of_platform.h> | 18 | #include <linux/of_platform.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/regulator/consumer.h> | ||
20 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
21 | 22 | ||
22 | #include <drm/drmP.h> | 23 | #include <drm/drmP.h> |
@@ -39,6 +40,7 @@ struct panel_lvds { | |||
39 | bool data_mirror; | 40 | bool data_mirror; |
40 | 41 | ||
41 | struct backlight_device *backlight; | 42 | struct backlight_device *backlight; |
43 | struct regulator *supply; | ||
42 | 44 | ||
43 | struct gpio_desc *enable_gpio; | 45 | struct gpio_desc *enable_gpio; |
44 | struct gpio_desc *reset_gpio; | 46 | struct gpio_desc *reset_gpio; |
@@ -69,6 +71,9 @@ static int panel_lvds_unprepare(struct drm_panel *panel) | |||
69 | if (lvds->enable_gpio) | 71 | if (lvds->enable_gpio) |
70 | gpiod_set_value_cansleep(lvds->enable_gpio, 0); | 72 | gpiod_set_value_cansleep(lvds->enable_gpio, 0); |
71 | 73 | ||
74 | if (lvds->supply) | ||
75 | regulator_disable(lvds->supply); | ||
76 | |||
72 | return 0; | 77 | return 0; |
73 | } | 78 | } |
74 | 79 | ||
@@ -76,6 +81,17 @@ static int panel_lvds_prepare(struct drm_panel *panel) | |||
76 | { | 81 | { |
77 | struct panel_lvds *lvds = to_panel_lvds(panel); | 82 | struct panel_lvds *lvds = to_panel_lvds(panel); |
78 | 83 | ||
84 | if (lvds->supply) { | ||
85 | int err; | ||
86 | |||
87 | err = regulator_enable(lvds->supply); | ||
88 | if (err < 0) { | ||
89 | dev_err(lvds->dev, "failed to enable supply: %d\n", | ||
90 | err); | ||
91 | return err; | ||
92 | } | ||
93 | } | ||
94 | |||
79 | if (lvds->enable_gpio) | 95 | if (lvds->enable_gpio) |
80 | gpiod_set_value_cansleep(lvds->enable_gpio, 1); | 96 | gpiod_set_value_cansleep(lvds->enable_gpio, 1); |
81 | 97 | ||
@@ -196,6 +212,13 @@ static int panel_lvds_probe(struct platform_device *pdev) | |||
196 | if (ret < 0) | 212 | if (ret < 0) |
197 | return ret; | 213 | return ret; |
198 | 214 | ||
215 | lvds->supply = devm_regulator_get_optional(lvds->dev, "power"); | ||
216 | if (IS_ERR(lvds->supply)) { | ||
217 | ret = PTR_ERR(lvds->supply); | ||
218 | dev_err(lvds->dev, "failed to request regulator: %d\n", ret); | ||
219 | return ret; | ||
220 | } | ||
221 | |||
199 | /* Get GPIOs and backlight controller. */ | 222 | /* Get GPIOs and backlight controller. */ |
200 | lvds->enable_gpio = devm_gpiod_get_optional(lvds->dev, "enable", | 223 | lvds->enable_gpio = devm_gpiod_get_optional(lvds->dev, "enable", |
201 | GPIOD_OUT_LOW); | 224 | GPIOD_OUT_LOW); |