|
14 | 14 | #include <linux/version.h>
|
15 | 15 | #include <linux/dma-buf.h>
|
16 | 16 | #include <linux/of_graph.h>
|
| 17 | +#include <linux/delay.h> |
17 | 18 |
|
18 | 19 | #include <drm/drm_fb_cma_helper.h>
|
19 | 20 | #include <drm/drm_fourcc.h>
|
@@ -130,9 +131,25 @@ static void tve200_display_enable(struct drm_simple_display_pipe *pipe,
|
130 | 131 | struct drm_connector *connector = priv->connector;
|
131 | 132 | u32 format = fb->format->format;
|
132 | 133 | u32 ctrl1 = 0;
|
| 134 | + int retries; |
133 | 135 |
|
134 | 136 | clk_prepare_enable(priv->clk);
|
135 | 137 |
|
| 138 | + /* Reset the TVE200 and wait for it to come back online */ |
| 139 | + writel(TVE200_CTRL_4_RESET, priv->regs + TVE200_CTRL_4); |
| 140 | + for (retries = 0; retries < 5; retries++) { |
| 141 | + usleep_range(30000, 50000); |
| 142 | + if (readl(priv->regs + TVE200_CTRL_4) & TVE200_CTRL_4_RESET) |
| 143 | + continue; |
| 144 | + else |
| 145 | + break; |
| 146 | + } |
| 147 | + if (retries == 5 && |
| 148 | + readl(priv->regs + TVE200_CTRL_4) & TVE200_CTRL_4_RESET) { |
| 149 | + dev_err(drm->dev, "can't get hardware out of reset\n"); |
| 150 | + return; |
| 151 | + } |
| 152 | + |
136 | 153 | /* Function 1 */
|
137 | 154 | ctrl1 |= TVE200_CTRL_CSMODE;
|
138 | 155 | /* Interlace mode for CCIR656: parameterize? */
|
@@ -230,8 +247,9 @@ static void tve200_display_disable(struct drm_simple_display_pipe *pipe)
|
230 | 247 |
|
231 | 248 | drm_crtc_vblank_off(crtc);
|
232 | 249 |
|
233 |
| - /* Disable and Power Down */ |
| 250 | + /* Disable put into reset and Power Down */ |
234 | 251 | writel(0, priv->regs + TVE200_CTRL);
|
| 252 | + writel(TVE200_CTRL_4_RESET, priv->regs + TVE200_CTRL_4); |
235 | 253 |
|
236 | 254 | clk_disable_unprepare(priv->clk);
|
237 | 255 | }
|
@@ -279,6 +297,8 @@ static int tve200_display_enable_vblank(struct drm_simple_display_pipe *pipe)
|
279 | 297 | struct drm_device *drm = crtc->dev;
|
280 | 298 | struct tve200_drm_dev_private *priv = drm->dev_private;
|
281 | 299 |
|
| 300 | + /* Clear any IRQs and enable */ |
| 301 | + writel(0xFF, priv->regs + TVE200_INT_CLR); |
282 | 302 | writel(TVE200_INT_V_STATUS, priv->regs + TVE200_INT_EN);
|
283 | 303 | return 0;
|
284 | 304 | }
|
|
0 commit comments