Skip to contentSkip to conversation

drm: exynos: few patches to enhance bridge chip support

PATCH Superseded Ajay Kumar 12 participants 41 messages Jun 11, 2014 – Jul 15, 2014 2 messages not in the archive

Subsystems (9)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Ajay Kumar

author
#0 lore raw

v4 cover drm: exynos: few patches to enhance bridge chip support

This series is based on exynos-drm-next branch of Inki Dae's tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git

I have tested this after adding few DT changes for exynos5250-snow, exynos5420-peach-pit and exynos5800-peach-pi boards.

This patchset also consolidates various inputs from the drm community regarding the bridge chaining concept:
(1) [RFC V2 0/3] drm/bridge: panel and chaining

	http://www.spinics.net/lists/linux-samsung-soc/msg30160.html
(2) [RFC V3 0/3] drm/bridge: panel and chaining
	http://www.spinics.net/lists/linux-samsung-soc/msg30507.html

Changes since V2:
-- Address comments from Jingoo Han for ps8622 driver -- Address comments from Daniel, Rob and Thierry regarding
bridge chaining
-- Address comments from Thierry regarding the names for
new drm_panel functions

Changes since V3:
-- Remove hotplug based initialization of exynos_dp -- Make exynos_dp work directly with drm_panel, remove
dependency on panel_binder
-- Minor cleanups in panel_binder and panel_lvds driver

The following patches can be divided into 2 groups:
patches 1 to 4: add drm_panel support to exynos_dp(peach-pi) patches 5 to 10: chaining of bridges and drm_panel(snow and peach-pit)

Ajay Kumar (8):
[PATCH V4 1/10] drm/exynos: Move DP setup out of hotplug workqueue [PATCH V4 2/10] drm/panel: add prepare and unprepare routines [PATCH V4 3/10] drm/exynos: dp: modify driver to support drm_panel [PATCH V4 4/10] drm/panel: Add driver for lvds/edp based panels [PATCH V4 5/10] drm/bridge: add helper functions to support bridge chain [PATCH V4 6/10] drm/bridge: Add a driver which binds drm_bridge with drm_panel [PATCH V4 7/10] drm/bridge: ptn3460: Support bridge chaining [PATCH V4 8/10] drm/exynos: dp: create bridge chain using ptn3460 and
panel_binder

Vincent Palatin (1):
[PATCH V4 9/10] drm/bridge: Add ps8622/ps8625 bridge driver

Rahul Sharma (1):
[PATCH V4 10/10] drm/exynos: Add ps8622 lvds bridge discovery to DP driver

 .../devicetree/bindings/drm/bridge/ps8622.txt      |   21 +
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 +++
 .../devicetree/bindings/video/exynos_dp.txt        |    2 +
 drivers/gpu/drm/bridge/Kconfig                     |   15 +
 drivers/gpu/drm/bridge/Makefile                    |    2 +
 drivers/gpu/drm/bridge/panel_binder.c              |  193 ++++++++
 drivers/gpu/drm/bridge/ps8622.c                    |  475 ++++++++++++++++++++
 drivers/gpu/drm/bridge/ptn3460.c                   |  136 +-----
 drivers/gpu/drm/exynos/Kconfig                     |    1 +
 drivers/gpu/drm/exynos/exynos_dp_core.c            |   87 +++-
 drivers/gpu/drm/exynos/exynos_dp_core.h            |    2 +
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 +++++++++++
 include/drm/bridge/panel_binder.h                  |   44 ++
 include/drm/bridge/ps8622.h                        |   41 ++
 include/drm/bridge/ptn3460.h                       |   15 +-
 include/drm/drm_crtc.h                             |   72 +++
 include/drm/drm_panel.h                            |   18 +
 19 files changed, 1309 insertions(+), 138 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/ps8622.txt
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/bridge/panel_binder.c
 create mode 100644 drivers/gpu/drm/bridge/ps8622.c
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
 create mode 100644 include/drm/bridge/panel_binder.h
 create mode 100644 include/drm/bridge/ps8622.h
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v4 1/10 drm/exynos: Move DP setup out of hotplug workqueue

Move the DP training and video enable from the hotplug handler into a seperate function and call the same during dpms ON.

With existing code, DP HPD should be generated just few ms before calling enable_irq in dp_poweron.

This patch removes that stringent time constraint.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +10 -1
index 5e05dbc..96b4e82 100644
@@ -875,10 +875,18 @@ static irqreturn_t exynos_dp_irq_handler(int irq, void *arg)
 static void exynos_dp_hotplug(struct work_struct *work)
 {
 	struct exynos_dp_device *dp;
-	int ret;
 
 	dp = container_of(work, struct exynos_dp_device, hotplug_work);
 
+	if (dp->drm_dev)
+		drm_helper_hpd_irq_event(dp->drm_dev);
+}
+
+static void exynos_dp_setup(void *in_ctx)
+{
+	struct exynos_dp_device *dp = in_ctx;
+	int ret;
+
 	ret = exynos_dp_detect_hpd(dp);
 	if (ret) {
 		/* Cable has been disconnected, we're done */
@@ -1059,6 +1067,7 @@ static void exynos_dp_poweron(struct exynos_dp_device *dp)
 	exynos_dp_phy_init(dp);
 	exynos_dp_init_dp(dp);
 	enable_irq(dp->irq);
+	exynos_dp_setup(dp);
 }
 
 static void exynos_dp_poweroff(struct exynos_dp_device *dp)
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH V4 01/10] drm/exynos: Move DP setup out of hotplug workqueue

ping.

Quoted 48 lines · Ajay Kumar

Move the DP training and video enable from the hotplug handler into a seperate function and call the same during dpms ON.

With existing code, DP HPD should be generated just few ms before calling enable_irq in dp_poweron.

