From: Ajay Kumar <ajaykumar.rs@samsung.com>
To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org
Cc: inki.dae@samsung.com, seanpaul@google.com, ajaynumb@gmail.com,
joshi@samsung.com, prashanth.g@samsung.com,
Ajay Kumar <ajaykumar.rs@samsung.com>
Subject: [PATCH V2 3/9] drm/panel: Add driver for exynos_dp based panels
Date: Tue, 22 Apr 2014 04:09:12 +0530 [thread overview]
Message-ID: <1398119958-32005-4-git-send-email-ajaykumar.rs@samsung.com> (raw)
In-Reply-To: <1398119958-32005-1-git-send-email-ajaykumar.rs@samsung.com>
This patch adds a simple driver to handle all the LCD and LED
powerup/down routines needed to support eDP/eDP-LVDS panels
supported on exynos boards.
The LCD and LED units are usually powered up via regulators,
and almost on all boards, we will have a BL_EN pin to enable/
disable the backlight. Sometimes, we can have LCD_EN switches
as well. The routines in this driver can be used to control
panel power sequence on such boards.
Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
---
Changes since V1:
Added routine for post_disable, removed few unwanted headers.
Refactored a lot of code.
.../devicetree/bindings/panel/exynos-dp-panel.txt | 45 ++++
drivers/gpu/drm/panel/Kconfig | 9 +
drivers/gpu/drm/panel/Makefile | 1 +
drivers/gpu/drm/panel/panel-exynos-dp.c | 251 ++++++++++++++++++++
4 files changed, 306 insertions(+)
create mode 100644 Documentation/devicetree/bindings/panel/exynos-dp-panel.txt
create mode 100644 drivers/gpu/drm/panel/panel-exynos-dp.c
diff --git a/Documentation/devicetree/bindings/panel/exynos-dp-panel.txt b/Documentation/devicetree/bindings/panel/exynos-dp-panel.txt
new file mode 100644
index 0000000..3fbca54
--- /dev/null
+++ b/Documentation/devicetree/bindings/panel/exynos-dp-panel.txt
@@ -0,0 +1,45 @@
+exynos_DP_panel/DP_to_LVDS_panel
+
+Required properties:
+ - compatible: "samsung,exynos-dp-panel"
+
+Optional properties:
+ -samsung,lcd-en-gpio:
+ eDP panel LCD poweron GPIO.
+ Indicates which GPIO needs to be powered up as output
+ to powerup/enable the switch to the LCD panel.
+ -samsung,led-en-gpio:
+ eDP panel LED enable GPIO.
+ Indicates which GPIO needs to be powered up as output
+ to enable the backlight.
+ -samsung,panel-pre-enable-delay:
+ delay value in ms required for panel_pre_enable process
+ Delay in ms needed for the eDP panel LCD unit to
+ powerup, and delay needed between panel_VCC and
+ video_enable.
+ -samsung,panel-enable-delay:
+ delay value in ms required for panel_enable process
+ Delay in ms needed for the eDP panel backlight/LED unit
+ to powerup, and delay needed between video_enable and
+ BL_EN.
+ samsung,panel-disable-delay:
+ delay value in ms required for panel_disable process
+ Delay in ms needed for the eDP panel backlight/LED unit
+ powerdown, and delay needed between BL_DISABLE and
+ video_disable.
+ samsung,panel-post-disable-delay:
+ delay value in ms required for panel_post_disable process
+ Delay in ms needed for the eDP panel LCD unit to
+ to powerdown, and delay between video_disable and
+ panel_VCC going down.
+
+Example:
+
+ dp-panel {
+ compatible = "samsung,exynos-dp-panel";
+ samsung,led-en-gpio = <&gpx3 0 1>;
+ samsung,panel-pre-enable-delay = <40>;
+ samsung,panel-enable-delay = <20>;
+ samsung,panel-disable-delay = <20>;
+ samsung,panel-post-disable-delay = <30>;
+ };
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 4ec874d..ea9d5ac 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -30,4 +30,13 @@ config DRM_PANEL_S6E8AA0
select DRM_MIPI_DSI
select VIDEOMODE_HELPERS
+config DRM_PANEL_EXYNOS_DP
+ tristate "support for DP panels"
+ depends on OF && DRM_PANEL && DRM_EXYNOS_DP
+ help
+ DRM panel driver for DP panels and LVDS connected via DP bridges
+ that need at most a regulator for LCD unit, a regulator for LED unit
+ and/or enable GPIOs for LCD or LED units. Delay values can also be
+ specified to support powerup and powerdown process.
+
endmenu
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 8b92921..30311a4 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -1,3 +1,4 @@
obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
obj-$(CONFIG_DRM_PANEL_LD9040) += panel-ld9040.o
obj-$(CONFIG_DRM_PANEL_S6E8AA0) += panel-s6e8aa0.o
+obj-$(CONFIG_DRM_PANEL_EXYNOS_DP) += panel-exynos-dp.o
diff --git a/drivers/gpu/drm/panel/panel-exynos-dp.c b/drivers/gpu/drm/panel/panel-exynos-dp.c
new file mode 100644
index 0000000..5568d6a
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-exynos-dp.c
@@ -0,0 +1,251 @@
+/*
+ * Exynos DP panel driver
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd
+ *
+ * Ajay Kumar <ajaykumar.rs@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/gpio.h>
+#include <linux/module.h>
+#include <linux/of_gpio.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_panel.h>
+
+enum panel_state {
+ PRE_ENABLE,
+ ENABLE,
+ DISABLE,
+ POST_DISABLE,
+};
+
+struct panel_exynos_dp {
+ struct drm_panel base;
+ struct regulator *backlight_fet;
+ struct regulator *lcd_fet;
+ int led_en_gpio;
+ int lcd_en_gpio;
+ int panel_pre_enable_delay;
+ int panel_enable_delay;
+ int panel_disable_delay;
+ int panel_post_disable_delay;
+ enum panel_state panel_state;
+};
+
+static inline struct panel_exynos_dp *to_panel(struct drm_panel *panel)
+{
+ return container_of(panel, struct panel_exynos_dp, base);
+}
+
+static int panel_exynos_dp_post_disable(struct drm_panel *panel)
+{
+ struct panel_exynos_dp *dp_panel = to_panel(panel);
+ struct device *dev = dp_panel->base.dev;
+
+ if (dp_panel->panel_state != DISABLE) {
+ dev_err(dev, "invoking panel_exynos_dp_post_disable" \
+ "from an improper state\n");
+ return -EINVAL;
+ }
+
+ if (gpio_is_valid(dp_panel->lcd_en_gpio))
+ gpio_set_value(dp_panel->lcd_en_gpio, 0);
+
+ if (!IS_ERR_OR_NULL(dp_panel->lcd_fet))
+ regulator_disable(dp_panel->lcd_fet);
+
+ msleep(dp_panel->panel_post_disable_delay);
+
+ dp_panel->panel_state = POST_DISABLE;
+
+ return 0;
+}
+
+static int panel_exynos_dp_disable(struct drm_panel *panel)
+{
+ struct panel_exynos_dp *dp_panel = to_panel(panel);
+ struct device *dev = dp_panel->base.dev;
+
+ if (dp_panel->panel_state != ENABLE) {
+ dev_err(dev, "invoking panel_exynos_dp_disable" \
+ "from an improper state\n");
+ return -EINVAL;
+ }
+
+ if (gpio_is_valid(dp_panel->led_en_gpio))
+ gpio_set_value(dp_panel->led_en_gpio, 0);
+
+ if (!IS_ERR_OR_NULL(dp_panel->backlight_fet))
+ regulator_disable(dp_panel->backlight_fet);
+
+ msleep(dp_panel->panel_disable_delay);
+
+ dp_panel->panel_state = DISABLE;
+
+ return 0;
+}
+
+static int panel_exynos_dp_pre_enable(struct drm_panel *panel)
+{
+ struct panel_exynos_dp *dp_panel = to_panel(panel);
+ struct device *dev = dp_panel->base.dev;
+
+ if (dp_panel->panel_state != POST_DISABLE) {
+ dev_err(dev, "invoking panel_exynos_dp_pre_enable" \
+ "from an improper state\n");
+ return -EINVAL;
+ }
+
+ if (!IS_ERR_OR_NULL(dp_panel->lcd_fet))
+ if (regulator_enable(dp_panel->lcd_fet))
+ DRM_ERROR("Failed to enable LCD fet\n");
+
+ if (gpio_is_valid(dp_panel->lcd_en_gpio))
+ gpio_set_value(dp_panel->lcd_en_gpio, 1);
+
+ msleep(dp_panel->panel_pre_enable_delay);
+
+ dp_panel->panel_state = PRE_ENABLE;
+
+ return 0;
+}
+
+static int panel_exynos_dp_enable(struct drm_panel *panel)
+{
+ struct panel_exynos_dp *dp_panel = to_panel(panel);
+ struct device *dev = dp_panel->base.dev;
+
+ if (dp_panel->panel_state != PRE_ENABLE) {
+ dev_err(dev, "invoking panel_exynos_dp_enable" \
+ "from an improper state\n");
+ return -EINVAL;
+ }
+
+ if (!IS_ERR_OR_NULL(dp_panel->backlight_fet))
+ if (regulator_enable(dp_panel->backlight_fet))
+ DRM_ERROR("Failed to enable LED fet\n");
+
+ msleep(dp_panel->panel_enable_delay);
+
+ if (gpio_is_valid(dp_panel->led_en_gpio))
+ gpio_set_value(dp_panel->led_en_gpio, 1);
+
+ dp_panel->panel_state = ENABLE;
+
+ return 0;
+}
+
+static const struct drm_panel_funcs panel_exynos_dp_funcs = {
+ .post_disable = panel_exynos_dp_post_disable,
+ .disable = panel_exynos_dp_disable,
+ .pre_enable = panel_exynos_dp_pre_enable,
+ .enable = panel_exynos_dp_enable,
+};
+
+static int panel_exynos_dp_probe(struct platform_device *pdev)
+{
+ struct panel_exynos_dp *dp_panel;
+ struct device *dev = &pdev->dev;
+ int ret;
+
+ dp_panel = devm_kzalloc(dev, sizeof(*dp_panel), GFP_KERNEL);
+ if (!dp_panel)
+ return -ENOMEM;
+
+ dp_panel->panel_state = POST_DISABLE;
+
+ dp_panel->lcd_en_gpio = of_get_named_gpio(dev->of_node,
+ "samsung,lcd-en-gpio", 0);
+ dp_panel->led_en_gpio = of_get_named_gpio(dev->of_node,
+ "samsung,led-en-gpio", 0);
+
+ of_property_read_u32(dev->of_node, "samsung,panel-pre-enable-delay",
+ &dp_panel->panel_pre_enable_delay);
+ of_property_read_u32(dev->of_node, "samsung,panel-enable-delay",
+ &dp_panel->panel_enable_delay);
+ of_property_read_u32(dev->of_node, "samsung,panel-disable-delay",
+ &dp_panel->panel_disable_delay);
+ of_property_read_u32(dev->of_node, "samsung,panel-post-disable-delay",
+ &dp_panel->panel_post_disable_delay);
+
+ dp_panel->lcd_fet = devm_regulator_get(dev, "lcd_vdd");
+ if (IS_ERR(dp_panel->lcd_fet))
+ return PTR_ERR(dp_panel->lcd_fet);
+
+ dp_panel->backlight_fet = devm_regulator_get(dev, "vcd_led");
+ if (IS_ERR(dp_panel->backlight_fet))
+ return PTR_ERR(dp_panel->backlight_fet);
+
+ if (gpio_is_valid(dp_panel->lcd_en_gpio)) {
+ ret = devm_gpio_request_one(dev, dp_panel->lcd_en_gpio,
+ GPIOF_OUT_INIT_LOW, "lcd_en_gpio");
+ if (ret) {
+ DRM_ERROR("failed to get lcd-en gpio [%d]\n", ret);
+ return ret;
+ }
+ } else {
+ dp_panel->lcd_en_gpio = -ENODEV;
+ }
+
+ if (gpio_is_valid(dp_panel->led_en_gpio)) {
+ ret = devm_gpio_request_one(dev, dp_panel->led_en_gpio,
+ GPIOF_OUT_INIT_LOW, "led_en_gpio");
+ if (ret) {
+ DRM_ERROR("failed to get led-en gpio [%d]\n", ret);
+ return ret;
+ }
+ } else {
+ dp_panel->led_en_gpio = -ENODEV;
+ }
+
+ dp_panel->panel_state = POST_DISABLE;
+ drm_panel_init(&dp_panel->base);
+ dp_panel->base.dev = dev;
+ dp_panel->base.funcs = &panel_exynos_dp_funcs;
+
+ ret = drm_panel_add(&dp_panel->base);
+ if (ret < 0)
+ return ret;
+
+ dev_set_drvdata(dev, dp_panel);
+
+ return 0;
+}
+
+static int panel_exynos_dp_remove(struct platform_device *pdev)
+{
+ struct panel_exynos_dp *dp_panel = dev_get_drvdata(&pdev->dev);
+
+ dp_panel->panel_state = ENABLE;
+ panel_exynos_dp_disable(&dp_panel->base);
+ panel_exynos_dp_post_disable(&dp_panel->base);
+
+ drm_panel_detach(&dp_panel->base);
+ drm_panel_remove(&dp_panel->base);
+
+ return 0;
+}
+
+static const struct of_device_id exynos_dp_panel_dt_match[] = {
+ { .compatible = "samsung,exynos-dp-panel" },
+ {},
+};
+
+struct platform_driver exynos_dp_panel_driver = {
+ .driver = {
+ .name = "exynos-dp-panel",
+ .owner = THIS_MODULE,
+ .of_match_table = exynos_dp_panel_dt_match,
+ },
+ .probe = panel_exynos_dp_probe,
+ .remove = panel_exynos_dp_remove,
+};
--
1.7.9.5
next prev parent reply other threads:[~2014-04-21 22:39 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-21 22:39 [PATCH V2 0/9] drm: exynos: few patches to enhance bridge chip support Ajay Kumar
2014-04-21 22:39 ` [PATCH V2 1/9] drm/exynos: dp: support hotplug detection via GPIO Ajay Kumar
2014-04-22 7:13 ` Jingoo Han
2014-05-09 0:57 ` Jingoo Han
2014-04-21 22:39 ` [PATCH V2 2/9] drm/panel: add pre_enable and post_disable routines Ajay Kumar
2014-04-22 8:19 ` Thierry Reding
2014-04-22 14:36 ` Ajay kumar
2014-04-23 7:29 ` Daniel Vetter
2014-04-23 7:42 ` Thierry Reding
2014-04-23 19:26 ` Ajay kumar
2014-04-24 18:31 ` Thierry Reding
2014-04-25 6:04 ` Ajay kumar
2014-04-25 18:16 ` Ajay kumar
2014-04-29 12:15 ` Ajay kumar
2014-04-23 19:14 ` Ajay kumar
2014-04-21 22:39 ` Ajay Kumar [this message]
2014-04-22 7:22 ` [PATCH V2 3/9] drm/panel: Add driver for exynos_dp based panels Jingoo Han
2014-04-22 14:37 ` Ajay kumar
2014-04-22 8:26 ` Thierry Reding
2014-04-22 14:53 ` Ajay kumar
2014-04-22 15:16 ` Thierry Reding
2014-04-21 22:39 ` [PATCH V2 4/9] drm/exynos: add exynos_dp_panel driver registration to drm driver Ajay Kumar
2014-04-22 8:33 ` Thierry Reding
2014-04-22 15:03 ` Ajay kumar
2014-04-22 15:26 ` Thierry Reding
2014-08-20 4:02 ` Stéphane Marchesin
2014-08-21 7:36 ` Thierry Reding
2014-08-21 8:25 ` Stéphane Marchesin
2014-08-21 9:27 ` Ajay kumar
2014-08-21 9:37 ` Thierry Reding
2014-08-21 9:28 ` Thierry Reding
2014-04-21 22:39 ` [PATCH V2 5/9] drm/exynos: dp: modify driver to support drm_panel Ajay Kumar
2014-04-22 8:37 ` Thierry Reding
2014-04-21 22:39 ` [PATCH V2 6/9] drm/bridge: ptn3460: enable polling based detection Ajay Kumar
2014-04-22 8:43 ` Thierry Reding
2014-04-21 22:39 ` [PATCH V2 7/9] drm/bridge: ptn3460: add drm_panel controls Ajay Kumar
2014-04-22 8:55 ` Thierry Reding
2014-04-22 11:34 ` Rob Clark
2014-04-22 13:53 ` Daniel Vetter
2014-04-23 18:56 ` Ajay kumar
2014-04-23 19:02 ` Ajay kumar
2014-04-24 16:11 ` Rob Clark
2014-04-24 16:55 ` Ajay kumar
2014-04-24 17:25 ` Rob Clark
2014-04-24 17:38 ` Ajay kumar
2014-04-25 6:10 ` Ajay kumar
2014-04-25 6:17 ` Ajay kumar
2014-04-27 12:55 ` Daniel Vetter
2014-04-28 13:08 ` Ajay kumar
2014-04-29 13:14 ` Rob Clark
2014-04-21 22:39 ` [PATCH V2 8/9] drm/bridge: Add PS8622 bridge driver Ajay Kumar
2014-04-22 8:43 ` Jingoo Han
2014-04-22 13:57 ` Ajay kumar
2014-04-22 13:31 ` Sean Paul
2014-04-22 14:03 ` Ajay kumar
2014-04-21 22:39 ` [PATCH V2 9/9] drm/exynos: Add ps8622 lvds bridge discovery to DP driver Ajay Kumar
2014-04-22 9:27 ` Thierry Reding
2014-04-22 17:20 ` Ajay kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1398119958-32005-4-git-send-email-ajaykumar.rs@samsung.com \
--to=ajaykumar.rs@samsung.com \
--cc=ajaynumb@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=inki.dae@samsung.com \
--cc=joshi@samsung.com \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=prashanth.g@samsung.com \
--cc=seanpaul@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox