aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2017-10-14 00:02:52 -0400
committerMaxime Ripard <maxime.ripard@free-electrons.com>2017-10-16 03:54:46 -0400
commitbfddd1469740ea27439afa866bff41ef1cd22bb1 (patch)
tree8344954f4db8782a1685f6606aed1a499d6093cf
parent31f5232effd30808f96772f123300d9d13f0cfd1 (diff)
drm/sun4i: hdmi: Move PAD_CTRL1 setting to mode_set function
Initially we configured the PAD_CTRL1 register at probe/bind time. However it seems the HDMI controller will modify some of the bits in this register by itself. On the A10 it is particularly annoying as it toggles the output invert bits, which inverts the colors on the display output. The U-boot driver this driver is based on sets this register twice, though it seems it's only needed for actual display output. Hence we move it to the mode_set function. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Link: https://patchwork.freedesktop.org/patch/msgid/20171014040252.9621-8-wens@csie.org
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index 027b5608dbe6..6ca6e6a74c4a 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -144,6 +144,22 @@ static void sun4i_hdmi_mode_set(struct drm_encoder *encoder,
144 writel(SUN4I_HDMI_UNKNOWN_INPUT_SYNC, 144 writel(SUN4I_HDMI_UNKNOWN_INPUT_SYNC,
145 hdmi->base + SUN4I_HDMI_UNKNOWN_REG); 145 hdmi->base + SUN4I_HDMI_UNKNOWN_REG);
146 146
147 /*
148 * Setup output pad (?) controls
149 *
150 * This is done here instead of at probe/bind time because
151 * the controller seems to toggle some of the bits on its own.
152 *
153 * We can't just initialize the register there, we need to
154 * protect the clock bits that have already been read out and
155 * cached by the clock framework.
156 */
157 val = readl(hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
158 val &= SUN4I_HDMI_PAD_CTRL1_HALVE_CLK;
159 val |= hdmi->variant->pad_ctrl1_init_val;
160 writel(val, hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
161 val = readl(hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
162
147 /* Setup timing registers */ 163 /* Setup timing registers */
148 writel(SUN4I_HDMI_VID_TIMING_X(mode->hdisplay) | 164 writel(SUN4I_HDMI_VID_TIMING_X(mode->hdisplay) |
149 SUN4I_HDMI_VID_TIMING_Y(mode->vdisplay), 165 SUN4I_HDMI_VID_TIMING_Y(mode->vdisplay),
@@ -489,16 +505,6 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
489 writel(hdmi->variant->pad_ctrl0_init_val, 505 writel(hdmi->variant->pad_ctrl0_init_val,
490 hdmi->base + SUN4I_HDMI_PAD_CTRL0_REG); 506 hdmi->base + SUN4I_HDMI_PAD_CTRL0_REG);
491 507
492 /*
493 * We can't just initialize the register there, we need to
494 * protect the clock bits that have already been read out and
495 * cached by the clock framework.
496 */
497 reg = readl(hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
498 reg &= SUN4I_HDMI_PAD_CTRL1_HALVE_CLK;
499 reg |= hdmi->variant->pad_ctrl1_init_val;
500 writel(reg, hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
501
502 reg = readl(hdmi->base + SUN4I_HDMI_PLL_CTRL_REG); 508 reg = readl(hdmi->base + SUN4I_HDMI_PLL_CTRL_REG);
503 reg &= SUN4I_HDMI_PLL_CTRL_DIV_MASK; 509 reg &= SUN4I_HDMI_PLL_CTRL_DIV_MASK;
504 reg |= hdmi->variant->pll_ctrl_init_val; 510 reg |= hdmi->variant->pll_ctrl_init_val;