This patch removes that stringent time constraint.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +10 -2
index 5e05dbc..96b4e82 100644
@@ -875,10 +875,18 @@ static irqreturn_t exynos_dp_irq_handler(int irq, void *arg)
 static void exynos_dp_hotplug(struct work_struct *work)
 {
        struct exynos_dp_device *dp;
-       int ret;
 
        dp = container_of(work, struct exynos_dp_device, hotplug_work);
 
+       if (dp->drm_dev)
+               drm_helper_hpd_irq_event(dp->drm_dev);
+}
+
+static void exynos_dp_setup(void *in_ctx)
+{
+       struct exynos_dp_device *dp = in_ctx;
+       int ret;
+
        ret = exynos_dp_detect_hpd(dp);
        if (ret) {
                /* Cable has been disconnected, we're done */
@@ -1059,6 +1067,7 @@ static void exynos_dp_poweron(struct exynos_dp_device *dp)
        exynos_dp_phy_init(dp);
        exynos_dp_init_dp(dp);
        enable_irq(dp->irq);
+       exynos_dp_setup(dp);
 }
 
 static void exynos_dp_poweroff(struct exynos_dp_device *dp)
--

1.7.9.5

author
#3 lore raw

PATCH v4 2/10 drm/panel: add prepare and unprepare routines

In reply to Ajay Kumar

Most of the panels need an init sequence as mentioned below:
-- poweron LCD unit/LCD_EN
-- start video data
-- poweron LED unit/BACKLIGHT_EN
And, a de-init sequence as mentioned below:
-- poweroff LED unit/BACKLIGHT_EN
-- stop video data
-- poweroff LCD unit/LCD_EN
With existing callbacks for drm panel, we cannot accomodate such panels, since only two callbacks, i.e "panel_enable" and panel_disable are supported.

This patch adds:
-- "prepare" callback which can be called before the actual video data is on, and then call the "enable" callback after the video data is available.

-- "unprepare" callback which can be called after the video data is off, and use "disable" callback to do something before switching off the video data.

Now, we can easily map the above scenario as shown below:
poweron LCD unit/LCD_EN = "prepare" callback poweron LED unit/BACKLIGHT_EN = "enable" callback poweroff LED unit/BACKLIGHT_EN = "disable" callback poweroff LCD unit/LCD_EN = "unprepare" callback

---
 include/drm/drm_panel.h |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/drm/drm_panel.h +18 -0
index c2ab77a..9addc69 100644
@@ -31,7 +31,9 @@ struct drm_device;
 struct drm_panel;
 
 struct drm_panel_funcs {
+	int (*unprepare)(struct drm_panel *panel);
 	int (*disable)(struct drm_panel *panel);
+	int (*prepare)(struct drm_panel *panel);
 	int (*enable)(struct drm_panel *panel);
 	int (*get_modes)(struct drm_panel *panel);
 };
@@ -46,6 +48,14 @@ struct drm_panel {
 	struct list_head list;
 };
 
+static inline int drm_panel_unprepare(struct drm_panel *panel)
+{
+	if (panel && panel->funcs && panel->funcs->unprepare)
+		return panel->funcs->unprepare(panel);
+
+	return panel ? -ENOSYS : -EINVAL;
+}
+
 static inline int drm_panel_disable(struct drm_panel *panel)
 {
 	if (panel && panel->funcs && panel->funcs->disable)
@@ -54,6 +64,14 @@ static inline int drm_panel_disable(struct drm_panel *panel)
 	return panel ? -ENOSYS : -EINVAL;
 }
 
+static inline int drm_panel_prepare(struct drm_panel *panel)
+{
+	if (panel && panel->funcs && panel->funcs->prepare)
+		return panel->funcs->prepare(panel);
+
+	return panel ? -ENOSYS : -EINVAL;
+}
+
 static inline int drm_panel_enable(struct drm_panel *panel)
 {
 	if (panel && panel->funcs && panel->funcs->enable)
Signature · 1 line
1.7.9.5
#4 lore raw

Re: [PATCH V4 02/10] drm/panel: add prepare and unprepare routines

ping.

Quoted 78 lines · Ajay Kumar

Most of the panels need an init sequence as mentioned below:
-- poweron LCD unit/LCD_EN
-- start video data
-- poweron LED unit/BACKLIGHT_EN
And, a de-init sequence as mentioned below:
-- poweroff LED unit/BACKLIGHT_EN
-- stop video data
-- poweroff LCD unit/LCD_EN
With existing callbacks for drm panel, we cannot accomodate such panels, since only two callbacks, i.e "panel_enable" and panel_disable are supported.

This patch adds:
-- "prepare" callback which can be called before the actual video data is on, and then call the "enable" callback after the video data is available.

-- "unprepare" callback which can be called after the video data is off, and use "disable" callback to do something before switching off the video data.

Now, we can easily map the above scenario as shown below:
poweron LCD unit/LCD_EN = "prepare" callback poweron LED unit/BACKLIGHT_EN = "enable" callback poweroff LED unit/BACKLIGHT_EN = "disable" callback poweroff LCD unit/LCD_EN = "unprepare" callback

---
 include/drm/drm_panel.h |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/drm/drm_panel.h +18 -1
index c2ab77a..9addc69 100644
@@ -31,7 +31,9 @@ struct drm_device;
 struct drm_panel;
 
 struct drm_panel_funcs {
+       int (*unprepare)(struct drm_panel *panel);
        int (*disable)(struct drm_panel *panel);
+       int (*prepare)(struct drm_panel *panel);
        int (*enable)(struct drm_panel *panel);
        int (*get_modes)(struct drm_panel *panel);
 };
@@ -46,6 +48,14 @@ struct drm_panel {
        struct list_head list;
 };
 
+static inline int drm_panel_unprepare(struct drm_panel *panel)
+{
+       if (panel && panel->funcs && panel->funcs->unprepare)
+               return panel->funcs->unprepare(panel);
+
+       return panel ? -ENOSYS : -EINVAL;
+}
+
 static inline int drm_panel_disable(struct drm_panel *panel)
 {
        if (panel && panel->funcs && panel->funcs->disable)
@@ -54,6 +64,14 @@ static inline int drm_panel_disable(struct drm_panel *panel)
        return panel ? -ENOSYS : -EINVAL;
 }
 
+static inline int drm_panel_prepare(struct drm_panel *panel)
+{
+       if (panel && panel->funcs && panel->funcs->prepare)
+               return panel->funcs->prepare(panel);
+
+       return panel ? -ENOSYS : -EINVAL;
+}
+
 static inline int drm_panel_enable(struct drm_panel *panel)
 {
        if (panel && panel->funcs && panel->funcs->enable)
--

1.7.9.5

author
#5 lore raw

PATCH v4 3/10 drm/exynos: dp: modify driver to support drm_panel

In reply to Ajay Kumar

Add drm_panel controls to support powerup/down of the eDP panel, if one is present at the sink side.

---
 .../devicetree/bindings/video/exynos_dp.txt        |    2 +
 drivers/gpu/drm/exynos/Kconfig                     |    1 +
 drivers/gpu/drm/exynos/exynos_dp_core.c            |   45 ++++++++++++++++----
 drivers/gpu/drm/exynos/exynos_dp_core.h            |    2 +
 4 files changed, 41 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/video/exynos_dp.txt +2 -0
index 53dbccf..c029a09 100644
@@ -51,6 +51,8 @@ Required properties for dp-controller:
 			LANE_COUNT1 = 1, LANE_COUNT2 = 2, LANE_COUNT4 = 4
 	- display-timings: timings for the connected panel as described by
 		Documentation/devicetree/bindings/video/display-timing.txt
+	-edp-panel:
+		phandle for the edp/lvds drm_panel node.
 
 Optional properties for dp-controller:
 	-interlaced:
drivers/gpu/drm/exynos/Kconfig +1 -0
index 178d2a9..fd1c070 100644
@@ -52,6 +52,7 @@ config DRM_EXYNOS_DP
 	bool "EXYNOS DRM DP driver support"
 	depends on DRM_EXYNOS_FIMD && ARCH_EXYNOS && (DRM_PTN3460=n || DRM_PTN3460=y || DRM_PTN3460=DRM_EXYNOS)
 	default DRM_EXYNOS
+	select DRM_PANEL
 	help
 	  This enables support for DP device.
 
drivers/gpu/drm/exynos/exynos_dp_core.c +36 -9

112 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_dp_core.h +2 -0
index 02cc4f9..3c29e4e 100644
@@ -146,9 +146,11 @@ struct link_train {
 
 struct exynos_dp_device {
 	struct device		*dev;
+	struct device_node	*panel_node;
 	struct drm_device	*drm_dev;
 	struct drm_connector	connector;
 	struct drm_encoder	*encoder;
+	struct drm_panel	*edp_panel;
 	struct clk		*clock;
 	unsigned int		irq;
 	void __iomem		*reg_base;
Signature · 1 line
1.7.9.5
#6 lore raw

Re: [PATCH V4 03/10] drm/exynos: dp: modify driver to support drm_panel

ping.

Quoted 180 lines · Ajay Kumar

Add drm_panel controls to support powerup/down of the eDP panel, if one is present at the sink side.

---
 .../devicetree/bindings/video/exynos_dp.txt        |    2 +
 drivers/gpu/drm/exynos/Kconfig                     |    1 +
 drivers/gpu/drm/exynos/exynos_dp_core.c            |   45 ++++++++++++++++----
 drivers/gpu/drm/exynos/exynos_dp_core.h            |    2 +
 4 files changed, 41 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/video/exynos_dp.txt +2 -0
index 53dbccf..c029a09 100644
@@ -51,6 +51,8 @@ Required properties for dp-controller:
                        LANE_COUNT1 = 1, LANE_COUNT2 = 2, LANE_COUNT4 = 4
        - display-timings: timings for the connected panel as described by
                Documentation/devicetree/bindings/video/display-timing.txt
+       -edp-panel:
+               phandle for the edp/lvds drm_panel node.
 
 Optional properties for dp-controller:
        -interlaced:
drivers/gpu/drm/exynos/Kconfig +1 -0
index 178d2a9..fd1c070 100644
@@ -52,6 +52,7 @@ config DRM_EXYNOS_DP
        bool "EXYNOS DRM DP driver support"
        depends on DRM_EXYNOS_FIMD && ARCH_EXYNOS && (DRM_PTN3460=n || DRM_PTN3460=y || DRM_PTN3460=DRM_EXYNOS)
        default DRM_EXYNOS
+       select DRM_PANEL
        help
          This enables support for DP device.
 
drivers/gpu/drm/exynos/exynos_dp_core.c +36 -9
index 96b4e82..aca739d 100644
@@ -28,6 +28,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_panel.h>
 #include <drm/bridge/ptn3460.h>
 
 #include "exynos_drm_drv.h"
@@ -1029,6 +1030,9 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
        drm_sysfs_connector_add(connector);
        drm_mode_connector_attach_encoder(connector, encoder);
 
+       if (dp->edp_panel)
+               drm_panel_attach(dp->edp_panel, &dp->connector);
+
        return 0;
 }
 
@@ -1063,11 +1067,13 @@ static void exynos_dp_poweron(struct exynos_dp_device *dp)
        if (dp->dpms_mode == DRM_MODE_DPMS_ON)
                return;
 
+       drm_panel_prepare(dp->edp_panel);
        clk_prepare_enable(dp->clock);
        exynos_dp_phy_init(dp);
        exynos_dp_init_dp(dp);
        enable_irq(dp->irq);
        exynos_dp_setup(dp);
+       drm_panel_enable(dp->edp_panel);
 }
 
 static void exynos_dp_poweroff(struct exynos_dp_device *dp)
@@ -1075,10 +1081,12 @@ static void exynos_dp_poweroff(struct exynos_dp_device *dp)
        if (dp->dpms_mode != DRM_MODE_DPMS_ON)
                return;
 
+       drm_panel_disable(dp->edp_panel);
        disable_irq(dp->irq);
        flush_work(&dp->hotplug_work);
        exynos_dp_phy_exit(dp);
        clk_disable_unprepare(dp->clock);
+       drm_panel_unprepare(dp->edp_panel);
 }
 
 static void exynos_dp_dpms(struct exynos_drm_display *display, int mode)
@@ -1209,8 +1217,17 @@ err:
 static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp)
 {
        int ret;
+       struct device_node *videomode_parent;
+
+       /* Receive video timing info from panel node
+        * if there is a panel node
+        */
+       if (dp->panel_node)
+               videomode_parent = dp->panel_node;
+       else
+               videomode_parent = dp->dev->of_node;
 
-       ret = of_get_videomode(dp->dev->of_node, &dp->panel.vm,
+       ret = of_get_videomode(videomode_parent, &dp->panel.vm,
                        OF_USE_NATIVE_MODE);
        if (ret) {
                DRM_ERROR("failed: of_get_videomode() : %d\n", ret);
@@ -1224,16 +1241,10 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
        struct platform_device *pdev = to_platform_device(dev);
        struct drm_device *drm_dev = data;
        struct resource *res;
-       struct exynos_dp_device *dp;
+       struct exynos_dp_device *dp = exynos_dp_display.ctx;
        unsigned int irq_flags;
-
        int ret = 0;
 
-       dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
-                               GFP_KERNEL);
-       if (!dp)
-               return -ENOMEM;
-
        dp->dev = &pdev->dev;
        dp->dpms_mode = DRM_MODE_DPMS_OFF;
 
@@ -1307,7 +1318,6 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
        disable_irq(dp->irq);
 
        dp->drm_dev = drm_dev;
-       exynos_dp_display.ctx = dp;
 
        platform_set_drvdata(pdev, &exynos_dp_display);
 
@@ -1334,6 +1344,8 @@ static const struct component_ops exynos_dp_ops = {
 
 static int exynos_dp_probe(struct platform_device *pdev)
 {
+       struct device *dev = &pdev->dev;
+       struct exynos_dp_device *dp;
        int ret;
 
        ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR,
@@ -1341,6 +1353,21 @@ static int exynos_dp_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
+       dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
+                               GFP_KERNEL);
+       if (!dp)
+               return -ENOMEM;
+
+       dp->panel_node = of_parse_phandle(dev->of_node, "edp-panel", 0);
+       if (dp->panel_node) {
+               dp->edp_panel = of_drm_find_panel(dp->panel_node);
+               of_node_put(dp->panel_node);
+               if (!dp->edp_panel)
+                       return -EPROBE_DEFER;
+       }
+
+       exynos_dp_display.ctx = dp;
+
        ret = component_add(&pdev->dev, &exynos_dp_ops);
        if (ret)
                exynos_drm_component_del(&pdev->dev,
drivers/gpu/drm/exynos/exynos_dp_core.h +2 -1
index 02cc4f9..3c29e4e 100644
@@ -146,9 +146,11 @@ struct link_train {
 
 struct exynos_dp_device {
        struct device           *dev;
+       struct device_node      *panel_node;
        struct drm_device       *drm_dev;
        struct drm_connector    connector;
        struct drm_encoder      *encoder;
+       struct drm_panel        *edp_panel;
        struct clk              *clock;
        unsigned int            irq;
        void __iomem            *reg_base;
--

1.7.9.5

author
#7 lore raw

PATCH v4 4/10 drm/panel: Add driver for lvds/edp based panels

In reply to Ajay Kumar

This patch adds a simple driver to handle all the LCD and LED powerup/down routines needed to support eDP/LVDS panels.

The LCD and LED units are usually powered up via regulators, and almost on all boards, we will have a BACKLIGHT_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.

---
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 ++++
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 ++++++++++++++++++++
 4 files changed, 323 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +50 -0
new file mode 100644
index 0000000..7cb6084
@@ -0,0 +1,50 @@
+panel interface for eDP/lvds panels
+
+Required properties:
+  - compatible: "panel-lvds"
+
+Optional properties:
+	-lcd-en-gpio:
+		panel LCD poweron GPIO.
+			Indicates which GPIO needs to be powered up as output
+			to powerup/enable the switch to the LCD panel.
+	-led-en-gpio:
+		panel LED enable GPIO.
+			Indicates which GPIO needs to be powered up as output
+			to enable the backlight.
+	-panel-prepare-delay:
+		delay value in ms required for panel_prepare process
+			Delay in ms needed for the panel LCD unit to
+			powerup completely.
+			ex: delay needed till eDP panel throws HPD.
+			    delay needed so that we cans tart reading edid.
+	-panel-enable-delay:
+		delay value in ms required for panel_enable process
+			Delay in ms needed for the panel backlight/LED unit
+			to powerup, and delay needed between video_enable and
+			backlight_enable.
+	-panel-disable-delay:
+		delay value in ms required for panel_disable process
+			Delay in ms needed for the panel backlight/LED unit
+			powerdown, and delay needed between backlight_disable
+			and video_disable.
+	-panel-unprepare-delay:
+		delay value in ms required for panel_post_disable process
+			Delay in ms needed for the panel LCD unit to
+			to powerdown completely, and the minimum delay needed
+			before powering it on again.
+	-panel-width-mm: physical panel width [mm]
+	-panel-height-mm: physical panel height [mm]
+
+Example:
+
+	panel-lvds {
+		compatible = "panel-lvds";
+		led-en-gpio = <&gpx3 0 1>;
+		panel-prepare-delay = <40>;
+		panel-enable-delay = <20>;
+		panel-disable-delay = <20>;
+		panel-unprepare-delay = <30>;
+		panel-width-mm = <256>;
+		panel-height-mm = <144>;
+	};
drivers/gpu/drm/panel/Kconfig +10 -0
index 4ec874d..8fe7ee5 100644
@@ -30,4 +30,14 @@ config DRM_PANEL_S6E8AA0
 	select DRM_MIPI_DSI
 	select VIDEOMODE_HELPERS
 
+config DRM_PANEL_EDP_LVDS
+	tristate "support for eDP/LVDS panels"
+	depends on OF && DRM_PANEL
+	select VIDEOMODE_HELPERS
+	help
+	  DRM panel driver for direct eDP panels or 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
drivers/gpu/drm/panel/Makefile +1 -0
index 8b92921..eaafa01 100644
@@ -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_EDP_LVDS) += panel-lvds.o
drivers/gpu/drm/panel/panel-lvds.c new file +262 -0

262 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#8 lore raw

Re: [PATCH V4 04/10] drm/panel: Add driver for lvds/edp based panels

ping.

Quoted 377 lines · Ajay Kumar

This patch adds a simple driver to handle all the LCD and LED powerup/down routines needed to support eDP/LVDS panels.

The LCD and LED units are usually powered up via regulators, and almost on all boards, we will have a BACKLIGHT_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.

---
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 ++++
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 ++++++++++++++++++++
 4 files changed, 323 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +50 -0
new file mode 100644
index 0000000..7cb6084
@@ -0,0 +1,50 @@
+panel interface for eDP/lvds panels
+
+Required properties:
+  - compatible: "panel-lvds"
+
+Optional properties:
+       -lcd-en-gpio:
+               panel LCD poweron GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to powerup/enable the switch to the LCD panel.
+       -led-en-gpio:
+               panel LED enable GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to enable the backlight.
+       -panel-prepare-delay:
+               delay value in ms required for panel_prepare process
+                       Delay in ms needed for the panel LCD unit to
+                       powerup completely.
+                       ex: delay needed till eDP panel throws HPD.
+                           delay needed so that we cans tart reading edid.
+       -panel-enable-delay:
+               delay value in ms required for panel_enable process
+                       Delay in ms needed for the panel backlight/LED unit
+                       to powerup, and delay needed between video_enable and
+                       backlight_enable.
+       -panel-disable-delay:
+               delay value in ms required for panel_disable process
+                       Delay in ms needed for the panel backlight/LED unit
+                       powerdown, and delay needed between backlight_disable
+                       and video_disable.
+       -panel-unprepare-delay:
+               delay value in ms required for panel_post_disable process
+                       Delay in ms needed for the panel LCD unit to
+                       to powerdown completely, and the minimum delay needed
+                       before powering it on again.
+       -panel-width-mm: physical panel width [mm]
+       -panel-height-mm: physical panel height [mm]
+
+Example:
+
+       panel-lvds {
+               compatible = "panel-lvds";
+               led-en-gpio = <&gpx3 0 1>;
+               panel-prepare-delay = <40>;
+               panel-enable-delay = <20>;
+               panel-disable-delay = <20>;
+               panel-unprepare-delay = <30>;
+               panel-width-mm = <256>;
+               panel-height-mm = <144>;
+       };
drivers/gpu/drm/panel/Kconfig +10 -0
index 4ec874d..8fe7ee5 100644
@@ -30,4 +30,14 @@ config DRM_PANEL_S6E8AA0
        select DRM_MIPI_DSI
        select VIDEOMODE_HELPERS
 
+config DRM_PANEL_EDP_LVDS
+       tristate "support for eDP/LVDS panels"
+       depends on OF && DRM_PANEL
+       select VIDEOMODE_HELPERS
+       help
+         DRM panel driver for direct eDP panels or 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
drivers/gpu/drm/panel/Makefile +1 -0
index 8b92921..eaafa01 100644
@@ -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_EDP_LVDS) += panel-lvds.o
drivers/gpu/drm/panel/panel-lvds.c new file +262 -1
new file mode 100644
index 0000000..2124fcb
@@ -0,0 +1,262 @@
+/*
+ * panel driver for lvds and eDP panels
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd
+ *
+ * Ajay Kumar <[email protected]>
+ *
+ * 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 <video/of_videomode.h>
+#include <video/videomode.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_panel.h>
+
+struct panel_lvds {
+       struct drm_panel        base;
+       struct regulator        *backlight_fet;
+       struct regulator        *lcd_fet;
+       struct videomode        vm;
+       int                     width_mm;
+       int                     height_mm;
+       bool                    backlight_fet_enabled;
+       bool                    lcd_fet_enabled;
+       int                     led_en_gpio;
+       int                     lcd_en_gpio;
+       int                     panel_prepare_delay;
+       int                     panel_enable_delay;
+       int                     panel_disable_delay;
+       int                     panel_unprepare_delay;
+};
+
+static inline struct panel_lvds *to_panel(struct drm_panel *panel)
+{
+       return container_of(panel, struct panel_lvds, base);
+}
+
+static int panel_lvds_prepare(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->lcd_fet))
+               if (!lvds_panel->lcd_fet_enabled) {
+                       if (regulator_enable(lvds_panel->lcd_fet))
+                               DRM_ERROR("failed to enable LCD fet\n");
+                       lvds_panel->lcd_fet_enabled = true;
+               }
+
+       if (gpio_is_valid(lvds_panel->lcd_en_gpio))
+               gpio_set_value(lvds_panel->lcd_en_gpio, 1);
+
+       msleep(lvds_panel->panel_prepare_delay);
+
+       return 0;
+}
+
+static int panel_lvds_enable(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->backlight_fet))
+               if (!lvds_panel->backlight_fet_enabled) {
+                       if (regulator_enable(lvds_panel->backlight_fet))
+                               DRM_ERROR("failed to enable LED fet\n");
+                       lvds_panel->backlight_fet_enabled = true;
+               }
+
+       msleep(lvds_panel->panel_enable_delay);
+
+       if (gpio_is_valid(lvds_panel->led_en_gpio))
+               gpio_set_value(lvds_panel->led_en_gpio, 1);
+
+       return 0;
+}
+
+static int panel_lvds_disable(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (gpio_is_valid(lvds_panel->led_en_gpio))
+               gpio_set_value(lvds_panel->led_en_gpio, 0);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->backlight_fet))
+               if (lvds_panel->backlight_fet_enabled) {
+                       regulator_disable(lvds_panel->backlight_fet);
+                       lvds_panel->backlight_fet_enabled = false;
+               }
+
+       msleep(lvds_panel->panel_disable_delay);
+
+       return 0;
+}
+
+static int panel_lvds_unprepare(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (gpio_is_valid(lvds_panel->lcd_en_gpio))
+               gpio_set_value(lvds_panel->lcd_en_gpio, 0);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->lcd_fet))
+               if (lvds_panel->lcd_fet_enabled) {
+                       regulator_disable(lvds_panel->lcd_fet);
+                       lvds_panel->lcd_fet_enabled = false;
+               }
+
+       msleep(lvds_panel->panel_unprepare_delay);
+
+       return 0;
+}
+
+static int panel_lvds_get_modes(struct drm_panel *panel)
+{
+       struct drm_connector *connector = panel->connector;
+       struct panel_lvds *lvds_panel = to_panel(panel);
+       struct drm_display_mode *mode;
+
+       mode = drm_mode_create(connector->dev);
+       if (!mode) {
+               DRM_ERROR("failed to create a new display mode.\n");
+               return 0;
+       }
+
+       drm_display_mode_from_videomode(&lvds_panel->vm, mode);
+       mode->width_mm = lvds_panel->width_mm;
+       mode->height_mm = lvds_panel->height_mm;
+       connector->display_info.width_mm = mode->width_mm;
+       connector->display_info.height_mm = mode->height_mm;
+
+       mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+       drm_mode_set_name(mode);
+       drm_mode_probed_add(connector, mode);
+
+       return 1;
+}
+
+static const struct drm_panel_funcs panel_lvds_funcs = {
+       .unprepare = panel_lvds_unprepare,
+       .disable = panel_lvds_disable,
+       .prepare = panel_lvds_prepare,
+       .enable = panel_lvds_enable,
+       .get_modes = panel_lvds_get_modes,
+};
+
+static int panel_lvds_probe(struct platform_device *pdev)
+{
+       struct panel_lvds *panel;
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->of_node;
+       int ret;
+
+       panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
+       if (!panel)
+               return -ENOMEM;
+
+       ret = of_get_videomode(node, &panel->vm, 0);
+       if (ret) {
+               DRM_ERROR("failed: of_get_videomode() : %d\n", ret);
+               return ret;
+       }
+
+       panel->lcd_fet = devm_regulator_get_optional(dev, "lcd_vdd");
+       if (IS_ERR(panel->lcd_fet))
+               return -EPROBE_DEFER;
+
+       panel->backlight_fet = devm_regulator_get_optional(dev, "vcd_led");
+       if (IS_ERR(panel->backlight_fet))
+               return -EPROBE_DEFER;
+
+       panel->lcd_en_gpio = of_get_named_gpio(node, "lcd-en-gpio", 0);
+       panel->led_en_gpio = of_get_named_gpio(node, "led-en-gpio", 0);
+
+       of_property_read_u32(node, "panel-width-mm", &panel->width_mm);
+       of_property_read_u32(node, "panel-height-mm", &panel->height_mm);
+
+       of_property_read_u32(node, "panel-prepare-delay",
+                                       &panel->panel_prepare_delay);
+       of_property_read_u32(node, "panel-enable-delay",
+                                       &panel->panel_enable_delay);
+       of_property_read_u32(node, "panel-disable-delay",
+                                       &panel->panel_disable_delay);
+       of_property_read_u32(node, "panel-unprepare-delay",
+                                       &panel->panel_unprepare_delay);
+
+       if (gpio_is_valid(panel->lcd_en_gpio)) {
+               ret = devm_gpio_request_one(dev, 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 0;
+               }
+       } else {
+               panel->lcd_en_gpio = -ENODEV;
+       }
+
+       if (gpio_is_valid(panel->led_en_gpio)) {
+               ret = devm_gpio_request_one(dev, 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 0;
+               }
+       } else {
+               panel->led_en_gpio = -ENODEV;
+       }
+
+       drm_panel_init(&panel->base);
+       panel->base.dev = dev;
+       panel->base.funcs = &panel_lvds_funcs;
+
+       ret = drm_panel_add(&panel->base);
+       if (ret < 0)
+               return ret;
+
+       dev_set_drvdata(dev, panel);
+
+       return 0;
+}
+
+static int panel_lvds_remove(struct platform_device *pdev)
+{
+       struct panel_lvds *panel = dev_get_drvdata(&pdev->dev);
+
+       panel_lvds_disable(&panel->base);
+       panel_lvds_unprepare(&panel->base);
+
+       drm_panel_remove(&panel->base);
+
+       return 0;
+}
+
+static const struct of_device_id lvds_panel_dt_match[] = {
+       { .compatible = "panel-lvds" },
+       {},
+};
+MODULE_DEVICE_TABLE(of, lvds_panel_dt_match);
+
+struct platform_driver lvds_panel_driver = {
+       .driver = {
+               .name = "panel_lvds",
+               .owner = THIS_MODULE,
+               .of_match_table = lvds_panel_dt_match,
+       },
+       .probe = panel_lvds_probe,
+       .remove = panel_lvds_remove,
+};
+module_platform_driver(lvds_panel_driver);
+
+MODULE_AUTHOR("Ajay Kumar <[email protected]>");
+MODULE_DESCRIPTION("lvds/eDP panel driver");
+MODULE_LICENSE("GPL v2");
--

1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1402511228-18945-5-git-send-email-ajaykumar.rs-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org

#10 lore raw

Re: [PATCH V4 04/10] drm/panel: Add driver for lvds/edp based panels

Hello Ajay,

Not an extensive review since I'm not familiar with the graphics stack but a few things I noticed are commented below.

Quoted 68 lines · Ajay Kumar

This patch adds a simple driver to handle all the LCD and LED powerup/down routines needed to support eDP/LVDS panels.

The LCD and LED units are usually powered up via regulators, and almost on all boards, we will have a BACKLIGHT_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.

---
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 ++++
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 ++++++++++++++++++++
 4 files changed, 323 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +40 -0
new file mode 100644
index 0000000..7cb6084
@@ -0,0 +1,50 @@
+panel interface for eDP/lvds panels
+
+Required properties:
+  - compatible: "panel-lvds"
+
+Optional properties:
+       -lcd-en-gpio:
+               panel LCD poweron GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to powerup/enable the switch to the LCD panel.
+       -led-en-gpio:
+               panel LED enable GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to enable the backlight.
+       -panel-prepare-delay:
+               delay value in ms required for panel_prepare process
+                       Delay in ms needed for the panel LCD unit to
+                       powerup completely.
+                       ex: delay needed till eDP panel throws HPD.
+                           delay needed so that we cans tart reading edid.
+       -panel-enable-delay:
+               delay value in ms required for panel_enable process
+                       Delay in ms needed for the panel backlight/LED unit
+                       to powerup, and delay needed between video_enable and
+                       backlight_enable.
+       -panel-disable-delay:
+               delay value in ms required for panel_disable process
+                       Delay in ms needed for the panel backlight/LED unit
+                       powerdown, and delay needed between backlight_disable
+                       and video_disable.
+       -panel-unprepare-delay:
+               delay value in ms required for panel_post_disable process
+                       Delay in ms needed for the panel LCD unit to
+                       to powerdown completely, and the minimum delay needed
+                       before powering it on again.
+       -panel-width-mm: physical panel width [mm]
+       -panel-height-mm: physical panel height [mm]
+
+Example:
+

Documentation/devicetree/bindings/panel/panel-lvds.txt line 50

Quoted 10 lines
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +10 -0
+       panel-lvds {
+               compatible = "panel-lvds";
+               led-en-gpio = <&gpx3 0 1>;
+               panel-prepare-delay = <40>;
+               panel-enable-delay = <20>;
+               panel-disable-delay = <20>;
+               panel-unprepare-delay = <30>;
+               panel-width-mm = <256>;
+               panel-height-mm = <144>;
+       };

Recently it's considered a good practice to have the DT binding documentation in a separate patch.

Quoted 81 lines
drivers/gpu/drm/panel/Kconfig +10 -0
index 4ec874d..8fe7ee5 100644
@@ -30,4 +30,14 @@ config DRM_PANEL_S6E8AA0
        select DRM_MIPI_DSI
        select VIDEOMODE_HELPERS
 
+config DRM_PANEL_EDP_LVDS
+       tristate "support for eDP/LVDS panels"
+       depends on OF && DRM_PANEL
+       select VIDEOMODE_HELPERS
+       help
+         DRM panel driver for direct eDP panels or 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
drivers/gpu/drm/panel/Makefile +1 -0
index 8b92921..eaafa01 100644
@@ -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_EDP_LVDS) += panel-lvds.o
drivers/gpu/drm/panel/panel-lvds.c new file +47 -0
new file mode 100644
index 0000000..2124fcb
@@ -0,0 +1,262 @@
+/*
+ * panel driver for lvds and eDP panels
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd
+ *
+ * Ajay Kumar <[email protected]>
+ *
+ * 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 <video/of_videomode.h>
+#include <video/videomode.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_panel.h>
+
+struct panel_lvds {
+       struct drm_panel        base;
+       struct regulator        *backlight_fet;
+       struct regulator        *lcd_fet;
+       struct videomode        vm;
+       int                     width_mm;
+       int                     height_mm;
+       bool                    backlight_fet_enabled;
+       bool                    lcd_fet_enabled;
+       int                     led_en_gpio;
+       int                     lcd_en_gpio;
+       int                     panel_prepare_delay;
+       int                     panel_enable_delay;
+       int                     panel_disable_delay;
+       int                     panel_unprepare_delay;
+};
+
+static inline struct panel_lvds *to_panel(struct drm_panel *panel)
+{
+       return container_of(panel, struct panel_lvds, base);
+}

drivers/gpu/drm/panel/panel-lvds.c line 57

Quoted 10 lines
drivers/gpu/drm/panel/panel-lvds.c new file +10 -0
+
+static int panel_lvds_prepare(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->lcd_fet))
+               if (!lvds_panel->lcd_fet_enabled) {
+                       if (regulator_enable(lvds_panel->lcd_fet))
+                               DRM_ERROR("failed to enable LCD fet\n");
+                       lvds_panel->lcd_fet_enabled = true;

If this is an expected condition then using DRM_INFO() instead? It looks like an error to me though so maybe should return an error in this case?

Quoted 9 lines
drivers/gpu/drm/panel/panel-lvds.c new file +9 -0
+               }
+
+       if (gpio_is_valid(lvds_panel->lcd_en_gpio))
+               gpio_set_value(lvds_panel->lcd_en_gpio, 1);
+
+       msleep(lvds_panel->panel_prepare_delay);
+
+       return 0;
+}

drivers/gpu/drm/panel/panel-lvds.c line 76

Quoted 10 lines
drivers/gpu/drm/panel/panel-lvds.c new file +10 -0
+
+static int panel_lvds_enable(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->backlight_fet))
+               if (!lvds_panel->backlight_fet_enabled) {
+                       if (regulator_enable(lvds_panel->backlight_fet))
+                               DRM_ERROR("failed to enable LED fet\n");
+                       lvds_panel->backlight_fet_enabled = true;

Same here.

Quoted 97 lines
drivers/gpu/drm/panel/panel-lvds.c new file +97 -0
+               }
+
+       msleep(lvds_panel->panel_enable_delay);
+
+       if (gpio_is_valid(lvds_panel->led_en_gpio))
+               gpio_set_value(lvds_panel->led_en_gpio, 1);
+
+       return 0;
+}
+
+static int panel_lvds_disable(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (gpio_is_valid(lvds_panel->led_en_gpio))
+               gpio_set_value(lvds_panel->led_en_gpio, 0);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->backlight_fet))
+               if (lvds_panel->backlight_fet_enabled) {
+                       regulator_disable(lvds_panel->backlight_fet);
+                       lvds_panel->backlight_fet_enabled = false;
+               }
+
+       msleep(lvds_panel->panel_disable_delay);
+
+       return 0;
+}
+
+static int panel_lvds_unprepare(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (gpio_is_valid(lvds_panel->lcd_en_gpio))
+               gpio_set_value(lvds_panel->lcd_en_gpio, 0);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->lcd_fet))
+               if (lvds_panel->lcd_fet_enabled) {
+                       regulator_disable(lvds_panel->lcd_fet);
+                       lvds_panel->lcd_fet_enabled = false;
+               }
+
+       msleep(lvds_panel->panel_unprepare_delay);
+
+       return 0;
+}
+
+static int panel_lvds_get_modes(struct drm_panel *panel)
+{
+       struct drm_connector *connector = panel->connector;
+       struct panel_lvds *lvds_panel = to_panel(panel);
+       struct drm_display_mode *mode;
+
+       mode = drm_mode_create(connector->dev);
+       if (!mode) {
+               DRM_ERROR("failed to create a new display mode.\n");
+               return 0;
+       }
+
+       drm_display_mode_from_videomode(&lvds_panel->vm, mode);
+       mode->width_mm = lvds_panel->width_mm;
+       mode->height_mm = lvds_panel->height_mm;
+       connector->display_info.width_mm = mode->width_mm;
+       connector->display_info.height_mm = mode->height_mm;
+
+       mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+       drm_mode_set_name(mode);
+       drm_mode_probed_add(connector, mode);
+
+       return 1;
+}
+
+static const struct drm_panel_funcs panel_lvds_funcs = {
+       .unprepare = panel_lvds_unprepare,
+       .disable = panel_lvds_disable,
+       .prepare = panel_lvds_prepare,
+       .enable = panel_lvds_enable,
+       .get_modes = panel_lvds_get_modes,
+};
+
+static int panel_lvds_probe(struct platform_device *pdev)
+{
+       struct panel_lvds *panel;
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->of_node;
+       int ret;
+
+       panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
+       if (!panel)
+               return -ENOMEM;
+
+       ret = of_get_videomode(node, &panel->vm, 0);
+       if (ret) {
+               DRM_ERROR("failed: of_get_videomode() : %d\n", ret);
+               return ret;
+       }
+
+       panel->lcd_fet = devm_regulator_get_optional(dev, "lcd_vdd");

drivers/gpu/drm/panel/panel-lvds.c line 183

Quoted 10 lines
drivers/gpu/drm/panel/panel-lvds.c new file +10 -0
+       if (IS_ERR(panel->lcd_fet))
+               return -EPROBE_DEFER;
+
+       panel->backlight_fet = devm_regulator_get_optional(dev, "vcd_led");
+       if (IS_ERR(panel->backlight_fet))
+               return -EPROBE_DEFER;
+
+       panel->lcd_en_gpio = of_get_named_gpio(node, "lcd-en-gpio", 0);
+       panel->led_en_gpio = of_get_named_gpio(node, "led-en-gpio", 0);
+

The old integer-based GPIO API has been deprecated and new drivers should use the new descriptor-based interface (Documentation/gpio/consumer.txt) instead if possible.

Quoted 8 lines
drivers/gpu/drm/panel/panel-lvds.c new file +8 -0
+       of_property_read_u32(node, "panel-width-mm", &panel->width_mm);
+       of_property_read_u32(node, "panel-height-mm", &panel->height_mm);
+
+       of_property_read_u32(node, "panel-prepare-delay",
+                                       &panel->panel_prepare_delay);
+       of_property_read_u32(node, "panel-enable-delay",
+                                       &panel->panel_enable_delay);
+       of_property_read_u32(node, "panel-disable-delay",

drivers/gpu/drm/panel/panel-lvds.c line 201

Quoted 10 lines
drivers/gpu/drm/panel/panel-lvds.c new file +10 -0
+                                       &panel->panel_disable_delay);
+       of_property_read_u32(node, "panel-unprepare-delay",
+                                       &panel->panel_unprepare_delay);
+
+       if (gpio_is_valid(panel->lcd_en_gpio)) {
+               ret = devm_gpio_request_one(dev, 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 0;

The probe() function returning 0 means success to the driver core but here is returning early due an error.

drivers/gpu/drm/panel/panel-lvds.c line 212

Quoted 11 lines
drivers/gpu/drm/panel/panel-lvds.c new file +11 -0
+               }
+       } else {
+               panel->lcd_en_gpio = -ENODEV;
+       }
+
+       if (gpio_is_valid(panel->led_en_gpio)) {
+               ret = devm_gpio_request_one(dev, 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 0;

Same here, it should return an error code instead 0.

Quoted 51 lines
drivers/gpu/drm/panel/panel-lvds.c new file +50 -1
+               }
+       } else {
+               panel->led_en_gpio = -ENODEV;
+       }
+
+       drm_panel_init(&panel->base);
+       panel->base.dev = dev;
+       panel->base.funcs = &panel_lvds_funcs;
+
+       ret = drm_panel_add(&panel->base);
+       if (ret < 0)
+               return ret;
+
+       dev_set_drvdata(dev, panel);
+
+       return 0;
+}
+
+static int panel_lvds_remove(struct platform_device *pdev)
+{
+       struct panel_lvds *panel = dev_get_drvdata(&pdev->dev);
+
+       panel_lvds_disable(&panel->base);
+       panel_lvds_unprepare(&panel->base);
+
+       drm_panel_remove(&panel->base);
+
+       return 0;
+}
+
+static const struct of_device_id lvds_panel_dt_match[] = {
+       { .compatible = "panel-lvds" },
+       {},
+};
+MODULE_DEVICE_TABLE(of, lvds_panel_dt_match);
+
+struct platform_driver lvds_panel_driver = {
+       .driver = {
+               .name = "panel_lvds",
+               .owner = THIS_MODULE,
+               .of_match_table = lvds_panel_dt_match,
+       },
+       .probe = panel_lvds_probe,
+       .remove = panel_lvds_remove,
+};
+module_platform_driver(lvds_panel_driver);
+
+MODULE_AUTHOR("Ajay Kumar <[email protected]>");
+MODULE_DESCRIPTION("lvds/eDP panel driver");
+MODULE_LICENSE("GPL v2");
--
Quoted 2 lines

1.7.9.5

Best regards,
Javier
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

Re: [PATCH V4 04/10] drm/panel: Add driver for lvds/edp based panels

Hi Javier,

Thanks for the review.

Quoted 79 lines · Javier Martinez Canillas

Hello Ajay,

Not an extensive review since I'm not familiar with the graphics stack but a few things I noticed are commented below.

Quoted 73 lines · Ajay Kumar

This patch adds a simple driver to handle all the LCD and LED powerup/down routines needed to support eDP/LVDS panels.

The LCD and LED units are usually powered up via regulators, and almost on all boards, we will have a BACKLIGHT_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.

---
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 ++++
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 ++++++++++++++++++++
 4 files changed, 323 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +45 -0
new file mode 100644
index 0000000..7cb6084
@@ -0,0 +1,50 @@
+panel interface for eDP/lvds panels
+
+Required properties:
+  - compatible: "panel-lvds"
+
+Optional properties:
+       -lcd-en-gpio:
+               panel LCD poweron GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to powerup/enable the switch to the LCD panel.
+       -led-en-gpio:
+               panel LED enable GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to enable the backlight.
+       -panel-prepare-delay:
+               delay value in ms required for panel_prepare process
+                       Delay in ms needed for the panel LCD unit to
+                       powerup completely.
+                       ex: delay needed till eDP panel throws HPD.
+                           delay needed so that we cans tart reading edid.
+       -panel-enable-delay:
+               delay value in ms required for panel_enable process
+                       Delay in ms needed for the panel backlight/LED unit
+                       to powerup, and delay needed between video_enable and
+                       backlight_enable.
+       -panel-disable-delay:
+               delay value in ms required for panel_disable process
+                       Delay in ms needed for the panel backlight/LED unit
+                       powerdown, and delay needed between backlight_disable
+                       and video_disable.
+       -panel-unprepare-delay:
+               delay value in ms required for panel_post_disable process
+                       Delay in ms needed for the panel LCD unit to
+                       to powerdown completely, and the minimum delay needed
+                       before powering it on again.
+       -panel-width-mm: physical panel width [mm]
+       -panel-height-mm: physical panel height [mm]
+
+Example:
+
+       panel-lvds {
+               compatible = "panel-lvds";
+               led-en-gpio = <&gpx3 0 1>;
+               panel-prepare-delay = <40>;
+               panel-enable-delay = <20>;
Quoted 8 lines

Documentation/devicetree/bindings/panel/panel-lvds.txt line 50

Quoted 5 lines
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +5 -0
+               panel-disable-delay = <20>;
+               panel-unprepare-delay = <30>;
+               panel-width-mm = <256>;
+               panel-height-mm = <144>;
+       };

Recently it's considered a good practice to have the DT binding documentation in a separate patch.

Ok, will remember this.

Quoted 87 lines
Quoted 87 lines
drivers/gpu/drm/panel/Kconfig +10 -0
index 4ec874d..8fe7ee5 100644
@@ -30,4 +30,14 @@ config DRM_PANEL_S6E8AA0
        select DRM_MIPI_DSI
        select VIDEOMODE_HELPERS
 
+config DRM_PANEL_EDP_LVDS
+       tristate "support for eDP/LVDS panels"
+       depends on OF && DRM_PANEL
+       select VIDEOMODE_HELPERS
+       help
+         DRM panel driver for direct eDP panels or 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
drivers/gpu/drm/panel/Makefile +1 -0
index 8b92921..eaafa01 100644
@@ -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_EDP_LVDS) += panel-lvds.o
drivers/gpu/drm/panel/panel-lvds.c new file +53 -0
new file mode 100644
index 0000000..2124fcb
@@ -0,0 +1,262 @@
+/*
+ * panel driver for lvds and eDP panels
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd
+ *
+ * Ajay Kumar <[email protected]>
+ *
+ * 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 <video/of_videomode.h>
+#include <video/videomode.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_panel.h>
+
+struct panel_lvds {
+       struct drm_panel        base;
+       struct regulator        *backlight_fet;
+       struct regulator        *lcd_fet;
+       struct videomode        vm;
+       int                     width_mm;
+       int                     height_mm;
+       bool                    backlight_fet_enabled;
+       bool                    lcd_fet_enabled;
+       int                     led_en_gpio;
+       int                     lcd_en_gpio;
+       int                     panel_prepare_delay;
+       int                     panel_enable_delay;
+       int                     panel_disable_delay;
+       int                     panel_unprepare_delay;
+};
+
+static inline struct panel_lvds *to_panel(struct drm_panel *panel)
+{
+       return container_of(panel, struct panel_lvds, base);
+}
+
+static int panel_lvds_prepare(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->lcd_fet))
Quoted 8 lines

drivers/gpu/drm/panel/panel-lvds.c line 57

Quoted 4 lines
drivers/gpu/drm/panel/panel-lvds.c new file +4 -0
+               if (!lvds_panel->lcd_fet_enabled) {
+                       if (regulator_enable(lvds_panel->lcd_fet))
+                               DRM_ERROR("failed to enable LCD fet\n");
+                       lvds_panel->lcd_fet_enabled = true;

If this is an expected condition then using DRM_INFO() instead? It looks like an error to me though so maybe should return an error in this case?

Right, we should ideally return an error here.

Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/panel/panel-lvds.c new file +13 -0
+               }
+
+       if (gpio_is_valid(lvds_panel->lcd_en_gpio))
+               gpio_set_value(lvds_panel->lcd_en_gpio, 1);
+
+       msleep(lvds_panel->panel_prepare_delay);
+
+       return 0;
+}
+
+static int panel_lvds_enable(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
Quoted 8 lines

drivers/gpu/drm/panel/panel-lvds.c line 76

Quoted 6 lines
drivers/gpu/drm/panel/panel-lvds.c new file +6 -0
+
+       if (!IS_ERR_OR_NULL(lvds_panel->backlight_fet))
+               if (!lvds_panel->backlight_fet_enabled) {
+                       if (regulator_enable(lvds_panel->backlight_fet))
+                               DRM_ERROR("failed to enable LED fet\n");
+                       lvds_panel->backlight_fet_enabled = true;

Same here.

Ok.

Quoted 103 lines
Quoted 103 lines
drivers/gpu/drm/panel/panel-lvds.c new file +103 -0
+               }
+
+       msleep(lvds_panel->panel_enable_delay);
+
+       if (gpio_is_valid(lvds_panel->led_en_gpio))
+               gpio_set_value(lvds_panel->led_en_gpio, 1);
+
+       return 0;
+}
+
+static int panel_lvds_disable(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (gpio_is_valid(lvds_panel->led_en_gpio))
+               gpio_set_value(lvds_panel->led_en_gpio, 0);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->backlight_fet))
+               if (lvds_panel->backlight_fet_enabled) {
+                       regulator_disable(lvds_panel->backlight_fet);
+                       lvds_panel->backlight_fet_enabled = false;
+               }
+
+       msleep(lvds_panel->panel_disable_delay);
+
+       return 0;
+}
+
+static int panel_lvds_unprepare(struct drm_panel *panel)
+{
+       struct panel_lvds *lvds_panel = to_panel(panel);
+
+       if (gpio_is_valid(lvds_panel->lcd_en_gpio))
+               gpio_set_value(lvds_panel->lcd_en_gpio, 0);
+
+       if (!IS_ERR_OR_NULL(lvds_panel->lcd_fet))
+               if (lvds_panel->lcd_fet_enabled) {
+                       regulator_disable(lvds_panel->lcd_fet);
+                       lvds_panel->lcd_fet_enabled = false;
+               }
+
+       msleep(lvds_panel->panel_unprepare_delay);
+
+       return 0;
+}
+
+static int panel_lvds_get_modes(struct drm_panel *panel)
+{
+       struct drm_connector *connector = panel->connector;
+       struct panel_lvds *lvds_panel = to_panel(panel);
+       struct drm_display_mode *mode;
+
+       mode = drm_mode_create(connector->dev);
+       if (!mode) {
+               DRM_ERROR("failed to create a new display mode.\n");
+               return 0;
+       }
+
+       drm_display_mode_from_videomode(&lvds_panel->vm, mode);
+       mode->width_mm = lvds_panel->width_mm;
+       mode->height_mm = lvds_panel->height_mm;
+       connector->display_info.width_mm = mode->width_mm;
+       connector->display_info.height_mm = mode->height_mm;
+
+       mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+       drm_mode_set_name(mode);
+       drm_mode_probed_add(connector, mode);
+
+       return 1;
+}
+
+static const struct drm_panel_funcs panel_lvds_funcs = {
+       .unprepare = panel_lvds_unprepare,
+       .disable = panel_lvds_disable,
+       .prepare = panel_lvds_prepare,
+       .enable = panel_lvds_enable,
+       .get_modes = panel_lvds_get_modes,
+};
+
+static int panel_lvds_probe(struct platform_device *pdev)
+{
+       struct panel_lvds *panel;
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->of_node;
+       int ret;
+
+       panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
+       if (!panel)
+               return -ENOMEM;
+
+       ret = of_get_videomode(node, &panel->vm, 0);
+       if (ret) {
+               DRM_ERROR("failed: of_get_videomode() : %d\n", ret);
+               return ret;
+       }
+
+       panel->lcd_fet = devm_regulator_get_optional(dev, "lcd_vdd");
+       if (IS_ERR(panel->lcd_fet))
+               return -EPROBE_DEFER;
+
+       panel->backlight_fet = devm_regulator_get_optional(dev, "vcd_led");
+       if (IS_ERR(panel->backlight_fet))
+               return -EPROBE_DEFER;
Quoted 8 lines

drivers/gpu/drm/panel/panel-lvds.c line 183

Quoted 4 lines
drivers/gpu/drm/panel/panel-lvds.c new file +4 -0
+
+       panel->lcd_en_gpio = of_get_named_gpio(node, "lcd-en-gpio", 0);
+       panel->led_en_gpio = of_get_named_gpio(node, "led-en-gpio", 0);
+

The old integer-based GPIO API has been deprecated and new drivers should use the new descriptor-based interface (Documentation/gpio/consumer.txt) instead if possible.

Ok, I just saw other panel drivers using the same. Will change this.

Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/panel/panel-lvds.c new file +13 -0
+       of_property_read_u32(node, "panel-width-mm", &panel->width_mm);
+       of_property_read_u32(node, "panel-height-mm", &panel->height_mm);
+
+       of_property_read_u32(node, "panel-prepare-delay",
+                                       &panel->panel_prepare_delay);
+       of_property_read_u32(node, "panel-enable-delay",
+                                       &panel->panel_enable_delay);
+       of_property_read_u32(node, "panel-disable-delay",
+                                       &panel->panel_disable_delay);
+       of_property_read_u32(node, "panel-unprepare-delay",
+                                       &panel->panel_unprepare_delay);
+
+       if (gpio_is_valid(panel->lcd_en_gpio)) {
Quoted 8 lines

drivers/gpu/drm/panel/panel-lvds.c line 201

Quoted 5 lines
drivers/gpu/drm/panel/panel-lvds.c new file +5 -0
+               ret = devm_gpio_request_one(dev, 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 0;

The probe() function returning 0 means success to the driver core but here is returning early due an error.

Right, will fix it.

Quoted 12 lines

drivers/gpu/drm/panel/panel-lvds.c line 212

Quoted 11 lines
drivers/gpu/drm/panel/panel-lvds.c new file +11 -0
+               }
+       } else {
+               panel->lcd_en_gpio = -ENODEV;
+       }
+
+       if (gpio_is_valid(panel->led_en_gpio)) {
+               ret = devm_gpio_request_one(dev, 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 0;
Quoted 1 line

Same here, it should return an error code instead 0.

Right, will fix it.

Quoted 56 lines
Quoted 51 lines
drivers/gpu/drm/panel/panel-lvds.c new file +50 -1
+               }
+       } else {
+               panel->led_en_gpio = -ENODEV;
+       }
+
+       drm_panel_init(&panel->base);
+       panel->base.dev = dev;
+       panel->base.funcs = &panel_lvds_funcs;
+
+       ret = drm_panel_add(&panel->base);
+       if (ret < 0)
+               return ret;
+
+       dev_set_drvdata(dev, panel);
+
+       return 0;
+}
+
+static int panel_lvds_remove(struct platform_device *pdev)
+{
+       struct panel_lvds *panel = dev_get_drvdata(&pdev->dev);
+
+       panel_lvds_disable(&panel->base);
+       panel_lvds_unprepare(&panel->base);
+
+       drm_panel_remove(&panel->base);
+
+       return 0;
+}
+
+static const struct of_device_id lvds_panel_dt_match[] = {
+       { .compatible = "panel-lvds" },
+       {},
+};
+MODULE_DEVICE_TABLE(of, lvds_panel_dt_match);
+
+struct platform_driver lvds_panel_driver = {
+       .driver = {
+               .name = "panel_lvds",
+               .owner = THIS_MODULE,
+               .of_match_table = lvds_panel_dt_match,
+       },
+       .probe = panel_lvds_probe,
+       .remove = panel_lvds_remove,
+};
+module_platform_driver(lvds_panel_driver);
+
+MODULE_AUTHOR("Ajay Kumar <[email protected]>");
+MODULE_DESCRIPTION("lvds/eDP panel driver");
+MODULE_LICENSE("GPL v2");
--
Quoted 2 lines

1.7.9.5

Best regards,
Javier

#12 lore raw

Re: [PATCH V4 04/10] drm/panel: Add driver for lvds/edp based panels

In reply to Ajay Kumar

Hi

2014-06-11 20:27 GMT+02:00 Ajay Kumar <[email protected]>:

Quoted 56 lines

This patch adds a simple driver to handle all the LCD and LED powerup/down routines needed to support eDP/LVDS panels.

The LCD and LED units are usually powered up via regulators, and almost on all boards, we will have a BACKLIGHT_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.

---
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 ++++
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 ++++++++++++++++++++
 4 files changed, 323 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +28 -0
new file mode 100644
index 0000000..7cb6084
@@ -0,0 +1,50 @@
+panel interface for eDP/lvds panels
+
+Required properties:
+  - compatible: "panel-lvds"
+
+Optional properties:
+       -lcd-en-gpio:
+               panel LCD poweron GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to powerup/enable the switch to the LCD panel.
+       -led-en-gpio:
+               panel LED enable GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to enable the backlight.
+       -panel-prepare-delay:
+               delay value in ms required for panel_prepare process
+                       Delay in ms needed for the panel LCD unit to
+                       powerup completely.
+                       ex: delay needed till eDP panel throws HPD.
+                           delay needed so that we cans tart reading edid.
+       -panel-enable-delay:
+               delay value in ms required for panel_enable process
+                       Delay in ms needed for the panel backlight/LED unit
+                       to powerup, and delay needed between video_enable and
+                       backlight_enable.
+       -panel-disable-delay:
+               delay value in ms required for panel_disable process
+                       Delay in ms needed for the panel backlight/LED unit

Documentation/devicetree/bindings/panel/panel-lvds.txt line 38

Quoted 10 lines
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +10 -0
+                       powerdown, and delay needed between backlight_disable
+                       and video_disable.
+       -panel-unprepare-delay:
+               delay value in ms required for panel_post_disable process
+                       Delay in ms needed for the panel LCD unit to
+                       to powerdown completely, and the minimum delay needed
+                       before powering it on again.
+       -panel-width-mm: physical panel width [mm]
+       -panel-height-mm: physical panel height [mm]
+

For what are these two properties are needed?

If I find some time I will give this patch a try as I need something like this for an imx6d based device.

greets
--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner

#13 lore raw

Re: [PATCH V4 04/10] drm/panel: Add driver for lvds/edp based panels

Hi Gmeiner,

Quoted 64 lines · Christian Gmeiner

Hi

2014-06-11 20:27 GMT+02:00 Ajay Kumar <[email protected]>:

Quoted 60 lines

This patch adds a simple driver to handle all the LCD and LED powerup/down routines needed to support eDP/LVDS panels.

The LCD and LED units are usually powered up via regulators, and almost on all boards, we will have a BACKLIGHT_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.

---
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 ++++
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 ++++++++++++++++++++
 4 files changed, 323 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +32 -0
new file mode 100644
index 0000000..7cb6084
@@ -0,0 +1,50 @@
+panel interface for eDP/lvds panels
+
+Required properties:
+  - compatible: "panel-lvds"
+
+Optional properties:
+       -lcd-en-gpio:
+               panel LCD poweron GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to powerup/enable the switch to the LCD panel.
+       -led-en-gpio:
+               panel LED enable GPIO.
+                       Indicates which GPIO needs to be powered up as output
+                       to enable the backlight.
+       -panel-prepare-delay:
+               delay value in ms required for panel_prepare process
+                       Delay in ms needed for the panel LCD unit to
+                       powerup completely.
+                       ex: delay needed till eDP panel throws HPD.
+                           delay needed so that we cans tart reading edid.
+       -panel-enable-delay:
+               delay value in ms required for panel_enable process
+                       Delay in ms needed for the panel backlight/LED unit
+                       to powerup, and delay needed between video_enable and
+                       backlight_enable.
+       -panel-disable-delay:
+               delay value in ms required for panel_disable process
+                       Delay in ms needed for the panel backlight/LED unit
+                       powerdown, and delay needed between backlight_disable
+                       and video_disable.
+       -panel-unprepare-delay:
+               delay value in ms required for panel_post_disable process
Quoted 8 lines

Documentation/devicetree/bindings/panel/panel-lvds.txt line 38

Quoted 6 lines
Documentation/devicetree/bindings/panel/panel-lvds.txt new file +6 -0
+                       Delay in ms needed for the panel LCD unit to
+                       to powerdown completely, and the minimum delay needed
+                       before powering it on again.
+       -panel-width-mm: physical panel width [mm]
+       -panel-height-mm: physical panel height [mm]
+

For what are these two properties are needed?

Actually, these are needed to caluculate DPI(dots/pixels per inch). That information will be used by the corresponding userspace to deliver proper size fonts.
You can refer other panel drivers, even they too are using it!

Regards,
Ajay

Quoted 2 lines

If I find some time I will give this patch a try as I need something like this for an imx6d based device.

That would be great, Thanks.

Ajay

author
#14 lore raw

PATCH v4 5/10 drm/bridge: add helper functions to support bridge chain

In reply to Ajay Kumar

Add helper functions to create bridge chain and to call the corresponding next_bridge functions.

---
 include/drm/drm_crtc.h |   72 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
include/drm/drm_crtc.h +72 -0
index a7fac56..ba6a0d2 100644
@@ -640,6 +640,7 @@ struct drm_bridge_funcs {
 struct drm_bridge {
 	struct drm_device *dev;
 	struct list_head head;
+	struct drm_bridge *next_bridge;
 
 	struct drm_mode_object base;
 
@@ -1148,6 +1149,77 @@ drm_property_blob_find(struct drm_device *dev, uint32_t id)
 	return mo ? obj_to_blob(mo) : NULL;
 }
 
+static inline int drm_bridge_add_to_chain(struct drm_bridge *head,
+					  struct drm_bridge *last)
+{
+	struct drm_bridge *temp = head;
+
+	if (head && last) {
+		while (temp->next_bridge)
+			temp = temp->next_bridge;
+
+		temp->next_bridge = last;
+		return 0;
+	}
+
+	return -EINVAL;
+}
+
+static inline void drm_next_bridge_mode_fixup(struct drm_bridge *bridge,
+					const struct drm_display_mode *mode,
+					struct drm_display_mode *adjusted_mode)
+{
+	if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+	    bridge->next_bridge->funcs->mode_fixup)
+		bridge->next_bridge->funcs->mode_fixup(bridge->next_bridge,
+							mode, adjusted_mode);
+}
+
+static inline void drm_next_bridge_disable(struct drm_bridge *bridge)
+{
+	if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+	    bridge->next_bridge->funcs->disable)
+		bridge->next_bridge->funcs->disable(bridge->next_bridge);
+}
+
+static inline void drm_next_bridge_post_disable(struct drm_bridge *bridge)
+{
+	if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+	    bridge->next_bridge->funcs->post_disable)
+		bridge->next_bridge->funcs->post_disable(bridge->next_bridge);
+}
+
+static inline void drm_next_bridge_mode_set(struct drm_bridge *bridge,
+					struct drm_display_mode *mode,
+					struct drm_display_mode *adjusted_mode)
+{
+	if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+	    bridge->next_bridge->funcs->mode_set)
+		bridge->next_bridge->funcs->mode_set(bridge->next_bridge,
+							mode, adjusted_mode);
+}
+
+static inline void drm_next_bridge_pre_enable(struct drm_bridge *bridge)
+{
+	if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+	    bridge->next_bridge->funcs->pre_enable)
+		bridge->next_bridge->funcs->pre_enable(bridge->next_bridge);
+}
+
+static inline void drm_next_bridge_enable(struct drm_bridge *bridge)
+{
+	if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+	    bridge->next_bridge->funcs->enable)
+		bridge->next_bridge->funcs->enable(bridge->next_bridge);
+}
+
+static inline void drm_next_bridge_destroy(struct drm_bridge *bridge)
+{
+	if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+	    bridge->next_bridge->funcs->destroy)
+		bridge->next_bridge->funcs->destroy(bridge->next_bridge);
+}
+
 /* Plane list iterator for legacy (overlay only) planes. */
 #define drm_for_each_legacy_plane(plane, planelist) \
 	list_for_each_entry(plane, planelist, head) \
Signature · 1 line
1.7.9.5
#15 lore raw

Re: [PATCH V4 05/10] drm/bridge: add helper functions to support bridge chain

ping.

Quoted 102 lines · Ajay Kumar

Add helper functions to create bridge chain and to call the corresponding next_bridge functions.

---
 include/drm/drm_crtc.h |   72 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
include/drm/drm_crtc.h +72 -1
index a7fac56..ba6a0d2 100644
@@ -640,6 +640,7 @@ struct drm_bridge_funcs {
 struct drm_bridge {
        struct drm_device *dev;
        struct list_head head;
+       struct drm_bridge *next_bridge;
 
        struct drm_mode_object base;
 
@@ -1148,6 +1149,77 @@ drm_property_blob_find(struct drm_device *dev, uint32_t id)
        return mo ? obj_to_blob(mo) : NULL;
 }
 
+static inline int drm_bridge_add_to_chain(struct drm_bridge *head,
+                                         struct drm_bridge *last)
+{
+       struct drm_bridge *temp = head;
+
+       if (head && last) {
+               while (temp->next_bridge)
+                       temp = temp->next_bridge;
+
+               temp->next_bridge = last;
+               return 0;
+       }
+
+       return -EINVAL;
+}
+
+static inline void drm_next_bridge_mode_fixup(struct drm_bridge *bridge,
+                                       const struct drm_display_mode *mode,
+                                       struct drm_display_mode *adjusted_mode)
+{
+       if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+           bridge->next_bridge->funcs->mode_fixup)
+               bridge->next_bridge->funcs->mode_fixup(bridge->next_bridge,
+                                                       mode, adjusted_mode);
+}
+
+static inline void drm_next_bridge_disable(struct drm_bridge *bridge)
+{
+       if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+           bridge->next_bridge->funcs->disable)
+               bridge->next_bridge->funcs->disable(bridge->next_bridge);
+}
+
+static inline void drm_next_bridge_post_disable(struct drm_bridge *bridge)
+{
+       if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+           bridge->next_bridge->funcs->post_disable)
+               bridge->next_bridge->funcs->post_disable(bridge->next_bridge);
+}
+
+static inline void drm_next_bridge_mode_set(struct drm_bridge *bridge,
+                                       struct drm_display_mode *mode,
+                                       struct drm_display_mode *adjusted_mode)
+{
+       if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+           bridge->next_bridge->funcs->mode_set)
+               bridge->next_bridge->funcs->mode_set(bridge->next_bridge,
+                                                       mode, adjusted_mode);
+}
+
+static inline void drm_next_bridge_pre_enable(struct drm_bridge *bridge)
+{
+       if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+           bridge->next_bridge->funcs->pre_enable)
+               bridge->next_bridge->funcs->pre_enable(bridge->next_bridge);
+}
+
+static inline void drm_next_bridge_enable(struct drm_bridge *bridge)
+{
+       if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+           bridge->next_bridge->funcs->enable)
+               bridge->next_bridge->funcs->enable(bridge->next_bridge);
+}
+
+static inline void drm_next_bridge_destroy(struct drm_bridge *bridge)
+{
+       if (bridge && bridge->next_bridge && bridge->next_bridge->funcs &&
+           bridge->next_bridge->funcs->destroy)
+               bridge->next_bridge->funcs->destroy(bridge->next_bridge);
+}
+
 /* Plane list iterator for legacy (overlay only) planes. */
 #define drm_for_each_legacy_plane(plane, planelist) \
        list_for_each_entry(plane, planelist, head) \
