Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <andrey@lebedev.lt>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20200219180858.4806-6-andrey.lebedev@gmail.com

authored by

Andrey Lebedev and committed by
Maxime Ripard
d718e53a cd0ecabd

+46 -1
+35 -1
drivers/gpu/drm/sun4i/sun4i_tcon.c
··· 114 114 } 115 115 } 116 116 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 + 117 141 static void sun6i_tcon_setup_lvds_phy(struct sun4i_tcon *tcon, 118 142 const struct drm_encoder *encoder) 119 143 { ··· 1478 1454 .dclk_min_div = 1, 1479 1455 }; 1480 1456 1457 + static const struct sun4i_tcon_quirks sun7i_a20_tcon0_quirks = { 1458 + .supports_lvds = true, 1459 + .has_channel_0 = true, 1460 + .has_channel_1 = true, 1461 + .dclk_min_div = 4, 1462 + /* Same display pipeline structure as A10 */ 1463 + .set_mux = sun4i_a10_tcon_set_mux, 1464 + .setup_lvds_phy = sun4i_tcon_setup_lvds_phy, 1465 + }; 1466 + 1481 1467 static const struct sun4i_tcon_quirks sun7i_a20_quirks = { 1482 1468 .has_channel_0 = true, 1483 1469 .has_channel_1 = true, ··· 1542 1508 { .compatible = "allwinner,sun6i-a31-tcon", .data = &sun6i_a31_quirks }, 1543 1509 { .compatible = "allwinner,sun6i-a31s-tcon", .data = &sun6i_a31s_quirks }, 1544 1510 { .compatible = "allwinner,sun7i-a20-tcon", .data = &sun7i_a20_quirks }, 1545 - { .compatible = "allwinner,sun7i-a20-tcon0", .data = &sun7i_a20_quirks }, 1511 + { .compatible = "allwinner,sun7i-a20-tcon0", .data = &sun7i_a20_tcon0_quirks }, 1546 1512 { .compatible = "allwinner,sun7i-a20-tcon1", .data = &sun7i_a20_quirks }, 1547 1513 { .compatible = "allwinner,sun8i-a23-tcon", .data = &sun8i_a33_quirks }, 1548 1514 { .compatible = "allwinner,sun8i-a33-tcon", .data = &sun8i_a33_quirks },
+11
drivers/gpu/drm/sun4i/sun4i_tcon.h
··· 193 193 #define SUN4I_TCON_MUX_CTRL_REG 0x200 194 194 195 195 #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 + 196 203 #define SUN6I_TCON0_LVDS_ANA0_EN_MB BIT(31) 197 204 #define SUN6I_TCON0_LVDS_ANA0_EN_LDO BIT(30) 198 205 #define SUN6I_TCON0_LVDS_ANA0_EN_DRVC BIT(24) ··· 207 200 #define SUN6I_TCON0_LVDS_ANA0_C(x) (((x) & 3) << 17) 208 201 #define SUN6I_TCON0_LVDS_ANA0_V(x) (((x) & 3) << 8) 209 202 #define SUN6I_TCON0_LVDS_ANA0_PD(x) (((x) & 3) << 4) 203 + 204 + #define SUN4I_TCON0_LVDS_ANA1_REG 0x224 205 + #define SUN4I_TCON0_LVDS_ANA1_INIT (0x1f << 26 | 0x1f << 10) 206 + #define SUN4I_TCON0_LVDS_ANA1_UPDATE (0x1f << 16 | 0x1f << 00) 210 207 211 208 #define SUN4I_TCON1_FILL_CTL_REG 0x300 212 209 #define SUN4I_TCON1_FILL_BEG0_REG 0x304