Commit ba19c537 authored by Maxime Ripard's avatar Maxime Ripard

drm/sun4i: tcon: Move out the tcon0 common setup

Some channel0 setup has to be done, no matter what the output interface is
(RGB, CPU, LVDS). Move that code into a common function in order to avoid
duplication.
Reviewed-by: default avatarChen-Yu Tsai <wens@csie.org>
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Link: https://patchwork.freedesktop.org/patch/183100/
parent 5b8f0910
...@@ -158,15 +158,26 @@ static int sun4i_tcon_get_clk_delay(const struct drm_display_mode *mode, ...@@ -158,15 +158,26 @@ static int sun4i_tcon_get_clk_delay(const struct drm_display_mode *mode,
return delay; return delay;
} }
static void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon, static void sun4i_tcon0_mode_set_common(struct sun4i_tcon *tcon,
const struct drm_display_mode *mode)
{
/* Configure the dot clock */
clk_set_rate(tcon->dclk, mode->crtc_clock * 1000);
/* Set the resolution */
regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG,
SUN4I_TCON0_BASIC0_X(mode->crtc_hdisplay) |
SUN4I_TCON0_BASIC0_Y(mode->crtc_vdisplay));
}
static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon,
const struct drm_display_mode *mode) const struct drm_display_mode *mode)
{ {
unsigned int bp, hsync, vsync; unsigned int bp, hsync, vsync;
u8 clk_delay; u8 clk_delay;
u32 val = 0; u32 val = 0;
/* Configure the dot clock */ sun4i_tcon0_mode_set_common(tcon, mode);
clk_set_rate(tcon->dclk, mode->crtc_clock * 1000);
/* Adjust clock delay */ /* Adjust clock delay */
clk_delay = sun4i_tcon_get_clk_delay(mode, 0); clk_delay = sun4i_tcon_get_clk_delay(mode, 0);
...@@ -174,11 +185,6 @@ static void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon, ...@@ -174,11 +185,6 @@ static void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon,
SUN4I_TCON0_CTL_CLK_DELAY_MASK, SUN4I_TCON0_CTL_CLK_DELAY_MASK,
SUN4I_TCON0_CTL_CLK_DELAY(clk_delay)); SUN4I_TCON0_CTL_CLK_DELAY(clk_delay));
/* Set the resolution */
regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG,
SUN4I_TCON0_BASIC0_X(mode->crtc_hdisplay) |
SUN4I_TCON0_BASIC0_Y(mode->crtc_vdisplay));
/* /*
* This is called a backporch in the register documentation, * This is called a backporch in the register documentation,
* but it really is the back porch + hsync * but it really is the back porch + hsync
...@@ -329,7 +335,7 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon, ...@@ -329,7 +335,7 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon,
{ {
switch (encoder->encoder_type) { switch (encoder->encoder_type) {
case DRM_MODE_ENCODER_NONE: case DRM_MODE_ENCODER_NONE:
sun4i_tcon0_mode_set(tcon, mode); sun4i_tcon0_mode_set_rgb(tcon, mode);
sun4i_tcon_set_mux(tcon, 0, encoder); sun4i_tcon_set_mux(tcon, 0, encoder);
break; break;
case DRM_MODE_ENCODER_TVDAC: case DRM_MODE_ENCODER_TVDAC:
......
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