--

1.7.9.5

author
#16 lore raw

PATCH v4 6/10 drm/bridge: Add a driver which binds drm_bridge with drm_panel

In reply to Ajay Kumar

Add a dummy bridge which binds all of the drm_bridge callbacks to corresponding drm_panel callbacks.

In theory, this is just a glue layer for the last bridge and the panel attached to it.

This driver also implements the required drm_connector ops for the encoder(on which the entire bridge chain is hanging off).

---
 drivers/gpu/drm/bridge/Kconfig        |    7 ++
 drivers/gpu/drm/bridge/Makefile       |    1 +
 drivers/gpu/drm/bridge/panel_binder.c |  193 +++++++++++++++++++++++++++++++++
 include/drm/bridge/panel_binder.h     |   44 ++++++++
 4 files changed, 245 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/panel_binder.c
 create mode 100644 include/drm/bridge/panel_binder.h
drivers/gpu/drm/bridge/Kconfig +7 -0
index 884923f..e3fb487 100644
@@ -3,3 +3,10 @@ config DRM_PTN3460
 	depends on DRM
 	select DRM_KMS_HELPER
 	---help---
+
+config DRM_PANEL_BINDER
+	tristate "bridge panel binder"
+	depends on DRM
+	select DRM_KMS_HELPER
+	select DRM_PANEL
+	---help---
drivers/gpu/drm/bridge/Makefile +1 -0
index b4733e1..ba8b5b8 100644
@@ -1,3 +1,4 @@
 ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
+obj-$(CONFIG_DRM_PANEL_BINDER) += panel_binder.o
drivers/gpu/drm/bridge/panel_binder.c new file +193 -0

193 lines not on this page · raw message

include/drm/bridge/panel_binder.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1402511228-18945-7-git-send-email-ajaykumar.rs-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org

#18 lore raw

Re: [PATCH V4 06/10] drm/bridge: Add a driver which binds drm_bridge with drm_panel

ping.

Quoted 293 lines · Ajay Kumar

Add a dummy bridge which binds all of the drm_bridge callbacks to corresponding drm_panel callbacks.

In theory, this is just a glue layer for the last bridge and the panel attached to it.

This driver also implements the required drm_connector ops for the encoder(on which the entire bridge chain is hanging off).

---
 drivers/gpu/drm/bridge/Kconfig        |    7 ++
 drivers/gpu/drm/bridge/Makefile       |    1 +
 drivers/gpu/drm/bridge/panel_binder.c |  193 +++++++++++++++++++++++++++++++++
 include/drm/bridge/panel_binder.h     |   44 ++++++++
 4 files changed, 245 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/panel_binder.c
 create mode 100644 include/drm/bridge/panel_binder.h
drivers/gpu/drm/bridge/Kconfig +7 -0
index 884923f..e3fb487 100644
@@ -3,3 +3,10 @@ config DRM_PTN3460
        depends on DRM
        select DRM_KMS_HELPER
        ---help---
+
+config DRM_PANEL_BINDER
+       tristate "bridge panel binder"
+       depends on DRM
+       select DRM_KMS_HELPER
+       select DRM_PANEL
+       ---help---
drivers/gpu/drm/bridge/Makefile +1 -0
index b4733e1..ba8b5b8 100644
@@ -1,3 +1,4 @@
 ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
+obj-$(CONFIG_DRM_PANEL_BINDER) += panel_binder.o
drivers/gpu/drm/bridge/panel_binder.c new file +193 -0
new file mode 100644
index 0000000..93d976b
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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 <linux/module.h>
+#include <linux/of.h>
+
+#include <drm/drm_panel.h>
+
+#include "drmP.h"
+#include "drm_crtc.h"
+#include "drm_crtc_helper.h"
+
+#include "bridge/panel_binder.h"
+
+struct panel_binder {
+       struct drm_connector    connector;
+       struct i2c_client       *client;
+       struct drm_encoder      *encoder;
+       struct drm_bridge       *bridge;
+       struct drm_panel        *panel;
+};
+
+static void panel_binder_pre_enable(struct drm_bridge *bridge)
+{
+       struct panel_binder *panel_binder = bridge->driver_private;
+
+       drm_panel_prepare(panel_binder->panel);
+}
+
+static void panel_binder_enable(struct drm_bridge *bridge)
+{
+       struct panel_binder *panel_binder = bridge->driver_private;
+
+       drm_panel_enable(panel_binder->panel);
+}
+
+static void panel_binder_disable(struct drm_bridge *bridge)
+{
+       struct panel_binder *panel_binder = bridge->driver_private;
+
+       drm_panel_disable(panel_binder->panel);
+}
+
+static void panel_binder_post_disable(struct drm_bridge *bridge)
+{
+       struct panel_binder *panel_binder = bridge->driver_private;
+
+       drm_panel_unprepare(panel_binder->panel);
+}
+
+void panel_binder_destroy(struct drm_bridge *bridge)
+{
+       struct panel_binder *panel_binder = bridge->driver_private;
+
+       drm_panel_detach(panel_binder->panel);
+       drm_bridge_cleanup(bridge);
+}
+
+struct drm_bridge_funcs panel_binder_funcs = {
+       .pre_enable = panel_binder_pre_enable,
+       .enable = panel_binder_enable,
+       .disable = panel_binder_disable,
+       .post_disable = panel_binder_post_disable,
+       .destroy = panel_binder_destroy,
+};
+
+static int panel_binder_mode_valid(struct drm_connector *connector,
+                                struct drm_display_mode *mode)
+{
+       return MODE_OK;
+}
+
+static int panel_binder_get_modes(struct drm_connector *connector)
+{
+       struct panel_binder *panel_binder;
+
+       panel_binder = container_of(connector, struct panel_binder, connector);
+
+       return panel_binder->panel->funcs->get_modes(panel_binder->panel);
+}
+
+static struct drm_encoder *panel_binder_best_encoder(struct drm_connector
+                                                               *connector)
+{
+       struct panel_binder *panel_binder;
+
+       panel_binder = container_of(connector, struct panel_binder, connector);
+
+       return panel_binder->encoder;
+}
+
+static const struct drm_connector_helper_funcs
+                                       panel_binder_connector_helper_funcs = {
+       .get_modes = panel_binder_get_modes,
+       .mode_valid = panel_binder_mode_valid,
+       .best_encoder = panel_binder_best_encoder,
+};
+
+static enum drm_connector_status panel_binder_detect(struct drm_connector
+                                                       *connector, bool force)
+{
+       return connector_status_connected;
+}
+
+static void panel_binder_connector_destroy(struct drm_connector *connector)
+{
+       drm_connector_cleanup(connector);
+}
+
+static const struct drm_connector_funcs panel_binder_connector_funcs = {
+       .dpms = drm_helper_connector_dpms,
+       .fill_modes = drm_helper_probe_single_connector_modes,
+       .detect = panel_binder_detect,
+       .destroy = panel_binder_connector_destroy,
+};
+
+struct drm_bridge *panel_binder_init(struct drm_device *dev,
+                                       struct drm_encoder *encoder,
+                                       struct i2c_client *client,
+                                       struct device_node *node,
+                                       struct drm_panel *panel,
+                                       int connector_type,
+                                       uint8_t polled)
+{
+       int ret;
+       struct drm_bridge *bridge;
+       struct panel_binder *panel_binder;
+
+       if (IS_ERR_OR_NULL(panel)) {
+               DRM_ERROR("invalid drm_panel pointer\n");
+               return NULL;
+       }
+
+       bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL);
+       if (!bridge) {
+               DRM_ERROR("failed to allocate drm bridge\n");
+               return NULL;
+       }
+
+       panel_binder = devm_kzalloc(dev->dev, sizeof(*panel_binder),
+                                                               GFP_KERNEL);
+       if (!panel_binder) {
+               DRM_ERROR("failed to allocate bridge panel_binder\n");
+               return NULL;
+       }
+
+       panel_binder->client = client;
+       panel_binder->encoder = encoder;
+       panel_binder->bridge = bridge;
+       panel_binder->panel = panel;
+
+       ret = drm_bridge_init(dev, bridge, &panel_binder_funcs);
+       if (ret) {
+               DRM_ERROR("failed to initialize bridge with drm\n");
+               goto err;
+       }
+
+       bridge->driver_private = panel_binder;
+
+       drm_panel_attach(panel_binder->panel, &panel_binder->connector);
+
+       if (!encoder->bridge)
+               /* First entry in the bridge chain */
+               encoder->bridge = bridge;
+
+       panel_binder->connector.polled = polled;
+       ret = drm_connector_init(dev, &panel_binder->connector,
+                       &panel_binder_connector_funcs, connector_type);
+       if (ret) {
+               DRM_ERROR("failed to initialize connector with drm\n");
+               goto err;
+       }
+       drm_connector_helper_add(&panel_binder->connector,
+                       &panel_binder_connector_helper_funcs);
+       drm_sysfs_connector_add(&panel_binder->connector);
+       drm_mode_connector_attach_encoder(&panel_binder->connector, encoder);
+
+       return bridge;
+
+err:
+       return NULL;
+}
+EXPORT_SYMBOL(panel_binder_init);
include/drm/bridge/panel_binder.h new file +44 -1
new file mode 100644
index 0000000..b5ebbc2
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#ifndef _DRM_BRIDGE_PANEL_H_
+#define _DRM_BRIDGE_PANEL_H_
+
+struct drm_device;
+struct drm_encoder;
+struct i2c_client;
+struct device_node;
+struct drm_panel;
+
+#if defined(CONFIG_DRM_PANEL_BINDER)
+struct drm_bridge *panel_binder_init(struct drm_device *dev,
+                                       struct drm_encoder *encoder,
+                                       struct i2c_client *client,
+                                       struct device_node *node,
+                                       struct drm_panel *panel,
+                                       int connector_type,
+                                       uint8_t polled);
+#else
+static inline struct drm_bridge *panel_binder_init(struct drm_device *dev,
+                                               struct drm_encoder *encoder,
+                                               struct i2c_client *client,
+                                               struct device_node *node,
+                                               struct drm_panel *panel,
+                                               int connector_type,
+                                               uint8_t polled)
+{
+       return 0;
+}
+#endif
+
+#endif
--
Quoted 2 lines

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#19 lore raw

PATCH v4 7/10 drm/bridge: ptn3460: Support bridge chaining

In reply to Ajay Kumar

Modify the driver to invoke callbacks for the next bridge in the bridge chain.
Also, remove the drm_connector implementation from ptn3460, since the same is implemented using panel_binder.

---
 drivers/gpu/drm/bridge/ptn3460.c        |  136 +++++--------------------------
 drivers/gpu/drm/exynos/exynos_dp_core.c |   16 ++--
 include/drm/bridge/ptn3460.h            |   15 ++--
 3 files changed, 39 insertions(+), 128 deletions(-)
drivers/gpu/drm/bridge/ptn3460.c +22 -114
index 98fd17a..21e9db8 100644
@@ -34,37 +34,15 @@
 #define PTN3460_EDID_SRAM_LOAD_ADDR		0x85
 
 struct ptn3460_bridge {
-	struct drm_connector connector;
 	struct i2c_client *client;
 	struct drm_encoder *encoder;
 	struct drm_bridge *bridge;
-	struct edid *edid;
 	int gpio_pd_n;
 	int gpio_rst_n;
 	u32 edid_emulation;
 	bool enabled;
 };
 
-static int ptn3460_read_bytes(struct ptn3460_bridge *ptn_bridge, char addr,
-		u8 *buf, int len)
-{
-	int ret;
-
-	ret = i2c_master_send(ptn_bridge->client, &addr, 1);
-	if (ret <= 0) {
-		DRM_ERROR("Failed to send i2c command, ret=%d\n", ret);
-		return ret;
-	}
-
-	ret = i2c_master_recv(ptn_bridge->client, buf, len);
-	if (ret <= 0) {
-		DRM_ERROR("Failed to recv i2c data, ret=%d\n", ret);
-		return ret;
-	}
-
-	return 0;
-}
-
 static int ptn3460_write_byte(struct ptn3460_bridge *ptn_bridge, char addr,
 		char val)
 {
@@ -126,6 +104,8 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
 		gpio_set_value(ptn_bridge->gpio_rst_n, 1);
 	}
 
