drm/exynos: dp: support drm_bridge
authorAjay Kumar <ajaykumar.rs@samsung.com>
Tue, 20 Jan 2015 16:38:46 +0000 (22:08 +0530)
committerThierry Reding <treding@nvidia.com>
Wed, 28 Jan 2015 07:47:29 +0000 (08:47 +0100)
Modify driver to support drm_bridge.

Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Tested-by: Rahul Sharma <rahul.sharma@samsung.com>
Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Tested-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Tested-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Documentation/devicetree/bindings/video/exynos_dp.txt
drivers/gpu/drm/exynos/exynos_dp_core.c
drivers/gpu/drm/exynos/exynos_dp_core.h

index 53dbccfa80caf7f0d1650b15c85d12afd2be518f..7a3a9cdb86ab2877c3f5df402fc1ea0a5d64f01c 100644 (file)
@@ -66,6 +66,10 @@ Optional properties for dp-controller:
                Hotplug detect GPIO.
                        Indicates which GPIO should be used for hotplug
                        detection
+       -video interfaces: Device node can contain video interface port
+                           nodes according to [1].
+
+[1]: Documentation/devicetree/bindings/media/video-interfaces.txt
 
 Example:
 
@@ -105,4 +109,12 @@ Board Specific portion:
                                vsync-len = <6>;
                        };
                };
+
+               ports {
+                       port@0 {
+                               dp_out: endpoint {
+                                       remote-endpoint = <&bridge_in>;
+                               };
+                       };
+               };
        };
index 27e3d272ca2d363ac871ce6b21dd86992e88846e..46f149737bc8d44926e06a7e1a11d34a9ae0fc46 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/interrupt.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
+#include <linux/of_graph.h>
 #include <linux/gpio.h>
 #include <linux/component.h>
 #include <linux/phy/phy.h>
@@ -994,9 +995,19 @@ static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
 };
 
 /* 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)
 {
+       int ret;
+
+       encoder->bridge = dp->bridge;
+       dp->bridge->encoder = encoder;
+       ret = drm_bridge_attach(encoder->dev, dp->bridge);
+       if (ret) {
+               DRM_ERROR("Failed to attach bridge to drm\n");
+               return ret;
+       }
+
        return 0;
 }
 
@@ -1010,9 +1021,11 @@ 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);
-       if (ret)
-               return 0;
+       if (dp->bridge) {
+               ret = exynos_drm_attach_lcd_bridge(dp, encoder);
+               if (!ret)
+                       return 0;
+       }
 
        connector->polled = DRM_CONNECTOR_POLL_HPD;
 
@@ -1219,7 +1232,7 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
                }
        }
 
-       if (!dp->panel) {
+       if (!dp->panel && !dp->bridge) {
                ret = exynos_dp_dt_parse_panel(dp);
                if (ret)
                        return ret;
@@ -1303,7 +1316,7 @@ static const struct component_ops exynos_dp_ops = {
 static int exynos_dp_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *panel_node;
+       struct device_node *panel_node, *bridge_node, *endpoint;
        struct exynos_dp_device *dp;
        int ret;
 
@@ -1329,6 +1342,18 @@ static int exynos_dp_probe(struct platform_device *pdev)
                        return -EPROBE_DEFER;
        }
 
+       endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+       if (endpoint) {
+               bridge_node = of_graph_get_remote_port_parent(endpoint);
+               if (bridge_node) {
+                       dp->bridge = of_drm_find_bridge(bridge_node);
+                       of_node_put(bridge_node);
+                       if (!dp->bridge)
+                               return -EPROBE_DEFER;
+               } else
+                       return -EPROBE_DEFER;
+       }
+
        ret = component_add(&pdev->dev, &exynos_dp_ops);
        if (ret)
                exynos_drm_component_del(&pdev->dev,
index 164f171168e7ef175d9d726e1f1ca231c8da2e49..a4e799679669420c3cb6d6920beee1c43684889d 100644 (file)
@@ -153,6 +153,7 @@ struct exynos_dp_device {
        struct drm_connector    connector;
        struct drm_encoder      *encoder;
        struct drm_panel        *panel;
+       struct drm_bridge       *bridge;
        struct clk              *clock;
        unsigned int            irq;
        void __iomem            *reg_base;