drm/vc4: Fix change to find_panel in the dsi_attach func
authorHoegeun Kwon <hoegeun.kwon@samsung.com>
Thu, 4 Jul 2019 08:40:58 +0000 (17:40 +0900)
committerJunghoon Kim <jhoon20.kim@samsung.com>
Thu, 2 Apr 2020 04:09:07 +0000 (13:09 +0900)
There is a problem that crtc does not bind while continuously
requesting EPROBE_DEFER, if dsi_bind does not successfully bind.
We need to change the part of find_panel in bind to dsi_attach
function.

Change-Id: Ifce518f047f496079eb8fbe112dabbd9bc7488bb
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
drivers/gpu/drm/vc4/vc4_dsi.c

index 79972da..980224f 100644 (file)
@@ -1306,6 +1306,8 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host,
                               struct mipi_dsi_device *device)
 {
        struct vc4_dsi *dsi = host_to_dsi(host);
+       struct drm_panel *panel;
+       int ret;
 
        dsi->lanes = device->lanes;
        dsi->channel = device->channel;
@@ -1340,6 +1342,28 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host,
                return 0;
        }
 
+       ret = drm_of_find_panel_or_bridge(dsi->pdev->dev.of_node, 0, 0,
+                       &panel, &dsi->bridge);
+       if (ret) {
+               /* If the bridge or panel pointed by dev->of_node is not
+                * enabled, just return 0 here so that we don't prevent the DRM
+                * dev from being registered. Of course that means the DSI
+                * encoder won't be exposed, but that's not a problem since
+                * nothing is connected to it.
+                */
+               if (ret == -ENODEV)
+                       return 0;
+
+               return ret;
+       }
+
+       if (panel) {
+               dsi->bridge = devm_drm_panel_bridge_add(&dsi->pdev->dev, panel,
+                               DRM_MODE_CONNECTOR_DSI);
+               if (IS_ERR(dsi->bridge))
+                       return PTR_ERR(dsi->bridge);
+       }
+
        return 0;
 }
 
@@ -1510,7 +1534,6 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
        struct vc4_dev *vc4 = to_vc4_dev(drm);
        struct vc4_dsi *dsi = dev_get_drvdata(dev);
        struct vc4_dsi_encoder *vc4_dsi_encoder;
-       struct drm_panel *panel;
        const struct of_device_id *match;
        dma_cap_mask_t dma_mask;
        int ret;
@@ -1620,30 +1643,6 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
                goto rel_dma_exit;
        }
 
-       ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
-                                         &panel, &dsi->bridge);
-       if (ret) {
-               /* If the bridge or panel pointed by dev->of_node is not
-                * enabled, just return 0 here so that we don't prevent the DRM
-                * dev from being registered. Of course that means the DSI
-                * encoder won't be exposed, but that's not a problem since
-                * nothing is connected to it.
-                */
-               if (ret == -ENODEV)
-                       return 0;
-
-               goto rel_dma_exit;
-       }
-
-       if (panel) {
-               dsi->bridge = devm_drm_panel_bridge_add(dev, panel,
-                                                       DRM_MODE_CONNECTOR_DSI);
-               if (IS_ERR(dsi->bridge)){
-                       ret = PTR_ERR(dsi->bridge);
-                       goto rel_dma_exit;
-               }
-       }
-
        /* The esc clock rate is supposed to always be 100Mhz. */
        ret = clk_set_rate(dsi->escape_clock, 100 * 1000000);
        if (ret) {
@@ -1662,10 +1661,12 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
                         DRM_MODE_ENCODER_DSI, NULL);
        drm_encoder_helper_add(dsi->encoder, &vc4_dsi_encoder_helper_funcs);
 
-       ret = drm_bridge_attach(dsi->encoder, dsi->bridge, NULL);
-       if (ret) {
-               dev_err(dev, "bridge attach failed: %d\n", ret);
-               goto rel_dma_exit;
+       if (dsi->bridge) {
+               ret = drm_bridge_attach(dsi->encoder, dsi->bridge, NULL);
+               if (ret) {
+                       dev_err(dev, "bridge attach failed: %d\n", ret);
+                       goto rel_dma_exit;
+               }
        }
        /* Disable the atomic helper calls into the bridge.  We
         * manually call the bridge pre_enable / enable / etc. calls