Commit 8a335736 authored by zain wang's avatar zain wang Committed by Andrzej Hajda

drm/bridge: analogix_dp: Retry bridge enable when it failed

When we enable bridge failed, we have to retry it, otherwise we would get
the abnormal display.

Cc: Stéphane Marchesin <marcheu@chromium.org>
Signed-off-by: default avatarzain wang <wzz@rock-chips.com>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Signed-off-by: default avatarThierry Escande <thierry.escande@collabora.com>
Reviewed-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180423105003.9004-5-enric.balletbo@collabora.com
parent 7ba8fb57
...@@ -43,8 +43,10 @@ struct bridge_init { ...@@ -43,8 +43,10 @@ struct bridge_init {
struct device_node *node; struct device_node *node;
}; };
static void analogix_dp_init_dp(struct analogix_dp_device *dp) static int analogix_dp_init_dp(struct analogix_dp_device *dp)
{ {
int ret;
analogix_dp_reset(dp); analogix_dp_reset(dp);
analogix_dp_swreset(dp); analogix_dp_swreset(dp);
...@@ -56,10 +58,13 @@ static void analogix_dp_init_dp(struct analogix_dp_device *dp) ...@@ -56,10 +58,13 @@ static void analogix_dp_init_dp(struct analogix_dp_device *dp)
analogix_dp_enable_sw_function(dp); analogix_dp_enable_sw_function(dp);
analogix_dp_config_interrupt(dp); analogix_dp_config_interrupt(dp);
analogix_dp_init_analog_func(dp); ret = analogix_dp_init_analog_func(dp);
if (ret)
return ret;
analogix_dp_init_hpd(dp); analogix_dp_init_hpd(dp);
analogix_dp_init_aux(dp); analogix_dp_init_aux(dp);
return 0;
} }
static int analogix_dp_detect_hpd(struct analogix_dp_device *dp) static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)
...@@ -918,7 +923,7 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg) ...@@ -918,7 +923,7 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static void analogix_dp_commit(struct analogix_dp_device *dp) static int analogix_dp_commit(struct analogix_dp_device *dp)
{ {
int ret; int ret;
...@@ -928,11 +933,10 @@ static void analogix_dp_commit(struct analogix_dp_device *dp) ...@@ -928,11 +933,10 @@ static void analogix_dp_commit(struct analogix_dp_device *dp)
DRM_ERROR("failed to disable the panel\n"); DRM_ERROR("failed to disable the panel\n");
} }
ret = readx_poll_timeout(analogix_dp_train_link, dp, ret, !ret, 100, ret = analogix_dp_train_link(dp);
DP_TIMEOUT_TRAINING_US * 5);
if (ret) { if (ret) {
dev_err(dp->dev, "unable to do link train, ret=%d\n", ret); dev_err(dp->dev, "unable to do link train, ret=%d\n", ret);
return; return ret;
} }
analogix_dp_enable_scramble(dp, 1); analogix_dp_enable_scramble(dp, 1);
...@@ -953,6 +957,7 @@ static void analogix_dp_commit(struct analogix_dp_device *dp) ...@@ -953,6 +957,7 @@ static void analogix_dp_commit(struct analogix_dp_device *dp)
dp->psr_enable = analogix_dp_detect_sink_psr(dp); dp->psr_enable = analogix_dp_detect_sink_psr(dp);
if (dp->psr_enable) if (dp->psr_enable)
analogix_dp_enable_sink_psr(dp); analogix_dp_enable_sink_psr(dp);
return 0;
} }
/* /*
...@@ -1149,12 +1154,9 @@ static void analogix_dp_bridge_pre_enable(struct drm_bridge *bridge) ...@@ -1149,12 +1154,9 @@ static void analogix_dp_bridge_pre_enable(struct drm_bridge *bridge)
DRM_ERROR("failed to setup the panel ret = %d\n", ret); DRM_ERROR("failed to setup the panel ret = %d\n", ret);
} }
static void analogix_dp_bridge_enable(struct drm_bridge *bridge) static int analogix_dp_set_bridge(struct analogix_dp_device *dp)
{ {
struct analogix_dp_device *dp = bridge->driver_private; int ret;
if (dp->dpms_mode == DRM_MODE_DPMS_ON)
return;
pm_runtime_get_sync(dp->dev); pm_runtime_get_sync(dp->dev);
...@@ -1162,11 +1164,46 @@ static void analogix_dp_bridge_enable(struct drm_bridge *bridge) ...@@ -1162,11 +1164,46 @@ static void analogix_dp_bridge_enable(struct drm_bridge *bridge)
dp->plat_data->power_on(dp->plat_data); dp->plat_data->power_on(dp->plat_data);
phy_power_on(dp->phy); phy_power_on(dp->phy);
analogix_dp_init_dp(dp);
ret = analogix_dp_init_dp(dp);
if (ret)
goto out_dp_init;
ret = analogix_dp_commit(dp);
if (ret)
goto out_dp_init;
enable_irq(dp->irq); enable_irq(dp->irq);
analogix_dp_commit(dp); return 0;
dp->dpms_mode = DRM_MODE_DPMS_ON; out_dp_init:
phy_power_off(dp->phy);
if (dp->plat_data->power_off)
dp->plat_data->power_off(dp->plat_data);
pm_runtime_put_sync(dp->dev);
return ret;
}
static void analogix_dp_bridge_enable(struct drm_bridge *bridge)
{
struct analogix_dp_device *dp = bridge->driver_private;
int timeout_loop = 0;
if (dp->dpms_mode == DRM_MODE_DPMS_ON)
return;
while (timeout_loop < MAX_PLL_LOCK_LOOP) {
if (analogix_dp_set_bridge(dp) == 0) {
dp->dpms_mode = DRM_MODE_DPMS_ON;
return;
}
dev_err(dp->dev, "failed to set bridge, retry: %d\n",
timeout_loop);
timeout_loop++;
usleep_range(10, 11);
}
dev_err(dp->dev, "too many times retry set bridge, give it up\n");
} }
static void analogix_dp_bridge_disable(struct drm_bridge *bridge) static void analogix_dp_bridge_disable(struct drm_bridge *bridge)
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#define DP_TIMEOUT_LOOP_COUNT 100 #define DP_TIMEOUT_LOOP_COUNT 100
#define MAX_CR_LOOP 5 #define MAX_CR_LOOP 5
#define MAX_EQ_LOOP 5 #define MAX_EQ_LOOP 5
#define MAX_PLL_LOCK_LOOP 5
/* Training takes 22ms if AUX channel comm fails. Use this as retry interval */ /* Training takes 22ms if AUX channel comm fails. Use this as retry interval */
#define DP_TIMEOUT_TRAINING_US 22000 #define DP_TIMEOUT_TRAINING_US 22000
...@@ -197,7 +198,7 @@ void analogix_dp_set_pll_power_down(struct analogix_dp_device *dp, bool enable); ...@@ -197,7 +198,7 @@ void analogix_dp_set_pll_power_down(struct analogix_dp_device *dp, bool enable);
void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp, void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp,
enum analog_power_block block, enum analog_power_block block,
bool enable); bool enable);
void analogix_dp_init_analog_func(struct analogix_dp_device *dp); int analogix_dp_init_analog_func(struct analogix_dp_device *dp);
void analogix_dp_init_hpd(struct analogix_dp_device *dp); void analogix_dp_init_hpd(struct analogix_dp_device *dp);
void analogix_dp_force_hpd(struct analogix_dp_device *dp); void analogix_dp_force_hpd(struct analogix_dp_device *dp);
enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp); enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp);
......
...@@ -333,7 +333,7 @@ void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp, ...@@ -333,7 +333,7 @@ void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp,
} }
} }
void analogix_dp_init_analog_func(struct analogix_dp_device *dp) int analogix_dp_init_analog_func(struct analogix_dp_device *dp)
{ {
u32 reg; u32 reg;
int timeout_loop = 0; int timeout_loop = 0;
...@@ -355,7 +355,7 @@ void analogix_dp_init_analog_func(struct analogix_dp_device *dp) ...@@ -355,7 +355,7 @@ void analogix_dp_init_analog_func(struct analogix_dp_device *dp)
timeout_loop++; timeout_loop++;
if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) { if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
dev_err(dp->dev, "failed to get pll lock status\n"); dev_err(dp->dev, "failed to get pll lock status\n");
return; return -ETIMEDOUT;
} }
usleep_range(10, 20); usleep_range(10, 20);
} }
...@@ -366,6 +366,7 @@ void analogix_dp_init_analog_func(struct analogix_dp_device *dp) ...@@ -366,6 +366,7 @@ void analogix_dp_init_analog_func(struct analogix_dp_device *dp)
reg &= ~(SERDES_FIFO_FUNC_EN_N | LS_CLK_DOMAIN_FUNC_EN_N reg &= ~(SERDES_FIFO_FUNC_EN_N | LS_CLK_DOMAIN_FUNC_EN_N
| AUX_FUNC_EN_N); | AUX_FUNC_EN_N);
writel(reg, dp->reg_base + ANALOGIX_DP_FUNC_EN_2); writel(reg, dp->reg_base + ANALOGIX_DP_FUNC_EN_2);
return 0;
} }
void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp) void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment