Skip to content

Commit 5627c9d

Browse files
keddermripard
authored andcommitted
drm/sun4i: tcon: Introduce LVDS setup routine setting
Different sunxi flavors require slightly different sequence for enabling LVDS output. This allows to differentiate between them. Signed-off-by: Andrey Lebedev <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 80579bf commit 5627c9d

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed

drivers/gpu/drm/sun4i/sun4i_tcon.c

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -114,46 +114,47 @@ static void sun4i_tcon_channel_set_status(struct sun4i_tcon *tcon, int channel,
114114
}
115115
}
116116

117+
static void sun6i_tcon_setup_lvds_phy(struct sun4i_tcon *tcon,
118+
const struct drm_encoder *encoder)
119+
{
120+
u8 val;
121+
122+
regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
123+
SUN6I_TCON0_LVDS_ANA0_C(2) |
124+
SUN6I_TCON0_LVDS_ANA0_V(3) |
125+
SUN6I_TCON0_LVDS_ANA0_PD(2) |
126+
SUN6I_TCON0_LVDS_ANA0_EN_LDO);
127+
udelay(2);
128+
129+
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
130+
SUN6I_TCON0_LVDS_ANA0_EN_MB,
131+
SUN6I_TCON0_LVDS_ANA0_EN_MB);
132+
udelay(2);
133+
134+
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
135+
SUN6I_TCON0_LVDS_ANA0_EN_DRVC,
136+
SUN6I_TCON0_LVDS_ANA0_EN_DRVC);
137+
138+
if (sun4i_tcon_get_pixel_depth(encoder) == 18)
139+
val = 7;
140+
else
141+
val = 0xf;
142+
143+
regmap_write_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
144+
SUN6I_TCON0_LVDS_ANA0_EN_DRVD(0xf),
145+
SUN6I_TCON0_LVDS_ANA0_EN_DRVD(val));
146+
}
147+
117148
static void sun4i_tcon_lvds_set_status(struct sun4i_tcon *tcon,
118149
const struct drm_encoder *encoder,
119150
bool enabled)
120151
{
121152
if (enabled) {
122-
u8 val;
123-
124153
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_IF_REG,
125154
SUN4I_TCON0_LVDS_IF_EN,
126155
SUN4I_TCON0_LVDS_IF_EN);
127-
128-
/*
129-
* As their name suggest, these values only apply to the A31
130-
* and later SoCs. We'll have to rework this when merging
131-
* support for the older SoCs.
132-
*/
133-
regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
134-
SUN6I_TCON0_LVDS_ANA0_C(2) |
135-
SUN6I_TCON0_LVDS_ANA0_V(3) |
136-
SUN6I_TCON0_LVDS_ANA0_PD(2) |
137-
SUN6I_TCON0_LVDS_ANA0_EN_LDO);
138-
udelay(2);
139-
140-
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
141-
SUN6I_TCON0_LVDS_ANA0_EN_MB,
142-
SUN6I_TCON0_LVDS_ANA0_EN_MB);
143-
udelay(2);
144-
145-
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
146-
SUN6I_TCON0_LVDS_ANA0_EN_DRVC,
147-
SUN6I_TCON0_LVDS_ANA0_EN_DRVC);
148-
149-
if (sun4i_tcon_get_pixel_depth(encoder) == 18)
150-
val = 7;
151-
else
152-
val = 0xf;
153-
154-
regmap_write_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
155-
SUN6I_TCON0_LVDS_ANA0_EN_DRVD(0xf),
156-
SUN6I_TCON0_LVDS_ANA0_EN_DRVD(val));
156+
if (tcon->quirks->setup_lvds_phy)
157+
tcon->quirks->setup_lvds_phy(tcon, encoder);
157158
} else {
158159
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_IF_REG,
159160
SUN4I_TCON0_LVDS_IF_EN, 0);
@@ -1465,12 +1466,14 @@ static const struct sun4i_tcon_quirks sun8i_a33_quirks = {
14651466
.has_channel_0 = true,
14661467
.has_lvds_alt = true,
14671468
.dclk_min_div = 1,
1469+
.setup_lvds_phy = sun6i_tcon_setup_lvds_phy,
14681470
};
14691471

14701472
static const struct sun4i_tcon_quirks sun8i_a83t_lcd_quirks = {
14711473
.supports_lvds = true,
14721474
.has_channel_0 = true,
14731475
.dclk_min_div = 1,
1476+
.setup_lvds_phy = sun6i_tcon_setup_lvds_phy,
14741477
};
14751478

14761479
static const struct sun4i_tcon_quirks sun8i_a83t_tv_quirks = {

drivers/gpu/drm/sun4i/sun4i_tcon.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ struct sun4i_tcon_quirks {
228228

229229
/* callback to handle tcon muxing options */
230230
int (*set_mux)(struct sun4i_tcon *, const struct drm_encoder *);
231+
/* handler for LVDS setup routine */
232+
void (*setup_lvds_phy)(struct sun4i_tcon *tcon,
233+
const struct drm_encoder *encoder);
231234
};
232235

233236
struct sun4i_tcon {

0 commit comments

Comments
 (0)