+	drm_next_bridge_pre_enable(bridge);
+
 	/*
 	 * There's a bug in the PTN chip where it falsely asserts hotplug before
 	 * it is fully functional. We're forced to wait for the maximum start up
@@ -142,6 +122,7 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
 
 static void ptn3460_enable(struct drm_bridge *bridge)
 {
+	drm_next_bridge_enable(bridge);
 }
 
 static void ptn3460_disable(struct drm_bridge *bridge)
@@ -153,6 +134,8 @@ static void ptn3460_disable(struct drm_bridge *bridge)
 
 	ptn_bridge->enabled = false;
 
+	drm_next_bridge_disable(bridge);
+
 	if (gpio_is_valid(ptn_bridge->gpio_rst_n))
 		gpio_set_value(ptn_bridge->gpio_rst_n, 1);
 
@@ -162,6 +145,7 @@ static void ptn3460_disable(struct drm_bridge *bridge)
 
 static void ptn3460_post_disable(struct drm_bridge *bridge)
 {
+	drm_next_bridge_post_disable(bridge);
 }
 
 void ptn3460_bridge_destroy(struct drm_bridge *bridge)
@@ -173,6 +157,9 @@ void ptn3460_bridge_destroy(struct drm_bridge *bridge)
 		gpio_free(ptn_bridge->gpio_pd_n);
 	if (gpio_is_valid(ptn_bridge->gpio_rst_n))
 		gpio_free(ptn_bridge->gpio_rst_n);
+
+	drm_next_bridge_destroy(bridge);
+
 	/* Nothing else to free, we've got devm allocated memory */
 }
 
@@ -184,81 +171,10 @@ struct drm_bridge_funcs ptn3460_bridge_funcs = {
 	.destroy = ptn3460_bridge_destroy,
 };
 
-int ptn3460_get_modes(struct drm_connector *connector)
-{
-	struct ptn3460_bridge *ptn_bridge;
-	u8 *edid;
-	int ret, num_modes;
-	bool power_off;
-
-	ptn_bridge = container_of(connector, struct ptn3460_bridge, connector);
-
-	if (ptn_bridge->edid)
-		return drm_add_edid_modes(connector, ptn_bridge->edid);
-
-	power_off = !ptn_bridge->enabled;
-	ptn3460_pre_enable(ptn_bridge->bridge);
-
-	edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-	if (!edid) {
-		DRM_ERROR("Failed to allocate edid\n");
-		return 0;
-	}
-
-	ret = ptn3460_read_bytes(ptn_bridge, PTN3460_EDID_ADDR, edid,
-			EDID_LENGTH);
-	if (ret) {
-		kfree(edid);
-		num_modes = 0;
-		goto out;
-	}
-
-	ptn_bridge->edid = (struct edid *)edid;
-	drm_mode_connector_update_edid_property(connector, ptn_bridge->edid);
-
-	num_modes = drm_add_edid_modes(connector, ptn_bridge->edid);
-
-out:
-	if (power_off)
-		ptn3460_disable(ptn_bridge->bridge);
-
-	return num_modes;
-}
-
-struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector)
-{
-	struct ptn3460_bridge *ptn_bridge;
-
-	ptn_bridge = container_of(connector, struct ptn3460_bridge, connector);
-
-	return ptn_bridge->encoder;
-}
-
-struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = {
-	.get_modes = ptn3460_get_modes,
-	.best_encoder = ptn3460_best_encoder,
-};
-
-enum drm_connector_status ptn3460_detect(struct drm_connector *connector,
-		bool force)
-{
-	return connector_status_connected;
-}
-
-void ptn3460_connector_destroy(struct drm_connector *connector)
-{
-	drm_connector_cleanup(connector);
-}
-
-struct drm_connector_funcs ptn3460_connector_funcs = {
-	.dpms = drm_helper_connector_dpms,
-	.fill_modes = drm_helper_probe_single_connector_modes,
-	.detect = ptn3460_detect,
-	.destroy = ptn3460_connector_destroy,
-};
-
-int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
-		struct i2c_client *client, struct device_node *node)
+struct drm_bridge *ptn3460_init(struct drm_device *dev,
+				struct drm_encoder *encoder,
+				struct i2c_client *client,
+				struct device_node *node)
 {
 	int ret;
 	struct drm_bridge *bridge;
@@ -267,13 +183,13 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
 	bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL);
 	if (!bridge) {
 		DRM_ERROR("Failed to allocate drm bridge\n");
-		return -ENOMEM;
+		return NULL;
 	}
 
 	ptn_bridge = devm_kzalloc(dev->dev, sizeof(*ptn_bridge), GFP_KERNEL);
 	if (!ptn_bridge) {
 		DRM_ERROR("Failed to allocate ptn bridge\n");
-		return -ENOMEM;
+		return NULL;
 	}
 
 	ptn_bridge->client = client;
@@ -285,7 +201,7 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
 				GPIOF_OUT_INIT_HIGH, "PTN3460_PD_N");
 		if (ret) {
 			DRM_ERROR("Request powerdown-gpio failed (%d)\n", ret);
-			return ret;
+			return NULL;
 		}
 	}
 
@@ -300,7 +216,7 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
 		if (ret) {
 			DRM_ERROR("Request reset-gpio failed (%d)\n", ret);
 			gpio_free(ptn_bridge->gpio_pd_n);
-			return ret;
+			return NULL;
 		}
 	}
 
@@ -318,26 +234,18 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
 	}
 
 	bridge->driver_private = ptn_bridge;
-	encoder->bridge = bridge;
 
-	ret = drm_connector_init(dev, &ptn_bridge->connector,
-			&ptn3460_connector_funcs, DRM_MODE_CONNECTOR_LVDS);
-	if (ret) {
-		DRM_ERROR("Failed to initialize connector with drm\n");
-		goto err;
-	}
-	drm_connector_helper_add(&ptn_bridge->connector,
-			&ptn3460_connector_helper_funcs);
-	drm_sysfs_connector_add(&ptn_bridge->connector);
-	drm_mode_connector_attach_encoder(&ptn_bridge->connector, encoder);
+	if (!encoder->bridge)
+		/* First entry in the bridge chain */
+		encoder->bridge = bridge;
 
-	return 0;
+	return bridge;
 
 err:
 	if (gpio_is_valid(ptn_bridge->gpio_pd_n))
 		gpio_free(ptn_bridge->gpio_pd_n);
 	if (gpio_is_valid(ptn_bridge->gpio_rst_n))
 		gpio_free(ptn_bridge->gpio_rst_n);
-	return ret;
+	return NULL;
 }
 EXPORT_SYMBOL(ptn3460_init);
drivers/gpu/drm/exynos/exynos_dp_core.c +8 -8
index aca739d..d8546ea 100644
@@ -988,19 +988,19 @@ static bool find_bridge(const char *compat, struct bridge_init *bridge)
 	return true;
 }
 
-/* returns the number of bridges attached */
-static int exynos_drm_attach_lcd_bridge(struct drm_device *dev,
+static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
 		struct drm_encoder *encoder)
 {
 	struct bridge_init bridge;
-	int ret;
+	struct drm_bridge *bridge_chain = NULL;
+	bool connector_created = false;
 
 	if (find_bridge("nxp,ptn3460", &bridge)) {
-		ret = ptn3460_init(dev, encoder, bridge.client, bridge.node);
-		if (!ret)
-			return 1;
+		bridge_chain = ptn3460_init(dp->drm_dev, encoder, bridge.client,
+								bridge.node);
 	}
-	return 0;
+
+	return connector_created;
 }
 
 static int exynos_dp_create_connector(struct exynos_drm_display *display,
@@ -1013,7 +1013,7 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
 	dp->encoder = encoder;
 
 	/* Pre-empt DP connector creation if there's a bridge */
-	ret = exynos_drm_attach_lcd_bridge(dp->drm_dev, encoder);
+	ret = exynos_drm_attach_lcd_bridge(dp, encoder);
 	if (ret)
 		return 0;
 
include/drm/bridge/ptn3460.h +9 -6
index ff62344..f612b9b 100644
@@ -21,15 +21,18 @@ struct device_node;
 
 #if defined(CONFIG_DRM_PTN3460) || defined(CONFIG_DRM_PTN3460_MODULE)
 
-int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
-		struct i2c_client *client, struct device_node *node);
+struct drm_bridge *ptn3460_init(struct drm_device *dev,
+				struct drm_encoder *encoder,
+				struct i2c_client *client,
+				struct device_node *node);
 #else
 
-static inline int ptn3460_init(struct drm_device *dev,
-		struct drm_encoder *encoder, struct i2c_client *client,
-		struct device_node *node)
+static inline struct drm_bridge *ptn3460_init(struct drm_device *dev,
+						struct drm_encoder *encoder,
+						struct i2c_client *client,
+						struct device_node *node)
 {
-	return 0;
+	return NULL;
 }
 
 #endif
Signature · 1 line
1.7.9.5
#20 lore raw

Re: [PATCH V4 07/10] drm/bridge: ptn3460: Support bridge chaining

ping.

Quoted 322 lines · Ajay Kumar

Modify the driver to invoke callbacks for the next bridge in the bridge chain.
Also, remove the drm_connector implementation from ptn3460, since the same is implemented using panel_binder.

---
 drivers/gpu/drm/bridge/ptn3460.c        |  136 +++++--------------------------
 drivers/gpu/drm/exynos/exynos_dp_core.c |   16 ++--
 include/drm/bridge/ptn3460.h            |   15 ++--
 3 files changed, 39 insertions(+), 128 deletions(-)
drivers/gpu/drm/bridge/ptn3460.c +22 -114
index 98fd17a..21e9db8 100644
@@ -34,37 +34,15 @@
 #define PTN3460_EDID_SRAM_LOAD_ADDR            0x85
 
 struct ptn3460_bridge {
-       struct drm_connector connector;
        struct i2c_client *client;
        struct drm_encoder *encoder;
        struct drm_bridge *bridge;
-       struct edid *edid;
        int gpio_pd_n;
        int gpio_rst_n;
        u32 edid_emulation;
        bool enabled;
 };
 
-static int ptn3460_read_bytes(struct ptn3460_bridge *ptn_bridge, char addr,
-               u8 *buf, int len)
-{
-       int ret;
-
-       ret = i2c_master_send(ptn_bridge->client, &addr, 1);
-       if (ret <= 0) {
-               DRM_ERROR("Failed to send i2c command, ret=%d\n", ret);
-               return ret;
-       }
-
-       ret = i2c_master_recv(ptn_bridge->client, buf, len);
-       if (ret <= 0) {
-               DRM_ERROR("Failed to recv i2c data, ret=%d\n", ret);
-               return ret;
-       }
-
-       return 0;
-}
-
 static int ptn3460_write_byte(struct ptn3460_bridge *ptn_bridge, char addr,
                char val)
 {
@@ -126,6 +104,8 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
                gpio_set_value(ptn_bridge->gpio_rst_n, 1);
        }
 
+       drm_next_bridge_pre_enable(bridge);
+
        /*
         * There's a bug in the PTN chip where it falsely asserts hotplug before
         * it is fully functional. We're forced to wait for the maximum start up
@@ -142,6 +122,7 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
 
 static void ptn3460_enable(struct drm_bridge *bridge)
 {
+       drm_next_bridge_enable(bridge);
 }
 
 static void ptn3460_disable(struct drm_bridge *bridge)
@@ -153,6 +134,8 @@ static void ptn3460_disable(struct drm_bridge *bridge)
 
        ptn_bridge->enabled = false;
 
+       drm_next_bridge_disable(bridge);
+
        if (gpio_is_valid(ptn_bridge->gpio_rst_n))
                gpio_set_value(ptn_bridge->gpio_rst_n, 1);
 
@@ -162,6 +145,7 @@ static void ptn3460_disable(struct drm_bridge *bridge)
 
 static void ptn3460_post_disable(struct drm_bridge *bridge)
 {
+       drm_next_bridge_post_disable(bridge);
 }
 
 void ptn3460_bridge_destroy(struct drm_bridge *bridge)
@@ -173,6 +157,9 @@ void ptn3460_bridge_destroy(struct drm_bridge *bridge)
                gpio_free(ptn_bridge->gpio_pd_n);
        if (gpio_is_valid(ptn_bridge->gpio_rst_n))
                gpio_free(ptn_bridge->gpio_rst_n);
+
+       drm_next_bridge_destroy(bridge);
+
        /* Nothing else to free, we've got devm allocated memory */
 }
 
@@ -184,81 +171,10 @@ struct drm_bridge_funcs ptn3460_bridge_funcs = {
        .destroy = ptn3460_bridge_destroy,
 };
 
-int ptn3460_get_modes(struct drm_connector *connector)
-{
-       struct ptn3460_bridge *ptn_bridge;
-       u8 *edid;
-       int ret, num_modes;
-       bool power_off;
-
-       ptn_bridge = container_of(connector, struct ptn3460_bridge, connector);
-
-       if (ptn_bridge->edid)
-               return drm_add_edid_modes(connector, ptn_bridge->edid);
-
-       power_off = !ptn_bridge->enabled;
-       ptn3460_pre_enable(ptn_bridge->bridge);
-
-       edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-       if (!edid) {
-               DRM_ERROR("Failed to allocate edid\n");
-               return 0;
-       }
-
-       ret = ptn3460_read_bytes(ptn_bridge, PTN3460_EDID_ADDR, edid,
-                       EDID_LENGTH);
-       if (ret) {
-               kfree(edid);
-               num_modes = 0;
-               goto out;
-       }
-
-       ptn_bridge->edid = (struct edid *)edid;
-       drm_mode_connector_update_edid_property(connector, ptn_bridge->edid);
-
-       num_modes = drm_add_edid_modes(connector, ptn_bridge->edid);
-
-out:
-       if (power_off)
-               ptn3460_disable(ptn_bridge->bridge);
-
-       return num_modes;
-}
-
-struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector)
-{
-       struct ptn3460_bridge *ptn_bridge;
-
-       ptn_bridge = container_of(connector, struct ptn3460_bridge, connector);
-
-       return ptn_bridge->encoder;
-}
-
-struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = {
-       .get_modes = ptn3460_get_modes,
-       .best_encoder = ptn3460_best_encoder,
-};
-
-enum drm_connector_status ptn3460_detect(struct drm_connector *connector,
-               bool force)
-{
-       return connector_status_connected;
-}
-
-void ptn3460_connector_destroy(struct drm_connector *connector)
-{
-       drm_connector_cleanup(connector);
-}
-
-struct drm_connector_funcs ptn3460_connector_funcs = {
-       .dpms = drm_helper_connector_dpms,
-       .fill_modes = drm_helper_probe_single_connector_modes,
-       .detect = ptn3460_detect,
-       .destroy = ptn3460_connector_destroy,
-};
-
-int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
-               struct i2c_client *client, struct device_node *node)
+struct drm_bridge *ptn3460_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node)
 {
        int ret;
        struct drm_bridge *bridge;
@@ -267,13 +183,13 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
        bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL);
        if (!bridge) {
                DRM_ERROR("Failed to allocate drm bridge\n");
-               return -ENOMEM;
+               return NULL;
        }
 
        ptn_bridge = devm_kzalloc(dev->dev, sizeof(*ptn_bridge), GFP_KERNEL);
        if (!ptn_bridge) {
                DRM_ERROR("Failed to allocate ptn bridge\n");
-               return -ENOMEM;
+               return NULL;
        }
 
        ptn_bridge->client = client;
@@ -285,7 +201,7 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
                                GPIOF_OUT_INIT_HIGH, "PTN3460_PD_N");
                if (ret) {
                        DRM_ERROR("Request powerdown-gpio failed (%d)\n", ret);
-                       return ret;
+                       return NULL;
                }
        }
 
@@ -300,7 +216,7 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
                if (ret) {
                        DRM_ERROR("Request reset-gpio failed (%d)\n", ret);
                        gpio_free(ptn_bridge->gpio_pd_n);
-                       return ret;
+                       return NULL;
                }
        }
 
@@ -318,26 +234,18 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
        }
 
        bridge->driver_private = ptn_bridge;
-       encoder->bridge = bridge;
 
-       ret = drm_connector_init(dev, &ptn_bridge->connector,
-                       &ptn3460_connector_funcs, DRM_MODE_CONNECTOR_LVDS);
-       if (ret) {
-               DRM_ERROR("Failed to initialize connector with drm\n");
-               goto err;
-       }
-       drm_connector_helper_add(&ptn_bridge->connector,
-                       &ptn3460_connector_helper_funcs);
-       drm_sysfs_connector_add(&ptn_bridge->connector);
-       drm_mode_connector_attach_encoder(&ptn_bridge->connector, encoder);
+       if (!encoder->bridge)
+               /* First entry in the bridge chain */
+               encoder->bridge = bridge;
 
-       return 0;
+       return bridge;
 
 err:
        if (gpio_is_valid(ptn_bridge->gpio_pd_n))
                gpio_free(ptn_bridge->gpio_pd_n);
        if (gpio_is_valid(ptn_bridge->gpio_rst_n))
                gpio_free(ptn_bridge->gpio_rst_n);
-       return ret;
+       return NULL;
 }
 EXPORT_SYMBOL(ptn3460_init);
drivers/gpu/drm/exynos/exynos_dp_core.c +8 -8
index aca739d..d8546ea 100644
@@ -988,19 +988,19 @@ static bool find_bridge(const char *compat, struct bridge_init *bridge)
        return true;
 }
 
-/* returns the number of bridges attached */
-static int exynos_drm_attach_lcd_bridge(struct drm_device *dev,
+static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
                struct drm_encoder *encoder)
 {
        struct bridge_init bridge;
-       int ret;
+       struct drm_bridge *bridge_chain = NULL;
+       bool connector_created = false;
 
        if (find_bridge("nxp,ptn3460", &bridge)) {
-               ret = ptn3460_init(dev, encoder, bridge.client, bridge.node);
-               if (!ret)
-                       return 1;
+               bridge_chain = ptn3460_init(dp->drm_dev, encoder, bridge.client,
+                                                               bridge.node);
        }
-       return 0;
+
+       return connector_created;
 }
 
 static int exynos_dp_create_connector(struct exynos_drm_display *display,
@@ -1013,7 +1013,7 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
        dp->encoder = encoder;
 
        /* Pre-empt DP connector creation if there's a bridge */
-       ret = exynos_drm_attach_lcd_bridge(dp->drm_dev, encoder);
+       ret = exynos_drm_attach_lcd_bridge(dp, encoder);
        if (ret)
                return 0;
 
include/drm/bridge/ptn3460.h +9 -7
index ff62344..f612b9b 100644
@@ -21,15 +21,18 @@ struct device_node;
 
 #if defined(CONFIG_DRM_PTN3460) || defined(CONFIG_DRM_PTN3460_MODULE)
 
-int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
-               struct i2c_client *client, struct device_node *node);
+struct drm_bridge *ptn3460_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node);
 #else
 
-static inline int ptn3460_init(struct drm_device *dev,
-               struct drm_encoder *encoder, struct i2c_client *client,
-               struct device_node *node)
+static inline struct drm_bridge *ptn3460_init(struct drm_device *dev,
+                                               struct drm_encoder *encoder,
+                                               struct i2c_client *client,
+                                               struct device_node *node)
 {
-       return 0;
+       return NULL;
 }
 
 #endif
--

1.7.9.5

author
#21 lore raw

PATCH v4 8/10 drm/exynos: dp: create bridge chain using ptn3460 and panel_binder

In reply to Ajay Kumar

exynos_dp supports a simple bridge chain with ptn3460 bridge and an LVDS panel attached to it.
This patch creates the bridge chain with ptn3460 as the head of the list and panel_binder being the tail.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +11 -1
index d8546ea..69535f7 100644
@@ -30,6 +30,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_panel.h>
 #include <drm/bridge/ptn3460.h>
+#include <drm/bridge/panel_binder.h>
 
 #include "exynos_drm_drv.h"
 #include "exynos_dp_core.h"
@@ -992,7 +993,7 @@ static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
 		struct drm_encoder *encoder)
 {
 	struct bridge_init bridge;
-	struct drm_bridge *bridge_chain = NULL;
+	struct drm_bridge *bridge_chain = NULL, *next = NULL;
 	bool connector_created = false;
 
 	if (find_bridge("nxp,ptn3460", &bridge)) {
@@ -1000,6 +1001,15 @@ static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
 								bridge.node);
 	}
 
+	if (bridge_chain && dp->edp_panel) {
+		next = panel_binder_init(dp->drm_dev, encoder, bridge.client,
+			bridge.node, dp->edp_panel, DRM_MODE_CONNECTOR_LVDS,
+			DRM_CONNECTOR_POLL_HPD);
+		if (next)
+			connector_created = true;
+		drm_bridge_add_to_chain(bridge_chain, next);
+	}
+
 	return connector_created;
 }
 
Signature · 1 line
1.7.9.5
#22 lore raw

Re: [PATCH V4 08/10] drm/exynos: dp: create bridge chain using ptn3460 and panel_binder

ping.

Quoted 50 lines · Ajay Kumar

exynos_dp supports a simple bridge chain with ptn3460 bridge and an LVDS panel attached to it.
This patch creates the bridge chain with ptn3460 as the head of the list and panel_binder being the tail.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +11 -2
index d8546ea..69535f7 100644
@@ -30,6 +30,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_panel.h>
 #include <drm/bridge/ptn3460.h>
+#include <drm/bridge/panel_binder.h>
 
 #include "exynos_drm_drv.h"
 #include "exynos_dp_core.h"
@@ -992,7 +993,7 @@ static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
                struct drm_encoder *encoder)
 {
        struct bridge_init bridge;
-       struct drm_bridge *bridge_chain = NULL;
+       struct drm_bridge *bridge_chain = NULL, *next = NULL;
        bool connector_created = false;
 
        if (find_bridge("nxp,ptn3460", &bridge)) {
@@ -1000,6 +1001,15 @@ static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
                                                                bridge.node);
        }
 
+       if (bridge_chain && dp->edp_panel) {
+               next = panel_binder_init(dp->drm_dev, encoder, bridge.client,
+                       bridge.node, dp->edp_panel, DRM_MODE_CONNECTOR_LVDS,
+                       DRM_CONNECTOR_POLL_HPD);
+               if (next)
+                       connector_created = true;
+               drm_bridge_add_to_chain(bridge_chain, next);
+       }
+
        return connector_created;
 }
 
--

1.7.9.5

author
#23 lore raw

PATCH v4 9/10 drm/bridge: Add ps8622/ps8625 bridge driver

In reply to Ajay Kumar

From: Vincent Palatin <[email protected]>

This patch adds drm_bridge driver for parade DisplayPort to LVDS bridge chip.

---
 .../devicetree/bindings/drm/bridge/ps8622.txt      |   21 +
 drivers/gpu/drm/bridge/Kconfig                     |    8 +
 drivers/gpu/drm/bridge/Makefile                    |    1 +
 drivers/gpu/drm/bridge/ps8622.c                    |  475 ++++++++++++++++++++
 include/drm/bridge/ps8622.h                        |   41 ++
 5 files changed, 546 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/ps8622.txt
 create mode 100644 drivers/gpu/drm/bridge/ps8622.c
 create mode 100644 include/drm/bridge/ps8622.h
Documentation/devicetree/bindings/drm/bridge/ps8622.txt new file +21 -0
new file mode 100644
index 0000000..1afbd9c
@@ -0,0 +1,21 @@
+ps8622-bridge bindings
+
+Required properties:
+	- compatible: "parade,ps8622"
+	- reg: first i2c address of the bridge
+	- sleep-gpio: OF device-tree gpio specification
+	- reset-gpio: OF device-tree gpio specification
+
+Optional properties:
+	- lane-count: number of DP lanes to use
+	- use-external-pwm: backlight will be controlled by an external PWM
+
+Example:
+	ps8622-bridge@48 {
+		compatible = "parade,ps8622";
+		reg = <0x48>;
+		sleep-gpio = <&gpc3 6 1 0 0>;
+		reset-gpio = <&gpc3 1 1 0 0>;
+		display-timings = <&lcd_display_timings>;
+		lane-count = <1>
+	};
drivers/gpu/drm/bridge/Kconfig +8 -0
index e3fb487..7b843c8 100644
@@ -10,3 +10,11 @@ config DRM_PANEL_BINDER
 	select DRM_KMS_HELPER
 	select DRM_PANEL
 	---help---
+
+config DRM_PS8622
+	tristate "Parade eDP/LVDS bridge"
+	depends on DRM
+	select DRM_KMS_HELPER
+	select BACKLIGHT_LCD_SUPPORT
+	select BACKLIGHT_CLASS_DEVICE
+	---help---
drivers/gpu/drm/bridge/Makefile +1 -0
index ba8b5b8..b494d4b 100644
@@ -2,3 +2,4 @@ ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
 obj-$(CONFIG_DRM_PANEL_BINDER) += panel_binder.o
+obj-$(CONFIG_DRM_PS8622) += ps8622.o
drivers/gpu/drm/bridge/ps8622.c new file +475 -0

475 lines not on this page · raw message

include/drm/bridge/ps8622.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#24 lore raw

Re: [PATCH V4 09/10] drm/bridge: Add ps8622/ps8625 bridge driver

ping.

Quoted 604 lines · Ajay Kumar

From: Vincent Palatin <[email protected]>

This patch adds drm_bridge driver for parade DisplayPort to LVDS bridge chip.

---
 .../devicetree/bindings/drm/bridge/ps8622.txt      |   21 +
 drivers/gpu/drm/bridge/Kconfig                     |    8 +
 drivers/gpu/drm/bridge/Makefile                    |    1 +
 drivers/gpu/drm/bridge/ps8622.c                    |  475 ++++++++++++++++++++
 include/drm/bridge/ps8622.h                        |   41 ++
 5 files changed, 546 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/ps8622.txt
 create mode 100644 drivers/gpu/drm/bridge/ps8622.c
 create mode 100644 include/drm/bridge/ps8622.h
Documentation/devicetree/bindings/drm/bridge/ps8622.txt new file +21 -0
new file mode 100644
index 0000000..1afbd9c
@@ -0,0 +1,21 @@
+ps8622-bridge bindings
+
+Required properties:
+       - compatible: "parade,ps8622"
+       - reg: first i2c address of the bridge
+       - sleep-gpio: OF device-tree gpio specification
+       - reset-gpio: OF device-tree gpio specification
+
+Optional properties:
+       - lane-count: number of DP lanes to use
+       - use-external-pwm: backlight will be controlled by an external PWM
+
+Example:
+       ps8622-bridge@48 {
+               compatible = "parade,ps8622";
+               reg = <0x48>;
+               sleep-gpio = <&gpc3 6 1 0 0>;
+               reset-gpio = <&gpc3 1 1 0 0>;
+               display-timings = <&lcd_display_timings>;
+               lane-count = <1>
+       };
drivers/gpu/drm/bridge/Kconfig +8 -0
index e3fb487..7b843c8 100644
@@ -10,3 +10,11 @@ config DRM_PANEL_BINDER
        select DRM_KMS_HELPER
        select DRM_PANEL
        ---help---
+
+config DRM_PS8622
+       tristate "Parade eDP/LVDS bridge"
+       depends on DRM
+       select DRM_KMS_HELPER
+       select BACKLIGHT_LCD_SUPPORT
+       select BACKLIGHT_CLASS_DEVICE
+       ---help---
drivers/gpu/drm/bridge/Makefile +1 -0
index ba8b5b8..b494d4b 100644
@@ -2,3 +2,4 @@ ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
 obj-$(CONFIG_DRM_PANEL_BINDER) += panel_binder.o
+obj-$(CONFIG_DRM_PS8622) += ps8622.o
drivers/gpu/drm/bridge/ps8622.c new file +475 -0
new file mode 100644
index 0000000..387d332
@@ -0,0 +1,475 @@
+/*
+ * Parade PS8622 eDP/LVDS bridge driver
+ *
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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 <linux/module.h>
+#include <linux/backlight.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/fb.h>
+#include <linux/gpio.h>
+#include <linux/i2c.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/pm.h>
+#include <linux/regulator/consumer.h>
+
+#include "drmP.h"
+#include "drm_crtc.h"
+#include "drm_crtc_helper.h"
+
+struct ps8622_bridge {
+       struct drm_bridge *bridge;
+       struct drm_encoder *encoder;
+       struct i2c_client *client;
+       struct regulator *v12;
+       struct backlight_device *bl;
+       struct mutex enable_mutex;
+
+       int gpio_slp_n;
+       int gpio_rst_n;
+
+       u8 max_lane_count;
+       u8 lane_count;
+
+       bool enabled;
+};
+
+struct ps8622_device_data {
+       u8 max_lane_count;
+};
+
+static const struct ps8622_device_data ps8622_data = {
+       .max_lane_count = 1,
+};
+
+static const struct ps8622_device_data ps8625_data = {
+       .max_lane_count = 2,
+};
+
+/* Brightness scale on the Parade chip */
+#define PS8622_MAX_BRIGHTNESS 0xff
+
+/* Timings taken from the version 1.7 datasheet for the PS8622/PS8625 */
+#define PS8622_POWER_RISE_T1_MIN_US 10
+#define PS8622_POWER_RISE_T1_MAX_US 10000
+#define PS8622_RST_HIGH_T2_MIN_US 3000
+#define PS8622_RST_HIGH_T2_MAX_US 30000
+#define PS8622_PWMO_END_T12_MS 200
+#define PS8622_POWER_FALL_T16_MAX_US 10000
+#define PS8622_POWER_OFF_T17_MS 500
+
+#if ((PS8622_RST_HIGH_T2_MIN_US + PS8622_POWER_RISE_T1_MAX_US) > \
+       (PS8622_RST_HIGH_T2_MAX_US + PS8622_POWER_RISE_T1_MIN_US))
+#error "T2.min + T1.max must be less than T2.max + T1.min"
+#endif
+
+static int ps8622_set(struct i2c_client *client, u8 page, u8 reg, u8 val)
+{
+       int ret;
+       struct i2c_adapter *adap = client->adapter;
+       struct i2c_msg msg;
+       u8 data[] = {reg, val};
+
+       msg.addr = client->addr + page;
+       msg.flags = 0;
+       msg.len = sizeof(data);
+       msg.buf = data;
+
+       ret = i2c_transfer(adap, &msg, 1);
+       if (ret != 1)
+               pr_warn("PS8622 I2C write (0x%02x,0x%02x,0x%02x) failed: %d\n",
+                       client->addr + page, reg, val, ret);
+       return !(ret == 1);
+}
+
+static int ps8622_send_config(struct ps8622_bridge *ps_bridge)
+{
+       struct i2c_client *cl = ps_bridge->client;
+       int err = 0;
+
+       /* wait 20ms after power ON */
+       usleep_range(20000, 30000);
+
+       err |= ps8622_set(cl, 0x02, 0xa1, 0x01); /* HPD low */
+       /* SW setting */
+       err |= ps8622_set(cl, 0x04, 0x14, 0x01); /* [1:0] SW output 1.2V voltage
+                                                 * is lower to 96% */
+       /* RCO SS setting */
+       err |= ps8622_set(cl, 0x04, 0xe3, 0x20); /* [5:4] = b01 0.5%, b10 1%,
+                                                 * b11 1.5% */
+       err |= ps8622_set(cl, 0x04, 0xe2, 0x80); /* [7] RCO SS enable */
+       /* RPHY Setting */
+       err |= ps8622_set(cl, 0x04, 0x8a, 0x0c); /* [3:2] CDR tune wait cycle
+                                                 * before measure for fine tune
+                                                 * b00: 1us b01: 0.5us b10:2us
+                                                 * b11: 4us */
+       err |= ps8622_set(cl, 0x04, 0x89, 0x08); /* [3] RFD always on */
+       err |= ps8622_set(cl, 0x04, 0x71, 0x2d); /* CTN lock in/out:
+                                                 * 20000ppm/80000ppm.
+                                                 * Lock out 2 times. */
+       /* 2.7G CDR settings */
+       err |= ps8622_set(cl, 0x04, 0x7d, 0x07); /* NOF=40LSB for HBR CDR
+                                                 * setting */
+       err |= ps8622_set(cl, 0x04, 0x7b, 0x00); /* [1:0] Fmin=+4bands */
+       err |= ps8622_set(cl, 0x04, 0x7a, 0xfd); /* [7:5] DCO_FTRNG=+-40% */
+       /* 1.62G CDR settings */
+       err |= ps8622_set(cl, 0x04, 0xc0, 0x12); /* [5:2]NOF=64LSB [1:0]DCO
+                                                 * scale is 2/5 */
+       err |= ps8622_set(cl, 0x04, 0xc1, 0x92); /* Gitune=-37% */
+       err |= ps8622_set(cl, 0x04, 0xc2, 0x1c); /* Fbstep=100% */
+       err |= ps8622_set(cl, 0x04, 0x32, 0x80); /* [7] LOS signal disable */
+       /* RPIO Setting */
+       err |= ps8622_set(cl, 0x04, 0x00, 0xb0); /* [7:4] LVDS driver bias
+                                                 * current : 75% (250mV swing)
+                                                 * */
+       err |= ps8622_set(cl, 0x04, 0x15, 0x40); /* [7:6] Right-bar GPIO output
+                                                 * strength is 8mA */
+       /* EQ Training State Machine Setting */
+       err |= ps8622_set(cl, 0x04, 0x54, 0x10); /* RCO calibration start */
+       /* Logic, needs more than 10 I2C command */
+       err |= ps8622_set(cl, 0x01, 0x02, 0x80 | ps_bridge->max_lane_count);
+                                                /* [4:0] MAX_LANE_COUNT set to
+                                                 * max supported lanes */
+       err |= ps8622_set(cl, 0x01, 0x21, 0x80 | ps_bridge->lane_count);
+                                                /* [4:0] LANE_COUNT_SET set to
+                                                 * chosen lane count */
+       err |= ps8622_set(cl, 0x00, 0x52, 0x20);
+       err |= ps8622_set(cl, 0x00, 0xf1, 0x03); /* HPD CP toggle enable */
+       err |= ps8622_set(cl, 0x00, 0x62, 0x41);
+       err |= ps8622_set(cl, 0x00, 0xf6, 0x01); /* Counter number, add 1ms
+                                                 * counter delay */
+       err |= ps8622_set(cl, 0x00, 0x77, 0x06); /* [6]PWM function control by
+                                                 * DPCD0040f[7], default is PWM
+                                                 * block always works. */
+       err |= ps8622_set(cl, 0x00, 0x4c, 0x04); /* 04h Adjust VTotal tolerance
+                                                 * to fix the 30Hz no display
+                                                 * issue */
+       err |= ps8622_set(cl, 0x01, 0xc0, 0x00); /* DPCD00400='h00, Parade OUI =
+                                                 * 'h001cf8 */
+       err |= ps8622_set(cl, 0x01, 0xc1, 0x1c); /* DPCD00401='h1c */
+       err |= ps8622_set(cl, 0x01, 0xc2, 0xf8); /* DPCD00402='hf8 */
+       err |= ps8622_set(cl, 0x01, 0xc3, 0x44); /* DPCD403~408 = ASCII code
+                                                 * D2SLV5='h4432534c5635 */
+       err |= ps8622_set(cl, 0x01, 0xc4, 0x32); /* DPCD404 */
+       err |= ps8622_set(cl, 0x01, 0xc5, 0x53); /* DPCD405 */
+       err |= ps8622_set(cl, 0x01, 0xc6, 0x4c); /* DPCD406 */
+       err |= ps8622_set(cl, 0x01, 0xc7, 0x56); /* DPCD407 */
+       err |= ps8622_set(cl, 0x01, 0xc8, 0x35); /* DPCD408 */
+       err |= ps8622_set(cl, 0x01, 0xca, 0x01); /* DPCD40A, Initial Code major
+                                                 * revision '01' */
+       err |= ps8622_set(cl, 0x01, 0xcb, 0x05); /* DPCD40B, Initial Code minor
+                                                 * revision '05' */
+       if (ps_bridge->bl) {
+               err |= ps8622_set(cl, 0x01, 0xa5, 0xa0);
+                                               /* DPCD720, internal PWM */
+               err |= ps8622_set(cl, 0x01, 0xa7,
+                               ps_bridge->bl->props.brightness);
+                                                /* FFh for 100% brightness,
+                                                 *  0h for 0% brightness */
+       } else {
+               err |= ps8622_set(cl, 0x01, 0xa5, 0x80);
+                                               /* DPCD720, external PWM */
+       }
+       err |= ps8622_set(cl, 0x01, 0xcc, 0x13); /* Set LVDS output as 6bit-VESA
+                                                 * mapping, single LVDS channel
+                                                 * */
+       err |= ps8622_set(cl, 0x02, 0xb1, 0x20); /* Enable SSC set by register
+                                                 * */
+       err |= ps8622_set(cl, 0x04, 0x10, 0x16); /* Set SSC enabled and +/-1%
+                                                 * central spreading */
+       /* Logic end */
+       err |= ps8622_set(cl, 0x04, 0x59, 0x60); /* MPU Clock source: LC => RCO
+                                                 * */
+       err |= ps8622_set(cl, 0x04, 0x54, 0x14); /* LC -> RCO */
+       err |= ps8622_set(cl, 0x02, 0xa1, 0x91); /* HPD high */
+
+       return err ? -EIO : 0;
+}
+
+static int ps8622_backlight_update(struct backlight_device *bl)
+{
+       struct ps8622_bridge *ps_bridge = dev_get_drvdata(&bl->dev);
+       int ret, brightness = bl->props.brightness;
+
+       if (bl->props.power != FB_BLANK_UNBLANK ||
+           bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+               brightness = 0;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+
+       if (!ps_bridge->enabled) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       ret = ps8622_set(ps_bridge->client, 0x01, 0xa7, brightness);
+
+out:
+       mutex_unlock(&ps_bridge->enable_mutex);
+       return ret;
+}
+
+static int ps8622_backlight_get(struct backlight_device *bl)
+{
+       return bl->props.brightness;
+}
+
+static const struct backlight_ops ps8622_backlight_ops = {
+       .update_status  = ps8622_backlight_update,
+       .get_brightness = ps8622_backlight_get,
+};
+
+static void ps8622_pre_enable(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+       int ret;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+       if (ps_bridge->enabled)
+               goto out;
+
+       if (gpio_is_valid(ps_bridge->gpio_rst_n))
+               gpio_set_value(ps_bridge->gpio_rst_n, 0);
+
+       if (ps_bridge->v12) {
+               ret = regulator_enable(ps_bridge->v12);
+               if (ret)
+                       DRM_ERROR("fails to enable ps_bridge->v12");
+       }
+
+       drm_next_bridge_pre_enable(bridge);
+
+       if (gpio_is_valid(ps_bridge->gpio_slp_n))
+               gpio_set_value(ps_bridge->gpio_slp_n, 1);
+
+       /*
+        * T1 is the range of time that it takes for the power to rise after we
+        * enable the lcd fet. T2 is the range of time in which the data sheet
+        * specifies we should deassert the reset pin.
+        *
+        * If it takes T1.max for the power to rise, we need to wait atleast
+        * T2.min before deasserting the reset pin. If it takes T1.min for the
+        * power to rise, we need to wait at most T2.max before deasserting the
+        * reset pin.
+        */
+       usleep_range(PS8622_RST_HIGH_T2_MIN_US + PS8622_POWER_RISE_T1_MAX_US,
+                    PS8622_RST_HIGH_T2_MAX_US + PS8622_POWER_RISE_T1_MIN_US);
+
+       if (gpio_is_valid(ps_bridge->gpio_rst_n))
+               gpio_set_value(ps_bridge->gpio_rst_n, 1);
+
+       ret = ps8622_send_config(ps_bridge);
+       if (ret)
+               DRM_ERROR("Failed to send config to bridge (%d)\n", ret);
+
+       ps_bridge->enabled = true;
+
+out:
+       mutex_unlock(&ps_bridge->enable_mutex);
+}
+
+static void ps8622_enable(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+       drm_next_bridge_enable(bridge);
+       mutex_unlock(&ps_bridge->enable_mutex);
+}
+
+static void ps8622_disable(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+
+       if (!ps_bridge->enabled)
+               goto out;
+
+       ps_bridge->enabled = false;
+
+       drm_next_bridge_disable(bridge);
+       msleep(PS8622_PWMO_END_T12_MS);
+
+       /*
+        * This doesn't matter if the regulators are turned off, but something
+        * else might keep them on. In that case, we want to assert the slp gpio
+        * to lower power.
+        */
+       if (gpio_is_valid(ps_bridge->gpio_slp_n))
+               gpio_set_value(ps_bridge->gpio_slp_n, 0);
+
+       if (ps_bridge->v12)
+               regulator_disable(ps_bridge->v12);
+
+       /*
+        * Sleep for at least the amount of time that it takes the power rail to
+        * fall to prevent asserting the rst gpio from doing anything.
+        */
+       usleep_range(PS8622_POWER_FALL_T16_MAX_US,
+                    2 * PS8622_POWER_FALL_T16_MAX_US);
+       if (gpio_is_valid(ps_bridge->gpio_rst_n))
+               gpio_set_value(ps_bridge->gpio_rst_n, 0);
+
+       msleep(PS8622_POWER_OFF_T17_MS);
+
+out:
+       mutex_unlock(&ps_bridge->enable_mutex);
+}
+
+static void ps8622_post_disable(struct drm_bridge *bridge)
+{
+       drm_next_bridge_post_disable(bridge);
+}
+
+static void ps8622_destroy(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+
+       drm_bridge_cleanup(bridge);
+       if (ps_bridge->bl)
+               backlight_device_unregister(ps_bridge->bl);
+
+       put_device(&ps_bridge->client->dev);
+}
+
+static const struct drm_bridge_funcs ps8622_bridge_funcs = {
+       .pre_enable = ps8622_pre_enable,
+       .enable = ps8622_enable,
+       .disable = ps8622_disable,
+       .post_disable = ps8622_post_disable,
+       .destroy = ps8622_destroy,
+};
+
+static const struct of_device_id ps8622_devices[] = {
+       {
+               .compatible = "parade,ps8622",
+               .data   = &ps8622_data,
+       }, {
+               .compatible = "parade,ps8625",
+               .data   = &ps8625_data,
+       }, {
+               /* end node */
+       }
+};
+
+struct drm_bridge *ps8622_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node)
+{
+       int ret;
+       const struct of_device_id *match;
+       const struct ps8622_device_data *device_data;
+       struct drm_bridge *bridge;
+       struct ps8622_bridge *ps_bridge;
+
+       node = of_find_matching_node_and_match(NULL, ps8622_devices, &match);
+       if (!node)
+               return NULL;
+
+       bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL);
+       if (!bridge) {
+               DRM_ERROR("Failed to allocate drm bridge\n");
+               return NULL;
+       }
+
+       ps_bridge = devm_kzalloc(dev->dev, sizeof(*ps_bridge), GFP_KERNEL);
+       if (!ps_bridge) {
+               DRM_ERROR("could not allocate ps bridge\n");
+               return NULL;
+       }
+
+       mutex_init(&ps_bridge->enable_mutex);
+
+       device_data = match->data;
+       ps_bridge->client = client;
+       ps_bridge->encoder = encoder;
+       ps_bridge->bridge = bridge;
+       ps_bridge->v12 = devm_regulator_get(&client->dev, "vdd_bridge");
+       if (IS_ERR(ps_bridge->v12)) {
+               DRM_INFO("no 1.2v regulator found for PS8622\n");
+               ps_bridge->v12 = NULL;
+       }
+
+       ps_bridge->gpio_slp_n = of_get_named_gpio(node, "sleep-gpio", 0);
+       if (gpio_is_valid(ps_bridge->gpio_slp_n)) {
+               ret = devm_gpio_request_one(&client->dev, ps_bridge->gpio_slp_n,
+                                           GPIOF_OUT_INIT_HIGH,
+                                           "PS8622_SLP_N");
+               if (ret)
+                       goto err_client;
+       }
+
+       ps_bridge->gpio_rst_n = of_get_named_gpio(node, "reset-gpio", 0);
+       if (gpio_is_valid(ps_bridge->gpio_rst_n)) {
+               /*
+                * Assert the reset pin high to avoid the bridge being
+                * initialized prematurely
+                */
+               ret = devm_gpio_request_one(&client->dev, ps_bridge->gpio_rst_n,
+                                           GPIOF_OUT_INIT_HIGH,
+                                           "PS8622_RST_N");
+               if (ret)
+                       goto err_client;
+       }
+
+       ps_bridge->max_lane_count = device_data->max_lane_count;
+
+       if (of_property_read_u8(node, "lane-count", &ps_bridge->lane_count))
+               ps_bridge->lane_count = ps_bridge->max_lane_count;
+       else if (ps_bridge->lane_count > ps_bridge->max_lane_count) {
+               DRM_ERROR("lane-count property is too high for DP bridge\n");
+               ps_bridge->lane_count = ps_bridge->max_lane_count;
+       }
+
+       if (!of_find_property(node, "use-external-pwm", NULL)) {
+               ps_bridge->bl = backlight_device_register("ps8622-backlight",
+                               dev->dev, ps_bridge, &ps8622_backlight_ops,
+                               NULL);
+               if (IS_ERR(ps_bridge->bl)) {
+                       DRM_ERROR("failed to register backlight\n");
+                       ret = PTR_ERR(ps_bridge->bl);
+                       ps_bridge->bl = NULL;
+                       goto err_client;
+               }
+               ps_bridge->bl->props.max_brightness = PS8622_MAX_BRIGHTNESS;
+               ps_bridge->bl->props.brightness = PS8622_MAX_BRIGHTNESS;
+       }
+
+       ret = drm_bridge_init(dev, ps_bridge->bridge, &ps8622_bridge_funcs);
+       if (ret) {
+               DRM_ERROR("Failed to initialize bridge with drm\n");
+               goto err_backlight;
+       }
+
+       ps_bridge->bridge->driver_private = ps_bridge;
+       ps_bridge->enabled = false;
+
+       if (!encoder->bridge)
+               /* First entry in the bridge chain */
+               encoder->bridge = bridge;
+
+       return bridge;
+
+err_backlight:
+       if (ps_bridge->bl)
+               backlight_device_unregister(ps_bridge->bl);
+err_client:
+       put_device(&client->dev);
+       DRM_ERROR("device probe failed : %d\n", ret);
+       return NULL;
+}
+EXPORT_SYMBOL(ps8622_init);
include/drm/bridge/ps8622.h new file +41 -1
new file mode 100644
index 0000000..22f37b6
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#ifndef _DRM_BRIDGE_PS8622_H_
+#define _DRM_BRIDGE_PS8622_H_
+
+struct drm_device;
+struct drm_encoder;
+struct i2c_client;
+struct device_node;
+
+#ifdef CONFIG_DRM_PS8622
+
+struct drm_bridge *ps8622_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node);
+
+#else
+
+static inline struct drm_bridge *ps8622_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node)
+{
+       return -ENODEV;
+}
+
+#endif
+
+#endif
--

1.7.9.5

#25 lore raw

Re: [PATCH V4 09/10] drm/bridge: Add ps8622/ps8625 bridge driver

In reply to Ajay Kumar

Hello Ajay,

Quoted 460 lines · Ajay Kumar

From: Vincent Palatin <[email protected]>

This patch adds drm_bridge driver for parade DisplayPort to LVDS bridge chip.

---
 .../devicetree/bindings/drm/bridge/ps8622.txt      |   21 +
 drivers/gpu/drm/bridge/Kconfig                     |    8 +
 drivers/gpu/drm/bridge/Makefile                    |    1 +
 drivers/gpu/drm/bridge/ps8622.c                    |  475 ++++++++++++++++++++
 include/drm/bridge/ps8622.h                        |   41 ++
 5 files changed, 546 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/ps8622.txt
 create mode 100644 drivers/gpu/drm/bridge/ps8622.c
 create mode 100644 include/drm/bridge/ps8622.h
Documentation/devicetree/bindings/drm/bridge/ps8622.txt new file +21 -0
new file mode 100644
index 0000000..1afbd9c
@@ -0,0 +1,21 @@
+ps8622-bridge bindings
+
+Required properties:
+       - compatible: "parade,ps8622"
+       - reg: first i2c address of the bridge
+       - sleep-gpio: OF device-tree gpio specification
+       - reset-gpio: OF device-tree gpio specification
+
+Optional properties:
+       - lane-count: number of DP lanes to use
+       - use-external-pwm: backlight will be controlled by an external PWM
+
+Example:
+       ps8622-bridge@48 {
+               compatible = "parade,ps8622";
+               reg = <0x48>;
+               sleep-gpio = <&gpc3 6 1 0 0>;
+               reset-gpio = <&gpc3 1 1 0 0>;
+               display-timings = <&lcd_display_timings>;
+               lane-count = <1>
+       };
drivers/gpu/drm/bridge/Kconfig +8 -0
index e3fb487..7b843c8 100644
@@ -10,3 +10,11 @@ config DRM_PANEL_BINDER
        select DRM_KMS_HELPER
        select DRM_PANEL
        ---help---
+
+config DRM_PS8622
+       tristate "Parade eDP/LVDS bridge"
+       depends on DRM
+       select DRM_KMS_HELPER
+       select BACKLIGHT_LCD_SUPPORT
+       select BACKLIGHT_CLASS_DEVICE
+       ---help---
drivers/gpu/drm/bridge/Makefile +1 -0
index ba8b5b8..b494d4b 100644
@@ -2,3 +2,4 @@ ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
 obj-$(CONFIG_DRM_PANEL_BINDER) += panel_binder.o
