Browse Source

drm/tegra: dsi - Add enable guard

To prevent the enable or disable operations to potentially be run
multiple times, add guards to return early when the output is already
in the targetted state.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Thierry Reding 11 năm trước cách đây
mục cha
commit
334ae6b527
1 tập tin đã thay đổi với 11 bổ sung0 xóa
  1. 11 0
      drivers/gpu/drm/tegra/dsi.c

+ 11 - 0
drivers/gpu/drm/tegra/dsi.c

@@ -53,6 +53,7 @@ struct tegra_dsi {
 	struct mipi_dsi_host host;
 	struct mipi_dsi_host host;
 
 
 	struct regulator *vdd;
 	struct regulator *vdd;
+	bool enabled;
 };
 };
 
 
 static inline struct tegra_dsi *
 static inline struct tegra_dsi *
@@ -436,6 +437,9 @@ static int tegra_output_dsi_enable(struct tegra_output *output)
 	const u32 *pkt_seq;
 	const u32 *pkt_seq;
 	int err;
 	int err;
 
 
+	if (dsi->enabled)
+		return 0;
+
 	if (dsi->flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) {
 	if (dsi->flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) {
 		DRM_DEBUG_KMS("Non-burst video mode with sync pulses\n");
 		DRM_DEBUG_KMS("Non-burst video mode with sync pulses\n");
 		pkt_seq = pkt_seq_video_non_burst_sync_pulses;
 		pkt_seq = pkt_seq_video_non_burst_sync_pulses;
@@ -530,6 +534,8 @@ static int tegra_output_dsi_enable(struct tegra_output *output)
 	value |= DSI_POWER_CONTROL_ENABLE;
 	value |= DSI_POWER_CONTROL_ENABLE;
 	tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
 	tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
 
 
+	dsi->enabled = true;
+
 	return 0;
 	return 0;
 }
 }
 
 
@@ -539,6 +545,9 @@ static int tegra_output_dsi_disable(struct tegra_output *output)
 	struct tegra_dsi *dsi = to_dsi(output);
 	struct tegra_dsi *dsi = to_dsi(output);
 	unsigned long value;
 	unsigned long value;
 
 
+	if (!dsi->enabled)
+		return 0;
+
 	/* disable DSI controller */
 	/* disable DSI controller */
 	value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
 	value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
 	value &= DSI_POWER_CONTROL_ENABLE;
 	value &= DSI_POWER_CONTROL_ENABLE;
@@ -568,6 +577,8 @@ static int tegra_output_dsi_disable(struct tegra_output *output)
 
 
 	clk_disable(dsi->clk);
 	clk_disable(dsi->clk);
 
 
+	dsi->enabled = false;
+
 	return 0;
 	return 0;
 }
 }