From 884b1a32d8edb9a9c8132f25162c35052a70e48d Mon Sep 17 00:00:00 2001 From: lilijun Date: Wed, 22 May 2024 14:27:49 +0800 Subject: [PATCH 029/222] feat(DRM): Add DSI support for linux 6.6 Changelogs: 1. Add support for mipi dsi driver 2. Add support for 4-lanes 1080p driver 3. make menuconfig select CONFIG_ESWIN_MIPI_DSI --- .../dts/eswin/eswin-win2030-die0-soc.dtsi | 46 +- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 3 +- drivers/gpu/drm/eswin/Kconfig | 8 + drivers/gpu/drm/eswin/Makefile | 4 +- drivers/gpu/drm/eswin/es_drv.c | 7 + drivers/gpu/drm/eswin/es_mipi_dsi.c | 661 ++++++++++++ drivers/gpu/drm/eswin/es_mipi_dsi.h | 11 + drivers/gpu/drm/eswin/es_panel.c | 943 ++++++++++++++++++ drivers/gpu/drm/eswin/es_panel.h | 67 ++ 9 files changed, 1713 insertions(+), 37 deletions(-) create mode 100644 drivers/gpu/drm/eswin/es_mipi_dsi.c create mode 100644 drivers/gpu/drm/eswin/es_mipi_dsi.h create mode 100644 drivers/gpu/drm/eswin/es_panel.c create mode 100644 drivers/gpu/drm/eswin/es_panel.h diff --git a/arch/riscv/boot/dts/eswin/eswin-win2030-die0-soc.dtsi b/arch/riscv/boot/dts/eswin/eswin-win2030-die0-soc.dtsi index a9f269bd9325..70f8a9d9af3b 100644 --- a/arch/riscv/boot/dts/eswin/eswin-win2030-die0-soc.dtsi +++ b/arch/riscv/boot/dts/eswin/eswin-win2030-die0-soc.dtsi @@ -1507,7 +1507,7 @@ portd: gpio-port@3 { reg = <3>; }; }; - + pwm0: pwm@0x50818000 { compatible = "eswin,pwm-eswin"; reg = <0x0 0x50818000 0x0 0x4000>; @@ -1772,9 +1772,9 @@ dc_out: port { #address-cells = <1>; #size-cells = <0>; - dc_out_dpi0: endpoint@0 { + dc_out_dsi: endpoint@0 { reg = <0>; - remote-endpoint = <&dsi_input0>; + remote-endpoint = <&dsi_input>; }; dc_out_dpi1: endpoint@1 { @@ -1782,10 +1782,10 @@ dc_out_dpi1: endpoint@1 { remote-endpoint = <&vd_input>; }; - dc_out_hdmi: endpoint@2 { - reg = <2>; - remote-endpoint = <&hdmi_in_dc>; - }; + dc_out_hdmi: endpoint@2 { + reg = <2>; + remote-endpoint = <&hdmi_in_dc>; + }; }; }; @@ -1802,36 +1802,13 @@ vd_input: endpoint { dsi_output: dsi-output { compatible = "eswin,dsi-encoder"; - - ports { - #address-cells = <1>; - #size-cells = <0>; - - /* input */ - port@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0>; - dsi_input0: endpoint@0 { - reg = <0>; - remote-endpoint = <&dc_out_dpi0>; - }; - }; - - /* output */ - port@1 { - reg = <1>; - dsi_out:endpoint { - remote-endpoint = <&mipi_dsi_in>; - }; - }; - }; + status = "disabled"; }; dsi_controller: mipi_dsi@50270000 { #address-cells = <1>; #size-cells = <0>; - compatible = "eswin,dw-mipi-dsi"; + compatible = "eswin,dsi"; reg = <0x0 0x50270000 0x0 0x10000>; clocks = <&d0_clock WIN2030_CLK_CLK_MIPI_TXESC>; clock-names = "pclk"; @@ -1850,9 +1827,8 @@ port@0 { #address-cells = <1>; #size-cells = <0>; reg = <0>; - - mipi_dsi_in: endpoint { - remote-endpoint = <&dsi_out>; + dsi_input: endpoint { + remote-endpoint = <&dc_out_dsi>; }; }; diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index 04d4a1a10698..3f3bf54f5da3 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -29,6 +29,7 @@ #include #define HWVER_131 0x31333100 /* IP version 1.31 */ +#define HWVER_30313500 0x30313500 #define DSI_VERSION 0x00 #define VERSION GENMASK(31, 8) @@ -781,7 +782,7 @@ static void dw_mipi_dsi_dphy_timing_config(struct dw_mipi_dsi *dsi) hw_version = dsi_read(dsi, DSI_VERSION) & VERSION; - if (hw_version >= HWVER_131) { + if (hw_version >= HWVER_131 || hw_version == HWVER_30313500) { dsi_write(dsi, DSI_PHY_TMR_CFG, PHY_HS2LP_TIME_V131(timing.data_hs2lp) | PHY_LP2HS_TIME_V131(timing.data_lp2hs)); diff --git a/drivers/gpu/drm/eswin/Kconfig b/drivers/gpu/drm/eswin/Kconfig index d518575e9bb3..1ad77afba9c3 100644 --- a/drivers/gpu/drm/eswin/Kconfig +++ b/drivers/gpu/drm/eswin/Kconfig @@ -70,3 +70,11 @@ config DW_HDMI_HDCP2 help Support the HDCP2 interface which is part of the Synopsys Designware HDMI block. + + +config ESWIN_MIPI_DSI + tristate "Eswin mipi dsi and 1080p panel driver" + select DRM_ESWIN + select DRM_DW_MIPI_DSI + help + Support mipi dsi 4-lanes panel output diff --git a/drivers/gpu/drm/eswin/Makefile b/drivers/gpu/drm/eswin/Makefile index 099597edf619..6d4043ca833c 100644 --- a/drivers/gpu/drm/eswin/Makefile +++ b/drivers/gpu/drm/eswin/Makefile @@ -20,4 +20,6 @@ es_drm-$(CONFIG_DW_HDMI_HDCP) += dw_hdmi_hdcp.o dw_hdcp2-$(CONFIG_DW_HDMI_HDCP2) += dw_hdmi_hdcp2.o obj-$(CONFIG_DRM_ESWIN) += es_drm.o -obj-$(CONFIG_DW_HDMI_HDCP2) += dw_hdcp2.o \ No newline at end of file +obj-$(CONFIG_DW_HDMI_HDCP2) += dw_hdcp2.o + +obj-$(CONFIG_ESWIN_MIPI_DSI)+= es_mipi_dsi.o es_panel.o \ No newline at end of file diff --git a/drivers/gpu/drm/eswin/es_drv.c b/drivers/gpu/drm/eswin/es_drv.c index 885b8d6fa5ab..936198b1c351 100644 --- a/drivers/gpu/drm/eswin/es_drv.c +++ b/drivers/gpu/drm/eswin/es_drv.c @@ -35,6 +35,8 @@ #include "dw-hdmi.h" #endif +#include "es_mipi_dsi.h" + #define DRV_NAME "es_drm" #define DRV_DESC "Eswin DRM driver" #define DRV_DATE "20191101" @@ -345,6 +347,11 @@ static struct platform_driver *drm_sub_drivers[] = { #ifdef CONFIG_ESWIN_VIRTUAL_DISPLAY &virtual_display_platform_driver, #endif + +#ifdef CONFIG_ESWIN_MIPI_DSI + &es_mipi_dsi_driver, +#endif + }; #define NUM_DRM_DRIVERS \ (sizeof(drm_sub_drivers) / sizeof(struct platform_driver *)) diff --git a/drivers/gpu/drm/eswin/es_mipi_dsi.c b/drivers/gpu/drm/eswin/es_mipi_dsi.c new file mode 100644 index 000000000000..8aa3c69378f2 --- /dev/null +++ b/drivers/gpu/drm/eswin/es_mipi_dsi.c @@ -0,0 +1,661 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Eswin Holdings Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include