+obj-$(CONFIG_DRM_PS8622) += ps8622.o
drivers/gpu/drm/bridge/ps8622.c new file +381 -0
new file mode 100644
index 0000000..387d332
@@ -0,0 +1,475 @@
+/*
+ * Parade PS8622 eDP/LVDS bridge driver
+ *
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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 <linux/module.h>
+#include <linux/backlight.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/fb.h>
+#include <linux/gpio.h>
+#include <linux/i2c.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/pm.h>
+#include <linux/regulator/consumer.h>
+
+#include "drmP.h"
+#include "drm_crtc.h"
+#include "drm_crtc_helper.h"
+
+struct ps8622_bridge {
+       struct drm_bridge *bridge;
+       struct drm_encoder *encoder;
+       struct i2c_client *client;
+       struct regulator *v12;
+       struct backlight_device *bl;
+       struct mutex enable_mutex;
+
+       int gpio_slp_n;
+       int gpio_rst_n;
+
+       u8 max_lane_count;
+       u8 lane_count;
+
+       bool enabled;
+};
+
+struct ps8622_device_data {
+       u8 max_lane_count;
+};
+
+static const struct ps8622_device_data ps8622_data = {
+       .max_lane_count = 1,
+};
+
+static const struct ps8622_device_data ps8625_data = {
+       .max_lane_count = 2,
+};
+
+/* Brightness scale on the Parade chip */
+#define PS8622_MAX_BRIGHTNESS 0xff
+
+/* Timings taken from the version 1.7 datasheet for the PS8622/PS8625 */
+#define PS8622_POWER_RISE_T1_MIN_US 10
+#define PS8622_POWER_RISE_T1_MAX_US 10000
+#define PS8622_RST_HIGH_T2_MIN_US 3000
+#define PS8622_RST_HIGH_T2_MAX_US 30000
+#define PS8622_PWMO_END_T12_MS 200
+#define PS8622_POWER_FALL_T16_MAX_US 10000
+#define PS8622_POWER_OFF_T17_MS 500
+
+#if ((PS8622_RST_HIGH_T2_MIN_US + PS8622_POWER_RISE_T1_MAX_US) > \
+       (PS8622_RST_HIGH_T2_MAX_US + PS8622_POWER_RISE_T1_MIN_US))
+#error "T2.min + T1.max must be less than T2.max + T1.min"
+#endif
+
+static int ps8622_set(struct i2c_client *client, u8 page, u8 reg, u8 val)
+{
+       int ret;
+       struct i2c_adapter *adap = client->adapter;
+       struct i2c_msg msg;
+       u8 data[] = {reg, val};
+
+       msg.addr = client->addr + page;
+       msg.flags = 0;
+       msg.len = sizeof(data);
+       msg.buf = data;
+
+       ret = i2c_transfer(adap, &msg, 1);
+       if (ret != 1)
+               pr_warn("PS8622 I2C write (0x%02x,0x%02x,0x%02x) failed: %d\n",
+                       client->addr + page, reg, val, ret);
+       return !(ret == 1);
+}
+
+static int ps8622_send_config(struct ps8622_bridge *ps_bridge)
+{
+       struct i2c_client *cl = ps_bridge->client;
+       int err = 0;
+
+       /* wait 20ms after power ON */
+       usleep_range(20000, 30000);
+
+       err |= ps8622_set(cl, 0x02, 0xa1, 0x01); /* HPD low */
+       /* SW setting */
+       err |= ps8622_set(cl, 0x04, 0x14, 0x01); /* [1:0] SW output 1.2V voltage
+                                                 * is lower to 96% */
+       /* RCO SS setting */
+       err |= ps8622_set(cl, 0x04, 0xe3, 0x20); /* [5:4] = b01 0.5%, b10 1%,
+                                                 * b11 1.5% */
+       err |= ps8622_set(cl, 0x04, 0xe2, 0x80); /* [7] RCO SS enable */
+       /* RPHY Setting */
+       err |= ps8622_set(cl, 0x04, 0x8a, 0x0c); /* [3:2] CDR tune wait cycle
+                                                 * before measure for fine tune
+                                                 * b00: 1us b01: 0.5us b10:2us
+                                                 * b11: 4us */
+       err |= ps8622_set(cl, 0x04, 0x89, 0x08); /* [3] RFD always on */
+       err |= ps8622_set(cl, 0x04, 0x71, 0x2d); /* CTN lock in/out:
+                                                 * 20000ppm/80000ppm.
+                                                 * Lock out 2 times. */
+       /* 2.7G CDR settings */
+       err |= ps8622_set(cl, 0x04, 0x7d, 0x07); /* NOF=40LSB for HBR CDR
+                                                 * setting */
+       err |= ps8622_set(cl, 0x04, 0x7b, 0x00); /* [1:0] Fmin=+4bands */
+       err |= ps8622_set(cl, 0x04, 0x7a, 0xfd); /* [7:5] DCO_FTRNG=+-40% */
+       /* 1.62G CDR settings */
+       err |= ps8622_set(cl, 0x04, 0xc0, 0x12); /* [5:2]NOF=64LSB [1:0]DCO
+                                                 * scale is 2/5 */
+       err |= ps8622_set(cl, 0x04, 0xc1, 0x92); /* Gitune=-37% */
+       err |= ps8622_set(cl, 0x04, 0xc2, 0x1c); /* Fbstep=100% */
+       err |= ps8622_set(cl, 0x04, 0x32, 0x80); /* [7] LOS signal disable */
+       /* RPIO Setting */
+       err |= ps8622_set(cl, 0x04, 0x00, 0xb0); /* [7:4] LVDS driver bias
+                                                 * current : 75% (250mV swing)
+                                                 * */
+       err |= ps8622_set(cl, 0x04, 0x15, 0x40); /* [7:6] Right-bar GPIO output
+                                                 * strength is 8mA */
+       /* EQ Training State Machine Setting */
+       err |= ps8622_set(cl, 0x04, 0x54, 0x10); /* RCO calibration start */
+       /* Logic, needs more than 10 I2C command */
+       err |= ps8622_set(cl, 0x01, 0x02, 0x80 | ps_bridge->max_lane_count);
+                                                /* [4:0] MAX_LANE_COUNT set to
+                                                 * max supported lanes */
+       err |= ps8622_set(cl, 0x01, 0x21, 0x80 | ps_bridge->lane_count);
+                                                /* [4:0] LANE_COUNT_SET set to
+                                                 * chosen lane count */
+       err |= ps8622_set(cl, 0x00, 0x52, 0x20);
+       err |= ps8622_set(cl, 0x00, 0xf1, 0x03); /* HPD CP toggle enable */
+       err |= ps8622_set(cl, 0x00, 0x62, 0x41);
+       err |= ps8622_set(cl, 0x00, 0xf6, 0x01); /* Counter number, add 1ms
+                                                 * counter delay */
+       err |= ps8622_set(cl, 0x00, 0x77, 0x06); /* [6]PWM function control by
+                                                 * DPCD0040f[7], default is PWM
+                                                 * block always works. */
+       err |= ps8622_set(cl, 0x00, 0x4c, 0x04); /* 04h Adjust VTotal tolerance
+                                                 * to fix the 30Hz no display
+                                                 * issue */
+       err |= ps8622_set(cl, 0x01, 0xc0, 0x00); /* DPCD00400='h00, Parade OUI =
+                                                 * 'h001cf8 */
+       err |= ps8622_set(cl, 0x01, 0xc1, 0x1c); /* DPCD00401='h1c */
+       err |= ps8622_set(cl, 0x01, 0xc2, 0xf8); /* DPCD00402='hf8 */
+       err |= ps8622_set(cl, 0x01, 0xc3, 0x44); /* DPCD403~408 = ASCII code
+                                                 * D2SLV5='h4432534c5635 */
+       err |= ps8622_set(cl, 0x01, 0xc4, 0x32); /* DPCD404 */
+       err |= ps8622_set(cl, 0x01, 0xc5, 0x53); /* DPCD405 */
+       err |= ps8622_set(cl, 0x01, 0xc6, 0x4c); /* DPCD406 */
+       err |= ps8622_set(cl, 0x01, 0xc7, 0x56); /* DPCD407 */
+       err |= ps8622_set(cl, 0x01, 0xc8, 0x35); /* DPCD408 */
+       err |= ps8622_set(cl, 0x01, 0xca, 0x01); /* DPCD40A, Initial Code major
+                                                 * revision '01' */
+       err |= ps8622_set(cl, 0x01, 0xcb, 0x05); /* DPCD40B, Initial Code minor
+                                                 * revision '05' */
+       if (ps_bridge->bl) {
+               err |= ps8622_set(cl, 0x01, 0xa5, 0xa0);
+                                               /* DPCD720, internal PWM */
+               err |= ps8622_set(cl, 0x01, 0xa7,
+                               ps_bridge->bl->props.brightness);
+                                                /* FFh for 100% brightness,
+                                                 *  0h for 0% brightness */
+       } else {
+               err |= ps8622_set(cl, 0x01, 0xa5, 0x80);
+                                               /* DPCD720, external PWM */
+       }
+       err |= ps8622_set(cl, 0x01, 0xcc, 0x13); /* Set LVDS output as 6bit-VESA
+                                                 * mapping, single LVDS channel
+                                                 * */
+       err |= ps8622_set(cl, 0x02, 0xb1, 0x20); /* Enable SSC set by register
+                                                 * */
+       err |= ps8622_set(cl, 0x04, 0x10, 0x16); /* Set SSC enabled and +/-1%
+                                                 * central spreading */
+       /* Logic end */
+       err |= ps8622_set(cl, 0x04, 0x59, 0x60); /* MPU Clock source: LC => RCO
+                                                 * */
+       err |= ps8622_set(cl, 0x04, 0x54, 0x14); /* LC -> RCO */
+       err |= ps8622_set(cl, 0x02, 0xa1, 0x91); /* HPD high */
+
+       return err ? -EIO : 0;
+}
+
+static int ps8622_backlight_update(struct backlight_device *bl)
+{
+       struct ps8622_bridge *ps_bridge = dev_get_drvdata(&bl->dev);
+       int ret, brightness = bl->props.brightness;
+
+       if (bl->props.power != FB_BLANK_UNBLANK ||
+           bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+               brightness = 0;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+
+       if (!ps_bridge->enabled) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       ret = ps8622_set(ps_bridge->client, 0x01, 0xa7, brightness);
+
+out:
+       mutex_unlock(&ps_bridge->enable_mutex);
+       return ret;
+}
+
+static int ps8622_backlight_get(struct backlight_device *bl)
+{
+       return bl->props.brightness;
+}
+
+static const struct backlight_ops ps8622_backlight_ops = {
+       .update_status  = ps8622_backlight_update,
+       .get_brightness = ps8622_backlight_get,
+};
+
+static void ps8622_pre_enable(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+       int ret;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+       if (ps_bridge->enabled)
+               goto out;
+
+       if (gpio_is_valid(ps_bridge->gpio_rst_n))
+               gpio_set_value(ps_bridge->gpio_rst_n, 0);
+
+       if (ps_bridge->v12) {
+               ret = regulator_enable(ps_bridge->v12);
+               if (ret)
+                       DRM_ERROR("fails to enable ps_bridge->v12");
+       }
+
+       drm_next_bridge_pre_enable(bridge);
+
+       if (gpio_is_valid(ps_bridge->gpio_slp_n))
+               gpio_set_value(ps_bridge->gpio_slp_n, 1);
+
+       /*
+        * T1 is the range of time that it takes for the power to rise after we
+        * enable the lcd fet. T2 is the range of time in which the data sheet
+        * specifies we should deassert the reset pin.
+        *
+        * If it takes T1.max for the power to rise, we need to wait atleast
+        * T2.min before deasserting the reset pin. If it takes T1.min for the
+        * power to rise, we need to wait at most T2.max before deasserting the
+        * reset pin.
+        */
+       usleep_range(PS8622_RST_HIGH_T2_MIN_US + PS8622_POWER_RISE_T1_MAX_US,
+                    PS8622_RST_HIGH_T2_MAX_US + PS8622_POWER_RISE_T1_MIN_US);
+
+       if (gpio_is_valid(ps_bridge->gpio_rst_n))
+               gpio_set_value(ps_bridge->gpio_rst_n, 1);
+
+       ret = ps8622_send_config(ps_bridge);
+       if (ret)
+               DRM_ERROR("Failed to send config to bridge (%d)\n", ret);
+
+       ps_bridge->enabled = true;
+
+out:
+       mutex_unlock(&ps_bridge->enable_mutex);
+}
+
+static void ps8622_enable(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+       drm_next_bridge_enable(bridge);
+       mutex_unlock(&ps_bridge->enable_mutex);
+}
+
+static void ps8622_disable(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+
+       if (!ps_bridge->enabled)
+               goto out;
+
+       ps_bridge->enabled = false;
+
+       drm_next_bridge_disable(bridge);
+       msleep(PS8622_PWMO_END_T12_MS);
+
+       /*
+        * This doesn't matter if the regulators are turned off, but something
+        * else might keep them on. In that case, we want to assert the slp gpio
+        * to lower power.
+        */
+       if (gpio_is_valid(ps_bridge->gpio_slp_n))
+               gpio_set_value(ps_bridge->gpio_slp_n, 0);
+
+       if (ps_bridge->v12)
+               regulator_disable(ps_bridge->v12);
+
+       /*
+        * Sleep for at least the amount of time that it takes the power rail to
+        * fall to prevent asserting the rst gpio from doing anything.
+        */
+       usleep_range(PS8622_POWER_FALL_T16_MAX_US,
+                    2 * PS8622_POWER_FALL_T16_MAX_US);
+       if (gpio_is_valid(ps_bridge->gpio_rst_n))
+               gpio_set_value(ps_bridge->gpio_rst_n, 0);
+
+       msleep(PS8622_POWER_OFF_T17_MS);
+
+out:
+       mutex_unlock(&ps_bridge->enable_mutex);
+}
+
+static void ps8622_post_disable(struct drm_bridge *bridge)
+{
+       drm_next_bridge_post_disable(bridge);
+}
+
+static void ps8622_destroy(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+
+       drm_bridge_cleanup(bridge);
+       if (ps_bridge->bl)
+               backlight_device_unregister(ps_bridge->bl);
+
+       put_device(&ps_bridge->client->dev);
+}
+
+static const struct drm_bridge_funcs ps8622_bridge_funcs = {
+       .pre_enable = ps8622_pre_enable,
+       .enable = ps8622_enable,
+       .disable = ps8622_disable,
+       .post_disable = ps8622_post_disable,
+       .destroy = ps8622_destroy,
+};
+
+static const struct of_device_id ps8622_devices[] = {
+       {
+               .compatible = "parade,ps8622",
+               .data   = &ps8622_data,
+       }, {
+               .compatible = "parade,ps8625",
+               .data   = &ps8625_data,
+       }, {
+               /* end node */
+       }
+};
+
+struct drm_bridge *ps8622_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node)
+{
+       int ret;
+       const struct of_device_id *match;
+       const struct ps8622_device_data *device_data;
+       struct drm_bridge *bridge;
+       struct ps8622_bridge *ps_bridge;
+
+       node = of_find_matching_node_and_match(NULL, ps8622_devices, &match);
+       if (!node)
+               return NULL;

drivers/gpu/drm/bridge/ps8622.c line 391

Quoted 10 lines
drivers/gpu/drm/bridge/ps8622.c new file +10 -0
+
+       bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL);
+       if (!bridge) {
+               DRM_ERROR("Failed to allocate drm bridge\n");
+               return NULL;
+       }
+
+       ps_bridge = devm_kzalloc(dev->dev, sizeof(*ps_bridge), GFP_KERNEL);
+       if (!ps_bridge) {
+               DRM_ERROR("could not allocate ps bridge\n");

It's not necessary to log OOM errors since the mm subsystem already logs this and calls dump_stack().

Quoted 6 lines
drivers/gpu/drm/bridge/ps8622.c new file +6 -0
+               return NULL;
+       }
+
+       mutex_init(&ps_bridge->enable_mutex);
+
+       device_data = match->data;

drivers/gpu/drm/bridge/ps8622.c line 407

Quoted 10 lines
drivers/gpu/drm/bridge/ps8622.c new file +10 -0
+       ps_bridge->client = client;
+       ps_bridge->encoder = encoder;
+       ps_bridge->bridge = bridge;
+       ps_bridge->v12 = devm_regulator_get(&client->dev, "vdd_bridge");
+       if (IS_ERR(ps_bridge->v12)) {
+               DRM_INFO("no 1.2v regulator found for PS8622\n");
+               ps_bridge->v12 = NULL;
+       }
+
+       ps_bridge->gpio_slp_n = of_get_named_gpio(node, "sleep-gpio", 0);

The new descriptor-based GPIO interface should be used if possible instead of the deprecated integer-based API.

Quoted 17 lines
drivers/gpu/drm/bridge/ps8622.c new file +17 -0
+       if (gpio_is_valid(ps_bridge->gpio_slp_n)) {
+               ret = devm_gpio_request_one(&client->dev, ps_bridge->gpio_slp_n,
+                                           GPIOF_OUT_INIT_HIGH,
+                                           "PS8622_SLP_N");
+               if (ret)
+                       goto err_client;
+       }
+
+       ps_bridge->gpio_rst_n = of_get_named_gpio(node, "reset-gpio", 0);
+       if (gpio_is_valid(ps_bridge->gpio_rst_n)) {
+               /*
+                * Assert the reset pin high to avoid the bridge being
+                * initialized prematurely
+                */
+               ret = devm_gpio_request_one(&client->dev, ps_bridge->gpio_rst_n,
+                                           GPIOF_OUT_INIT_HIGH,
+                                           "PS8622_RST_N");

drivers/gpu/drm/bridge/ps8622.c line 434

Quoted 10 lines
drivers/gpu/drm/bridge/ps8622.c new file +10 -0
+               if (ret)
+                       goto err_client;
+       }
+
+       ps_bridge->max_lane_count = device_data->max_lane_count;
+
+       if (of_property_read_u8(node, "lane-count", &ps_bridge->lane_count))
+               ps_bridge->lane_count = ps_bridge->max_lane_count;
+       else if (ps_bridge->lane_count > ps_bridge->max_lane_count) {
+               DRM_ERROR("lane-count property is too high for DP bridge\n");

DRM_INFO() instead?

Quoted 89 lines
drivers/gpu/drm/bridge/ps8622.c new file +41 -0
+               ps_bridge->lane_count = ps_bridge->max_lane_count;
+       }
+
+       if (!of_find_property(node, "use-external-pwm", NULL)) {
+               ps_bridge->bl = backlight_device_register("ps8622-backlight",
+                               dev->dev, ps_bridge, &ps8622_backlight_ops,
+                               NULL);
+               if (IS_ERR(ps_bridge->bl)) {
+                       DRM_ERROR("failed to register backlight\n");
+                       ret = PTR_ERR(ps_bridge->bl);
+                       ps_bridge->bl = NULL;
+                       goto err_client;
+               }
+               ps_bridge->bl->props.max_brightness = PS8622_MAX_BRIGHTNESS;
+               ps_bridge->bl->props.brightness = PS8622_MAX_BRIGHTNESS;
+       }
+
+       ret = drm_bridge_init(dev, ps_bridge->bridge, &ps8622_bridge_funcs);
+       if (ret) {
+               DRM_ERROR("Failed to initialize bridge with drm\n");
+               goto err_backlight;
+       }
+
+       ps_bridge->bridge->driver_private = ps_bridge;
+       ps_bridge->enabled = false;
+
+       if (!encoder->bridge)
+               /* First entry in the bridge chain */
+               encoder->bridge = bridge;
+
+       return bridge;
+
+err_backlight:
+       if (ps_bridge->bl)
+               backlight_device_unregister(ps_bridge->bl);
+err_client:
+       put_device(&client->dev);
+       DRM_ERROR("device probe failed : %d\n", ret);
+       return NULL;
+}
+EXPORT_SYMBOL(ps8622_init);
include/drm/bridge/ps8622.h new file +41 -1
new file mode 100644
index 0000000..22f37b6
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#ifndef _DRM_BRIDGE_PS8622_H_
+#define _DRM_BRIDGE_PS8622_H_
+
+struct drm_device;
+struct drm_encoder;
+struct i2c_client;
+struct device_node;
+
+#ifdef CONFIG_DRM_PS8622
+
+struct drm_bridge *ps8622_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node);
+
+#else
+
+static inline struct drm_bridge *ps8622_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node)
+{
+       return -ENODEV;
+}
+
+#endif
+
+#endif
--
Quoted 2 lines

1.7.9.5

Best regards,
Javier

#26 lore raw

Re: [PATCH V4 09/10] drm/bridge: Add ps8622/ps8625 bridge driver

Hi Javier,

Thanks for the review.

Quoted 468 lines · Javier Martinez Canillas

Hello Ajay,

Quoted 465 lines · Ajay Kumar

From: Vincent Palatin <[email protected]>

This patch adds drm_bridge driver for parade DisplayPort to LVDS bridge chip.

---
 .../devicetree/bindings/drm/bridge/ps8622.txt      |   21 +
 drivers/gpu/drm/bridge/Kconfig                     |    8 +
 drivers/gpu/drm/bridge/Makefile                    |    1 +
 drivers/gpu/drm/bridge/ps8622.c                    |  475 ++++++++++++++++++++
 include/drm/bridge/ps8622.h                        |   41 ++
 5 files changed, 546 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/ps8622.txt
 create mode 100644 drivers/gpu/drm/bridge/ps8622.c
 create mode 100644 include/drm/bridge/ps8622.h
Documentation/devicetree/bindings/drm/bridge/ps8622.txt new file +21 -0
new file mode 100644
index 0000000..1afbd9c
@@ -0,0 +1,21 @@
+ps8622-bridge bindings
+
+Required properties:
+       - compatible: "parade,ps8622"
+       - reg: first i2c address of the bridge
+       - sleep-gpio: OF device-tree gpio specification
+       - reset-gpio: OF device-tree gpio specification
+
+Optional properties:
+       - lane-count: number of DP lanes to use
+       - use-external-pwm: backlight will be controlled by an external PWM
+
+Example:
+       ps8622-bridge@48 {
+               compatible = "parade,ps8622";
+               reg = <0x48>;
+               sleep-gpio = <&gpc3 6 1 0 0>;
+               reset-gpio = <&gpc3 1 1 0 0>;
+               display-timings = <&lcd_display_timings>;
+               lane-count = <1>
+       };
drivers/gpu/drm/bridge/Kconfig +8 -0
index e3fb487..7b843c8 100644
@@ -10,3 +10,11 @@ config DRM_PANEL_BINDER
        select DRM_KMS_HELPER
        select DRM_PANEL
        ---help---
+
+config DRM_PS8622
+       tristate "Parade eDP/LVDS bridge"
+       depends on DRM
+       select DRM_KMS_HELPER
+       select BACKLIGHT_LCD_SUPPORT
+       select BACKLIGHT_CLASS_DEVICE
+       ---help---
drivers/gpu/drm/bridge/Makefile +1 -0
index ba8b5b8..b494d4b 100644
@@ -2,3 +2,4 @@ ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
 obj-$(CONFIG_DRM_PANEL_BINDER) += panel_binder.o
+obj-$(CONFIG_DRM_PS8622) += ps8622.o
drivers/gpu/drm/bridge/ps8622.c new file +386 -0
new file mode 100644
index 0000000..387d332
@@ -0,0 +1,475 @@
+/*
+ * Parade PS8622 eDP/LVDS bridge driver
+ *
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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 <linux/module.h>
+#include <linux/backlight.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/fb.h>
+#include <linux/gpio.h>
+#include <linux/i2c.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/pm.h>
+#include <linux/regulator/consumer.h>
+
+#include "drmP.h"
+#include "drm_crtc.h"
+#include "drm_crtc_helper.h"
+
+struct ps8622_bridge {
+       struct drm_bridge *bridge;
+       struct drm_encoder *encoder;
+       struct i2c_client *client;
+       struct regulator *v12;
+       struct backlight_device *bl;
+       struct mutex enable_mutex;
+
+       int gpio_slp_n;
+       int gpio_rst_n;
+
+       u8 max_lane_count;
+       u8 lane_count;
+
+       bool enabled;
+};
+
+struct ps8622_device_data {
+       u8 max_lane_count;
+};
+
+static const struct ps8622_device_data ps8622_data = {
+       .max_lane_count = 1,
+};
+
+static const struct ps8622_device_data ps8625_data = {
+       .max_lane_count = 2,
+};
+
+/* Brightness scale on the Parade chip */
+#define PS8622_MAX_BRIGHTNESS 0xff
+
+/* Timings taken from the version 1.7 datasheet for the PS8622/PS8625 */
+#define PS8622_POWER_RISE_T1_MIN_US 10
+#define PS8622_POWER_RISE_T1_MAX_US 10000
+#define PS8622_RST_HIGH_T2_MIN_US 3000
+#define PS8622_RST_HIGH_T2_MAX_US 30000
+#define PS8622_PWMO_END_T12_MS 200
+#define PS8622_POWER_FALL_T16_MAX_US 10000
+#define PS8622_POWER_OFF_T17_MS 500
+
+#if ((PS8622_RST_HIGH_T2_MIN_US + PS8622_POWER_RISE_T1_MAX_US) > \
+       (PS8622_RST_HIGH_T2_MAX_US + PS8622_POWER_RISE_T1_MIN_US))
+#error "T2.min + T1.max must be less than T2.max + T1.min"
+#endif
+
+static int ps8622_set(struct i2c_client *client, u8 page, u8 reg, u8 val)
+{
+       int ret;
+       struct i2c_adapter *adap = client->adapter;
+       struct i2c_msg msg;
+       u8 data[] = {reg, val};
+
+       msg.addr = client->addr + page;
+       msg.flags = 0;
+       msg.len = sizeof(data);
+       msg.buf = data;
+
+       ret = i2c_transfer(adap, &msg, 1);
+       if (ret != 1)
+               pr_warn("PS8622 I2C write (0x%02x,0x%02x,0x%02x) failed: %d\n",
+                       client->addr + page, reg, val, ret);
+       return !(ret == 1);
+}
+
+static int ps8622_send_config(struct ps8622_bridge *ps_bridge)
+{
+       struct i2c_client *cl = ps_bridge->client;
+       int err = 0;
+
+       /* wait 20ms after power ON */
+       usleep_range(20000, 30000);
+
+       err |= ps8622_set(cl, 0x02, 0xa1, 0x01); /* HPD low */
+       /* SW setting */
+       err |= ps8622_set(cl, 0x04, 0x14, 0x01); /* [1:0] SW output 1.2V voltage
+                                                 * is lower to 96% */
+       /* RCO SS setting */
+       err |= ps8622_set(cl, 0x04, 0xe3, 0x20); /* [5:4] = b01 0.5%, b10 1%,
+                                                 * b11 1.5% */
+       err |= ps8622_set(cl, 0x04, 0xe2, 0x80); /* [7] RCO SS enable */
+       /* RPHY Setting */
+       err |= ps8622_set(cl, 0x04, 0x8a, 0x0c); /* [3:2] CDR tune wait cycle
+                                                 * before measure for fine tune
+                                                 * b00: 1us b01: 0.5us b10:2us
+                                                 * b11: 4us */
+       err |= ps8622_set(cl, 0x04, 0x89, 0x08); /* [3] RFD always on */
+       err |= ps8622_set(cl, 0x04, 0x71, 0x2d); /* CTN lock in/out:
+                                                 * 20000ppm/80000ppm.
+                                                 * Lock out 2 times. */
+       /* 2.7G CDR settings */
+       err |= ps8622_set(cl, 0x04, 0x7d, 0x07); /* NOF=40LSB for HBR CDR
+                                                 * setting */
+       err |= ps8622_set(cl, 0x04, 0x7b, 0x00); /* [1:0] Fmin=+4bands */
+       err |= ps8622_set(cl, 0x04, 0x7a, 0xfd); /* [7:5] DCO_FTRNG=+-40% */
+       /* 1.62G CDR settings */
+       err |= ps8622_set(cl, 0x04, 0xc0, 0x12); /* [5:2]NOF=64LSB [1:0]DCO
+                                                 * scale is 2/5 */
+       err |= ps8622_set(cl, 0x04, 0xc1, 0x92); /* Gitune=-37% */
+       err |= ps8622_set(cl, 0x04, 0xc2, 0x1c); /* Fbstep=100% */
+       err |= ps8622_set(cl, 0x04, 0x32, 0x80); /* [7] LOS signal disable */
+       /* RPIO Setting */
+       err |= ps8622_set(cl, 0x04, 0x00, 0xb0); /* [7:4] LVDS driver bias
+                                                 * current : 75% (250mV swing)
+                                                 * */
+       err |= ps8622_set(cl, 0x04, 0x15, 0x40); /* [7:6] Right-bar GPIO output
+                                                 * strength is 8mA */
+       /* EQ Training State Machine Setting */
+       err |= ps8622_set(cl, 0x04, 0x54, 0x10); /* RCO calibration start */
+       /* Logic, needs more than 10 I2C command */
+       err |= ps8622_set(cl, 0x01, 0x02, 0x80 | ps_bridge->max_lane_count);
+                                                /* [4:0] MAX_LANE_COUNT set to
+                                                 * max supported lanes */
+       err |= ps8622_set(cl, 0x01, 0x21, 0x80 | ps_bridge->lane_count);
+                                                /* [4:0] LANE_COUNT_SET set to
+                                                 * chosen lane count */
+       err |= ps8622_set(cl, 0x00, 0x52, 0x20);
+       err |= ps8622_set(cl, 0x00, 0xf1, 0x03); /* HPD CP toggle enable */
+       err |= ps8622_set(cl, 0x00, 0x62, 0x41);
+       err |= ps8622_set(cl, 0x00, 0xf6, 0x01); /* Counter number, add 1ms
+                                                 * counter delay */
+       err |= ps8622_set(cl, 0x00, 0x77, 0x06); /* [6]PWM function control by
+                                                 * DPCD0040f[7], default is PWM
+                                                 * block always works. */
+       err |= ps8622_set(cl, 0x00, 0x4c, 0x04); /* 04h Adjust VTotal tolerance
+                                                 * to fix the 30Hz no display
+                                                 * issue */
+       err |= ps8622_set(cl, 0x01, 0xc0, 0x00); /* DPCD00400='h00, Parade OUI =
+                                                 * 'h001cf8 */
+       err |= ps8622_set(cl, 0x01, 0xc1, 0x1c); /* DPCD00401='h1c */
+       err |= ps8622_set(cl, 0x01, 0xc2, 0xf8); /* DPCD00402='hf8 */
+       err |= ps8622_set(cl, 0x01, 0xc3, 0x44); /* DPCD403~408 = ASCII code
+                                                 * D2SLV5='h4432534c5635 */
+       err |= ps8622_set(cl, 0x01, 0xc4, 0x32); /* DPCD404 */
+       err |= ps8622_set(cl, 0x01, 0xc5, 0x53); /* DPCD405 */
+       err |= ps8622_set(cl, 0x01, 0xc6, 0x4c); /* DPCD406 */
+       err |= ps8622_set(cl, 0x01, 0xc7, 0x56); /* DPCD407 */
+       err |= ps8622_set(cl, 0x01, 0xc8, 0x35); /* DPCD408 */
+       err |= ps8622_set(cl, 0x01, 0xca, 0x01); /* DPCD40A, Initial Code major
+                                                 * revision '01' */
+       err |= ps8622_set(cl, 0x01, 0xcb, 0x05); /* DPCD40B, Initial Code minor
+                                                 * revision '05' */
+       if (ps_bridge->bl) {
+               err |= ps8622_set(cl, 0x01, 0xa5, 0xa0);
+                                               /* DPCD720, internal PWM */
+               err |= ps8622_set(cl, 0x01, 0xa7,
+                               ps_bridge->bl->props.brightness);
+                                                /* FFh for 100% brightness,
+                                                 *  0h for 0% brightness */
+       } else {
+               err |= ps8622_set(cl, 0x01, 0xa5, 0x80);
+                                               /* DPCD720, external PWM */
+       }
+       err |= ps8622_set(cl, 0x01, 0xcc, 0x13); /* Set LVDS output as 6bit-VESA
+                                                 * mapping, single LVDS channel
+                                                 * */
+       err |= ps8622_set(cl, 0x02, 0xb1, 0x20); /* Enable SSC set by register
+                                                 * */
+       err |= ps8622_set(cl, 0x04, 0x10, 0x16); /* Set SSC enabled and +/-1%
+                                                 * central spreading */
+       /* Logic end */
+       err |= ps8622_set(cl, 0x04, 0x59, 0x60); /* MPU Clock source: LC => RCO
+                                                 * */
+       err |= ps8622_set(cl, 0x04, 0x54, 0x14); /* LC -> RCO */
+       err |= ps8622_set(cl, 0x02, 0xa1, 0x91); /* HPD high */
+
+       return err ? -EIO : 0;
+}
+
+static int ps8622_backlight_update(struct backlight_device *bl)
+{
+       struct ps8622_bridge *ps_bridge = dev_get_drvdata(&bl->dev);
+       int ret, brightness = bl->props.brightness;
+
+       if (bl->props.power != FB_BLANK_UNBLANK ||
+           bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+               brightness = 0;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+
+       if (!ps_bridge->enabled) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       ret = ps8622_set(ps_bridge->client, 0x01, 0xa7, brightness);
+
+out:
+       mutex_unlock(&ps_bridge->enable_mutex);
+       return ret;
+}
+
+static int ps8622_backlight_get(struct backlight_device *bl)
+{
+       return bl->props.brightness;
+}
+
+static const struct backlight_ops ps8622_backlight_ops = {
+       .update_status  = ps8622_backlight_update,
+       .get_brightness = ps8622_backlight_get,
+};
+
+static void ps8622_pre_enable(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+       int ret;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+       if (ps_bridge->enabled)
+               goto out;
+
+       if (gpio_is_valid(ps_bridge->gpio_rst_n))
+               gpio_set_value(ps_bridge->gpio_rst_n, 0);
+
+       if (ps_bridge->v12) {
+               ret = regulator_enable(ps_bridge->v12);
+               if (ret)
+                       DRM_ERROR("fails to enable ps_bridge->v12");
+       }
+
+       drm_next_bridge_pre_enable(bridge);
+
+       if (gpio_is_valid(ps_bridge->gpio_slp_n))
+               gpio_set_value(ps_bridge->gpio_slp_n, 1);
+
+       /*
+        * T1 is the range of time that it takes for the power to rise after we
+        * enable the lcd fet. T2 is the range of time in which the data sheet
+        * specifies we should deassert the reset pin.
+        *
+        * If it takes T1.max for the power to rise, we need to wait atleast
+        * T2.min before deasserting the reset pin. If it takes T1.min for the
+        * power to rise, we need to wait at most T2.max before deasserting the
+        * reset pin.
+        */
+       usleep_range(PS8622_RST_HIGH_T2_MIN_US + PS8622_POWER_RISE_T1_MAX_US,
+                    PS8622_RST_HIGH_T2_MAX_US + PS8622_POWER_RISE_T1_MIN_US);
+
+       if (gpio_is_valid(ps_bridge->gpio_rst_n))
+               gpio_set_value(ps_bridge->gpio_rst_n, 1);
+
+       ret = ps8622_send_config(ps_bridge);
+       if (ret)
+               DRM_ERROR("Failed to send config to bridge (%d)\n", ret);
+
+       ps_bridge->enabled = true;
+
+out:
+       mutex_unlock(&ps_bridge->enable_mutex);
+}
+
+static void ps8622_enable(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+       drm_next_bridge_enable(bridge);
+       mutex_unlock(&ps_bridge->enable_mutex);
+}
+
+static void ps8622_disable(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+
+       mutex_lock(&ps_bridge->enable_mutex);
+
+       if (!ps_bridge->enabled)
+               goto out;
+
+       ps_bridge->enabled = false;
+
+       drm_next_bridge_disable(bridge);
+       msleep(PS8622_PWMO_END_T12_MS);
+
+       /*
+        * This doesn't matter if the regulators are turned off, but something
+        * else might keep them on. In that case, we want to assert the slp gpio
+        * to lower power.
+        */
+       if (gpio_is_valid(ps_bridge->gpio_slp_n))
+               gpio_set_value(ps_bridge->gpio_slp_n, 0);
+
+       if (ps_bridge->v12)
+               regulator_disable(ps_bridge->v12);
+
+       /*
+        * Sleep for at least the amount of time that it takes the power rail to
+        * fall to prevent asserting the rst gpio from doing anything.
+        */
+       usleep_range(PS8622_POWER_FALL_T16_MAX_US,
+                    2 * PS8622_POWER_FALL_T16_MAX_US);
+       if (gpio_is_valid(ps_bridge->gpio_rst_n))
+               gpio_set_value(ps_bridge->gpio_rst_n, 0);
+
+       msleep(PS8622_POWER_OFF_T17_MS);
+
+out:
+       mutex_unlock(&ps_bridge->enable_mutex);
+}
+
+static void ps8622_post_disable(struct drm_bridge *bridge)
+{
+       drm_next_bridge_post_disable(bridge);
+}
+
+static void ps8622_destroy(struct drm_bridge *bridge)
+{
+       struct ps8622_bridge *ps_bridge = bridge->driver_private;
+
+       drm_bridge_cleanup(bridge);
+       if (ps_bridge->bl)
+               backlight_device_unregister(ps_bridge->bl);
+
+       put_device(&ps_bridge->client->dev);
+}
+
+static const struct drm_bridge_funcs ps8622_bridge_funcs = {
+       .pre_enable = ps8622_pre_enable,
+       .enable = ps8622_enable,
+       .disable = ps8622_disable,
+       .post_disable = ps8622_post_disable,
+       .destroy = ps8622_destroy,
+};
+
+static const struct of_device_id ps8622_devices[] = {
+       {
+               .compatible = "parade,ps8622",
+               .data   = &ps8622_data,
+       }, {
+               .compatible = "parade,ps8625",
+               .data   = &ps8625_data,
+       }, {
+               /* end node */
+       }
+};
+
+struct drm_bridge *ps8622_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node)
+{
+       int ret;
+       const struct of_device_id *match;
+       const struct ps8622_device_data *device_data;
+       struct drm_bridge *bridge;
+       struct ps8622_bridge *ps_bridge;
+
+       node = of_find_matching_node_and_match(NULL, ps8622_devices, &match);
+       if (!node)
+               return NULL;
+
+       bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL);
+       if (!bridge) {
+               DRM_ERROR("Failed to allocate drm bridge\n");
+               return NULL;
Quoted 8 lines

drivers/gpu/drm/bridge/ps8622.c line 391

Quoted 5 lines
drivers/gpu/drm/bridge/ps8622.c new file +5 -0
+       }
+
+       ps_bridge = devm_kzalloc(dev->dev, sizeof(*ps_bridge), GFP_KERNEL);
+       if (!ps_bridge) {
+               DRM_ERROR("could not allocate ps bridge\n");

It's not necessary to log OOM errors since the mm subsystem already logs this and calls dump_stack().

Ok. Will remove it.

Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/bridge/ps8622.c new file +11 -0
+               return NULL;
+       }
+
+       mutex_init(&ps_bridge->enable_mutex);
+
+       device_data = match->data;
+       ps_bridge->client = client;
+       ps_bridge->encoder = encoder;
+       ps_bridge->bridge = bridge;
+       ps_bridge->v12 = devm_regulator_get(&client->dev, "vdd_bridge");
+       if (IS_ERR(ps_bridge->v12)) {
Quoted 8 lines

drivers/gpu/drm/bridge/ps8622.c line 407

Quoted 5 lines
drivers/gpu/drm/bridge/ps8622.c new file +5 -0
+               DRM_INFO("no 1.2v regulator found for PS8622\n");
+               ps_bridge->v12 = NULL;
+       }
+
+       ps_bridge->gpio_slp_n = of_get_named_gpio(node, "sleep-gpio", 0);

