From 08164ea6580063bc17a3e98fb696b9cff5ab4d2b Mon Sep 17 00:00:00 2001 From: "shengyang.chen" Date: Fri, 17 Jun 2022 15:04:44 +0800 Subject: [PATCH] riscv:linux:driver:drm:rgb2hdmi update rgb2hdmi driver support Signed-off-by:shengyang.chenshengyang.chen@starfivetech.com --- arch/riscv/boot/dts/starfive/jh7110-common.dtsi | 6 +- arch/riscv/boot/dts/starfive/jh7110_pinctrl.dtsi | 10 +-- drivers/gpu/drm/verisilicon/README | 81 ++++++++++++++++++++++-- drivers/gpu/drm/verisilicon/inno_hdmi.c | 4 +- drivers/gpu/drm/verisilicon/vs_dc.c | 34 +++++++++- drivers/gpu/drm/verisilicon/vs_drv.c | 3 + 6 files changed, 123 insertions(+), 15 deletions(-) diff --git a/arch/riscv/boot/dts/starfive/jh7110-common.dtsi b/arch/riscv/boot/dts/starfive/jh7110-common.dtsi index b08b333..cd24d62 100644 --- a/arch/riscv/boot/dts/starfive/jh7110-common.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110-common.dtsi @@ -666,6 +666,8 @@ &hdmi_output { status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&rgb_pad_pins>; ports { #address-cells = <1>; @@ -712,8 +714,8 @@ }; &mipi_dsi { - pinctrl-names = "default"; - pinctrl-0 = <&mipitx_pins>; + //pinctrl-names = "default"; + //pinctrl-0 = <&mipitx_pins>; status = "disabled"; }; diff --git a/arch/riscv/boot/dts/starfive/jh7110_pinctrl.dtsi b/arch/riscv/boot/dts/starfive/jh7110_pinctrl.dtsi index 956cd79..af0b352 100644 --- a/arch/riscv/boot/dts/starfive/jh7110_pinctrl.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110_pinctrl.dtsi @@ -258,8 +258,8 @@ i2c3_pins: i2c3-pins { i2c3-pins-scl { - sf,pins = ; - sf,pinmux = ; + sf,pins = ; + sf,pinmux = ; sf,pin-ioconfig = ; sf,pin-gpio-dout = ; sf,pin-gpio-doen = ; @@ -267,8 +267,8 @@ }; i2c3-pins-sda { - sf,pins = ; - sf,pinmux = ; + sf,pins = ; + sf,pinmux = ; sf,pin-ioconfig = ; sf,pin-gpio-dout = ; sf,pin-gpio-doen = ; @@ -930,7 +930,7 @@ rgb-0-pins { sf,pins = ; sf,pinmux = ; - sf,pin-ioconfig = ; + sf,pin-ioconfig = ; }; rgb-1-pins { sf,pins = ; diff --git a/drivers/gpu/drm/verisilicon/README b/drivers/gpu/drm/verisilicon/README index b8225f4..6037b0a 100644 --- a/drivers/gpu/drm/verisilicon/README +++ b/drivers/gpu/drm/verisilicon/README @@ -1,4 +1,4 @@ -build drm need to config: +build drm need to config: # CONFIG_DRM_I2C_ADV7511_CEC is not set CONFIG_DRM_VERISILICON=y CONFIG_DRM_I2C_ADV7513=y @@ -8,7 +8,7 @@ CONFIG_DRM_LEGACY=y notes: -1、DC8200 rgbpad GPIO 和其他模块存在大规模冲突,需要等evb板子做进一步确认 +1、DC8200 rgbpad GPIO 和其他模块存在大规模冲突, 需要等evb板子做进一步确认 2、evb板子当前与hdmi冲突的gpio有 i2c0 i2c1 i2c2 i2c3 sdio1 tdm @@ -17,6 +17,8 @@ i2c0 i2c1 i2c2 i2c3 sdio1 tdm +=============================================================================================== + build drm mipi-dsi need to config: # CONFIG_DRM_I2C_ADV7511_CEC is not set CONFIG_DRM_VERISILICON=y @@ -25,12 +27,13 @@ CONFIG_DRM_LEGACY=y CONFIG_STARFIVE_DSI=y CONFIG_PHY_M31_DPHY_RX0=y #STARFIVE_INNO_HDMI is not set +#CONFIG_DRM_I2C_NXP_TDA998X is not set # CONFIG_DRM_VGEM is not set # CONFIG_DRM_VKMS is not set notes: 1. -测试mipi-dsi时,在编译前需要打开的dts节点有: +测试mipi-dsi时,在编译前需要打开的dts节点有: jh7110.dtsi: dc8200, encoder: display-encoder, mipi_dphy, mipi_dsi, mipi_panel @@ -40,7 +43,75 @@ jh7100-common.dtsi: 2. evb板子当前与mipi-dsi冲突的gpio有: -i2c0, i2c3, hdmi(inno), hdmi_output(rgb), sdio1(mmc1) +sdio1(mmc1) 调试mipi-dsi的时候建议在jh7100-common.dtsi文件 -将这些模块的pin的结点进行注释或者将node disabled \ No newline at end of file +将这些模块的pin的结点进行注释或者将node disabled + +3. +mipi-dsi通路目前和rgb2hdmi通路是互斥的, +不能同时打开。使用某一个时需要关闭另一个 +如: +使用mipi-dsi需要关闭 +CONFIG_DRM_I2C_NXP_TDA998X + + +=============================================================================================== + + +build rgb2hdmi channel need to config: + +CONFIG_DRM=y +CONFIG_DRM_I2C_NXP_TDA998X=y +CONFIG_DRM_VERISILICON=y +CONFIG_STARFIVE_INNO_HDMI=y +# CONFIG_DRM_IMG_NULLDISP is not set +CONFIG_DRM_LEGACY=y +# CONFIG_STARFIVE_DSI is not set + + +notes: +1. +evb板子当前与tda998x-rgb2hdmi通路存在gpio冲突的模块有 +pdm0, i2srx_3ch, pwmdac, spi0~spi6, inno_hdmi, tdm, i2c0, can1, ptc, vin_sysctl, pcie0 +调试tda998x-rgb2hdmi通路的时候建议在jh7110-common.dtsi文件 +将这些模块的pin的结点进行注释或者将node disabled(&hdmi节点比较特殊,详见3) + +2. +mipi-dsi通路目前和rgb2hdmi通路是互斥的 +不能同时打开。使用某一个时需要关闭另一个 +如: +使用rgb2hdmi需要关闭 +CONFIG_STARFIVE_DSI + +3. +关于&hdmi节点 +在使用rgb2hdmi时需要将其打开(status = "okay";) +并将其引用的pin(pinctrl-0 = <&inno_hdmi_pins>;) 注释掉 +如: +&hdmi { + status = "okay";//okay //rgb need this, connector/encoder problem + //pinctrl-names = "default"; //if rgb, comment them + //pinctrl-0 = <&inno_hdmi_pins>; //if rgb, comment them + + hdmi_in: port { + #address-cells = <1>; + #size-cells = <0>; + hdmi_in_lcdc: endpoint@0 { + reg = <0>; + remote-endpoint = <&dc_out_dpi1>; + }; + }; +}; + +4. +测试rgb2hdmi需要打开的dts节点有: +jh7110.dtsi: +hdmi_output, hdmi, dc8200 + +jh7110-common.dtsi: +&hdmi_output, &hdmi(详见3), &dc8200, &i2c2 + +关闭节点: +jh7100-common.dtsi: +&encoder \ No newline at end of file diff --git a/drivers/gpu/drm/verisilicon/inno_hdmi.c b/drivers/gpu/drm/verisilicon/inno_hdmi.c index f15ce1a..40fe808 100644 --- a/drivers/gpu/drm/verisilicon/inno_hdmi.c +++ b/drivers/gpu/drm/verisilicon/inno_hdmi.c @@ -1153,7 +1153,9 @@ static int inno_hdmi_bind(struct device *dev, struct device *master, goto err_disable_clk; } //inno_hdmi_set_pinmux();//20220601 disable for testing dts pinctrl setting - //inno_hdmi_init(hdmi); +#ifdef CONFIG_DRM_I2C_NXP_TDA998X + inno_hdmi_init(hdmi); +#endif //inno_hdmi_get_edid(hdmi,51200000, data);//20220525 inno_hdmi_reset(hdmi); diff --git a/drivers/gpu/drm/verisilicon/vs_dc.c b/drivers/gpu/drm/verisilicon/vs_dc.c index 13291f9..3e26baa 100644 --- a/drivers/gpu/drm/verisilicon/vs_dc.c +++ b/drivers/gpu/drm/verisilicon/vs_dc.c @@ -805,6 +805,11 @@ static int dc_vout_clk_rst_init(struct device *dev, struct vs_dc *dc) int sys_vout_mux_config(void) { + #ifdef CONFIG_DRM_I2C_NXP_TDA998X//tda998x-rgb2hdmi + SET_U0_LCD_DATA_MAPPING_DPI_DP_SEL(0);//DC8200_INTERFACE_DPI + SET_U0_LCD_DATA_MAPPING_DP_RGB_FMT(0);//0-RGB888 + SET_U0_DISPLAY_PANEL_MUX_PANEL_SEL(0);//panel 0 + #else if(1){ SET_U0_HDMI_DATA_MAPPING_DPI_DP_SEL(0); SET_U0_HDMI_DATA_MAPPING_DPI_BIT_DEPTH(0); @@ -813,13 +818,20 @@ int sys_vout_mux_config(void) SET_U2_DISPLAY_PANEL_MUX_PANEL_SEL(0); } + #endif return 0; } int sys_dispctrl_clk(void) { - _SWITCH_CLOCK_CLK_U0_DC8200_CLK_PIX0_SOURCE_CLK_HDMITX0_PIXELCLK_; - //_SWITCH_CLOCK_CLK_U0_DC8200_CLK_PIX0_SOURCE_CLK_DC8200_PIX0_; + #ifdef CONFIG_DRM_I2C_NXP_TDA998X//tda998x-rgb2hdmi + _SWITCH_CLOCK_CLK_U0_DC8200_CLK_PIX1_SOURCE_CLK_HDMITX0_PIXELCLK_; + _SWITCH_CLOCK_CLK_U0_DC8200_CLK_PIX0_SOURCE_CLK_HDMITX0_PIXELCLK_; + //_ENABLE_CLOCK_CLK_DOM_VOUT_TOP_LCD_CLK_;//disabled standard + #else + _SWITCH_CLOCK_CLK_U0_DC8200_CLK_PIX0_SOURCE_CLK_HDMITX0_PIXELCLK_; + //_SWITCH_CLOCK_CLK_U0_DC8200_CLK_PIX0_SOURCE_CLK_DC8200_PIX0_; + #endif return 0; } @@ -891,6 +903,7 @@ static int dc_init(struct device *dev) return ret; } #ifdef CONFIG_STARFIVE_DSI + dev_info(dev, "dc mipi channel\n"); dc->vout_src = devm_clk_get(dev, "vout_src"); if (IS_ERR(dc->vout_src)){ dev_err(dev,"failed to get dc->vout_src\n"); @@ -907,6 +920,23 @@ static int dc_init(struct device *dev) return ret; } #endif + + #ifdef CONFIG_DRM_I2C_NXP_TDA998X + _ENABLE_CLOCK_CLK_DOM_VOUT_TOP_LCD_CLK_; + /* + dev_info(dev, "dc rgb2hdmi channel\n"); + dc->vout_top_lcd = devm_clk_get(dev, "vout_top_lcd"); + if (IS_ERR(dc->vout_top_lcd)){ + dev_err(dev,"failed to get dc->vout_top_lcd\n"); + return PTR_ERR(dc->vout_top_lcd); + } + ret = clk_prepare_enable(dc->vout_top_lcd); + if (ret) { + dev_err(dev, "failed to prepare/enable vout_top_lcd\n"); + return ret; + } + */ + #endif printk("====> %s, %d.\n", __func__, __LINE__); ret = dc_hw_init(&dc->hw); diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c index 3529586..0508da6 100644 --- a/drivers/gpu/drm/verisilicon/vs_drv.c +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -314,6 +314,9 @@ static struct platform_driver *drm_sub_drivers[] = { /* encoder */ //&simple_encoder_driver, //&starfive_encoder_driver, +#ifdef CONFIG_DRM_I2C_NXP_TDA998X + &simple_encoder_driver, +#endif #ifdef CONFIG_VERISILICON_VIRTUAL_DISPLAY &virtual_display_platform_driver, -- 2.7.4