/* * (C) Copyright 2008-2017 Fuzhou Rockchip Electronics Co., Ltd * * SPDX-License-Identifier: GPL-2.0+ */ #include #include #include #include "rockchip_display.h" #include "rockchip_crtc.h" #include "rockchip_connector.h" #include "dw_hdmi.h" #include "rockchip_dw_hdmi.h" #define HDMI_SEL_LCDC(x, bit) ((((x) & 1) << bit) | (1 << (16 + bit))) #define RK3288_GRF_SOC_CON6 0x025C #define RK3288_HDMI_LCDC_SEL BIT(4) #define RK3399_GRF_SOC_CON20 0x6250 #define RK3399_HDMI_LCDC_SEL BIT(6) static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = { { 30666000, { { 0x00b3, 0x0000 }, { 0x2153, 0x0000 }, { 0x40f3, 0x0000 }, }, }, { 36800000, { { 0x00b3, 0x0000 }, { 0x2153, 0x0000 }, { 0x40a2, 0x0001 }, }, }, { 46000000, { { 0x00b3, 0x0000 }, { 0x2142, 0x0001 }, { 0x40a2, 0x0001 }, }, }, { 61333000, { { 0x0072, 0x0001 }, { 0x2142, 0x0001 }, { 0x40a2, 0x0001 }, }, }, { 73600000, { { 0x0072, 0x0001 }, { 0x2142, 0x0001 }, { 0x4061, 0x0002 }, }, }, { 92000000, { { 0x0072, 0x0001 }, { 0x2145, 0x0002 }, { 0x4061, 0x0002 }, }, }, { 122666000, { { 0x0051, 0x0002 }, { 0x2145, 0x0002 }, { 0x4061, 0x0002 }, }, }, { 147200000, { { 0x0051, 0x0002 }, { 0x2145, 0x0002 }, { 0x4064, 0x0003 }, }, }, { 184000000, { { 0x0051, 0x0002 }, { 0x214c, 0x0003 }, { 0x4064, 0x0003 }, }, }, { 226666000, { { 0x0040, 0x0003 }, { 0x214c, 0x0003 }, { 0x4064, 0x0003 }, }, }, { 272000000, { { 0x0040, 0x0003 }, { 0x214c, 0x0003 }, { 0x5a64, 0x0003 }, }, }, { 340000000, { { 0x0040, 0x0003 }, { 0x3b4c, 0x0003 }, { 0x5a64, 0x0003 }, }, }, { 600000000, { { 0x1a40, 0x0003 }, { 0x3b4c, 0x0003 }, { 0x5a64, 0x0003 }, }, }, { ~0UL, { { 0x0000, 0x0000 }, { 0x0000, 0x0000 }, { 0x0000, 0x0000 }, }, } }; static const struct dw_hdmi_curr_ctrl rockchip_cur_ctr[] = { /* pixelclk bpp8 bpp10 bpp12 */ { 600000000, { 0x0000, 0x0000, 0x0000 }, }, { ~0UL, { 0x0000, 0x0000, 0x0000}, } }; static const struct dw_hdmi_phy_config rockchip_phy_config[] = { /*pixelclk symbol term vlev*/ { 74250000, 0x8009, 0x0004, 0x0272}, { 165000000, 0x802b, 0x0004, 0x0209}, { 297000000, 0x8039, 0x0005, 0x028d}, { 594000000, 0x8039, 0x0000, 0x019d}, { ~0UL, 0x0000, 0x0000, 0x0000} }; static const struct rockchip_connector_funcs rockchip_dw_hdmi_funcs = { .init = rockchip_dw_hdmi_init, .deinit = rockchip_dw_hdmi_deinit, .prepare = rockchip_dw_hdmi_prepare, .enable = rockchip_dw_hdmi_enable, .disable = rockchip_dw_hdmi_disable, .get_timing = rockchip_dw_hdmi_get_timing, .detect = rockchip_dw_hdmi_detect, .get_edid = rockchip_dw_hdmi_get_edid, }; static const struct dw_hdmi_plat_data rk3288_hdmi_drv_data = { .vop_sel_bit = 4, .grf_vop_sel_reg = RK3288_GRF_SOC_CON6, .dev_type = RK3288_HDMI, }; static const struct dw_hdmi_plat_data rk3399_hdmi_drv_data = { .vop_sel_bit = 6, .grf_vop_sel_reg = RK3399_GRF_SOC_CON20, .mpll_cfg = rockchip_mpll_cfg, .cur_ctr = rockchip_cur_ctr, .phy_config = rockchip_phy_config, .dev_type = RK3399_HDMI, }; static const struct rockchip_connector rk3399_dw_hdmi_data = { .funcs = &rockchip_dw_hdmi_funcs, .data = &rk3399_hdmi_drv_data, }; static const struct rockchip_connector rk3288_dw_hdmi_data = { .funcs = &rockchip_dw_hdmi_funcs, .data = &rk3288_hdmi_drv_data, }; static int rockchip_dw_hdmi_probe(struct udevice *dev) { return 0; } static const struct udevice_id rockchip_dw_hdmi_ids[] = { { .compatible = "rockchip,rk3399-dw-hdmi", .data = (ulong)&rk3399_dw_hdmi_data, }, { .compatible = "rockchip,rk3288-dw-hdmi", .data = (ulong)&rk3288_dw_hdmi_data, }, {} }; U_BOOT_DRIVER(rockchip_dw_hdmi) = { .name = "rockchip_dw_hdmi", .id = UCLASS_DISPLAY, .of_match = rockchip_dw_hdmi_ids, .probe = rockchip_dw_hdmi_probe, };