The new descriptor-based GPIO interface should be used if possible instead of the deprecated integer-based API.

Ok, will use the same.

Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/bridge/ps8622.c new file +21 -0
+       if (gpio_is_valid(ps_bridge->gpio_slp_n)) {
+               ret = devm_gpio_request_one(&client->dev, ps_bridge->gpio_slp_n,
+                                           GPIOF_OUT_INIT_HIGH,
+                                           "PS8622_SLP_N");
+               if (ret)
+                       goto err_client;
+       }
+
+       ps_bridge->gpio_rst_n = of_get_named_gpio(node, "reset-gpio", 0);
+       if (gpio_is_valid(ps_bridge->gpio_rst_n)) {
+               /*
+                * Assert the reset pin high to avoid the bridge being
+                * initialized prematurely
+                */
+               ret = devm_gpio_request_one(&client->dev, ps_bridge->gpio_rst_n,
+                                           GPIOF_OUT_INIT_HIGH,
+                                           "PS8622_RST_N");
+               if (ret)
+                       goto err_client;
+       }
+
Quoted 8 lines

drivers/gpu/drm/bridge/ps8622.c line 434

Quoted 6 lines
drivers/gpu/drm/bridge/ps8622.c new file +6 -0
+       ps_bridge->max_lane_count = device_data->max_lane_count;
+
+       if (of_property_read_u8(node, "lane-count", &ps_bridge->lane_count))
+               ps_bridge->lane_count = ps_bridge->max_lane_count;
+       else if (ps_bridge->lane_count > ps_bridge->max_lane_count) {
+               DRM_ERROR("lane-count property is too high for DP bridge\n");

DRM_INFO() instead?

Right. Will change it.

Quoted 86 lines
Quoted 86 lines
drivers/gpu/drm/bridge/ps8622.c new file +41 -0
+               ps_bridge->lane_count = ps_bridge->max_lane_count;
+       }
+
+       if (!of_find_property(node, "use-external-pwm", NULL)) {
+               ps_bridge->bl = backlight_device_register("ps8622-backlight",
+                               dev->dev, ps_bridge, &ps8622_backlight_ops,
+                               NULL);
+               if (IS_ERR(ps_bridge->bl)) {
+                       DRM_ERROR("failed to register backlight\n");
+                       ret = PTR_ERR(ps_bridge->bl);
+                       ps_bridge->bl = NULL;
+                       goto err_client;
+               }
+               ps_bridge->bl->props.max_brightness = PS8622_MAX_BRIGHTNESS;
+               ps_bridge->bl->props.brightness = PS8622_MAX_BRIGHTNESS;
+       }
+
+       ret = drm_bridge_init(dev, ps_bridge->bridge, &ps8622_bridge_funcs);
+       if (ret) {
+               DRM_ERROR("Failed to initialize bridge with drm\n");
+               goto err_backlight;
+       }
+
+       ps_bridge->bridge->driver_private = ps_bridge;
+       ps_bridge->enabled = false;
+
+       if (!encoder->bridge)
+               /* First entry in the bridge chain */
+               encoder->bridge = bridge;
+
+       return bridge;
+
+err_backlight:
+       if (ps_bridge->bl)
+               backlight_device_unregister(ps_bridge->bl);
+err_client:
+       put_device(&client->dev);
+       DRM_ERROR("device probe failed : %d\n", ret);
+       return NULL;
+}
+EXPORT_SYMBOL(ps8622_init);
include/drm/bridge/ps8622.h new file +39 -0
new file mode 100644
index 0000000..22f37b6
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#ifndef _DRM_BRIDGE_PS8622_H_
+#define _DRM_BRIDGE_PS8622_H_
+
+struct drm_device;
+struct drm_encoder;
+struct i2c_client;
+struct device_node;
+
+#ifdef CONFIG_DRM_PS8622
+
+struct drm_bridge *ps8622_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node);
+
+#else
+
+static inline struct drm_bridge *ps8622_init(struct drm_device *dev,
+                               struct drm_encoder *encoder,
+                               struct i2c_client *client,
+                               struct device_node *node)
+{
+       return -ENODEV;
+}
+
+#endif
Quoted 8 lines
Quoted 5 lines
include/drm/bridge/ps8622.h new file +2 -1
+
+#endif
--

1.7.9.5

Best regards,
Javier

Regards,
Ajay

author
#27 lore raw

PATCH v4 10/10 drm/exynos: Add ps8622 lvds bridge discovery to DP driver

In reply to Ajay Kumar

From: Rahul Sharma <[email protected]>

This patch adds ps8622 lvds bridge discovery code to the dp driver.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/exynos/exynos_dp_core.c +5 -0
index 69535f7..87eabe7 100644
@@ -31,6 +31,7 @@
 #include <drm/drm_panel.h>
 #include <drm/bridge/ptn3460.h>
 #include <drm/bridge/panel_binder.h>
+#include <drm/bridge/ps8622.h>
 
 #include "exynos_drm_drv.h"
 #include "exynos_dp_core.h"
@@ -999,6 +1000,10 @@ static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
 	if (find_bridge("nxp,ptn3460", &bridge)) {
 		bridge_chain = ptn3460_init(dp->drm_dev, encoder, bridge.client,
 								bridge.node);
+	} else if (find_bridge("parade,ps8622", &bridge) ||
+				find_bridge("parade,ps8625", &bridge)) {
+		bridge_chain = ps8622_init(dp->drm_dev, encoder, bridge.client,
+								bridge.node);
 	}
 
 	if (bridge_chain && dp->edp_panel) {
Signature · 1 line
1.7.9.5
#28 lore raw

Re: [PATCH V4 10/10] drm/exynos: Add ps8622 lvds bridge discovery to DP driver

ping.

Quoted 36 lines · Ajay Kumar

From: Rahul Sharma <[email protected]>

This patch adds ps8622 lvds bridge discovery code to the dp driver.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/exynos/exynos_dp_core.c +5 -1
index 69535f7..87eabe7 100644
@@ -31,6 +31,7 @@
 #include <drm/drm_panel.h>
 #include <drm/bridge/ptn3460.h>
 #include <drm/bridge/panel_binder.h>
+#include <drm/bridge/ps8622.h>
 
 #include "exynos_drm_drv.h"
 #include "exynos_dp_core.h"
@@ -999,6 +1000,10 @@ static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
        if (find_bridge("nxp,ptn3460", &bridge)) {
                bridge_chain = ptn3460_init(dp->drm_dev, encoder, bridge.client,
                                                                bridge.node);
+       } else if (find_bridge("parade,ps8622", &bridge) ||
+                               find_bridge("parade,ps8625", &bridge)) {
+               bridge_chain = ps8622_init(dp->drm_dev, encoder, bridge.client,
+                                                               bridge.node);
        }
 
        if (bridge_chain && dp->edp_panel) {
--

1.7.9.5

#29 lore raw
In reply to Ajay Kumar

ping.

Quoted 78 lines · Ajay Kumar

This series is based on exynos-drm-next branch of Inki Dae's tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git

I have tested this after adding few DT changes for exynos5250-snow, exynos5420-peach-pit and exynos5800-peach-pi boards.

This patchset also consolidates various inputs from the drm community regarding the bridge chaining concept:
(1) [RFC V2 0/3] drm/bridge: panel and chaining

        http://www.spinics.net/lists/linux-samsung-soc/msg30160.html
(2) [RFC V3 0/3] drm/bridge: panel and chaining
        http://www.spinics.net/lists/linux-samsung-soc/msg30507.html

Changes since V2:
-- Address comments from Jingoo Han for ps8622 driver -- Address comments from Daniel, Rob and Thierry regarding
bridge chaining
-- Address comments from Thierry regarding the names for
new drm_panel functions

Changes since V3:
-- Remove hotplug based initialization of exynos_dp -- Make exynos_dp work directly with drm_panel, remove
dependency on panel_binder
-- Minor cleanups in panel_binder and panel_lvds driver

The following patches can be divided into 2 groups:
patches 1 to 4: add drm_panel support to exynos_dp(peach-pi) patches 5 to 10: chaining of bridges and drm_panel(snow and peach-pit)

Ajay Kumar (8):
[PATCH V4 1/10] drm/exynos: Move DP setup out of hotplug workqueue [PATCH V4 2/10] drm/panel: add prepare and unprepare routines [PATCH V4 3/10] drm/exynos: dp: modify driver to support drm_panel [PATCH V4 4/10] drm/panel: Add driver for lvds/edp based panels [PATCH V4 5/10] drm/bridge: add helper functions to support bridge chain [PATCH V4 6/10] drm/bridge: Add a driver which binds drm_bridge with drm_panel [PATCH V4 7/10] drm/bridge: ptn3460: Support bridge chaining [PATCH V4 8/10] drm/exynos: dp: create bridge chain using ptn3460 and
panel_binder

Vincent Palatin (1):
[PATCH V4 9/10] drm/bridge: Add ps8622/ps8625 bridge driver

Rahul Sharma (1):
[PATCH V4 10/10] drm/exynos: Add ps8622 lvds bridge discovery to DP driver

 .../devicetree/bindings/drm/bridge/ps8622.txt      |   21 +
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 +++
 .../devicetree/bindings/video/exynos_dp.txt        |    2 +
 drivers/gpu/drm/bridge/Kconfig                     |   15 +
 drivers/gpu/drm/bridge/Makefile                    |    2 +
 drivers/gpu/drm/bridge/panel_binder.c              |  193 ++++++++
 drivers/gpu/drm/bridge/ps8622.c                    |  475 ++++++++++++++++++++
 drivers/gpu/drm/bridge/ptn3460.c                   |  136 +-----
 drivers/gpu/drm/exynos/Kconfig                     |    1 +
 drivers/gpu/drm/exynos/exynos_dp_core.c            |   87 +++-
 drivers/gpu/drm/exynos/exynos_dp_core.h            |    2 +
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 +++++++++++
 include/drm/bridge/panel_binder.h                  |   44 ++
 include/drm/bridge/ps8622.h                        |   41 ++
 include/drm/bridge/ptn3460.h                       |   15 +-
 include/drm/drm_crtc.h                             |   72 +++
 include/drm/drm_panel.h                            |   18 +
 19 files changed, 1309 insertions(+), 138 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/ps8622.txt
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/bridge/panel_binder.c
 create mode 100644 drivers/gpu/drm/bridge/ps8622.c
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
 create mode 100644 include/drm/bridge/panel_binder.h
 create mode 100644 include/drm/bridge/ps8622.h

--
1.7.9.5

maintainer
#30 lore raw

2014-06-20 17:06 GMT+09:00 Ajay kumar <[email protected]>:

Quoted 1 line

ping.

I will have a review soon but I'm afraid that I cannot have a test yet because I have no any board with panel based on eDP and LVDS so wait for until I get a board.
Otherwise, can anyone give me tested-by? and I'd happy to give me reviewed-by so that I can pick this patch series up.

Thanks,
Inki Dae

Quoted 84 lines · Ajay Kumar
Quoted 75 lines

This series is based on exynos-drm-next branch of Inki Dae's tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git

I have tested this after adding few DT changes for exynos5250-snow, exynos5420-peach-pit and exynos5800-peach-pi boards.

This patchset also consolidates various inputs from the drm community regarding the bridge chaining concept:
(1) [RFC V2 0/3] drm/bridge: panel and chaining

        http://www.spinics.net/lists/linux-samsung-soc/msg30160.html
(2) [RFC V3 0/3] drm/bridge: panel and chaining
        http://www.spinics.net/lists/linux-samsung-soc/msg30507.html

Changes since V2:
-- Address comments from Jingoo Han for ps8622 driver -- Address comments from Daniel, Rob and Thierry regarding
bridge chaining
-- Address comments from Thierry regarding the names for
new drm_panel functions

Changes since V3:
-- Remove hotplug based initialization of exynos_dp -- Make exynos_dp work directly with drm_panel, remove
dependency on panel_binder
-- Minor cleanups in panel_binder and panel_lvds driver

The following patches can be divided into 2 groups:
patches 1 to 4: add drm_panel support to exynos_dp(peach-pi) patches 5 to 10: chaining of bridges and drm_panel(snow and peach-pit)

Ajay Kumar (8):
[PATCH V4 1/10] drm/exynos: Move DP setup out of hotplug workqueue [PATCH V4 2/10] drm/panel: add prepare and unprepare routines [PATCH V4 3/10] drm/exynos: dp: modify driver to support drm_panel [PATCH V4 4/10] drm/panel: Add driver for lvds/edp based panels [PATCH V4 5/10] drm/bridge: add helper functions to support bridge chain [PATCH V4 6/10] drm/bridge: Add a driver which binds drm_bridge with drm_panel [PATCH V4 7/10] drm/bridge: ptn3460: Support bridge chaining [PATCH V4 8/10] drm/exynos: dp: create bridge chain using ptn3460 and
panel_binder

Vincent Palatin (1):
[PATCH V4 9/10] drm/bridge: Add ps8622/ps8625 bridge driver

Rahul Sharma (1):
[PATCH V4 10/10] drm/exynos: Add ps8622 lvds bridge discovery to DP driver

 .../devicetree/bindings/drm/bridge/ps8622.txt      |   21 +
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 +++
 .../devicetree/bindings/video/exynos_dp.txt        |    2 +
 drivers/gpu/drm/bridge/Kconfig                     |   15 +
 drivers/gpu/drm/bridge/Makefile                    |    2 +
 drivers/gpu/drm/bridge/panel_binder.c              |  193 ++++++++
 drivers/gpu/drm/bridge/ps8622.c                    |  475 ++++++++++++++++++++
 drivers/gpu/drm/bridge/ptn3460.c                   |  136 +-----
 drivers/gpu/drm/exynos/Kconfig                     |    1 +
 drivers/gpu/drm/exynos/exynos_dp_core.c            |   87 +++-
 drivers/gpu/drm/exynos/exynos_dp_core.h            |    2 +
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 +++++++++++
 include/drm/bridge/panel_binder.h                  |   44 ++
 include/drm/bridge/ps8622.h                        |   41 ++
 include/drm/bridge/ptn3460.h                       |   15 +-
 include/drm/drm_crtc.h                             |   72 +++
 include/drm/drm_panel.h                            |   18 +
 19 files changed, 1309 insertions(+), 138 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/ps8622.txt
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/bridge/panel_binder.c
 create mode 100644 drivers/gpu/drm/bridge/ps8622.c
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
 create mode 100644 include/drm/bridge/panel_binder.h
 create mode 100644 include/drm/bridge/ps8622.h
Quoted 3 lines

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Tested-by
#31 lore raw

Hi Ajay, Inki,

I tested this series for Exynos5420 based peach-pit board, Exynos5800 based Peach-pi board and Exynos5250 based Snow board. I verified with the chrome test environment and able to see upto Login Screen. DPMS on/off functionality and S2R is also working fine for Display. therefore:

Regards,
Rahul Sharma.

Quoted 100 lines · Inki Dae

2014-06-20 17:06 GMT+09:00 Ajay kumar <[email protected]>:

Quoted 1 line

ping.

I will have a review soon but I'm afraid that I cannot have a test yet because I have no any board with panel based on eDP and LVDS so wait for until I get a board.
Otherwise, can anyone give me tested-by? and I'd happy to give me reviewed-by so that I can pick this patch series up.

Thanks,
Inki Dae

Quoted 77 lines · Ajay Kumar
Quoted 75 lines

This series is based on exynos-drm-next branch of Inki Dae's tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git

I have tested this after adding few DT changes for exynos5250-snow, exynos5420-peach-pit and exynos5800-peach-pi boards.

This patchset also consolidates various inputs from the drm community regarding the bridge chaining concept:
(1) [RFC V2 0/3] drm/bridge: panel and chaining

        http://www.spinics.net/lists/linux-samsung-soc/msg30160.html
(2) [RFC V3 0/3] drm/bridge: panel and chaining
        http://www.spinics.net/lists/linux-samsung-soc/msg30507.html

Changes since V2:
-- Address comments from Jingoo Han for ps8622 driver -- Address comments from Daniel, Rob and Thierry regarding
bridge chaining
-- Address comments from Thierry regarding the names for
new drm_panel functions

Changes since V3:
-- Remove hotplug based initialization of exynos_dp -- Make exynos_dp work directly with drm_panel, remove
dependency on panel_binder
-- Minor cleanups in panel_binder and panel_lvds driver

The following patches can be divided into 2 groups:
patches 1 to 4: add drm_panel support to exynos_dp(peach-pi) patches 5 to 10: chaining of bridges and drm_panel(snow and peach-pit)

Ajay Kumar (8):
[PATCH V4 1/10] drm/exynos: Move DP setup out of hotplug workqueue [PATCH V4 2/10] drm/panel: add prepare and unprepare routines [PATCH V4 3/10] drm/exynos: dp: modify driver to support drm_panel [PATCH V4 4/10] drm/panel: Add driver for lvds/edp based panels [PATCH V4 5/10] drm/bridge: add helper functions to support bridge chain [PATCH V4 6/10] drm/bridge: Add a driver which binds drm_bridge with drm_panel [PATCH V4 7/10] drm/bridge: ptn3460: Support bridge chaining [PATCH V4 8/10] drm/exynos: dp: create bridge chain using ptn3460 and
panel_binder

Vincent Palatin (1):
[PATCH V4 9/10] drm/bridge: Add ps8622/ps8625 bridge driver

Rahul Sharma (1):
[PATCH V4 10/10] drm/exynos: Add ps8622 lvds bridge discovery to DP driver

 .../devicetree/bindings/drm/bridge/ps8622.txt      |   21 +
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 +++
 .../devicetree/bindings/video/exynos_dp.txt        |    2 +
 drivers/gpu/drm/bridge/Kconfig                     |   15 +
 drivers/gpu/drm/bridge/Makefile                    |    2 +
 drivers/gpu/drm/bridge/panel_binder.c              |  193 ++++++++
 drivers/gpu/drm/bridge/ps8622.c                    |  475 ++++++++++++++++++++
 drivers/gpu/drm/bridge/ptn3460.c                   |  136 +-----
 drivers/gpu/drm/exynos/Kconfig                     |    1 +
 drivers/gpu/drm/exynos/exynos_dp_core.c            |   87 +++-
 drivers/gpu/drm/exynos/exynos_dp_core.h            |    2 +
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 +++++++++++
 include/drm/bridge/panel_binder.h                  |   44 ++
 include/drm/bridge/ps8622.h                        |   41 ++
 include/drm/bridge/ptn3460.h                       |   15 +-
 include/drm/drm_crtc.h                             |   72 +++
 include/drm/drm_panel.h                            |   18 +
 19 files changed, 1309 insertions(+), 138 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/ps8622.txt
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/bridge/panel_binder.c
 create mode 100644 drivers/gpu/drm/bridge/ps8622.c
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
 create mode 100644 include/drm/bridge/panel_binder.h
 create mode 100644 include/drm/bridge/ps8622.h
Quoted 7 lines
Quoted 3 lines

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#32 lore raw

Hi Rahul,

Quoted 7 lines · Rahul Sharma

Hi Ajay, Inki,

I tested this series for Exynos5420 based peach-pit board, Exynos5800 based Peach-pi board and Exynos5250 based Snow board. I verified with the chrome test environment and able to see upto Login Screen. DPMS on/off functionality and S2R is also working fine for Display. therefore:

What tree did you apply this patches onto? I don't see S2R support for Exynos5420 or 5800 in current linux-next (e.g. there are no PMU tables present for these SoCs).

Best regards,
Tomasz

#33 lore raw

Hi Tomasz,

Quoted 11 lines · Tomasz Figa

Hi Rahul,

Quoted 7 lines · Rahul Sharma

Hi Ajay, Inki,

I tested this series for Exynos5420 based peach-pit board, Exynos5800 based Peach-pi board and Exynos5250 based Snow board. I verified with the chrome test environment and able to see upto Login Screen. DPMS on/off functionality and S2R is also working fine for Display. therefore:

Quoted 3 lines

What tree did you apply this patches onto? I don't see S2R support for Exynos5420 or 5800 in current linux-next (e.g. there are no PMU tables present for these SoCs).

I verified them with inflight patches and some private patches. All of them are available at
https://github.com/exynos-reference/kernel/tree/linux-3.16-rc1-ui-s2r

Regards,
Rahul Sharma.

Quoted 7 lines

Best regards,
Tomasz
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#34 lore raw
In reply to Inki Dae

Hello,

Quoted 12 lines · Inki Dae

2014-06-20 17:06 GMT+09:00 Ajay kumar <[email protected]>:

Quoted 1 line

ping.

I will have a review soon but I'm afraid that I cannot have a test yet because I have no any board with panel based on eDP and LVDS so wait for until I get a board.
Otherwise, can anyone give me tested-by? and I'd happy to give me reviewed-by so that I can pick this patch series up.

Thanks,
Inki Dae

I've also tested this series on an Exynos5420 Peach pit board and LVDS display was working for me.

Best regards,
Javier

Quoted 88 lines
Quoted 77 lines · Ajay Kumar
Quoted 75 lines

This series is based on exynos-drm-next branch of Inki Dae's tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git

I have tested this after adding few DT changes for exynos5250-snow, exynos5420-peach-pit and exynos5800-peach-pi boards.

This patchset also consolidates various inputs from the drm community regarding the bridge chaining concept:
(1) [RFC V2 0/3] drm/bridge: panel and chaining

        http://www.spinics.net/lists/linux-samsung-soc/msg30160.html
(2) [RFC V3 0/3] drm/bridge: panel and chaining
        http://www.spinics.net/lists/linux-samsung-soc/msg30507.html

Changes since V2:
-- Address comments from Jingoo Han for ps8622 driver -- Address comments from Daniel, Rob and Thierry regarding
bridge chaining
-- Address comments from Thierry regarding the names for
new drm_panel functions

Changes since V3:
-- Remove hotplug based initialization of exynos_dp -- Make exynos_dp work directly with drm_panel, remove
dependency on panel_binder
-- Minor cleanups in panel_binder and panel_lvds driver

The following patches can be divided into 2 groups:
patches 1 to 4: add drm_panel support to exynos_dp(peach-pi) patches 5 to 10: chaining of bridges and drm_panel(snow and peach-pit)

Ajay Kumar (8):
[PATCH V4 1/10] drm/exynos: Move DP setup out of hotplug workqueue [PATCH V4 2/10] drm/panel: add prepare and unprepare routines [PATCH V4 3/10] drm/exynos: dp: modify driver to support drm_panel [PATCH V4 4/10] drm/panel: Add driver for lvds/edp based panels [PATCH V4 5/10] drm/bridge: add helper functions to support bridge chain [PATCH V4 6/10] drm/bridge: Add a driver which binds drm_bridge with drm_panel [PATCH V4 7/10] drm/bridge: ptn3460: Support bridge chaining [PATCH V4 8/10] drm/exynos: dp: create bridge chain using ptn3460 and
panel_binder

Vincent Palatin (1):
[PATCH V4 9/10] drm/bridge: Add ps8622/ps8625 bridge driver

Rahul Sharma (1):
[PATCH V4 10/10] drm/exynos: Add ps8622 lvds bridge discovery to DP driver

 .../devicetree/bindings/drm/bridge/ps8622.txt      |   21 +
 .../devicetree/bindings/panel/panel-lvds.txt       |   50 +++
 .../devicetree/bindings/video/exynos_dp.txt        |    2 +
 drivers/gpu/drm/bridge/Kconfig                     |   15 +
 drivers/gpu/drm/bridge/Makefile                    |    2 +
 drivers/gpu/drm/bridge/panel_binder.c              |  193 ++++++++
 drivers/gpu/drm/bridge/ps8622.c                    |  475 ++++++++++++++++++++
 drivers/gpu/drm/bridge/ptn3460.c                   |  136 +-----
 drivers/gpu/drm/exynos/Kconfig                     |    1 +
 drivers/gpu/drm/exynos/exynos_dp_core.c            |   87 +++-
 drivers/gpu/drm/exynos/exynos_dp_core.h            |    2 +
 drivers/gpu/drm/panel/Kconfig                      |   10 +
 drivers/gpu/drm/panel/Makefile                     |    1 +
 drivers/gpu/drm/panel/panel-lvds.c                 |  262 +++++++++++
 include/drm/bridge/panel_binder.h                  |   44 ++
 include/drm/bridge/ps8622.h                        |   41 ++
 include/drm/bridge/ptn3460.h                       |   15 +-
 include/drm/drm_crtc.h                             |   72 +++
 include/drm/drm_panel.h                            |   18 +
 19 files changed, 1309 insertions(+), 138 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/ps8622.txt
 create mode 100644 Documentation/devicetree/bindings/panel/panel-lvds.txt
 create mode 100644 drivers/gpu/drm/bridge/panel_binder.c
 create mode 100644 drivers/gpu/drm/bridge/ps8622.c
 create mode 100644 drivers/gpu/drm/panel/panel-lvds.c
 create mode 100644 include/drm/bridge/panel_binder.h
 create mode 100644 include/drm/bridge/ps8622.h
Quoted 7 lines
Quoted 3 lines

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#35 lore raw
In reply to Ajay Kumar

Hi Ajay,

Thanks a lot for your work on this.

Am 11.06.2014 20:26, schrieb Ajay Kumar:

Quoted 5 lines

This series is based on exynos-drm-next branch of Inki Dae's tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git

I have tested this after adding few DT changes for exynos5250-snow, exynos5420-peach-pit and exynos5800-peach-pi boards.

Unfortunately this series per se does not yet fix my display issues on the Spring Chromebook. Can you share what dt changes you made for Snow?

Before, if the dp-controller dt node was present, I would get a dark screen immediately and I could ssh into the system shortly after. I worked around that by commenting the node out, which would allow me to graphically boot pretty much instantly.

With these 10 patches applied on top of my dt on top of kgene's tree, the last U-Boot screen stays visible for ~50 seconds, then the screen goes blank, and I can ssh in some time later.
If I comment out the dp-controller node again, it takes long for the kernel boot to graphically proceed but works okay then.
In both cases there's a gap of ~2900 seconds visible in dmesg.

Is presence of a framebuffer dt node or U-Boot not disabling FIMD interfering here, i.e. do I need to replace nv U-Boot? Or do I need to cherry-pick any preparatory patches from exynos-drm-next?

I'm building with LPAE, but the only two warnings in drm code I see are about a NULL cast to dma_addr_t and a %x in debug code, which I consider non-critical (but would be nice if Inki could silence them).

Regards,
Andreas

https://github.com/afaerber/linux/commits/spring-next
https://github.com/afaerber/u-boot/commits/spring

w/ dp-controller:

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 3.16.0-rc2+ ([email protected]) (gcc

version 4.
8.2 20140404 [gcc-4_8-branch revision 209122] (SUSE Linux) ) #8 SMP PREEMPT Thu
Jul 3 05:56:13 CEST 2014

[    0.000000] CPU: ARMv7 Processor [410fc0f4] revision 4 (ARMv7),
cr=30c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction
cache
[    0.000000] Machine model: Google Spring
[    0.000000] Forcing write-allocate cache policy for SMP
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] On node 0 totalpages: 523264
[    0.000000] free_area_init_node: node 0, pgdat c0659dc0, node_mem_map
ee7fc00
0
[    0.000000]   Normal zone: 1520 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 194560 pages, LIFO batch:31
[    0.000000]   HighMem zone: 2568 pages used for memmap
[    0.000000]   HighMem zone: 328704 pages, LIFO batch:31
[    0.000000] PERCPU: Embedded 7 pages/cpu @ee7bb000 s7104 r8192 d13376
u32768
[    0.000000] pcpu-alloc: s7104 r8192 d13376 u32768 alloc=8*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.
Total pag
es: 521744
[    0.000000] Kernel command line: console=tty1 root=/dev/sda3
rootfstype=ext4
rw rootwait clk_ignore_unused
[    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288
bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144
bytes)
[    0.000000] Memory: 2068780K/2093056K available (4454K kernel code,
258K rwdata, 1480K rodata, 278K init, 281K bss, 24276K reserved,
1314816K highmem)
[    0.000000] Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xffe00000   (2048 kB)
    vmalloc : 0xf0000000 - 0xff000000   ( 240 MB)
    lowmem  : 0xc0000000 - 0xef800000   ( 760 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc05d3dd4   (5936 kB)
      .init : 0xc05d4000 - 0xc0619bc0   ( 279 kB)
      .data : 0xc061a000 - 0xc065a9e0   ( 259 kB)
       .bss : 0xc065a9ec - 0xc06a1080   ( 282 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] L2C: failed to init: -19
[    0.000000] Exynos5250: clock setup completed, armclk=1700000000
[    0.000000] Architected cp15 timer(s) running at 24.00MHz (virt).
[    0.000002] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps
every 2863311519744ns
[    0.000007] Switching to timer-based delay loop
[ 2869.295699] sched_clock: 64 bits at 24MHz, resolution 41ns, wraps
every 2863311519744ns
[ 2869.295841] Console: colour dummy device 80x30
[ 2869.296042] console [tty1] enabled
[ 2869.296056] Calibrating delay loop (skipped), value calculated using
timer frequency.. 48.00 BogoMIPS (lpj=120000)
[ 2869.296073] pid_max: default: 32768 minimum: 301
[ 2869.296160] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 2869.296171] Mountpoint-cache hash table entries: 2048 (order: 1, 8192
bytes)
[ 2869.296520] CPU: Testing write buffer coherency: ok
[ 2869.296649] CPU0: update cpu_capacity 1024
[ 2869.296660] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 2869.296757] Setting up static identity map for 0x4043c0d8 - 0x4043c130
[ 2920.607940] CPU1: Booted secondary processor
[ 2920.607972] CPU1: update cpu_capacity 1024
[ 2920.607976] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[ 2920.608020] Brought up 2 CPUs

