Skip to content

Commit d718e53

Browse files
keddermripard
authored andcommitted
drm/sun4i: tcon: Support LVDS output on Allwinner A20
A20 SoC (found in Cubieboard 2 among others) requires different LVDS set up procedure than A33. Timing controller (tcon) driver only implements sun6i-style procedure, that doesn't work on A20 (sun7i). 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 cd0ecab commit d718e53

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

drivers/gpu/drm/sun4i/sun4i_tcon.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,30 @@ static void sun4i_tcon_channel_set_status(struct sun4i_tcon *tcon, int channel,
114114
}
115115
}
116116

117+
static void sun4i_tcon_setup_lvds_phy(struct sun4i_tcon *tcon,
118+
const struct drm_encoder *encoder)
119+
{
120+
regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
121+
SUN4I_TCON0_LVDS_ANA0_CK_EN |
122+
SUN4I_TCON0_LVDS_ANA0_REG_V |
123+
SUN4I_TCON0_LVDS_ANA0_REG_C |
124+
SUN4I_TCON0_LVDS_ANA0_EN_MB |
125+
SUN4I_TCON0_LVDS_ANA0_PD |
126+
SUN4I_TCON0_LVDS_ANA0_DCHS);
127+
128+
udelay(2); /* delay at least 1200 ns */
129+
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG,
130+
SUN4I_TCON0_LVDS_ANA1_INIT,
131+
SUN4I_TCON0_LVDS_ANA1_INIT);
132+
udelay(1); /* delay at least 120 ns */
133+
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG,
134+
SUN4I_TCON0_LVDS_ANA1_UPDATE,
135+
SUN4I_TCON0_LVDS_ANA1_UPDATE);
136+
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
137+
SUN4I_TCON0_LVDS_ANA0_EN_MB,
138+
SUN4I_TCON0_LVDS_ANA0_EN_MB);
139+
}
140+
117141
static void sun6i_tcon_setup_lvds_phy(struct sun4i_tcon *tcon,
118142
const struct drm_encoder *encoder)
119143
{
@@ -1454,6 +1478,16 @@ static const struct sun4i_tcon_quirks sun6i_a31s_quirks = {
14541478
.dclk_min_div = 1,
14551479
};
14561480

1481+
static const struct sun4i_tcon_quirks sun7i_a20_tcon0_quirks = {
1482+
.supports_lvds = true,
1483+
.has_channel_0 = true,
1484+
.has_channel_1 = true,
1485+
.dclk_min_div = 4,
1486+
/* Same display pipeline structure as A10 */
1487+
.set_mux = sun4i_a10_tcon_set_mux,
1488+
.setup_lvds_phy = sun4i_tcon_setup_lvds_phy,
1489+
};
1490+
14571491
static const struct sun4i_tcon_quirks sun7i_a20_quirks = {
14581492
.has_channel_0 = true,
14591493
.has_channel_1 = true,
@@ -1508,7 +1542,7 @@ const struct of_device_id sun4i_tcon_of_table[] = {
15081542
{ .compatible = "allwinner,sun6i-a31-tcon", .data = &sun6i_a31_quirks },
15091543
{ .compatible = "allwinner,sun6i-a31s-tcon", .data = &sun6i_a31s_quirks },
15101544
{ .compatible = "allwinner,sun7i-a20-tcon", .data = &sun7i_a20_quirks },
1511-
{ .compatible = "allwinner,sun7i-a20-tcon0", .data = &sun7i_a20_quirks },
1545+
{ .compatible = "allwinner,sun7i-a20-tcon0", .data = &sun7i_a20_tcon0_quirks },
15121546
{ .compatible = "allwinner,sun7i-a20-tcon1", .data = &sun7i_a20_quirks },
15131547
{ .compatible = "allwinner,sun8i-a23-tcon", .data = &sun8i_a33_quirks },
15141548
{ .compatible = "allwinner,sun8i-a33-tcon", .data = &sun8i_a33_quirks },

drivers/gpu/drm/sun4i/sun4i_tcon.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@
193193
#define SUN4I_TCON_MUX_CTRL_REG 0x200
194194

195195
#define SUN4I_TCON0_LVDS_ANA0_REG 0x220
196+
#define SUN4I_TCON0_LVDS_ANA0_DCHS BIT(16)
197+
#define SUN4I_TCON0_LVDS_ANA0_PD (BIT(20) | BIT(21))
198+
#define SUN4I_TCON0_LVDS_ANA0_EN_MB BIT(22)
199+
#define SUN4I_TCON0_LVDS_ANA0_REG_C (BIT(24) | BIT(25))
200+
#define SUN4I_TCON0_LVDS_ANA0_REG_V (BIT(26) | BIT(27))
201+
#define SUN4I_TCON0_LVDS_ANA0_CK_EN (BIT(29) | BIT(28))
202+
196203
#define SUN6I_TCON0_LVDS_ANA0_EN_MB BIT(31)
197204
#define SUN6I_TCON0_LVDS_ANA0_EN_LDO BIT(30)
198205
#define SUN6I_TCON0_LVDS_ANA0_EN_DRVC BIT(24)
@@ -201,6 +208,10 @@
201208
#define SUN6I_TCON0_LVDS_ANA0_V(x) (((x) & 3) << 8)
202209
#define SUN6I_TCON0_LVDS_ANA0_PD(x) (((x) & 3) << 4)
203210

211+
#define SUN4I_TCON0_LVDS_ANA1_REG 0x224
212+
#define SUN4I_TCON0_LVDS_ANA1_INIT (0x1f << 26 | 0x1f << 10)
213+
#define SUN4I_TCON0_LVDS_ANA1_UPDATE (0x1f << 16 | 0x1f << 00)
214+
204215
#define SUN4I_TCON1_FILL_CTL_REG 0x300
205216
#define SUN4I_TCON1_FILL_BEG0_REG 0x304
206217
#define SUN4I_TCON1_FILL_END0_REG 0x308

0 commit comments

Comments
 (0)