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

drm/sun4i: hdmi: Add support for A31's HDMI controller

The HDMI controller found in the A31 SoCs is slightly different
from the one already supported, which is found in the A10s:

- Need different initial values for the PLL related registers

- Different behavior of the DDC and TMDS clocks

- Different register layout for the DDC portion

- Separate DDC parent clock

This patch adds support for it.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171010032008.682-10-wens@csie.org

authored by

Chen-Yu Tsai and committed by
Maxime Ripard
da184dee c4a9aec3

+61
+3
drivers/gpu/drm/sun4i/sun4i_hdmi.h
··· 59 59 #define SUN4I_HDMI_PAD_CTRL0_TXEN BIT(23) 60 60 61 61 #define SUN4I_HDMI_PAD_CTRL1_REG 0x204 62 + #define SUN4I_HDMI_PAD_CTRL1_UNKNOWN BIT(24) /* set on A31 */ 62 63 #define SUN4I_HDMI_PAD_CTRL1_AMP_OPT BIT(23) 63 64 #define SUN4I_HDMI_PAD_CTRL1_AMPCK_OPT BIT(22) 64 65 #define SUN4I_HDMI_PAD_CTRL1_EMP_OPT BIT(20) 65 66 #define SUN4I_HDMI_PAD_CTRL1_EMPCK_OPT BIT(19) 67 + #define SUN4I_HDMI_PAD_CTRL1_PWSCK BIT(18) 68 + #define SUN4I_HDMI_PAD_CTRL1_PWSDT BIT(17) 66 69 #define SUN4I_HDMI_PAD_CTRL1_REG_DEN BIT(15) 67 70 #define SUN4I_HDMI_PAD_CTRL1_REG_DENCK BIT(14) 68 71 #define SUN4I_HDMI_PAD_CTRL1_REG_EMP(n) (((n) & 7) << 10)
+58
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
··· 324 324 .ddc_fifo_has_dir = true, 325 325 }; 326 326 327 + static const struct sun4i_hdmi_variant sun6i_variant = { 328 + .has_ddc_parent_clk = true, 329 + .has_reset_control = true, 330 + .pad_ctrl0_init_val = 0xff | 331 + SUN4I_HDMI_PAD_CTRL0_TXEN | 332 + SUN4I_HDMI_PAD_CTRL0_CKEN | 333 + SUN4I_HDMI_PAD_CTRL0_PWENG | 334 + SUN4I_HDMI_PAD_CTRL0_PWEND | 335 + SUN4I_HDMI_PAD_CTRL0_PWENC | 336 + SUN4I_HDMI_PAD_CTRL0_LDODEN | 337 + SUN4I_HDMI_PAD_CTRL0_LDOCEN, 338 + .pad_ctrl1_init_val = SUN4I_HDMI_PAD_CTRL1_REG_AMP(6) | 339 + SUN4I_HDMI_PAD_CTRL1_REG_EMP(4) | 340 + SUN4I_HDMI_PAD_CTRL1_REG_DENCK | 341 + SUN4I_HDMI_PAD_CTRL1_REG_DEN | 342 + SUN4I_HDMI_PAD_CTRL1_EMPCK_OPT | 343 + SUN4I_HDMI_PAD_CTRL1_EMP_OPT | 344 + SUN4I_HDMI_PAD_CTRL1_PWSDT | 345 + SUN4I_HDMI_PAD_CTRL1_PWSCK | 346 + SUN4I_HDMI_PAD_CTRL1_AMPCK_OPT | 347 + SUN4I_HDMI_PAD_CTRL1_AMP_OPT | 348 + SUN4I_HDMI_PAD_CTRL1_UNKNOWN, 349 + .pll_ctrl_init_val = SUN4I_HDMI_PLL_CTRL_VCO_S(8) | 350 + SUN4I_HDMI_PLL_CTRL_CS(3) | 351 + SUN4I_HDMI_PLL_CTRL_CP_S(10) | 352 + SUN4I_HDMI_PLL_CTRL_S(4) | 353 + SUN4I_HDMI_PLL_CTRL_VCO_GAIN(4) | 354 + SUN4I_HDMI_PLL_CTRL_SDIV2 | 355 + SUN4I_HDMI_PLL_CTRL_LDO2_EN | 356 + SUN4I_HDMI_PLL_CTRL_LDO1_EN | 357 + SUN4I_HDMI_PLL_CTRL_HV_IS_33 | 358 + SUN4I_HDMI_PLL_CTRL_PLL_EN, 359 + 360 + .ddc_clk_reg = REG_FIELD(SUN6I_HDMI_DDC_CLK_REG, 0, 6), 361 + .ddc_clk_pre_divider = 1, 362 + .ddc_clk_m_offset = 2, 363 + 364 + .tmds_clk_div_offset = 1, 365 + 366 + .field_ddc_en = REG_FIELD(SUN6I_HDMI_DDC_CTRL_REG, 0, 0), 367 + .field_ddc_start = REG_FIELD(SUN6I_HDMI_DDC_CTRL_REG, 27, 27), 368 + .field_ddc_reset = REG_FIELD(SUN6I_HDMI_DDC_CTRL_REG, 31, 31), 369 + .field_ddc_addr_reg = REG_FIELD(SUN6I_HDMI_DDC_ADDR_REG, 1, 31), 370 + .field_ddc_slave_addr = REG_FIELD(SUN6I_HDMI_DDC_ADDR_REG, 1, 7), 371 + .field_ddc_int_status = REG_FIELD(SUN6I_HDMI_DDC_INT_STATUS_REG, 0, 8), 372 + .field_ddc_fifo_clear = REG_FIELD(SUN6I_HDMI_DDC_FIFO_CTRL_REG, 18, 18), 373 + .field_ddc_fifo_rx_thres = REG_FIELD(SUN6I_HDMI_DDC_FIFO_CTRL_REG, 4, 7), 374 + .field_ddc_fifo_tx_thres = REG_FIELD(SUN6I_HDMI_DDC_FIFO_CTRL_REG, 0, 3), 375 + .field_ddc_byte_count = REG_FIELD(SUN6I_HDMI_DDC_CMD_REG, 16, 25), 376 + .field_ddc_cmd = REG_FIELD(SUN6I_HDMI_DDC_CMD_REG, 0, 2), 377 + .field_ddc_sda_en = REG_FIELD(SUN6I_HDMI_DDC_CTRL_REG, 6, 6), 378 + .field_ddc_sck_en = REG_FIELD(SUN6I_HDMI_DDC_CTRL_REG, 4, 4), 379 + 380 + .ddc_fifo_reg = SUN6I_HDMI_DDC_FIFO_DATA_REG, 381 + .ddc_fifo_thres_incl = true, 382 + }; 383 + 327 384 static const struct regmap_config sun4i_hdmi_regmap_config = { 328 385 .reg_bits = 32, 329 386 .val_bits = 32, ··· 608 551 609 552 static const struct of_device_id sun4i_hdmi_of_table[] = { 610 553 { .compatible = "allwinner,sun5i-a10s-hdmi", .data = &sun5i_variant, }, 554 + { .compatible = "allwinner,sun6i-a31-hdmi", .data = &sun6i_variant, }, 611 555 { } 612 556 }; 613 557 MODULE_DEVICE_TABLE(of, sun4i_hdmi_of_table);