drm/bridge: ti-sn65dsi86: Poll for training complete
authorSean Paul <seanpaul@chromium.org>
Mon, 13 Aug 2018 21:30:45 +0000 (17:30 -0400)
committerSean Paul <seanpaul@chromium.org>
Tue, 14 Aug 2018 18:06:13 +0000 (14:06 -0400)
Instead of just waiting 20ms for training to complete, actually poll the
status to ensure training is finished.

Changes in v3:
- Added to the set

Cc: Sandeep Panda <spanda@codeaurora.org>
Reviewed-by: Sandeep Panda <spanda@codeaurora.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20180813213058.184821-7-sean@poorly.run
drivers/gpu/drm/bridge/ti-sn65dsi86.c

index f02bdedae1e5ede0eaa02344c5678b5ec5aab985..d3e27e52ea7597686fe1b46cd8d9719fee3e0da3 100644 (file)
@@ -493,7 +493,17 @@ static void ti_sn_bridge_enable(struct drm_bridge *bridge)
 
        /* Semi auto link training mode */
        regmap_write(pdata->regmap, SN_ML_TX_MODE_REG, 0x0A);
-       msleep(20); /* 20ms delay recommended by spec */
+       ret = regmap_read_poll_timeout(pdata->regmap, SN_ML_TX_MODE_REG, val,
+                                      val == ML_TX_MAIN_LINK_OFF ||
+                                      val == ML_TX_NORMAL_MODE, 1000,
+                                      500 * 1000);
+       if (ret) {
+               DRM_ERROR("Training complete polling failed (%d)\n", ret);
+               return;
+       } else if (val == ML_TX_MAIN_LINK_OFF) {
+               DRM_ERROR("Link training failed, link is off\n");
+               return;
+       }
 
        /* config video parameters */
        ti_sn_bridge_set_video_timings(pdata);