[...]

w/o dp-controller:

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 3.16.0-rc2+ ([email protected]) (gcc
version 4.8.2 20140404 [gcc-4_8-branch revision 209122] (SUSE Linux) )
#8 SMP PREEMPT Thu Jul 3 05:56:13 CEST 2014
[    0.000000] CPU: ARMv7 Processor [410fc0f4] revision 4 (ARMv7),
cr=30c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction
cache
[    0.000000] Machine model: Google Spring
[    0.000000] Forcing write-allocate cache policy for SMP
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] On node 0 totalpages: 523264
[    0.000000] free_area_init_node: node 0, pgdat c0659dc0, node_mem_map
ee7fc000
[    0.000000]   Normal zone: 1520 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 194560 pages, LIFO batch:31
[    0.000000]   HighMem zone: 2568 pages used for memmap
[    0.000000]   HighMem zone: 328704 pages, LIFO batch:31
[    0.000000] PERCPU: Embedded 7 pages/cpu @ee7bc000 s7104 r8192 d13376
u32768
[    0.000000] pcpu-alloc: s7104 r8192 d13376 u32768 alloc=8*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 521744
[    0.000000] Kernel command line: console=tty1 root=/dev/sda3
rootfstype=ext4 rw rootwait clk_ignore_unused
[    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288
bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144
bytes)
[    0.000000] Memory: 2068784K/2093056K available (4454K kernel code,
258K rwdata, 1480K rodata, 278K init, 281K bss, 24272K reserved,
1314816K highmem)
[    0.000000] Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xffe00000   (2048 kB)
    vmalloc : 0xf0000000 - 0xff000000   ( 240 MB)
    lowmem  : 0xc0000000 - 0xef800000   ( 760 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc05d3dd4   (5936 kB)
      .init : 0xc05d4000 - 0xc0619bc0   ( 279 kB)
      .data : 0xc061a000 - 0xc065a9e0   ( 259 kB)
       .bss : 0xc065a9ec - 0xc06a1080   ( 282 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] L2C: failed to init: -19
[    0.000000] Exynos5250: clock setup completed, armclk=1700000000
[    0.000000] Architected cp15 timer(s) running at 24.00MHz (virt).
[    0.000003] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps
every 2863311519744ns
[    0.000007] Switching to timer-based delay loop
[ 2870.975122] sched_clock: 64 bits at 24MHz, resolution 41ns, wraps
every 2863311519744ns
[ 2870.975267] Console: colour dummy device 80x30
[ 2870.975468] console [tty1] enabled
[ 2870.975482] Calibrating delay loop (skipped), value calculated using
timer frequency.. 48.00 BogoMIPS (lpj=120000)
[ 2870.975499] pid_max: default: 32768 minimum: 301
[ 2870.975587] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 2870.975598] Mountpoint-cache hash table entries: 2048 (order: 1, 8192
bytes)
[ 2870.975950] CPU: Testing write buffer coherency: ok
[ 2870.976081] CPU0: update cpu_capacity 1024
[ 2870.976092] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 2870.976188] Setting up static identity map for 0x4043c0d8 - 0x4043c130
[ 2920.607946] CPU1: Booted secondary processor
[ 2920.607979] CPU1: update cpu_capacity 1024
[ 2920.607983] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[ 2920.608027] Brought up 2 CPUs

[...]

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#36 lore raw

Hi Andreas,

Quoted 34 lines · Andreas Färber

Hi Ajay,

Thanks a lot for your work on this.

Am 11.06.2014 20:26, schrieb Ajay Kumar:

Quoted 5 lines

This series is based on exynos-drm-next branch of Inki Dae's tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git

I have tested this after adding few DT changes for exynos5250-snow, exynos5420-peach-pit and exynos5800-peach-pi boards.

Unfortunately this series per se does not yet fix my display issues on the Spring Chromebook. Can you share what dt changes you made for Snow?

Before, if the dp-controller dt node was present, I would get a dark screen immediately and I could ssh into the system shortly after. I worked around that by commenting the node out, which would allow me to graphically boot pretty much instantly.

With these 10 patches applied on top of my dt on top of kgene's tree, the last U-Boot screen stays visible for ~50 seconds, then the screen goes blank, and I can ssh in some time later.
If I comment out the dp-controller node again, it takes long for the kernel boot to graphically proceed but works okay then.
In both cases there's a gap of ~2900 seconds visible in dmesg.

Is presence of a framebuffer dt node or U-Boot not disabling FIMD interfering here, i.e. do I need to replace nv U-Boot? Or do I need to cherry-pick any preparatory patches from exynos-drm-next?

I'm building with LPAE, but the only two warnings in drm code I see are about a NULL cast to dma_addr_t and a %x in debug code, which I consider non-critical (but would be nice if Inki could silence them).

Quoted 5 lines

Regards,
Andreas

https://github.com/afaerber/linux/commits/spring-next
https://github.com/afaerber/u-boot/commits/spring

You need to add bridge chip node and panel node to use my patch series. Also, to support that you need to enable tps65090 regulator on spring.

I have attached a patch which adds the bridge chip node and panel node. Also, I have attached a sample config which I used to compile the kernel.

Doug can help you in adding changes required for tps65090.

Regards,
Ajay Kumar

Quoted 161 lines

w/ dp-controller:

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 3.16.0-rc2+ ([email protected]) (gcc

version 4.
8.2 20140404 [gcc-4_8-branch revision 209122] (SUSE Linux) ) #8 SMP PREEMPT Thu
Jul 3 05:56:13 CEST 2014

[    0.000000] CPU: ARMv7 Processor [410fc0f4] revision 4 (ARMv7),
cr=30c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction
cache
[    0.000000] Machine model: Google Spring
[    0.000000] Forcing write-allocate cache policy for SMP
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] On node 0 totalpages: 523264
[    0.000000] free_area_init_node: node 0, pgdat c0659dc0, node_mem_map
ee7fc00
0
[    0.000000]   Normal zone: 1520 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 194560 pages, LIFO batch:31
[    0.000000]   HighMem zone: 2568 pages used for memmap
[    0.000000]   HighMem zone: 328704 pages, LIFO batch:31
[    0.000000] PERCPU: Embedded 7 pages/cpu @ee7bb000 s7104 r8192 d13376
u32768
[    0.000000] pcpu-alloc: s7104 r8192 d13376 u32768 alloc=8*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.
Total pag
es: 521744
[    0.000000] Kernel command line: console=tty1 root=/dev/sda3
rootfstype=ext4
rw rootwait clk_ignore_unused
[    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288
bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144
bytes)
[    0.000000] Memory: 2068780K/2093056K available (4454K kernel code,
258K rwdata, 1480K rodata, 278K init, 281K bss, 24276K reserved,
1314816K highmem)
[    0.000000] Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xffe00000   (2048 kB)
    vmalloc : 0xf0000000 - 0xff000000   ( 240 MB)
    lowmem  : 0xc0000000 - 0xef800000   ( 760 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc05d3dd4   (5936 kB)
      .init : 0xc05d4000 - 0xc0619bc0   ( 279 kB)
      .data : 0xc061a000 - 0xc065a9e0   ( 259 kB)
       .bss : 0xc065a9ec - 0xc06a1080   ( 282 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] L2C: failed to init: -19
[    0.000000] Exynos5250: clock setup completed, armclk=1700000000
[    0.000000] Architected cp15 timer(s) running at 24.00MHz (virt).
[    0.000002] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps
every 2863311519744ns
[    0.000007] Switching to timer-based delay loop
[ 2869.295699] sched_clock: 64 bits at 24MHz, resolution 41ns, wraps
every 2863311519744ns
[ 2869.295841] Console: colour dummy device 80x30
[ 2869.296042] console [tty1] enabled
[ 2869.296056] Calibrating delay loop (skipped), value calculated using
timer frequency.. 48.00 BogoMIPS (lpj=120000)
[ 2869.296073] pid_max: default: 32768 minimum: 301
[ 2869.296160] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 2869.296171] Mountpoint-cache hash table entries: 2048 (order: 1, 8192
bytes)
[ 2869.296520] CPU: Testing write buffer coherency: ok
[ 2869.296649] CPU0: update cpu_capacity 1024
[ 2869.296660] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 2869.296757] Setting up static identity map for 0x4043c0d8 - 0x4043c130
[ 2920.607940] CPU1: Booted secondary processor
[ 2920.607972] CPU1: update cpu_capacity 1024
[ 2920.607976] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[ 2920.608020] Brought up 2 CPUs

[...]

w/o dp-controller:

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 3.16.0-rc2+ ([email protected]) (gcc
version 4.8.2 20140404 [gcc-4_8-branch revision 209122] (SUSE Linux) )
#8 SMP PREEMPT Thu Jul 3 05:56:13 CEST 2014
[    0.000000] CPU: ARMv7 Processor [410fc0f4] revision 4 (ARMv7),
cr=30c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction
cache
[    0.000000] Machine model: Google Spring
[    0.000000] Forcing write-allocate cache policy for SMP
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] On node 0 totalpages: 523264
[    0.000000] free_area_init_node: node 0, pgdat c0659dc0, node_mem_map
ee7fc000
[    0.000000]   Normal zone: 1520 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 194560 pages, LIFO batch:31
[    0.000000]   HighMem zone: 2568 pages used for memmap
[    0.000000]   HighMem zone: 328704 pages, LIFO batch:31
[    0.000000] PERCPU: Embedded 7 pages/cpu @ee7bc000 s7104 r8192 d13376
u32768
[    0.000000] pcpu-alloc: s7104 r8192 d13376 u32768 alloc=8*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 521744
[    0.000000] Kernel command line: console=tty1 root=/dev/sda3
rootfstype=ext4 rw rootwait clk_ignore_unused
[    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288
bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144
bytes)
[    0.000000] Memory: 2068784K/2093056K available (4454K kernel code,
258K rwdata, 1480K rodata, 278K init, 281K bss, 24272K reserved,
1314816K highmem)
[    0.000000] Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xffe00000   (2048 kB)
    vmalloc : 0xf0000000 - 0xff000000   ( 240 MB)
    lowmem  : 0xc0000000 - 0xef800000   ( 760 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc05d3dd4   (5936 kB)
      .init : 0xc05d4000 - 0xc0619bc0   ( 279 kB)
      .data : 0xc061a000 - 0xc065a9e0   ( 259 kB)
       .bss : 0xc065a9ec - 0xc06a1080   ( 282 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] L2C: failed to init: -19
[    0.000000] Exynos5250: clock setup completed, armclk=1700000000
[    0.000000] Architected cp15 timer(s) running at 24.00MHz (virt).
[    0.000003] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps
every 2863311519744ns
[    0.000007] Switching to timer-based delay loop
[ 2870.975122] sched_clock: 64 bits at 24MHz, resolution 41ns, wraps
every 2863311519744ns
[ 2870.975267] Console: colour dummy device 80x30
[ 2870.975468] console [tty1] enabled
[ 2870.975482] Calibrating delay loop (skipped), value calculated using
timer frequency.. 48.00 BogoMIPS (lpj=120000)
[ 2870.975499] pid_max: default: 32768 minimum: 301
[ 2870.975587] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 2870.975598] Mountpoint-cache hash table entries: 2048 (order: 1, 8192
bytes)
[ 2870.975950] CPU: Testing write buffer coherency: ok
[ 2870.976081] CPU0: update cpu_capacity 1024
[ 2870.976092] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 2870.976188] Setting up static identity map for 0x4043c0d8 - 0x4043c130
[ 2920.607946] CPU1: Booted secondary processor
[ 2920.607979] CPU1: update cpu_capacity 1024
[ 2920.607983] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[ 2920.608027] Brought up 2 CPUs
Quoted 5 lines

[...]

--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

From 4b0b01c8c52229b09b065d47de005304917d7f44 Mon Sep 17 00:00:00 2001
From: Ajay Kumar <[email protected]>
Date: Thu, 3 Jul 2014 20:15:59 +0530
Subject: [PATCH] ARM: dts: Add ps8622 and panel node for spring

---
 arch/arm/boot/dts/exynos5250-spring.dts | 57 ++++++++++++++++++++++++---------
 1 file changed, 42 insertions(+), 15 deletions(-)
arch/arm/boot/dts/exynos5250-spring.dts +42 -15
index 92efe36..e07fbaa 100644
@@ -64,23 +64,13 @@
 		vdd_pll-supply = <&s5m_ldo8_reg>;
 	};
 
-/*
-	dp-controller@145B0000 {
-		status = "okay";
-		pinctrl-names = "default";
-		pinctrl-0 = <&dp_hpd>;
-		samsung,color-space = <0>;
-		samsung,dynamic-range = <0>;
-		samsung,ycbcr-coeff = <0>;
-		samsung,color-depth = <1>;
-		samsung,link-rate = <0x0a>;
-		samsung,lane-count = <1>;
-		samsung,hpd-gpio = <&gpc3 0 0>;
+	panel_lvds: panel-lvds {
+		compatible = "panel-lvds";
 
 		display-timings {
-			native-mode = <&timing1>;
+			native-mode = <&timing0>;
 
-			timing1: timing@1 {
+			timing0: timing@0 {
 				clock-frequency = <70589280>;
 				hactive = <1366>;
 				vactive = <768>;
@@ -93,7 +83,20 @@
 			};
 		};
 	};
-*/
+
+	dp-controller@145B0000 {
+		status = "okay";
+		pinctrl-names = "default";
+		pinctrl-0 = <&dp_hpd_gpio>;
+		samsung,color-space = <0>;
+		samsung,dynamic-range = <0>;
+		samsung,ycbcr-coeff = <0>;
+		samsung,color-depth = <1>;
+		samsung,link-rate = <0x0a>;
+		samsung,lane-count = <1>;
+		samsung,hpd-gpio = <&gpc3 0 0>;
+		edp-panel = <&panel_lvds>;
+	};
 
 	fixed-rate-clocks {
 		xxti {
@@ -405,6 +408,16 @@
 	status = "okay";
 	samsung,i2c-sda-delay = <100>;
 	samsung,i2c-max-bus-freq = <66000>;
+
+	ps8622-bridge@20 {
+		compatible = "parade,ps8622";
+		reg = <0x08>;
+		sleep-gpio = <&gpc3 6 0>;
+		reset-gpio = <&gpc3 1 0>;
+		lane-count = <1>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&ps8622_gpios>;
+	};
 };
 
 &i2c_8 {
@@ -468,6 +481,20 @@
 		samsung,pin-pud = <0>;
 	};
 
+	dp_hpd_gpio: dp-hpd {
+		samsung,pins = "gpc3-0";
+		samsung,pin-function = <0>;
+		samsung,pin-pud = <3>;
+		samsung,pin-drv = <0>;
+	};
+
+	ps8622_gpios: ps8622-gpios {
+		samsung,pins = "gpc3-1", "gpc3-6";
+		samsung,pin-function = <1>;
+		samsung,pin-pud = <0>;
+		samsung,pin-drv = <0>;
+	};
+
 	s5m8767_dvs: s5m8767-dvs {
 		samsung,pins = "gpd1-0", "gpd1-1", "gpd1-2";
 		samsung,pin-function = <0>;
Signature · 1 line
1.8.3.2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#37 lore raw

Hi Ajay,

Am 03.07.2014 16:55, schrieb Ajay kumar:

Quoted 22 lines · Andreas Färber
Quoted 21 lines

Am 11.06.2014 20:26, schrieb Ajay Kumar:

Quoted 5 lines

This series is based on exynos-drm-next branch of Inki Dae's tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git

I have tested this after adding few DT changes for exynos5250-snow, exynos5420-peach-pit and exynos5800-peach-pi boards.

Unfortunately this series per se does not yet fix my display issues on the Spring Chromebook. Can you share what dt changes you made for Snow?

Before, if the dp-controller dt node was present, I would get a dark screen immediately and I could ssh into the system shortly after. I worked around that by commenting the node out, which would allow me to graphically boot pretty much instantly.

With these 10 patches applied on top of my dt on top of kgene's tree, the last U-Boot screen stays visible for ~50 seconds, then the screen goes blank, and I can ssh in some time later.
If I comment out the dp-controller node again, it takes long for the kernel boot to graphically proceed but works okay then.
In both cases there's a gap of ~2900 seconds visible in dmesg.

[...]

Quoted 6 lines
Quoted 2 lines

https://github.com/afaerber/linux/commits/spring-next
https://github.com/afaerber/u-boot/commits/spring

You need to add bridge chip node and panel node to use my patch series. Also, to support that you need to enable tps65090 regulator on spring.

I have attached a patch which adds the bridge chip node and panel node.

Wow, that's more help than I expected! Many thanks.

I'll strip down dp-controller accordingly for my v2.

Your dt changes level again with my commenting out dp-controller. So I take it, the minute-long delay is regulator-induced somehow.

Quoted 1 line

Also, I have attached a sample config which I used to compile the kernel.

I simply answered y to all your new options. :)

Quoted 1 line

Doug can help you in adding changes required for tps65090.

Hm, Doug had pointed out an issue with tps65090 in my v1, so I dropped
it: https://patchwork.kernel.org/patch/4397321/

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#38 lore raw

Andreas,

Quoted 4 lines · Andreas Färber
Quoted 1 line

Doug can help you in adding changes required for tps65090.

Hm, Doug had pointed out an issue with tps65090 in my v1, so I dropped
it: https://patchwork.kernel.org/patch/4397321/

tps65090 on Spring is nowhere near obvious due to the EC commands that were available during the Spring timeframe. See
http://crbug.com/391797 for some details.

-Doug

#39 lore raw
In reply to Andreas Färber

Hi,

Quoted 6 lines · Andreas Färber

With these 10 patches applied on top of my dt on top of kgene's tree, the last U-Boot screen stays visible for ~50 seconds, then the screen goes blank, and I can ssh in some time later.
If I comment out the dp-controller node again, it takes long for the kernel boot to graphically proceed but works okay then.
In both cases there's a gap of ~2900 seconds visible in dmesg.

I would have imagined that this was fixed by (1d80415 clocksource:
exynos_mct: Don't reset the counter during boot and resume).

...that should also fix a long delay at bootup (delay was based on how much time you spent in U-Boot).

#40 lore raw

Hi Daniel, Thierry and Rob,

Currently, the following boards are working fine with the bridge chip series:
- snow
- spring
- peach_pit
- peach_pi
And, I did change my original patchset based on your comments here:
(1) [RFC V2 0/3] drm/bridge: panel and chaining

        http://www.spinics.net/lists/linux-samsung-soc/msg30160.html
(2) [RFC V3 0/3] drm/bridge: panel and chaining
        http://www.spinics.net/lists/linux-samsung-soc/msg30507.html

If you think this is not the right way of doing it, please come forward with more suggestions, or kindly ACK it.
I am just wondering how long can I keep waiting for comments?

Regards,
Ajay

#41 lore raw

Inki,

You have acks, and you have the tested-bys you requested. Can you please pick this up quickly so that we can have graphics working with an upstream kernel on chromebooks?

Dave, if Inki keeps dragging his feet like this can you please apply this series directly? These delays are ridiculous and it's hurting forward progress on the platform as a whole.

Thanks,

-Olof

Quoted 23 lines · Ajay kumar

Hi Daniel, Thierry and Rob,

Currently, the following boards are working fine with the bridge chip series:
- snow
- spring
- peach_pit
- peach_pi
And, I did change my original patchset based on your comments here:
(1) [RFC V2 0/3] drm/bridge: panel and chaining

        http://www.spinics.net/lists/linux-samsung-soc/msg30160.html
(2) [RFC V3 0/3] drm/bridge: panel and chaining
        http://www.spinics.net/lists/linux-samsung-soc/msg30507.html

If you think this is not the right way of doing it, please come forward with more suggestions, or kindly ACK it.
I am just wondering how long can I keep waiting for comments?

Regards,
Ajay
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#42 lore raw
Quoted 10 lines · Olof Johansson

Inki,

You have acks, and you have the tested-bys you requested. Can you please pick this up quickly so that we can have graphics working with an upstream kernel on chromebooks?

Dave, if Inki keeps dragging his feet like this can you please apply this series directly? These delays are ridiculous and it's hurting forward progress on the platform as a whole.

Hi,

I am not really dragging. We need to wait for ACKs of other maintainers:
please know that this patch series includes non-Exynos part.

For this, Ajay requested already it to Daniel, Thierry, and Rob a week ago. If there are no any ACKs from them until this week, I plan to pick them up.

So please wait.

Thanks,
Inki Dae

Quoted 31 lines

Thanks,

-Olof

Quoted 23 lines · Ajay kumar

Hi Daniel, Thierry and Rob,

Currently, the following boards are working fine with the bridge chip series:
- snow
- spring
- peach_pit
- peach_pi
And, I did change my original patchset based on your comments here:
(1) [RFC V2 0/3] drm/bridge: panel and chaining

        http://www.spinics.net/lists/linux-samsung-soc/msg30160.html
(2) [RFC V3 0/3] drm/bridge: panel and chaining
        http://www.spinics.net/lists/linux-samsung-soc/msg30507.html

If you think this is not the right way of doing it, please come forward with more suggestions, or kindly ACK it.
I am just wondering how long can I keep waiting for comments?

Regards,
Ajay
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel