* [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520)
@ 2026-01-29 2:39 Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 1/8] dt-bindings: vendor-prefixes: add verisilicon Icenowy Zheng
` (8 more replies)
0 siblings, 9 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-01-29 2:39 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng, Icenowy Zheng
This patchset tries to add a driver for Verisilicon DC8200 driver, and
demonstrates the driver on T-Head TH1520 with its HDMI output.
This display controller IP is used on StarFive JH7110 too, but as the
HDMI controller used there isn't as common as the DesignWare one, I
choose to use TH1520 in this patchset.
The DC driver is written with other DC-series (mainly DC8000, which is
known to be used on Eswin EIC7700 SoC) display controllers in mind, and
uses the identification registers available on all Vivante branded IPs.
A known exception is DCNano display controller, which is unlikely to be
supported by this driver because of totally different register map and
no known identification registers. (P.S. the in-tree loongson DRM driver
seems to be for some DCNano instances based on the register map.)
The HDMI controller seems to come with some common PHY by Synopsys, the
DesignWare HDMI TX 2.0 PHY. By searching a few register names from the
BSP driver of that PHY, that PHY seems to be used by a in-tree dw-hdmi
glue, rcar_dw_hdmi -- an updated downstream version of rcar_dw_hdmi
contains all 6 registers set here in the th1520-dw-hdmi driver. Some
more suprising thing is that RK3288 uses the same PHY too, but the
in-tree dw_hdmi-rockchip driver writes the configuration data array in a
weird way to reuse the HDMI 3D TX PHY configuring function. It might be
valuable to add common configuring function and configuration data
definition for this HDMI 2.0 PHY too, but the current driver in this
patchset simply duplicated most configuration logic from rcar_dw_hdmi
driver (but with 3 extra configuration registers configured, which is
done by their downstream kernel).
This revision contains only little code change -- only a Kconfig select
is added. The other purpose is to collect Thomas Zimmermann's tags and
squash MAINTAINERS change to real driver per his suggestion.
Icenowy Zheng (8):
dt-bindings: vendor-prefixes: add verisilicon
dt-bindings: display: add verisilicon,dc
drm: verisilicon: add a driver for Verisilicon display controllers
dt-bindings: display/bridge: add binding for TH1520 HDMI controller
drm/bridge: add a driver for T-Head TH1520 HDMI controller
riscv: dts: thead: add DPU and HDMI device tree nodes
riscv: dts: thead: lichee-pi-4a: enable HDMI
mailmap: map all Icenowy Zheng's mail addresses
.mailmap | 4 +
.../display/bridge/thead,th1520-dw-hdmi.yaml | 120 ++++++
.../bindings/display/verisilicon,dc.yaml | 122 ++++++
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
MAINTAINERS | 8 +
.../boot/dts/thead/th1520-lichee-pi-4a.dts | 25 ++
arch/riscv/boot/dts/thead/th1520.dtsi | 66 ++++
drivers/gpu/drm/Kconfig | 2 +
drivers/gpu/drm/Makefile | 1 +
drivers/gpu/drm/bridge/Kconfig | 10 +
drivers/gpu/drm/bridge/Makefile | 1 +
drivers/gpu/drm/bridge/th1520-dw-hdmi.c | 173 ++++++++
drivers/gpu/drm/verisilicon/Kconfig | 16 +
drivers/gpu/drm/verisilicon/Makefile | 5 +
drivers/gpu/drm/verisilicon/vs_bridge.c | 371 ++++++++++++++++++
drivers/gpu/drm/verisilicon/vs_bridge.h | 39 ++
drivers/gpu/drm/verisilicon/vs_bridge_regs.h | 54 +++
drivers/gpu/drm/verisilicon/vs_crtc.c | 191 +++++++++
drivers/gpu/drm/verisilicon/vs_crtc.h | 31 ++
drivers/gpu/drm/verisilicon/vs_crtc_regs.h | 60 +++
drivers/gpu/drm/verisilicon/vs_dc.c | 207 ++++++++++
drivers/gpu/drm/verisilicon/vs_dc.h | 38 ++
drivers/gpu/drm/verisilicon/vs_dc_top_regs.h | 27 ++
drivers/gpu/drm/verisilicon/vs_drm.c | 182 +++++++++
drivers/gpu/drm/verisilicon/vs_drm.h | 28 ++
drivers/gpu/drm/verisilicon/vs_hwdb.c | 150 +++++++
drivers/gpu/drm/verisilicon/vs_hwdb.h | 29 ++
drivers/gpu/drm/verisilicon/vs_plane.c | 124 ++++++
drivers/gpu/drm/verisilicon/vs_plane.h | 72 ++++
.../gpu/drm/verisilicon/vs_primary_plane.c | 173 ++++++++
.../drm/verisilicon/vs_primary_plane_regs.h | 53 +++
31 files changed, 2384 insertions(+)
create mode 100644 Documentation/devicetree/bindings/display/bridge/thead,th1520-dw-hdmi.yaml
create mode 100644 Documentation/devicetree/bindings/display/verisilicon,dc.yaml
create mode 100644 drivers/gpu/drm/bridge/th1520-dw-hdmi.c
create mode 100644 drivers/gpu/drm/verisilicon/Kconfig
create mode 100644 drivers/gpu/drm/verisilicon/Makefile
create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge_regs.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc_regs.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_top_regs.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_drm.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_drm.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_hwdb.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_hwdb.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_primary_plane.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_primary_plane_regs.h
--
2.52.0
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v7 1/8] dt-bindings: vendor-prefixes: add verisilicon
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
@ 2026-01-29 2:39 ` Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 2/8] dt-bindings: display: add verisilicon,dc Icenowy Zheng
` (7 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-01-29 2:39 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng, Icenowy Zheng
From: Icenowy Zheng <uwu@icenowy.me>
VeriSilicon is a Silicon IP vendor, which is the current owner of
Vivante series video-related IPs and Hantro series video codec IPs.
Add a vendor prefix for this company.
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
---
No changes since v4.
Changes in v3:
- Add Rob's ACK.
No changes in v2.
Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index c7591b2aec2a7..18f931f369198 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1745,6 +1745,8 @@ patternProperties:
description: Variscite Ltd.
"^vdl,.*":
description: Van der Laan b.v.
+ "^verisilicon,.*":
+ description: VeriSilicon Microelectronics (Shanghai) Co., Ltd.
"^vertexcom,.*":
description: Vertexcom Technologies, Inc.
"^via,.*":
--
2.52.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 2/8] dt-bindings: display: add verisilicon,dc
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 1/8] dt-bindings: vendor-prefixes: add verisilicon Icenowy Zheng
@ 2026-01-29 2:39 ` Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers Icenowy Zheng
` (6 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-01-29 2:39 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng, Icenowy Zheng
From: Icenowy Zheng <uwu@icenowy.me>
Verisilicon has a series of display controllers prefixed with DC and
with self-identification facility like their GC series GPUs.
Add a device tree binding for it.
Depends on the specific DC model, it can have either one or two display
outputs, and each display output could be set to DPI signal or "DP"
signal (which seems to be some plain parallel bus to HDMI controllers).
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
---
No changes in v7.
Changes in v6:
- Added Rob's R-b.
Changes in v5:
- Dropped the requirement of port@0.
- Dropped the if clause for TH1520, which seems to be not needed because
of implicit DT binding rules.
Changes in v4:
- Added a comment for "verisilicon,dc" that says the ID/revision is
discoverable via registers.
- Removed clock minItems constraint w/o specific compatible strings.
Changes in v3:
- Added SoC-specific compatible string, and arm the binding with clock /
port checking for the specific SoC (with a 2-output DC).
Changes in v2:
- Fixed misspelt "versilicon" in title.
- Moved minItems in clock properties to be earlier than items.
- Re-aligned multi-line clocks and resets in example.
.../bindings/display/verisilicon,dc.yaml | 122 ++++++++++++++++++
1 file changed, 122 insertions(+)
create mode 100644 Documentation/devicetree/bindings/display/verisilicon,dc.yaml
diff --git a/Documentation/devicetree/bindings/display/verisilicon,dc.yaml b/Documentation/devicetree/bindings/display/verisilicon,dc.yaml
new file mode 100644
index 0000000000000..9dc35ab973f20
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/verisilicon,dc.yaml
@@ -0,0 +1,122 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/verisilicon,dc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Verisilicon DC-series display controllers
+
+maintainers:
+ - Icenowy Zheng <uwu@icenowy.me>
+
+properties:
+ $nodename:
+ pattern: "^display@[0-9a-f]+$"
+
+ compatible:
+ items:
+ - enum:
+ - thead,th1520-dc8200
+ - const: verisilicon,dc # DC IPs have discoverable ID/revision registers
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ clocks:
+ items:
+ - description: DC Core clock
+ - description: DMA AXI bus clock
+ - description: Configuration AHB bus clock
+ - description: Pixel clock of output 0
+ - description: Pixel clock of output 1
+
+ clock-names:
+ items:
+ - const: core
+ - const: axi
+ - const: ahb
+ - const: pix0
+ - const: pix1
+
+ resets:
+ items:
+ - description: DC Core reset
+ - description: DMA AXI bus reset
+ - description: Configuration AHB bus reset
+
+ reset-names:
+ items:
+ - const: core
+ - const: axi
+ - const: ahb
+
+ ports:
+ $ref: /schemas/graph.yaml#/properties/ports
+
+ properties:
+ port@0:
+ $ref: /schemas/graph.yaml#/properties/port
+ description: The first output channel , endpoint 0 should be
+ used for DPI format output and endpoint 1 should be used
+ for DP format output.
+
+ port@1:
+ $ref: /schemas/graph.yaml#/properties/port
+ description: The second output channel if the DC variant
+ supports. Follow the same endpoint addressing rule with
+ the first port.
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - clocks
+ - clock-names
+ - ports
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/clock/thead,th1520-clk-ap.h>
+ #include <dt-bindings/reset/thead,th1520-reset.h>
+ soc {
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ display@ffef600000 {
+ compatible = "thead,th1520-dc8200", "verisilicon,dc";
+ reg = <0xff 0xef600000 0x0 0x100000>;
+ interrupts = <93 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk_vo CLK_DPU_CCLK>,
+ <&clk_vo CLK_DPU_ACLK>,
+ <&clk_vo CLK_DPU_HCLK>,
+ <&clk_vo CLK_DPU_PIXELCLK0>,
+ <&clk_vo CLK_DPU_PIXELCLK1>;
+ clock-names = "core", "axi", "ahb", "pix0", "pix1";
+ resets = <&rst TH1520_RESET_ID_DPU_CORE>,
+ <&rst TH1520_RESET_ID_DPU_AXI>,
+ <&rst TH1520_RESET_ID_DPU_AHB>;
+ reset-names = "core", "axi", "ahb";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@1 {
+ reg = <1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ dpu_out_dp1: endpoint@1 {
+ reg = <1>;
+ remote-endpoint = <&hdmi_in>;
+ };
+ };
+ };
+ };
+ };
--
2.52.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 1/8] dt-bindings: vendor-prefixes: add verisilicon Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 2/8] dt-bindings: display: add verisilicon,dc Icenowy Zheng
@ 2026-01-29 2:39 ` Icenowy Zheng
2026-03-09 12:47 ` Luca Ceresoli
2026-01-29 2:39 ` [PATCH v7 4/8] dt-bindings: display/bridge: add binding for TH1520 HDMI controller Icenowy Zheng
` (5 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Icenowy Zheng @ 2026-01-29 2:39 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng, Icenowy Zheng
From: Icenowy Zheng <uwu@icenowy.me>
This is a from-scratch driver targeting Verisilicon DC-series display
controllers, which feature self-identification functionality like their
GC-series GPUs.
Only DC8200 is being supported now, and only the main framebuffer is set
up (as the DRM primary plane). Support for more DC models and more
features is my further targets.
As the display controller is delivered to SoC vendors as a whole part,
this driver does not use component framework and extra bridges inside a
SoC is expected to be implemented as dedicated bridges (this driver
properly supports bridge chaining).
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Tested-by: Han Gao <gaohan@iscas.ac.cn>
Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
---
Changes in v7:
- Added Thomas's R-b.
- Added a missing `select DRM_DISPLAY_HELPER` found by kernel test
robot.
- Squashed in MAINTAINERS item.
Changes in v6:
- Sorted Kconfig dependency.
- Get rid of obsolete uppercase DRM_* printk marcos.
- Optimization to printk messages (unknown IRQ message is only printed
once, device recognition message has "Found" added, "Skipping output"
message priority lowered to debug).
- Splitted most bridge functions for DPI/DP output.
- Get rid of custom CRTC atomic_flush, which doesn't do anything
device-specific.
- Adapted macro HZ_PER_KHZ and VSDC_DISP_TIMING_VALUE_MAX.
- Switched to use drm_mode_size_dumb() to align dumb buffer pitch.
- Reordered some function calls in vs_drm_initialize() (
aperture_remove_all_conflicting_devices() is now called earlier and
drm_mode_config_reset() is now called later).
- Splitted out vs_fb_get_dma_addr() and switched to use
drm_format_info_min_pitch() to calculate the src X offset to the
framebuffer address.
- Splitted out atomic_{en,dis}able for primary plane.
- Removed an unused pm_runtime.h inclusion because the driver now does
not do runpm.
Changes in v5:
- Switching to drm_atomic_get_new_bridge_state, which seems to let the
driver get rid of the hack of saving bus format itself.
- Add the internal bridge before attaching it.
- Adapted next_bridge struct field name suggested by Luca Ceresoli.
- Refactored the probe code to not use port count, to allow port@0 being
missing.
Changes in v4:
- Switch to drm_* logger when we're handling with struct drm_device.
Changes in v3:
- Get rid of drm_atomic_get_existing_crtc_state() which is marked
deprecated.
Changes in v2:
- Changed some Control flows according to previous reviews.
- Added missing of_node_put when checking of endpoints for output type.
- Switched all userspace-visible modeset objects to be managed by drmm
instead of devm.
- Utilize devm_drm_bridge_alloc() in internal bridge.
- Prevented the usage of simple encoder helpers by passing a NULL funcs pointer.
- Let devm enable clocks when getting them.
- Removed explicit `.cache_type = REGCACHE_NONE` in regmap config.
- Fixed a debug print using a variable before initialization.
- Fixed a wrong index when using bulk to handle resets.
- Added missing configuration for DPI format (currently fixed RGB888).
MAINTAINERS | 7 +
drivers/gpu/drm/Kconfig | 2 +
drivers/gpu/drm/Makefile | 1 +
drivers/gpu/drm/verisilicon/Kconfig | 16 +
drivers/gpu/drm/verisilicon/Makefile | 5 +
drivers/gpu/drm/verisilicon/vs_bridge.c | 371 ++++++++++++++++++
drivers/gpu/drm/verisilicon/vs_bridge.h | 39 ++
drivers/gpu/drm/verisilicon/vs_bridge_regs.h | 54 +++
drivers/gpu/drm/verisilicon/vs_crtc.c | 191 +++++++++
drivers/gpu/drm/verisilicon/vs_crtc.h | 31 ++
drivers/gpu/drm/verisilicon/vs_crtc_regs.h | 60 +++
drivers/gpu/drm/verisilicon/vs_dc.c | 207 ++++++++++
drivers/gpu/drm/verisilicon/vs_dc.h | 38 ++
drivers/gpu/drm/verisilicon/vs_dc_top_regs.h | 27 ++
drivers/gpu/drm/verisilicon/vs_drm.c | 182 +++++++++
drivers/gpu/drm/verisilicon/vs_drm.h | 28 ++
drivers/gpu/drm/verisilicon/vs_hwdb.c | 150 +++++++
drivers/gpu/drm/verisilicon/vs_hwdb.h | 29 ++
drivers/gpu/drm/verisilicon/vs_plane.c | 124 ++++++
drivers/gpu/drm/verisilicon/vs_plane.h | 72 ++++
.../gpu/drm/verisilicon/vs_primary_plane.c | 173 ++++++++
.../drm/verisilicon/vs_primary_plane_regs.h | 53 +++
22 files changed, 1860 insertions(+)
create mode 100644 drivers/gpu/drm/verisilicon/Kconfig
create mode 100644 drivers/gpu/drm/verisilicon/Makefile
create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge_regs.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc_regs.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_top_regs.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_drm.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_drm.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_hwdb.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_hwdb.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h
create mode 100644 drivers/gpu/drm/verisilicon/vs_primary_plane.c
create mode 100644 drivers/gpu/drm/verisilicon/vs_primary_plane_regs.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 67db88b04537b..adf302286e77d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8667,6 +8667,13 @@ F: Documentation/devicetree/bindings/display/brcm,bcm2835-*.yaml
F: drivers/gpu/drm/vc4/
F: include/uapi/drm/vc4_drm.h
+DRM DRIVERS FOR VERISILICON DISPLAY CONTROLLER IP
+M: Icenowy Zheng <zhengxingda@iscas.ac.cn>
+L: dri-devel@lists.freedesktop.org
+S: Maintained
+F: Documentation/devicetree/bindings/display/verisilicon,dc.yaml
+F: drivers/gpu/drm/verisilicon/
+
DRM DRIVERS FOR VIVANTE GPU IP
M: Lucas Stach <l.stach@pengutronix.de>
R: Russell King <linux+etnaviv@armlinux.org.uk>
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index ed85d0ceee3ba..a0917595d11ca 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -398,6 +398,8 @@ source "drivers/gpu/drm/imagination/Kconfig"
source "drivers/gpu/drm/tyr/Kconfig"
+source "drivers/gpu/drm/verisilicon/Kconfig"
+
config DRM_HYPERV
tristate "DRM Support for Hyper-V synthetic video device"
depends on DRM && PCI && HYPERV_VMBUS
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index d261917174280..a5727a1bf8330 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -237,6 +237,7 @@ obj-y += solomon/
obj-$(CONFIG_DRM_SPRD) += sprd/
obj-$(CONFIG_DRM_LOONGSON) += loongson/
obj-$(CONFIG_DRM_POWERVR) += imagination/
+obj-$(CONFIG_DRM_VERISILICON_DC) += verisilicon/
# Ensure drm headers are self-contained and pass kernel-doc
hdrtest-files := \
diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig
new file mode 100644
index 0000000000000..44711684b7d48
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/Kconfig
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config DRM_VERISILICON_DC
+ tristate "DRM Support for Verisilicon DC-series display controllers"
+ depends on DRM && COMMON_CLK
+ depends on RISCV || COMPILER_TEST
+ select DRM_CLIENT_SELECTION
+ select DRM_DISPLAY_HELPER
+ select DRM_GEM_DMA_HELPER
+ select DRM_KMS_HELPER
+ select DRM_BRIDGE_CONNECTOR
+ select REGMAP_MMIO
+ select VIDEOMODE_HELPERS
+ help
+ Choose this option if you have a SoC with Verisilicon DC-series
+ display controllers. If M is selected, the module will be called
+ verisilicon-dc.
diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile
new file mode 100644
index 0000000000000..fd8d805fbcde1
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+verisilicon-dc-objs := vs_bridge.o vs_crtc.o vs_dc.o vs_drm.o vs_hwdb.o vs_plane.o vs_primary_plane.o
+
+obj-$(CONFIG_DRM_VERISILICON_DC) += verisilicon-dc.o
diff --git a/drivers/gpu/drm/verisilicon/vs_bridge.c b/drivers/gpu/drm/verisilicon/vs_bridge.c
new file mode 100644
index 0000000000000..2a0ad00a94d6d
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_bridge.c
@@ -0,0 +1,371 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#include <linux/of.h>
+#include <linux/regmap.h>
+
+#include <uapi/linux/media-bus-format.h>
+
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_bridge.h>
+#include <drm/drm_bridge_connector.h>
+#include <drm/drm_connector.h>
+#include <drm/drm_encoder.h>
+#include <drm/drm_of.h>
+#include <drm/drm_print.h>
+#include <drm/drm_simple_kms_helper.h>
+
+#include "vs_bridge.h"
+#include "vs_bridge_regs.h"
+#include "vs_crtc.h"
+#include "vs_dc.h"
+
+static int vs_bridge_attach(struct drm_bridge *bridge,
+ struct drm_encoder *encoder,
+ enum drm_bridge_attach_flags flags)
+{
+ struct vs_bridge *vbridge = drm_bridge_to_vs_bridge(bridge);
+
+ return drm_bridge_attach(encoder, vbridge->next_bridge,
+ bridge, flags);
+}
+
+struct vsdc_dp_format {
+ u32 linux_fmt;
+ bool is_yuv;
+ u32 vsdc_fmt;
+};
+
+static struct vsdc_dp_format vsdc_dp_supported_fmts[] = {
+ /* default to RGB888 */
+ { MEDIA_BUS_FMT_FIXED, false, VSDC_DISP_DP_CONFIG_FMT_RGB888 },
+ { MEDIA_BUS_FMT_RGB888_1X24, false, VSDC_DISP_DP_CONFIG_FMT_RGB888 },
+ { MEDIA_BUS_FMT_RGB565_1X16, false, VSDC_DISP_DP_CONFIG_FMT_RGB565 },
+ { MEDIA_BUS_FMT_RGB666_1X18, false, VSDC_DISP_DP_CONFIG_FMT_RGB666 },
+ { MEDIA_BUS_FMT_RGB101010_1X30,
+ false, VSDC_DISP_DP_CONFIG_FMT_RGB101010 },
+ { MEDIA_BUS_FMT_UYVY8_1X16, true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY8 },
+ { MEDIA_BUS_FMT_UYVY10_1X20, true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY10 },
+ { MEDIA_BUS_FMT_YUV8_1X24, true, VSDC_DISP_DP_CONFIG_YUV_FMT_YUV8 },
+ { MEDIA_BUS_FMT_YUV10_1X30, true, VSDC_DISP_DP_CONFIG_YUV_FMT_YUV10 },
+ { MEDIA_BUS_FMT_UYYVYY8_0_5X24,
+ true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY8 },
+ { MEDIA_BUS_FMT_UYYVYY10_0_5X30,
+ true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY10 },
+};
+
+static u32 *vs_bridge_atomic_get_output_bus_fmts_dpi(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state,
+ unsigned int *num_output_fmts)
+{
+ u32 *output_fmts;
+
+ *num_output_fmts = 2;
+
+ output_fmts = kcalloc(*num_output_fmts, sizeof(*output_fmts),
+ GFP_KERNEL);
+ if (!output_fmts)
+ return NULL;
+
+ /* TODO: support more DPI output formats */
+ output_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
+ output_fmts[1] = MEDIA_BUS_FMT_FIXED;
+
+ return output_fmts;
+}
+
+static u32 *vs_bridge_atomic_get_output_bus_fmts_dp(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state,
+ unsigned int *num_output_fmts)
+{
+ u32 *output_fmts;
+ unsigned int i;
+
+ *num_output_fmts = ARRAY_SIZE(vsdc_dp_supported_fmts);
+
+ output_fmts = kcalloc(*num_output_fmts, sizeof(*output_fmts),
+ GFP_KERNEL);
+ if (!output_fmts)
+ return NULL;
+
+ for (i = 0; i < *num_output_fmts; i++)
+ output_fmts[i] = vsdc_dp_supported_fmts[i].linux_fmt;
+
+ return output_fmts;
+}
+
+static bool vs_bridge_out_dp_fmt_supported(u32 out_fmt)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(vsdc_dp_supported_fmts); i++)
+ if (vsdc_dp_supported_fmts[i].linux_fmt == out_fmt)
+ return true;
+
+ return false;
+}
+
+static u32 *vs_bridge_atomic_get_input_bus_fmts_dp(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state,
+ u32 output_fmt,
+ unsigned int *num_input_fmts)
+{
+ if (!vs_bridge_out_dp_fmt_supported(output_fmt)) {
+ *num_input_fmts = 0;
+ return NULL;
+ }
+
+ return drm_atomic_helper_bridge_propagate_bus_fmt(bridge, bridge_state,
+ crtc_state,
+ conn_state,
+ output_fmt,
+ num_input_fmts);
+}
+
+static int vs_bridge_atomic_check_dp(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state)
+{
+ if (!vs_bridge_out_dp_fmt_supported(bridge_state->output_bus_cfg.format))
+ return -EINVAL;
+
+ return 0;
+}
+
+static void vs_bridge_enable_common(struct vs_crtc *crtc,
+ struct drm_bridge_state *br_state)
+{
+ struct vs_dc *dc = crtc->dc;
+ unsigned int output = crtc->id;
+
+ regmap_clear_bits(dc->regs, VSDC_DISP_PANEL_CONFIG(output),
+ VSDC_DISP_PANEL_CONFIG_DAT_POL);
+ regmap_assign_bits(dc->regs, VSDC_DISP_PANEL_CONFIG(output),
+ VSDC_DISP_PANEL_CONFIG_DE_POL,
+ br_state->output_bus_cfg.flags &
+ DRM_BUS_FLAG_DE_LOW);
+ regmap_assign_bits(dc->regs, VSDC_DISP_PANEL_CONFIG(output),
+ VSDC_DISP_PANEL_CONFIG_CLK_POL,
+ br_state->output_bus_cfg.flags &
+ DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE);
+ regmap_set_bits(dc->regs, VSDC_DISP_PANEL_CONFIG(output),
+ VSDC_DISP_PANEL_CONFIG_DE_EN |
+ VSDC_DISP_PANEL_CONFIG_DAT_EN |
+ VSDC_DISP_PANEL_CONFIG_CLK_EN);
+ regmap_set_bits(dc->regs, VSDC_DISP_PANEL_CONFIG(output),
+ VSDC_DISP_PANEL_CONFIG_RUNNING);
+ regmap_clear_bits(dc->regs, VSDC_DISP_PANEL_START,
+ VSDC_DISP_PANEL_START_MULTI_DISP_SYNC);
+ regmap_set_bits(dc->regs, VSDC_DISP_PANEL_START,
+ VSDC_DISP_PANEL_START_RUNNING(output));
+
+ regmap_set_bits(dc->regs, VSDC_DISP_PANEL_CONFIG_EX(crtc->id),
+ VSDC_DISP_PANEL_CONFIG_EX_COMMIT);
+}
+
+static void vs_bridge_atomic_enable_dpi(struct drm_bridge *bridge,
+ struct drm_atomic_state *state)
+{
+ struct vs_bridge *vbridge = drm_bridge_to_vs_bridge(bridge);
+ struct drm_bridge_state *br_state =
+ drm_atomic_get_new_bridge_state(state, bridge);
+ struct vs_crtc *crtc = vbridge->crtc;
+ struct vs_dc *dc = crtc->dc;
+ unsigned int output = crtc->id;
+
+ regmap_clear_bits(dc->regs, VSDC_DISP_DP_CONFIG(output),
+ VSDC_DISP_DP_CONFIG_DP_EN);
+ regmap_write(dc->regs, VSDC_DISP_DPI_CONFIG(output),
+ VSDC_DISP_DPI_CONFIG_FMT_RGB888);
+
+ vs_bridge_enable_common(crtc, br_state);
+}
+
+static void vs_bridge_atomic_enable_dp(struct drm_bridge *bridge,
+ struct drm_atomic_state *state)
+{
+ struct vs_bridge *vbridge = drm_bridge_to_vs_bridge(bridge);
+ struct drm_bridge_state *br_state =
+ drm_atomic_get_new_bridge_state(state, bridge);
+ struct vs_crtc *crtc = vbridge->crtc;
+ struct vs_dc *dc = crtc->dc;
+ unsigned int output = crtc->id;
+ u32 dp_fmt;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(vsdc_dp_supported_fmts); i++) {
+ if (vsdc_dp_supported_fmts[i].linux_fmt ==
+ br_state->output_bus_cfg.format)
+ break;
+ }
+ if (WARN_ON_ONCE(i == ARRAY_SIZE(vsdc_dp_supported_fmts)))
+ return;
+ dp_fmt = vsdc_dp_supported_fmts[i].vsdc_fmt;
+ dp_fmt |= VSDC_DISP_DP_CONFIG_DP_EN;
+ regmap_write(dc->regs, VSDC_DISP_DP_CONFIG(output), dp_fmt);
+ regmap_assign_bits(dc->regs, VSDC_DISP_PANEL_CONFIG(output),
+ VSDC_DISP_PANEL_CONFIG_YUV,
+ vsdc_dp_supported_fmts[i].is_yuv);
+
+ vs_bridge_enable_common(crtc, br_state);
+}
+
+static void vs_bridge_atomic_disable(struct drm_bridge *bridge,
+ struct drm_atomic_state *state)
+{
+ struct vs_bridge *vbridge = drm_bridge_to_vs_bridge(bridge);
+ struct vs_crtc *crtc = vbridge->crtc;
+ struct vs_dc *dc = crtc->dc;
+ unsigned int output = crtc->id;
+
+ regmap_clear_bits(dc->regs, VSDC_DISP_PANEL_START,
+ VSDC_DISP_PANEL_START_MULTI_DISP_SYNC |
+ VSDC_DISP_PANEL_START_RUNNING(output));
+ regmap_clear_bits(dc->regs, VSDC_DISP_PANEL_CONFIG(output),
+ VSDC_DISP_PANEL_CONFIG_RUNNING);
+
+ regmap_set_bits(dc->regs, VSDC_DISP_PANEL_CONFIG_EX(crtc->id),
+ VSDC_DISP_PANEL_CONFIG_EX_COMMIT);
+}
+
+static const struct drm_bridge_funcs vs_dpi_bridge_funcs = {
+ .attach = vs_bridge_attach,
+ .atomic_enable = vs_bridge_atomic_enable_dpi,
+ .atomic_disable = vs_bridge_atomic_disable,
+ .atomic_get_input_bus_fmts = drm_atomic_helper_bridge_propagate_bus_fmt,
+ .atomic_get_output_bus_fmts = vs_bridge_atomic_get_output_bus_fmts_dpi,
+ .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+ .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+ .atomic_reset = drm_atomic_helper_bridge_reset,
+};
+
+static const struct drm_bridge_funcs vs_dp_bridge_funcs = {
+ .attach = vs_bridge_attach,
+ .atomic_enable = vs_bridge_atomic_enable_dp,
+ .atomic_disable = vs_bridge_atomic_disable,
+ .atomic_check = vs_bridge_atomic_check_dp,
+ .atomic_get_input_bus_fmts = vs_bridge_atomic_get_input_bus_fmts_dp,
+ .atomic_get_output_bus_fmts = vs_bridge_atomic_get_output_bus_fmts_dp,
+ .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+ .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+ .atomic_reset = drm_atomic_helper_bridge_reset,
+};
+
+static int vs_bridge_detect_output_interface(struct device_node *of_node,
+ unsigned int output)
+{
+ int ret;
+ struct device_node *remote;
+
+ remote = of_graph_get_remote_node(of_node, output,
+ VSDC_OUTPUT_INTERFACE_DPI);
+ if (remote) {
+ ret = VSDC_OUTPUT_INTERFACE_DPI;
+ } else {
+ remote = of_graph_get_remote_node(of_node, output,
+ VSDC_OUTPUT_INTERFACE_DP);
+ if (remote)
+ ret = VSDC_OUTPUT_INTERFACE_DP;
+ else
+ ret = -ENODEV;
+ }
+
+ if (remote)
+ of_node_put(remote);
+
+ return ret;
+}
+
+struct vs_bridge *vs_bridge_init(struct drm_device *drm_dev,
+ struct vs_crtc *crtc)
+{
+ unsigned int output = crtc->id;
+ struct vs_bridge *bridge;
+ struct drm_bridge *next;
+ enum vs_bridge_output_interface intf;
+ const struct drm_bridge_funcs *bridge_funcs;
+ int ret, enctype;
+
+ intf = vs_bridge_detect_output_interface(drm_dev->dev->of_node,
+ output);
+ if (intf == -ENODEV) {
+ drm_dbg(drm_dev, "Skipping output %u\n", output);
+ return NULL;
+ }
+
+ next = devm_drm_of_get_bridge(drm_dev->dev, drm_dev->dev->of_node,
+ output, intf);
+ if (IS_ERR(next)) {
+ ret = PTR_ERR(next);
+ if (ret != -EPROBE_DEFER)
+ drm_err(drm_dev,
+ "Cannot get downstream bridge of output %u\n",
+ output);
+ return ERR_PTR(ret);
+ }
+
+ if (intf == VSDC_OUTPUT_INTERFACE_DPI)
+ bridge_funcs = &vs_dpi_bridge_funcs;
+ else
+ bridge_funcs = &vs_dp_bridge_funcs;
+
+ bridge = devm_drm_bridge_alloc(drm_dev->dev, struct vs_bridge, base,
+ bridge_funcs);
+ if (IS_ERR(bridge))
+ return ERR_PTR(PTR_ERR(bridge));
+
+ bridge->crtc = crtc;
+ bridge->intf = intf;
+ bridge->next_bridge = next;
+
+ if (intf == VSDC_OUTPUT_INTERFACE_DPI)
+ enctype = DRM_MODE_ENCODER_DPI;
+ else
+ enctype = DRM_MODE_ENCODER_NONE;
+
+ bridge->enc = drmm_plain_encoder_alloc(drm_dev, NULL, enctype, NULL);
+ if (IS_ERR(bridge->enc)) {
+ drm_err(drm_dev,
+ "Cannot initialize encoder for output %u\n", output);
+ ret = PTR_ERR(bridge->enc);
+ return ERR_PTR(ret);
+ }
+
+ bridge->enc->possible_crtcs = drm_crtc_mask(&crtc->base);
+
+ ret = devm_drm_bridge_add(drm_dev->dev, &bridge->base);
+ if (ret) {
+ drm_err(drm_dev,
+ "Cannot add bridge for output %u\n", output);
+ return ERR_PTR(ret);
+ }
+
+ ret = drm_bridge_attach(bridge->enc, &bridge->base, NULL,
+ DRM_BRIDGE_ATTACH_NO_CONNECTOR);
+ if (ret) {
+ drm_err(drm_dev,
+ "Cannot attach bridge for output %u\n", output);
+ return ERR_PTR(ret);
+ }
+
+ bridge->conn = drm_bridge_connector_init(drm_dev, bridge->enc);
+ if (IS_ERR(bridge->conn)) {
+ drm_err(drm_dev,
+ "Cannot create connector for output %u\n", output);
+ ret = PTR_ERR(bridge->conn);
+ return ERR_PTR(ret);
+ }
+ drm_connector_attach_encoder(bridge->conn, bridge->enc);
+
+ return bridge;
+}
diff --git a/drivers/gpu/drm/verisilicon/vs_bridge.h b/drivers/gpu/drm/verisilicon/vs_bridge.h
new file mode 100644
index 0000000000000..70fee1749699a
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_bridge.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#ifndef _VS_BRIDGE_H_
+#define _VS_BRIDGE_H_
+
+#include <linux/types.h>
+
+#include <drm/drm_bridge.h>
+#include <drm/drm_connector.h>
+#include <drm/drm_encoder.h>
+
+struct vs_crtc;
+
+enum vs_bridge_output_interface {
+ VSDC_OUTPUT_INTERFACE_DPI = 0,
+ VSDC_OUTPUT_INTERFACE_DP = 1
+};
+
+struct vs_bridge {
+ struct drm_bridge base;
+ struct drm_encoder *enc;
+ struct drm_connector *conn;
+
+ struct vs_crtc *crtc;
+ struct drm_bridge *next_bridge;
+ enum vs_bridge_output_interface intf;
+};
+
+static inline struct vs_bridge *drm_bridge_to_vs_bridge(struct drm_bridge *bridge)
+{
+ return container_of(bridge, struct vs_bridge, base);
+}
+
+struct vs_bridge *vs_bridge_init(struct drm_device *drm_dev,
+ struct vs_crtc *crtc);
+#endif /* _VS_BRIDGE_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_bridge_regs.h b/drivers/gpu/drm/verisilicon/vs_bridge_regs.h
new file mode 100644
index 0000000000000..9eb30e4564beb
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_bridge_regs.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ *
+ * Based on vs_dc_hw.h, which is:
+ * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd.
+ */
+
+#ifndef _VS_BRIDGE_REGS_H_
+#define _VS_BRIDGE_REGS_H_
+
+#include <linux/bits.h>
+
+#define VSDC_DISP_PANEL_CONFIG(n) (0x1418 + 0x4 * (n))
+#define VSDC_DISP_PANEL_CONFIG_DE_EN BIT(0)
+#define VSDC_DISP_PANEL_CONFIG_DE_POL BIT(1)
+#define VSDC_DISP_PANEL_CONFIG_DAT_EN BIT(4)
+#define VSDC_DISP_PANEL_CONFIG_DAT_POL BIT(5)
+#define VSDC_DISP_PANEL_CONFIG_CLK_EN BIT(8)
+#define VSDC_DISP_PANEL_CONFIG_CLK_POL BIT(9)
+#define VSDC_DISP_PANEL_CONFIG_RUNNING BIT(12)
+#define VSDC_DISP_PANEL_CONFIG_GAMMA BIT(13)
+#define VSDC_DISP_PANEL_CONFIG_YUV BIT(16)
+
+#define VSDC_DISP_DPI_CONFIG(n) (0x14B8 + 0x4 * (n))
+#define VSDC_DISP_DPI_CONFIG_FMT_MASK GENMASK(2, 0)
+#define VSDC_DISP_DPI_CONFIG_FMT_RGB565 (0)
+#define VSDC_DISP_DPI_CONFIG_FMT_RGB666 (3)
+#define VSDC_DISP_DPI_CONFIG_FMT_RGB888 (5)
+#define VSDC_DISP_DPI_CONFIG_FMT_RGB101010 (6)
+
+#define VSDC_DISP_PANEL_START 0x1CCC
+#define VSDC_DISP_PANEL_START_RUNNING(n) BIT(n)
+#define VSDC_DISP_PANEL_START_MULTI_DISP_SYNC BIT(3)
+
+#define VSDC_DISP_DP_CONFIG(n) (0x1CD0 + 0x4 * (n))
+#define VSDC_DISP_DP_CONFIG_DP_EN BIT(3)
+#define VSDC_DISP_DP_CONFIG_FMT_MASK GENMASK(2, 0)
+#define VSDC_DISP_DP_CONFIG_FMT_RGB565 (0)
+#define VSDC_DISP_DP_CONFIG_FMT_RGB666 (1)
+#define VSDC_DISP_DP_CONFIG_FMT_RGB888 (2)
+#define VSDC_DISP_DP_CONFIG_FMT_RGB101010 (3)
+#define VSDC_DISP_DP_CONFIG_YUV_FMT_MASK GENMASK(7, 4)
+#define VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY8 (2 << 4)
+#define VSDC_DISP_DP_CONFIG_YUV_FMT_YUV8 (4 << 4)
+#define VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY10 (8 << 4)
+#define VSDC_DISP_DP_CONFIG_YUV_FMT_YUV10 (10 << 4)
+#define VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY8 (12 << 4)
+#define VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY10 (13 << 4)
+
+#define VSDC_DISP_PANEL_CONFIG_EX(n) (0x2518 + 0x4 * (n))
+#define VSDC_DISP_PANEL_CONFIG_EX_COMMIT BIT(0)
+
+#endif /* _VS_BRIDGE_REGS_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c b/drivers/gpu/drm/verisilicon/vs_crtc.c
new file mode 100644
index 0000000000000..f494017130006
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_crtc.c
@@ -0,0 +1,191 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#include <linux/clk.h>
+#include <linux/regmap.h>
+#include <linux/units.h>
+
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_print.h>
+#include <drm/drm_managed.h>
+#include <drm/drm_vblank_helper.h>
+
+#include "vs_crtc_regs.h"
+#include "vs_crtc.h"
+#include "vs_dc.h"
+#include "vs_dc_top_regs.h"
+#include "vs_drm.h"
+#include "vs_plane.h"
+
+static void vs_crtc_atomic_disable(struct drm_crtc *crtc,
+ struct drm_atomic_state *state)
+{
+ struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
+ struct vs_dc *dc = vcrtc->dc;
+ unsigned int output = vcrtc->id;
+
+ drm_crtc_vblank_off(crtc);
+
+ clk_disable_unprepare(dc->pix_clk[output]);
+}
+
+static void vs_crtc_atomic_enable(struct drm_crtc *crtc,
+ struct drm_atomic_state *state)
+{
+ struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
+ struct vs_dc *dc = vcrtc->dc;
+ unsigned int output = vcrtc->id;
+
+ drm_WARN_ON(&dc->drm_dev->base,
+ clk_prepare_enable(dc->pix_clk[output]));
+
+ drm_crtc_vblank_on(crtc);
+}
+
+static void vs_crtc_mode_set_nofb(struct drm_crtc *crtc)
+{
+ struct drm_display_mode *mode = &crtc->state->adjusted_mode;
+ struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
+ struct vs_dc *dc = vcrtc->dc;
+ unsigned int output = vcrtc->id;
+
+ regmap_write(dc->regs, VSDC_DISP_HSIZE(output),
+ VSDC_DISP_HSIZE_DISP(mode->hdisplay) |
+ VSDC_DISP_HSIZE_TOTAL(mode->htotal));
+ regmap_write(dc->regs, VSDC_DISP_VSIZE(output),
+ VSDC_DISP_VSIZE_DISP(mode->vdisplay) |
+ VSDC_DISP_VSIZE_TOTAL(mode->vtotal));
+ regmap_write(dc->regs, VSDC_DISP_HSYNC(output),
+ VSDC_DISP_HSYNC_START(mode->hsync_start) |
+ VSDC_DISP_HSYNC_END(mode->hsync_end) |
+ VSDC_DISP_HSYNC_EN);
+ if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
+ regmap_set_bits(dc->regs, VSDC_DISP_HSYNC(output),
+ VSDC_DISP_HSYNC_POL);
+ regmap_write(dc->regs, VSDC_DISP_VSYNC(output),
+ VSDC_DISP_VSYNC_START(mode->vsync_start) |
+ VSDC_DISP_VSYNC_END(mode->vsync_end) |
+ VSDC_DISP_VSYNC_EN);
+ if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
+ regmap_set_bits(dc->regs, VSDC_DISP_VSYNC(output),
+ VSDC_DISP_VSYNC_POL);
+
+ WARN_ON(clk_set_rate(dc->pix_clk[output], mode->crtc_clock * 1000));
+}
+
+static enum drm_mode_status
+vs_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
+{
+ struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
+ struct vs_dc *dc = vcrtc->dc;
+ unsigned int output = vcrtc->id;
+ long rate;
+
+ if (mode->htotal > VSDC_DISP_TIMING_VALUE_MAX)
+ return MODE_BAD_HVALUE;
+ if (mode->vtotal > VSDC_DISP_TIMING_VALUE_MAX)
+ return MODE_BAD_VVALUE;
+
+ rate = clk_round_rate(dc->pix_clk[output], mode->clock * HZ_PER_KHZ);
+ if (rate <= 0)
+ return MODE_CLOCK_RANGE;
+
+ return MODE_OK;
+}
+
+static bool vs_crtc_mode_fixup(struct drm_crtc *crtc,
+ const struct drm_display_mode *m,
+ struct drm_display_mode *adjusted_mode)
+{
+ struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
+ struct vs_dc *dc = vcrtc->dc;
+ unsigned int output = vcrtc->id;
+ long clk_rate;
+
+ drm_mode_set_crtcinfo(adjusted_mode, 0);
+
+ /* Feedback the pixel clock to crtc_clock */
+ clk_rate = adjusted_mode->crtc_clock * HZ_PER_KHZ;
+ clk_rate = clk_round_rate(dc->pix_clk[output], clk_rate);
+ if (clk_rate <= 0)
+ return false;
+
+ adjusted_mode->crtc_clock = clk_rate / HZ_PER_KHZ;
+
+ return true;
+}
+
+static const struct drm_crtc_helper_funcs vs_crtc_helper_funcs = {
+ .atomic_flush = drm_crtc_vblank_atomic_flush,
+ .atomic_enable = vs_crtc_atomic_enable,
+ .atomic_disable = vs_crtc_atomic_disable,
+ .mode_set_nofb = vs_crtc_mode_set_nofb,
+ .mode_valid = vs_crtc_mode_valid,
+ .mode_fixup = vs_crtc_mode_fixup,
+};
+
+static int vs_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+ struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
+ struct vs_dc *dc = vcrtc->dc;
+
+ regmap_set_bits(dc->regs, VSDC_TOP_IRQ_EN, VSDC_TOP_IRQ_VSYNC(vcrtc->id));
+
+ return 0;
+}
+
+static void vs_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+ struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
+ struct vs_dc *dc = vcrtc->dc;
+
+ regmap_clear_bits(dc->regs, VSDC_TOP_IRQ_EN, VSDC_TOP_IRQ_VSYNC(vcrtc->id));
+}
+
+static const struct drm_crtc_funcs vs_crtc_funcs = {
+ .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+ .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
+ .page_flip = drm_atomic_helper_page_flip,
+ .reset = drm_atomic_helper_crtc_reset,
+ .set_config = drm_atomic_helper_set_config,
+ .enable_vblank = vs_crtc_enable_vblank,
+ .disable_vblank = vs_crtc_disable_vblank,
+};
+
+struct vs_crtc *vs_crtc_init(struct drm_device *drm_dev, struct vs_dc *dc,
+ unsigned int output)
+{
+ struct vs_crtc *vcrtc;
+ struct drm_plane *primary;
+ int ret;
+
+ vcrtc = drmm_kzalloc(drm_dev, sizeof(*vcrtc), GFP_KERNEL);
+ if (!vcrtc)
+ return ERR_PTR(-ENOMEM);
+ vcrtc->dc = dc;
+ vcrtc->id = output;
+
+ /* Create our primary plane */
+ primary = vs_primary_plane_init(drm_dev, dc);
+ if (IS_ERR(primary)) {
+ drm_err(drm_dev, "Couldn't create the primary plane\n");
+ return ERR_PTR(PTR_ERR(primary));
+ }
+
+ ret = drmm_crtc_init_with_planes(drm_dev, &vcrtc->base,
+ primary,
+ NULL,
+ &vs_crtc_funcs,
+ NULL);
+ if (ret) {
+ drm_err(drm_dev, "Couldn't initialize CRTC\n");
+ return ERR_PTR(ret);
+ }
+
+ drm_crtc_helper_add(&vcrtc->base, &vs_crtc_helper_funcs);
+
+ return vcrtc;
+}
diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.h b/drivers/gpu/drm/verisilicon/vs_crtc.h
new file mode 100644
index 0000000000000..b45580bd99b33
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_crtc.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#ifndef _VS_CRTC_H_
+#define _VS_CRTC_H_
+
+#include <drm/drm_crtc.h>
+#include <drm/drm_vblank.h>
+
+#define VSDC_DISP_TIMING_VALUE_MAX BIT_MASK(15)
+
+struct vs_dc;
+
+struct vs_crtc {
+ struct drm_crtc base;
+
+ struct vs_dc *dc;
+ unsigned int id;
+};
+
+static inline struct vs_crtc *drm_crtc_to_vs_crtc(struct drm_crtc *crtc)
+{
+ return container_of(crtc, struct vs_crtc, base);
+}
+
+struct vs_crtc *vs_crtc_init(struct drm_device *drm_dev, struct vs_dc *dc,
+ unsigned int output);
+
+#endif /* _VS_CRTC_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_crtc_regs.h b/drivers/gpu/drm/verisilicon/vs_crtc_regs.h
new file mode 100644
index 0000000000000..c7930e817635c
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_crtc_regs.h
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ *
+ * Based on vs_dc_hw.h, which is:
+ * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd.
+ */
+
+#ifndef _VS_CRTC_REGS_H_
+#define _VS_CRTC_REGS_H_
+
+#include <linux/bits.h>
+
+#define VSDC_DISP_DITHER_CONFIG(n) (0x1410 + 0x4 * (n))
+
+#define VSDC_DISP_DITHER_TABLE_LOW(n) (0x1420 + 0x4 * (n))
+#define VSDC_DISP_DITHER_TABLE_LOW_DEFAULT 0x7B48F3C0
+
+#define VSDC_DISP_DITHER_TABLE_HIGH(n) (0x1428 + 0x4 * (n))
+#define VSDC_DISP_DITHER_TABLE_HIGH_DEFAULT 0x596AD1E2
+
+#define VSDC_DISP_HSIZE(n) (0x1430 + 0x4 * (n))
+#define VSDC_DISP_HSIZE_DISP_MASK GENMASK(14, 0)
+#define VSDC_DISP_HSIZE_DISP(v) ((v) << 0)
+#define VSDC_DISP_HSIZE_TOTAL_MASK GENMASK(30, 16)
+#define VSDC_DISP_HSIZE_TOTAL(v) ((v) << 16)
+
+#define VSDC_DISP_HSYNC(n) (0x1438 + 0x4 * (n))
+#define VSDC_DISP_HSYNC_START_MASK GENMASK(14, 0)
+#define VSDC_DISP_HSYNC_START(v) ((v) << 0)
+#define VSDC_DISP_HSYNC_END_MASK GENMASK(29, 15)
+#define VSDC_DISP_HSYNC_END(v) ((v) << 15)
+#define VSDC_DISP_HSYNC_EN BIT(30)
+#define VSDC_DISP_HSYNC_POL BIT(31)
+
+#define VSDC_DISP_VSIZE(n) (0x1440 + 0x4 * (n))
+#define VSDC_DISP_VSIZE_DISP_MASK GENMASK(14, 0)
+#define VSDC_DISP_VSIZE_DISP(v) ((v) << 0)
+#define VSDC_DISP_VSIZE_TOTAL_MASK GENMASK(30, 16)
+#define VSDC_DISP_VSIZE_TOTAL(v) ((v) << 16)
+
+#define VSDC_DISP_VSYNC(n) (0x1448 + 0x4 * (n))
+#define VSDC_DISP_VSYNC_START_MASK GENMASK(14, 0)
+#define VSDC_DISP_VSYNC_START(v) ((v) << 0)
+#define VSDC_DISP_VSYNC_END_MASK GENMASK(29, 15)
+#define VSDC_DISP_VSYNC_END(v) ((v) << 15)
+#define VSDC_DISP_VSYNC_EN BIT(30)
+#define VSDC_DISP_VSYNC_POL BIT(31)
+
+#define VSDC_DISP_CURRENT_LOCATION(n) (0x1450 + 0x4 * (n))
+
+#define VSDC_DISP_GAMMA_INDEX(n) (0x1458 + 0x4 * (n))
+
+#define VSDC_DISP_GAMMA_DATA(n) (0x1460 + 0x4 * (n))
+
+#define VSDC_DISP_IRQ_STA 0x147C
+
+#define VSDC_DISP_IRQ_EN 0x1480
+
+#endif /* _VS_CRTC_REGS_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_dc.c b/drivers/gpu/drm/verisilicon/vs_dc.c
new file mode 100644
index 0000000000000..ba1b3f261a3ae
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_dc.c
@@ -0,0 +1,207 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/irqreturn.h>
+#include <linux/of.h>
+#include <linux/of_graph.h>
+
+#include "vs_crtc.h"
+#include "vs_dc.h"
+#include "vs_dc_top_regs.h"
+#include "vs_drm.h"
+#include "vs_hwdb.h"
+
+static const struct regmap_config vs_dc_regmap_cfg = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = sizeof(u32),
+ /* VSDC_OVL_CONFIG_EX(1) */
+ .max_register = 0x2544,
+};
+
+static const struct of_device_id vs_dc_driver_dt_match[] = {
+ { .compatible = "verisilicon,dc" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, vs_dc_driver_dt_match);
+
+static irqreturn_t vs_dc_irq_handler(int irq, void *private)
+{
+ struct vs_dc *dc = private;
+ u32 irqs;
+
+ regmap_read(dc->regs, VSDC_TOP_IRQ_ACK, &irqs);
+
+ vs_drm_handle_irq(dc, irqs);
+
+ return IRQ_HANDLED;
+}
+
+static int vs_dc_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct vs_dc *dc;
+ void __iomem *regs;
+ unsigned int port_count, i;
+ /* pix0/pix1 */
+ char pixclk_name[5];
+ int irq, ret;
+
+ if (!dev->of_node) {
+ dev_err(dev, "can't find DC devices\n");
+ return -ENODEV;
+ }
+
+ port_count = of_graph_get_port_count(dev->of_node);
+ if (!port_count) {
+ dev_err(dev, "can't find DC downstream ports\n");
+ return -ENODEV;
+ }
+ if (port_count > VSDC_MAX_OUTPUTS) {
+ dev_err(dev, "too many DC downstream ports than possible\n");
+ return -EINVAL;
+ }
+
+ ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+ if (ret) {
+ dev_err(dev, "No suitable DMA available\n");
+ return ret;
+ }
+
+ dc = devm_kzalloc(dev, sizeof(*dc), GFP_KERNEL);
+ if (!dc)
+ return -ENOMEM;
+
+ dc->rsts[0].id = "core";
+ dc->rsts[1].id = "axi";
+ dc->rsts[2].id = "ahb";
+
+ ret = devm_reset_control_bulk_get_optional_shared(dev, VSDC_RESET_COUNT,
+ dc->rsts);
+ if (ret) {
+ dev_err(dev, "can't get reset lines\n");
+ return ret;
+ }
+
+ dc->core_clk = devm_clk_get_enabled(dev, "core");
+ if (IS_ERR(dc->core_clk)) {
+ dev_err(dev, "can't get core clock\n");
+ return PTR_ERR(dc->core_clk);
+ }
+
+ dc->axi_clk = devm_clk_get_enabled(dev, "axi");
+ if (IS_ERR(dc->axi_clk)) {
+ dev_err(dev, "can't get axi clock\n");
+ return PTR_ERR(dc->axi_clk);
+ }
+
+ dc->ahb_clk = devm_clk_get_enabled(dev, "ahb");
+ if (IS_ERR(dc->ahb_clk)) {
+ dev_err(dev, "can't get ahb clock\n");
+ return PTR_ERR(dc->ahb_clk);
+ }
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0) {
+ dev_err(dev, "can't get irq\n");
+ return irq;
+ }
+
+ ret = reset_control_bulk_deassert(VSDC_RESET_COUNT, dc->rsts);
+ if (ret) {
+ dev_err(dev, "can't deassert reset lines\n");
+ return ret;
+ }
+
+ regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(regs)) {
+ dev_err(dev, "can't map registers");
+ ret = PTR_ERR(regs);
+ goto err_rst_assert;
+ }
+
+ dc->regs = devm_regmap_init_mmio(dev, regs, &vs_dc_regmap_cfg);
+ if (IS_ERR(dc->regs)) {
+ ret = PTR_ERR(dc->regs);
+ goto err_rst_assert;
+ }
+
+ ret = vs_fill_chip_identity(dc->regs, &dc->identity);
+ if (ret)
+ goto err_rst_assert;
+
+ dev_info(dev, "Found DC%x rev %x customer %x\n", dc->identity.model,
+ dc->identity.revision, dc->identity.customer_id);
+
+ if (port_count > dc->identity.display_count) {
+ dev_err(dev, "too many downstream ports than HW capability\n");
+ ret = -EINVAL;
+ goto err_rst_assert;
+ }
+
+ for (i = 0; i < dc->identity.display_count; i++) {
+ snprintf(pixclk_name, sizeof(pixclk_name), "pix%u", i);
+ dc->pix_clk[i] = devm_clk_get(dev, pixclk_name);
+ if (IS_ERR(dc->pix_clk[i])) {
+ dev_err(dev, "can't get pixel clk %u\n", i);
+ ret = PTR_ERR(dc->pix_clk[i]);
+ goto err_rst_assert;
+ }
+ }
+
+ ret = devm_request_irq(dev, irq, vs_dc_irq_handler, 0,
+ dev_name(dev), dc);
+ if (ret) {
+ dev_err(dev, "can't request irq\n");
+ goto err_rst_assert;
+ }
+
+ dev_set_drvdata(dev, dc);
+
+ ret = vs_drm_initialize(dc, pdev);
+ if (ret)
+ goto err_rst_assert;
+
+ return 0;
+
+err_rst_assert:
+ reset_control_bulk_assert(VSDC_RESET_COUNT, dc->rsts);
+ return ret;
+}
+
+static void vs_dc_remove(struct platform_device *pdev)
+{
+ struct vs_dc *dc = dev_get_drvdata(&pdev->dev);
+
+ vs_drm_finalize(dc);
+
+ dev_set_drvdata(&pdev->dev, NULL);
+
+ reset_control_bulk_assert(VSDC_RESET_COUNT, dc->rsts);
+}
+
+static void vs_dc_shutdown(struct platform_device *pdev)
+{
+ struct vs_dc *dc = dev_get_drvdata(&pdev->dev);
+
+ vs_drm_shutdown_handler(dc);
+}
+
+struct platform_driver vs_dc_platform_driver = {
+ .probe = vs_dc_probe,
+ .remove = vs_dc_remove,
+ .shutdown = vs_dc_shutdown,
+ .driver = {
+ .name = "verisilicon-dc",
+ .of_match_table = vs_dc_driver_dt_match,
+ },
+};
+
+module_platform_driver(vs_dc_platform_driver);
+
+MODULE_AUTHOR("Icenowy Zheng <uwu@icenowy.me>");
+MODULE_DESCRIPTION("Verisilicon display controller driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/drm/verisilicon/vs_dc.h b/drivers/gpu/drm/verisilicon/vs_dc.h
new file mode 100644
index 0000000000000..ed1016f18758e
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_dc.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ *
+ * Based on vs_dc_hw.h, which is:
+ * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd.
+ */
+
+#ifndef _VS_DC_H_
+#define _VS_DC_H_
+
+#include <linux/clk.h>
+#include <linux/regmap.h>
+#include <linux/reset.h>
+
+#include <drm/drm_device.h>
+
+#include "vs_hwdb.h"
+
+#define VSDC_MAX_OUTPUTS 2
+#define VSDC_RESET_COUNT 3
+
+struct vs_drm_dev;
+struct vs_crtc;
+
+struct vs_dc {
+ struct regmap *regs;
+ struct clk *core_clk;
+ struct clk *axi_clk;
+ struct clk *ahb_clk;
+ struct clk *pix_clk[VSDC_MAX_OUTPUTS];
+ struct reset_control_bulk_data rsts[VSDC_RESET_COUNT];
+
+ struct vs_drm_dev *drm_dev;
+ struct vs_chip_identity identity;
+};
+
+#endif /* _VS_DC_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_dc_top_regs.h b/drivers/gpu/drm/verisilicon/vs_dc_top_regs.h
new file mode 100644
index 0000000000000..50509bbbff08f
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_dc_top_regs.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ *
+ * Based on vs_dc_hw.h, which is:
+ * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd.
+ */
+
+#ifndef _VS_DC_TOP_H_
+#define _VS_DC_TOP_H_
+
+#include <linux/bits.h>
+
+#define VSDC_TOP_RST 0x0000
+
+#define VSDC_TOP_IRQ_ACK 0x0010
+#define VSDC_TOP_IRQ_VSYNC(n) BIT(n)
+
+#define VSDC_TOP_IRQ_EN 0x0014
+
+#define VSDC_TOP_CHIP_MODEL 0x0020
+
+#define VSDC_TOP_CHIP_REV 0x0024
+
+#define VSDC_TOP_CHIP_CUSTOMER_ID 0x0030
+
+#endif /* _VS_DC_TOP_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_drm.c b/drivers/gpu/drm/verisilicon/vs_drm.c
new file mode 100644
index 0000000000000..fd259d53f49f1
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_drm.c
@@ -0,0 +1,182 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#include <linux/aperture.h>
+#include <linux/dma-mapping.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/console.h>
+
+#include <drm/clients/drm_client_setup.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_dumb_buffers.h>
+#include <drm/drm_fbdev_dma.h>
+#include <drm/drm_gem_dma_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_of.h>
+#include <drm/drm_print.h>
+#include <drm/drm_probe_helper.h>
+#include <drm/drm_vblank.h>
+
+#include "vs_bridge.h"
+#include "vs_crtc.h"
+#include "vs_dc.h"
+#include "vs_dc_top_regs.h"
+#include "vs_drm.h"
+
+#define DRIVER_NAME "verisilicon"
+#define DRIVER_DESC "Verisilicon DC-series display controller driver"
+#define DRIVER_MAJOR 1
+#define DRIVER_MINOR 0
+
+static int vs_gem_dumb_create(struct drm_file *file_priv,
+ struct drm_device *drm,
+ struct drm_mode_create_dumb *args)
+{
+ int ret;
+
+ /* The hardware wants 128B-aligned pitches for linear buffers. */
+ ret = drm_mode_size_dumb(drm, args, 128, 0);
+ if (ret)
+ return ret;
+
+ return drm_gem_dma_dumb_create_internal(file_priv, drm, args);
+}
+
+DEFINE_DRM_GEM_FOPS(vs_drm_driver_fops);
+
+static const struct drm_driver vs_drm_driver = {
+ .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
+ .fops = &vs_drm_driver_fops,
+ .name = DRIVER_NAME,
+ .desc = DRIVER_DESC,
+ .major = DRIVER_MAJOR,
+ .minor = DRIVER_MINOR,
+
+ /* GEM Operations */
+ DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(vs_gem_dumb_create),
+ DRM_FBDEV_DMA_DRIVER_OPS,
+};
+
+static const struct drm_mode_config_funcs vs_mode_config_funcs = {
+ .fb_create = drm_gem_fb_create,
+ .atomic_check = drm_atomic_helper_check,
+ .atomic_commit = drm_atomic_helper_commit,
+};
+
+static struct drm_mode_config_helper_funcs vs_mode_config_helper_funcs = {
+ .atomic_commit_tail = drm_atomic_helper_commit_tail,
+};
+
+static void vs_mode_config_init(struct drm_device *drm)
+{
+ drm->mode_config.min_width = 0;
+ drm->mode_config.min_height = 0;
+ drm->mode_config.max_width = 8192;
+ drm->mode_config.max_height = 8192;
+ drm->mode_config.funcs = &vs_mode_config_funcs;
+ drm->mode_config.helper_private = &vs_mode_config_helper_funcs;
+}
+
+int vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct vs_drm_dev *vdrm;
+ struct drm_device *drm;
+ struct vs_crtc *crtc;
+ struct vs_bridge *bridge;
+ unsigned int i;
+ int ret;
+
+ vdrm = devm_drm_dev_alloc(dev, &vs_drm_driver, struct vs_drm_dev, base);
+ if (IS_ERR(vdrm))
+ return PTR_ERR(vdrm);
+
+ drm = &vdrm->base;
+ vdrm->dc = dc;
+ dc->drm_dev = vdrm;
+
+ ret = drmm_mode_config_init(drm);
+ if (ret)
+ return ret;
+
+ /* Remove early framebuffers (ie. simple-framebuffer) */
+ ret = aperture_remove_all_conflicting_devices(DRIVER_NAME);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < dc->identity.display_count; i++) {
+ crtc = vs_crtc_init(drm, dc, i);
+ if (IS_ERR(crtc))
+ return PTR_ERR(crtc);
+
+ bridge = vs_bridge_init(drm, crtc);
+ if (IS_ERR(bridge))
+ return PTR_ERR(bridge);
+
+ vdrm->crtcs[i] = crtc;
+ }
+
+ ret = drm_vblank_init(drm, dc->identity.display_count);
+ if (ret)
+ return ret;
+
+ vs_mode_config_init(drm);
+
+ /* Enable connectors polling */
+ drm_kms_helper_poll_init(drm);
+
+ drm_mode_config_reset(drm);
+
+ ret = drm_dev_register(drm, 0);
+ if (ret)
+ goto err_fini_poll;
+
+ drm_client_setup(drm, NULL);
+
+ return 0;
+
+err_fini_poll:
+ drm_kms_helper_poll_fini(drm);
+ return ret;
+}
+
+void vs_drm_finalize(struct vs_dc *dc)
+{
+ struct vs_drm_dev *vdrm = dc->drm_dev;
+ struct drm_device *drm = &vdrm->base;
+
+ drm_dev_unregister(drm);
+ drm_kms_helper_poll_fini(drm);
+ drm_atomic_helper_shutdown(drm);
+ dc->drm_dev = NULL;
+}
+
+void vs_drm_shutdown_handler(struct vs_dc *dc)
+{
+ struct vs_drm_dev *vdrm = dc->drm_dev;
+
+ drm_atomic_helper_shutdown(&vdrm->base);
+}
+
+void vs_drm_handle_irq(struct vs_dc *dc, u32 irqs)
+{
+ unsigned int i;
+
+ for (i = 0; i < dc->identity.display_count; i++) {
+ if (irqs & VSDC_TOP_IRQ_VSYNC(i)) {
+ irqs &= ~VSDC_TOP_IRQ_VSYNC(i);
+ if (dc->drm_dev->crtcs[i])
+ drm_crtc_handle_vblank(&dc->drm_dev->crtcs[i]->base);
+ }
+ }
+
+ if (irqs)
+ drm_warn_once(&dc->drm_dev->base,
+ "Unknown Verisilicon DC interrupt 0x%x fired!\n",
+ irqs);
+}
diff --git a/drivers/gpu/drm/verisilicon/vs_drm.h b/drivers/gpu/drm/verisilicon/vs_drm.h
new file mode 100644
index 0000000000000..606338206a427
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_drm.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#ifndef _VS_DRM_H_
+#define _VS_DRM_H_
+
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
+#include <drm/drm_device.h>
+
+struct vs_dc;
+
+struct vs_drm_dev {
+ struct drm_device base;
+
+ struct vs_dc *dc;
+ struct vs_crtc *crtcs[VSDC_MAX_OUTPUTS];
+};
+
+int vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev);
+void vs_drm_finalize(struct vs_dc *dc);
+void vs_drm_shutdown_handler(struct vs_dc *dc);
+void vs_drm_handle_irq(struct vs_dc *dc, u32 irqs);
+
+#endif /* _VS_DRM_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_hwdb.c b/drivers/gpu/drm/verisilicon/vs_hwdb.c
new file mode 100644
index 0000000000000..09336af0900ae
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_hwdb.c
@@ -0,0 +1,150 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#include <linux/errno.h>
+
+#include <drm/drm_fourcc.h>
+
+#include "vs_dc_top_regs.h"
+#include "vs_hwdb.h"
+
+static const u32 vs_formats_array_no_yuv444[] = {
+ DRM_FORMAT_XRGB4444,
+ DRM_FORMAT_XBGR4444,
+ DRM_FORMAT_RGBX4444,
+ DRM_FORMAT_BGRX4444,
+ DRM_FORMAT_ARGB4444,
+ DRM_FORMAT_ABGR4444,
+ DRM_FORMAT_RGBA4444,
+ DRM_FORMAT_BGRA4444,
+ DRM_FORMAT_XRGB1555,
+ DRM_FORMAT_XBGR1555,
+ DRM_FORMAT_RGBX5551,
+ DRM_FORMAT_BGRX5551,
+ DRM_FORMAT_ARGB1555,
+ DRM_FORMAT_ABGR1555,
+ DRM_FORMAT_RGBA5551,
+ DRM_FORMAT_BGRA5551,
+ DRM_FORMAT_RGB565,
+ DRM_FORMAT_BGR565,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_XBGR8888,
+ DRM_FORMAT_RGBX8888,
+ DRM_FORMAT_BGRX8888,
+ DRM_FORMAT_ARGB8888,
+ DRM_FORMAT_ABGR8888,
+ DRM_FORMAT_RGBA8888,
+ DRM_FORMAT_BGRA8888,
+ DRM_FORMAT_ARGB2101010,
+ DRM_FORMAT_ABGR2101010,
+ DRM_FORMAT_RGBA1010102,
+ DRM_FORMAT_BGRA1010102,
+ /* TODO: non-RGB formats */
+};
+
+static const u32 vs_formats_array_with_yuv444[] = {
+ DRM_FORMAT_XRGB4444,
+ DRM_FORMAT_XBGR4444,
+ DRM_FORMAT_RGBX4444,
+ DRM_FORMAT_BGRX4444,
+ DRM_FORMAT_ARGB4444,
+ DRM_FORMAT_ABGR4444,
+ DRM_FORMAT_RGBA4444,
+ DRM_FORMAT_BGRA4444,
+ DRM_FORMAT_XRGB1555,
+ DRM_FORMAT_XBGR1555,
+ DRM_FORMAT_RGBX5551,
+ DRM_FORMAT_BGRX5551,
+ DRM_FORMAT_ARGB1555,
+ DRM_FORMAT_ABGR1555,
+ DRM_FORMAT_RGBA5551,
+ DRM_FORMAT_BGRA5551,
+ DRM_FORMAT_RGB565,
+ DRM_FORMAT_BGR565,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_XBGR8888,
+ DRM_FORMAT_RGBX8888,
+ DRM_FORMAT_BGRX8888,
+ DRM_FORMAT_ARGB8888,
+ DRM_FORMAT_ABGR8888,
+ DRM_FORMAT_RGBA8888,
+ DRM_FORMAT_BGRA8888,
+ DRM_FORMAT_ARGB2101010,
+ DRM_FORMAT_ABGR2101010,
+ DRM_FORMAT_RGBA1010102,
+ DRM_FORMAT_BGRA1010102,
+ /* TODO: non-RGB formats */
+};
+
+static const struct vs_formats vs_formats_no_yuv444 = {
+ .array = vs_formats_array_no_yuv444,
+ .num = ARRAY_SIZE(vs_formats_array_no_yuv444)
+};
+
+static const struct vs_formats vs_formats_with_yuv444 = {
+ .array = vs_formats_array_with_yuv444,
+ .num = ARRAY_SIZE(vs_formats_array_with_yuv444)
+};
+
+static struct vs_chip_identity vs_chip_identities[] = {
+ {
+ .model = 0x8200,
+ .revision = 0x5720,
+ .customer_id = ~0U,
+
+ .display_count = 2,
+ .formats = &vs_formats_no_yuv444,
+ },
+ {
+ .model = 0x8200,
+ .revision = 0x5721,
+ .customer_id = 0x30B,
+
+ .display_count = 2,
+ .formats = &vs_formats_no_yuv444,
+ },
+ {
+ .model = 0x8200,
+ .revision = 0x5720,
+ .customer_id = 0x310,
+
+ .display_count = 2,
+ .formats = &vs_formats_with_yuv444,
+ },
+ {
+ .model = 0x8200,
+ .revision = 0x5720,
+ .customer_id = 0x311,
+
+ .display_count = 2,
+ .formats = &vs_formats_no_yuv444,
+ },
+};
+
+int vs_fill_chip_identity(struct regmap *regs,
+ struct vs_chip_identity *ident)
+{
+ u32 model;
+ u32 revision;
+ u32 customer_id;
+ int i;
+
+ regmap_read(regs, VSDC_TOP_CHIP_MODEL, &model);
+ regmap_read(regs, VSDC_TOP_CHIP_REV, &revision);
+ regmap_read(regs, VSDC_TOP_CHIP_CUSTOMER_ID, &customer_id);
+
+ for (i = 0; i < ARRAY_SIZE(vs_chip_identities); i++) {
+ if (vs_chip_identities[i].model == model &&
+ vs_chip_identities[i].revision == revision &&
+ (vs_chip_identities[i].customer_id == customer_id ||
+ vs_chip_identities[i].customer_id == ~0U)) {
+ memcpy(ident, &vs_chip_identities[i], sizeof(*ident));
+ ident->customer_id = customer_id;
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
diff --git a/drivers/gpu/drm/verisilicon/vs_hwdb.h b/drivers/gpu/drm/verisilicon/vs_hwdb.h
new file mode 100644
index 0000000000000..92192e4fa0862
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_hwdb.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#ifndef _VS_HWDB_H_
+#define _VS_HWDB_H_
+
+#include <linux/regmap.h>
+#include <linux/types.h>
+
+struct vs_formats {
+ const u32 *array;
+ unsigned int num;
+};
+
+struct vs_chip_identity {
+ u32 model;
+ u32 revision;
+ u32 customer_id;
+
+ u32 display_count;
+ const struct vs_formats *formats;
+};
+
+int vs_fill_chip_identity(struct regmap *regs,
+ struct vs_chip_identity *ident);
+
+#endif /* _VS_HWDB_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_plane.c b/drivers/gpu/drm/verisilicon/vs_plane.c
new file mode 100644
index 0000000000000..2f3953e588a34
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_plane.c
@@ -0,0 +1,124 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#include <linux/errno.h>
+#include <linux/printk.h>
+
+#include <drm/drm_fb_dma_helper.h>
+#include <drm/drm_fourcc.h>
+#include <drm/drm_gem_dma_helper.h>
+
+#include "vs_plane.h"
+
+void drm_format_to_vs_format(u32 drm_format, struct vs_format *vs_format)
+{
+ switch (drm_format) {
+ case DRM_FORMAT_XRGB4444:
+ case DRM_FORMAT_RGBX4444:
+ case DRM_FORMAT_XBGR4444:
+ case DRM_FORMAT_BGRX4444:
+ vs_format->color = VSDC_COLOR_FORMAT_X4R4G4B4;
+ break;
+ case DRM_FORMAT_ARGB4444:
+ case DRM_FORMAT_RGBA4444:
+ case DRM_FORMAT_ABGR4444:
+ case DRM_FORMAT_BGRA4444:
+ vs_format->color = VSDC_COLOR_FORMAT_A4R4G4B4;
+ break;
+ case DRM_FORMAT_XRGB1555:
+ case DRM_FORMAT_RGBX5551:
+ case DRM_FORMAT_XBGR1555:
+ case DRM_FORMAT_BGRX5551:
+ vs_format->color = VSDC_COLOR_FORMAT_X1R5G5B5;
+ break;
+ case DRM_FORMAT_ARGB1555:
+ case DRM_FORMAT_RGBA5551:
+ case DRM_FORMAT_ABGR1555:
+ case DRM_FORMAT_BGRA5551:
+ vs_format->color = VSDC_COLOR_FORMAT_A1R5G5B5;
+ break;
+ case DRM_FORMAT_RGB565:
+ case DRM_FORMAT_BGR565:
+ vs_format->color = VSDC_COLOR_FORMAT_R5G6B5;
+ break;
+ case DRM_FORMAT_XRGB8888:
+ case DRM_FORMAT_RGBX8888:
+ case DRM_FORMAT_XBGR8888:
+ case DRM_FORMAT_BGRX8888:
+ vs_format->color = VSDC_COLOR_FORMAT_X8R8G8B8;
+ break;
+ case DRM_FORMAT_ARGB8888:
+ case DRM_FORMAT_RGBA8888:
+ case DRM_FORMAT_ABGR8888:
+ case DRM_FORMAT_BGRA8888:
+ vs_format->color = VSDC_COLOR_FORMAT_A8R8G8B8;
+ break;
+ case DRM_FORMAT_ARGB2101010:
+ case DRM_FORMAT_RGBA1010102:
+ case DRM_FORMAT_ABGR2101010:
+ case DRM_FORMAT_BGRA1010102:
+ vs_format->color = VSDC_COLOR_FORMAT_A2R10G10B10;
+ break;
+ default:
+ pr_warn("Unexpected drm format!\n");
+ }
+
+ switch (drm_format) {
+ case DRM_FORMAT_RGBX4444:
+ case DRM_FORMAT_RGBA4444:
+ case DRM_FORMAT_RGBX5551:
+ case DRM_FORMAT_RGBA5551:
+ case DRM_FORMAT_RGBX8888:
+ case DRM_FORMAT_RGBA8888:
+ case DRM_FORMAT_RGBA1010102:
+ vs_format->swizzle = VSDC_SWIZZLE_RGBA;
+ break;
+ case DRM_FORMAT_XBGR4444:
+ case DRM_FORMAT_ABGR4444:
+ case DRM_FORMAT_XBGR1555:
+ case DRM_FORMAT_ABGR1555:
+ case DRM_FORMAT_BGR565:
+ case DRM_FORMAT_XBGR8888:
+ case DRM_FORMAT_ABGR8888:
+ case DRM_FORMAT_ABGR2101010:
+ vs_format->swizzle = VSDC_SWIZZLE_ABGR;
+ break;
+ case DRM_FORMAT_BGRX4444:
+ case DRM_FORMAT_BGRA4444:
+ case DRM_FORMAT_BGRX5551:
+ case DRM_FORMAT_BGRA5551:
+ case DRM_FORMAT_BGRX8888:
+ case DRM_FORMAT_BGRA8888:
+ case DRM_FORMAT_BGRA1010102:
+ vs_format->swizzle = VSDC_SWIZZLE_BGRA;
+ break;
+ default:
+ /* N/A for YUV formats */
+ vs_format->swizzle = VSDC_SWIZZLE_ARGB;
+ }
+
+ /* N/A for non-YUV formats */
+ vs_format->uv_swizzle = false;
+}
+
+dma_addr_t vs_fb_get_dma_addr(struct drm_framebuffer *fb,
+ const struct drm_rect *src_rect)
+{
+ struct drm_gem_dma_object *gem;
+ dma_addr_t dma_addr;
+
+ /* Get the physical address of the buffer in memory */
+ gem = drm_fb_dma_get_gem_obj(fb, 0);
+
+ /* Compute the start of the displayed memory */
+ dma_addr = gem->dma_addr + fb->offsets[0];
+
+ /* Fixup framebuffer address for src coordinates */
+ dma_addr += drm_format_info_min_pitch(fb->format, 0,
+ src_rect->x1 >> 16);
+ dma_addr += (src_rect->y1 >> 16) * fb->pitches[0];
+
+ return dma_addr;
+}
diff --git a/drivers/gpu/drm/verisilicon/vs_plane.h b/drivers/gpu/drm/verisilicon/vs_plane.h
new file mode 100644
index 0000000000000..41875ea3d66a5
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_plane.h
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ *
+ * Based on vs_dc_hw.h, which is:
+ * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd.
+ */
+
+#ifndef _VS_PLANE_H_
+#define _VS_PLANE_H_
+
+#include <linux/types.h>
+
+#include <drm/drm_device.h>
+#include <drm/drm_framebuffer.h>
+#include <drm/drm_plane.h>
+#include <drm/drm_rect.h>
+
+#define VSDC_MAKE_PLANE_SIZE(w, h) (((w) & 0x7fff) | (((h) & 0x7fff) << 15))
+#define VSDC_MAKE_PLANE_POS(x, y) (((x) & 0x7fff) | (((y) & 0x7fff) << 15))
+
+struct vs_dc;
+
+enum vs_color_format {
+ VSDC_COLOR_FORMAT_X4R4G4B4,
+ VSDC_COLOR_FORMAT_A4R4G4B4,
+ VSDC_COLOR_FORMAT_X1R5G5B5,
+ VSDC_COLOR_FORMAT_A1R5G5B5,
+ VSDC_COLOR_FORMAT_R5G6B5,
+ VSDC_COLOR_FORMAT_X8R8G8B8,
+ VSDC_COLOR_FORMAT_A8R8G8B8,
+ VSDC_COLOR_FORMAT_YUY2,
+ VSDC_COLOR_FORMAT_UYVY,
+ VSDC_COLOR_FORMAT_INDEX8,
+ VSDC_COLOR_FORMAT_MONOCHROME,
+ VSDC_COLOR_FORMAT_YV12 = 0xf,
+ VSDC_COLOR_FORMAT_A8,
+ VSDC_COLOR_FORMAT_NV12,
+ VSDC_COLOR_FORMAT_NV16,
+ VSDC_COLOR_FORMAT_RG16,
+ VSDC_COLOR_FORMAT_R8,
+ VSDC_COLOR_FORMAT_NV12_10BIT,
+ VSDC_COLOR_FORMAT_A2R10G10B10,
+ VSDC_COLOR_FORMAT_NV16_10BIT,
+ VSDC_COLOR_FORMAT_INDEX1,
+ VSDC_COLOR_FORMAT_INDEX2,
+ VSDC_COLOR_FORMAT_INDEX4,
+ VSDC_COLOR_FORMAT_P010,
+ VSDC_COLOR_FORMAT_YUV444,
+ VSDC_COLOR_FORMAT_YUV444_10BIT
+};
+
+enum vs_swizzle {
+ VSDC_SWIZZLE_ARGB,
+ VSDC_SWIZZLE_RGBA,
+ VSDC_SWIZZLE_ABGR,
+ VSDC_SWIZZLE_BGRA,
+};
+
+struct vs_format {
+ enum vs_color_format color;
+ enum vs_swizzle swizzle;
+ bool uv_swizzle;
+};
+
+void drm_format_to_vs_format(u32 drm_format, struct vs_format *vs_format);
+dma_addr_t vs_fb_get_dma_addr(struct drm_framebuffer *fb,
+ const struct drm_rect *src_rect);
+
+struct drm_plane *vs_primary_plane_init(struct drm_device *dev, struct vs_dc *dc);
+
+#endif /* _VS_PLANE_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
new file mode 100644
index 0000000000000..e8fcb5958615c
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
@@ -0,0 +1,173 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ */
+
+#include <linux/regmap.h>
+
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_fourcc.h>
+#include <drm/drm_framebuffer.h>
+#include <drm/drm_gem_atomic_helper.h>
+#include <drm/drm_modeset_helper_vtables.h>
+#include <drm/drm_plane.h>
+#include <drm/drm_print.h>
+
+#include "vs_crtc.h"
+#include "vs_plane.h"
+#include "vs_dc.h"
+#include "vs_primary_plane_regs.h"
+
+static int vs_primary_plane_atomic_check(struct drm_plane *plane,
+ struct drm_atomic_state *state)
+{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
+ plane);
+ struct drm_crtc *crtc = new_plane_state->crtc;
+ struct drm_crtc_state *crtc_state;
+
+ if (!crtc)
+ return 0;
+
+ crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+ if (WARN_ON(!crtc_state))
+ return -EINVAL;
+
+ return drm_atomic_helper_check_plane_state(new_plane_state,
+ crtc_state,
+ DRM_PLANE_NO_SCALING,
+ DRM_PLANE_NO_SCALING,
+ false, true);
+}
+
+static void vs_primary_plane_commit(struct vs_dc *dc, unsigned int output)
+{
+ regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
+ VSDC_FB_CONFIG_EX_COMMIT);
+}
+
+static void vs_primary_plane_atomic_enable(struct drm_plane *plane,
+ struct drm_atomic_state *atomic_state)
+{
+ struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state,
+ plane);
+ struct drm_crtc *crtc = state->crtc;
+ struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
+ unsigned int output = vcrtc->id;
+ struct vs_dc *dc = vcrtc->dc;
+
+ regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
+ VSDC_FB_CONFIG_EX_FB_EN);
+ regmap_update_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
+ VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
+ VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
+
+ vs_primary_plane_commit(dc, output);
+}
+
+static void vs_primary_plane_atomic_disable(struct drm_plane *plane,
+ struct drm_atomic_state *atomic_state)
+{
+ struct drm_plane_state *state = drm_atomic_get_old_plane_state(atomic_state,
+ plane);
+ struct drm_crtc *crtc = state->crtc;
+ struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
+ unsigned int output = vcrtc->id;
+ struct vs_dc *dc = vcrtc->dc;
+
+ regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
+ VSDC_FB_CONFIG_EX_FB_EN);
+
+ vs_primary_plane_commit(dc, output);
+}
+
+static void vs_primary_plane_atomic_update(struct drm_plane *plane,
+ struct drm_atomic_state *atomic_state)
+{
+ struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state,
+ plane);
+ struct drm_framebuffer *fb = state->fb;
+ struct drm_crtc *crtc = state->crtc;
+ struct vs_dc *dc;
+ struct vs_crtc *vcrtc;
+ struct vs_format fmt;
+ unsigned int output;
+ dma_addr_t dma_addr;
+
+ if (!state->visible) {
+ vs_primary_plane_atomic_disable(plane, atomic_state);
+ return;
+ }
+
+ vcrtc = drm_crtc_to_vs_crtc(crtc);
+ output = vcrtc->id;
+ dc = vcrtc->dc;
+
+ drm_format_to_vs_format(state->fb->format->format, &fmt);
+
+ regmap_update_bits(dc->regs, VSDC_FB_CONFIG(output),
+ VSDC_FB_CONFIG_FMT_MASK,
+ VSDC_FB_CONFIG_FMT(fmt.color));
+ regmap_update_bits(dc->regs, VSDC_FB_CONFIG(output),
+ VSDC_FB_CONFIG_SWIZZLE_MASK,
+ VSDC_FB_CONFIG_SWIZZLE(fmt.swizzle));
+ regmap_assign_bits(dc->regs, VSDC_FB_CONFIG(output),
+ VSDC_FB_CONFIG_UV_SWIZZLE_EN, fmt.uv_swizzle);
+
+ dma_addr = vs_fb_get_dma_addr(fb, &state->src);
+
+ regmap_write(dc->regs, VSDC_FB_ADDRESS(output),
+ lower_32_bits(dma_addr));
+ regmap_write(dc->regs, VSDC_FB_STRIDE(output),
+ fb->pitches[0]);
+
+ regmap_write(dc->regs, VSDC_FB_TOP_LEFT(output),
+ VSDC_MAKE_PLANE_POS(state->crtc_x, state->crtc_y));
+ regmap_write(dc->regs, VSDC_FB_BOTTOM_RIGHT(output),
+ VSDC_MAKE_PLANE_POS(state->crtc_x + state->crtc_w,
+ state->crtc_y + state->crtc_h));
+ regmap_write(dc->regs, VSDC_FB_SIZE(output),
+ VSDC_MAKE_PLANE_SIZE(state->crtc_w, state->crtc_h));
+
+ regmap_write(dc->regs, VSDC_FB_BLEND_CONFIG(output),
+ VSDC_FB_BLEND_CONFIG_BLEND_DISABLE);
+
+ vs_primary_plane_commit(dc, output);
+}
+
+static const struct drm_plane_helper_funcs vs_primary_plane_helper_funcs = {
+ .atomic_check = vs_primary_plane_atomic_check,
+ .atomic_update = vs_primary_plane_atomic_update,
+ .atomic_enable = vs_primary_plane_atomic_enable,
+ .atomic_disable = vs_primary_plane_atomic_disable,
+};
+
+static const struct drm_plane_funcs vs_primary_plane_funcs = {
+ .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
+ .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+ .disable_plane = drm_atomic_helper_disable_plane,
+ .reset = drm_atomic_helper_plane_reset,
+ .update_plane = drm_atomic_helper_update_plane,
+};
+
+struct drm_plane *vs_primary_plane_init(struct drm_device *drm_dev, struct vs_dc *dc)
+{
+ struct drm_plane *plane;
+
+ plane = drmm_universal_plane_alloc(drm_dev, struct drm_plane, dev, 0,
+ &vs_primary_plane_funcs,
+ dc->identity.formats->array,
+ dc->identity.formats->num,
+ NULL,
+ DRM_PLANE_TYPE_PRIMARY,
+ NULL);
+
+ if (IS_ERR(plane))
+ return plane;
+
+ drm_plane_helper_add(plane, &vs_primary_plane_helper_funcs);
+
+ return plane;
+}
diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane_regs.h b/drivers/gpu/drm/verisilicon/vs_primary_plane_regs.h
new file mode 100644
index 0000000000000..cbb125c46b390
--- /dev/null
+++ b/drivers/gpu/drm/verisilicon/vs_primary_plane_regs.h
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ *
+ * Based on vs_dc_hw.h, which is:
+ * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd.
+ */
+
+#ifndef _VS_PRIMARY_PLANE_REGS_H_
+#define _VS_PRIMARY_PLANE_REGS_H_
+
+#include <linux/bits.h>
+
+#define VSDC_FB_ADDRESS(n) (0x1400 + 0x4 * (n))
+
+#define VSDC_FB_STRIDE(n) (0x1408 + 0x4 * (n))
+
+#define VSDC_FB_CONFIG(n) (0x1518 + 0x4 * (n))
+#define VSDC_FB_CONFIG_CLEAR_EN BIT(8)
+#define VSDC_FB_CONFIG_ROT_MASK GENMASK(13, 11)
+#define VSDC_FB_CONFIG_ROT(v) ((v) << 11)
+#define VSDC_FB_CONFIG_YUV_SPACE_MASK GENMASK(16, 14)
+#define VSDC_FB_CONFIG_YUV_SPACE(v) ((v) << 14)
+#define VSDC_FB_CONFIG_TILE_MODE_MASK GENMASK(21, 17)
+#define VSDC_FB_CONFIG_TILE_MODE(v) ((v) << 14)
+#define VSDC_FB_CONFIG_SCALE_EN BIT(22)
+#define VSDC_FB_CONFIG_SWIZZLE_MASK GENMASK(24, 23)
+#define VSDC_FB_CONFIG_SWIZZLE(v) ((v) << 23)
+#define VSDC_FB_CONFIG_UV_SWIZZLE_EN BIT(25)
+#define VSDC_FB_CONFIG_FMT_MASK GENMASK(31, 26)
+#define VSDC_FB_CONFIG_FMT(v) ((v) << 26)
+
+#define VSDC_FB_SIZE(n) (0x1810 + 0x4 * (n))
+/* Fill with value generated with VSDC_MAKE_PLANE_SIZE(w, h) */
+
+#define VSDC_FB_CONFIG_EX(n) (0x1CC0 + 0x4 * (n))
+#define VSDC_FB_CONFIG_EX_COMMIT BIT(12)
+#define VSDC_FB_CONFIG_EX_FB_EN BIT(13)
+#define VSDC_FB_CONFIG_EX_ZPOS_MASK GENMASK(18, 16)
+#define VSDC_FB_CONFIG_EX_ZPOS(v) ((v) << 16)
+#define VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK GENMASK(19, 19)
+#define VSDC_FB_CONFIG_EX_DISPLAY_ID(v) ((v) << 19)
+
+#define VSDC_FB_TOP_LEFT(n) (0x24D8 + 0x4 * (n))
+/* Fill with value generated with VSDC_MAKE_PLANE_POS(x, y) */
+
+#define VSDC_FB_BOTTOM_RIGHT(n) (0x24E0 + 0x4 * (n))
+/* Fill with value generated with VSDC_MAKE_PLANE_POS(x, y) */
+
+#define VSDC_FB_BLEND_CONFIG(n) (0x2510 + 0x4 * (n))
+#define VSDC_FB_BLEND_CONFIG_BLEND_DISABLE BIT(1)
+
+#endif /* _VS_PRIMARY_PLANE_REGS_H_ */
--
2.52.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 4/8] dt-bindings: display/bridge: add binding for TH1520 HDMI controller
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
` (2 preceding siblings ...)
2026-01-29 2:39 ` [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers Icenowy Zheng
@ 2026-01-29 2:39 ` Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 5/8] drm/bridge: add a driver for T-Head " Icenowy Zheng
` (4 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-01-29 2:39 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng, Icenowy Zheng, Krzysztof Kozlowski
From: Icenowy Zheng <uwu@icenowy.me>
T-Head TH1520 SoC contains a Synopsys DesignWare HDMI controller paired
with DesignWare HDMI PHY, with an extra clock gate for HDMI pixel clock
and two reset controls.
Add a device tree binding to it.
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
No changes since v3.
Changes in v2:
- Re-aligned multi-line clocks/resets in example.
- Added Krzysztof's R-b.
.../display/bridge/thead,th1520-dw-hdmi.yaml | 120 ++++++++++++++++++
1 file changed, 120 insertions(+)
create mode 100644 Documentation/devicetree/bindings/display/bridge/thead,th1520-dw-hdmi.yaml
diff --git a/Documentation/devicetree/bindings/display/bridge/thead,th1520-dw-hdmi.yaml b/Documentation/devicetree/bindings/display/bridge/thead,th1520-dw-hdmi.yaml
new file mode 100644
index 0000000000000..68fff885ce15b
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/thead,th1520-dw-hdmi.yaml
@@ -0,0 +1,120 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/bridge/thead,th1520-dw-hdmi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: T-Head TH1520 DesignWare HDMI TX Encoder
+
+maintainers:
+ - Icenowy Zheng <uwu@icenowy.me>
+
+description:
+ The HDMI transmitter is a Synopsys DesignWare HDMI TX controller
+ paired with a DesignWare HDMI Gen2 TX PHY.
+
+allOf:
+ - $ref: /schemas/display/bridge/synopsys,dw-hdmi.yaml#
+
+properties:
+ compatible:
+ enum:
+ - thead,th1520-dw-hdmi
+
+ reg-io-width:
+ const: 4
+
+ clocks:
+ maxItems: 4
+
+ clock-names:
+ items:
+ - const: iahb
+ - const: isfr
+ - const: cec
+ - const: pix
+
+ resets:
+ items:
+ - description: Main reset
+ - description: Configuration APB reset
+
+ reset-names:
+ items:
+ - const: main
+ - const: apb
+
+ ports:
+ $ref: /schemas/graph.yaml#/properties/ports
+
+ properties:
+ port@0:
+ $ref: /schemas/graph.yaml#/properties/port
+ description: Input port connected to DC8200 DPU "DP" output
+
+ port@1:
+ $ref: /schemas/graph.yaml#/properties/port
+ description: HDMI output port
+
+ required:
+ - port@0
+ - port@1
+
+required:
+ - compatible
+ - reg
+ - reg-io-width
+ - clocks
+ - clock-names
+ - resets
+ - reset-names
+ - interrupts
+ - ports
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/clock/thead,th1520-clk-ap.h>
+ #include <dt-bindings/reset/thead,th1520-reset.h>
+
+ soc {
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ hdmi@ffef540000 {
+ compatible = "thead,th1520-dw-hdmi";
+ reg = <0xff 0xef540000 0x0 0x40000>;
+ reg-io-width = <4>;
+ interrupts = <111 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk_vo CLK_HDMI_PCLK>,
+ <&clk_vo CLK_HDMI_SFR>,
+ <&clk_vo CLK_HDMI_CEC>,
+ <&clk_vo CLK_HDMI_PIXCLK>;
+ clock-names = "iahb", "isfr", "cec", "pix";
+ resets = <&rst_vo TH1520_RESET_ID_HDMI>,
+ <&rst_vo TH1520_RESET_ID_HDMI_APB>;
+ reset-names = "main", "apb";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ port@0 {
+ reg = <0>;
+
+ hdmi_in: endpoint {
+ remote-endpoint = <&dpu_out_dp1>;
+ };
+ };
+
+ port@1 {
+ reg = <1>;
+
+ hdmi_out_conn: endpoint {
+ remote-endpoint = <&hdmi_conn_in>;
+ };
+ };
+ };
+ };
+ };
--
2.52.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 5/8] drm/bridge: add a driver for T-Head TH1520 HDMI controller
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
` (3 preceding siblings ...)
2026-01-29 2:39 ` [PATCH v7 4/8] dt-bindings: display/bridge: add binding for TH1520 HDMI controller Icenowy Zheng
@ 2026-01-29 2:39 ` Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 6/8] riscv: dts: thead: add DPU and HDMI device tree nodes Icenowy Zheng
` (3 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-01-29 2:39 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng, Icenowy Zheng
From: Icenowy Zheng <uwu@icenowy.me>
T-Head TH1520 SoC contains a Synopsys DesignWare HDMI controller (paired
with DesignWare HDMI TX PHY Gen2) that takes the "DP" output from the
display controller.
Add a driver for this controller utilizing the common DesignWare HDMI
code in the kernel.
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Tested-by: Han Gao <gaohan@iscas.ac.cn>
Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
---
Changes in v7:
- Added Thomas's A-b.
No changes in v3-v6.
Changes in v2:
- Created a new function to set PHY parameters and refactored the
control flow of the configure_phy callback.
MAINTAINERS | 1 +
drivers/gpu/drm/bridge/Kconfig | 10 ++
drivers/gpu/drm/bridge/Makefile | 1 +
drivers/gpu/drm/bridge/th1520-dw-hdmi.c | 173 ++++++++++++++++++++++++
4 files changed, 185 insertions(+)
create mode 100644 drivers/gpu/drm/bridge/th1520-dw-hdmi.c
diff --git a/MAINTAINERS b/MAINTAINERS
index adf302286e77d..96fc72b1d686a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22583,6 +22583,7 @@ F: Documentation/devicetree/bindings/reset/thead,th1520-reset.yaml
F: arch/riscv/boot/dts/thead/
F: drivers/clk/thead/clk-th1520-ap.c
F: drivers/firmware/thead,th1520-aon.c
+F: drivers/gpu/drm/bridge/th1520-dw-hdmi.c
F: drivers/mailbox/mailbox-th1520.c
F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
F: drivers/pinctrl/pinctrl-th1520.c
diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index a250afd8d6622..8e19f5fb9ad7c 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -335,6 +335,16 @@ config DRM_THINE_THC63LVD1024
help
Thine THC63LVD1024 LVDS/parallel converter driver.
+config DRM_THEAD_TH1520_DW_HDMI
+ tristate "T-Head TH1520 DesignWare HDMI bridge"
+ depends on OF
+ depends on COMMON_CLK
+ depends on ARCH_THEAD || COMPILE_TEST
+ select DRM_DW_HDMI
+ help
+ Choose this to enable support for the internal HDMI bridge found
+ on the T-Head TH1520 SoC.
+
config DRM_TOSHIBA_TC358762
tristate "TC358762 DSI/DPI bridge"
depends on OF
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index c7dc03182e592..085b5db45d6fd 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_DRM_SII902X) += sii902x.o
obj-$(CONFIG_DRM_SII9234) += sii9234.o
obj-$(CONFIG_DRM_SIMPLE_BRIDGE) += simple-bridge.o
obj-$(CONFIG_DRM_SOLOMON_SSD2825) += ssd2825.o
+obj-$(CONFIG_DRM_THEAD_TH1520_DW_HDMI) += th1520-dw-hdmi.o
obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
obj-$(CONFIG_DRM_TOSHIBA_TC358762) += tc358762.o
obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
diff --git a/drivers/gpu/drm/bridge/th1520-dw-hdmi.c b/drivers/gpu/drm/bridge/th1520-dw-hdmi.c
new file mode 100644
index 0000000000000..389eead5f1c45
--- /dev/null
+++ b/drivers/gpu/drm/bridge/th1520-dw-hdmi.c
@@ -0,0 +1,173 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
+ *
+ * Based on rcar_dw_hdmi.c, which is:
+ * Copyright (C) 2016 Renesas Electronics Corporation
+ * Based on imx8mp-hdmi-tx.c, which is:
+ * Copyright (C) 2022 Pengutronix, Lucas Stach <kernel@pengutronix.de>
+ */
+
+#include <linux/clk.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/reset.h>
+
+#include <drm/bridge/dw_hdmi.h>
+#include <drm/drm_modes.h>
+
+#define TH1520_HDMI_PHY_OPMODE_PLLCFG 0x06 /* Mode of operation and PLL dividers */
+#define TH1520_HDMI_PHY_CKSYMTXCTRL 0x09 /* Clock Symbol and Transmitter Control Register */
+#define TH1520_HDMI_PHY_VLEVCTRL 0x0e /* Voltage Level Control Register */
+#define TH1520_HDMI_PHY_PLLCURRGMPCTRL 0x10 /* PLL current and Gmp (conductance) */
+#define TH1520_HDMI_PHY_PLLDIVCTRL 0x11 /* PLL dividers */
+#define TH1520_HDMI_PHY_TXTERM 0x19 /* Transmission Termination Register */
+
+struct th1520_hdmi_phy_params {
+ unsigned long mpixelclock;
+ u16 opmode_pllcfg;
+ u16 pllcurrgmpctrl;
+ u16 plldivctrl;
+ u16 cksymtxctrl;
+ u16 vlevctrl;
+ u16 txterm;
+};
+
+static const struct th1520_hdmi_phy_params th1520_hdmi_phy_params[] = {
+ { 35500000, 0x0003, 0x0283, 0x0628, 0x8088, 0x01a0, 0x0007 },
+ { 44900000, 0x0003, 0x0285, 0x0228, 0x8088, 0x01a0, 0x0007 },
+ { 71000000, 0x0002, 0x1183, 0x0614, 0x8088, 0x01a0, 0x0007 },
+ { 90000000, 0x0002, 0x1142, 0x0214, 0x8088, 0x01a0, 0x0007 },
+ { 121750000, 0x0001, 0x20c0, 0x060a, 0x8088, 0x01a0, 0x0007 },
+ { 165000000, 0x0001, 0x2080, 0x020a, 0x8088, 0x01a0, 0x0007 },
+ { 198000000, 0x0000, 0x3040, 0x0605, 0x83c8, 0x0120, 0x0004 },
+ { 297000000, 0x0000, 0x3041, 0x0205, 0x81dc, 0x0200, 0x0005 },
+ { 371250000, 0x0640, 0x3041, 0x0205, 0x80f6, 0x0140, 0x0000 },
+ { 495000000, 0x0640, 0x3080, 0x0005, 0x80f6, 0x0140, 0x0000 },
+ { 594000000, 0x0640, 0x3080, 0x0005, 0x80fa, 0x01e0, 0x0004 },
+};
+
+struct th1520_hdmi {
+ struct dw_hdmi_plat_data plat_data;
+ struct dw_hdmi *dw_hdmi;
+ struct clk *pixclk;
+ struct reset_control *mainrst, *prst;
+};
+
+static enum drm_mode_status
+th1520_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
+ const struct drm_display_info *info,
+ const struct drm_display_mode *mode)
+{
+ /*
+ * The maximum supported clock frequency is 594 MHz, as shown in the PHY
+ * parameters table.
+ */
+ if (mode->clock > 594000)
+ return MODE_CLOCK_HIGH;
+
+ return MODE_OK;
+}
+
+static void th1520_hdmi_phy_set_params(struct dw_hdmi *hdmi,
+ const struct th1520_hdmi_phy_params *params)
+{
+ dw_hdmi_phy_i2c_write(hdmi, params->opmode_pllcfg,
+ TH1520_HDMI_PHY_OPMODE_PLLCFG);
+ dw_hdmi_phy_i2c_write(hdmi, params->pllcurrgmpctrl,
+ TH1520_HDMI_PHY_PLLCURRGMPCTRL);
+ dw_hdmi_phy_i2c_write(hdmi, params->plldivctrl,
+ TH1520_HDMI_PHY_PLLDIVCTRL);
+ dw_hdmi_phy_i2c_write(hdmi, params->vlevctrl,
+ TH1520_HDMI_PHY_VLEVCTRL);
+ dw_hdmi_phy_i2c_write(hdmi, params->cksymtxctrl,
+ TH1520_HDMI_PHY_CKSYMTXCTRL);
+ dw_hdmi_phy_i2c_write(hdmi, params->txterm,
+ TH1520_HDMI_PHY_TXTERM);
+}
+
+static int th1520_hdmi_phy_configure(struct dw_hdmi *hdmi, void *data,
+ unsigned long mpixelclock)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(th1520_hdmi_phy_params); i++) {
+ if (mpixelclock <= th1520_hdmi_phy_params[i].mpixelclock) {
+ th1520_hdmi_phy_set_params(hdmi,
+ &th1520_hdmi_phy_params[i]);
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
+
+static int th1520_dw_hdmi_probe(struct platform_device *pdev)
+{
+ struct th1520_hdmi *hdmi;
+ struct dw_hdmi_plat_data *plat_data;
+ struct device *dev = &pdev->dev;
+
+ hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
+ if (!hdmi)
+ return -ENOMEM;
+
+ plat_data = &hdmi->plat_data;
+
+ hdmi->pixclk = devm_clk_get_enabled(dev, "pix");
+ if (IS_ERR(hdmi->pixclk))
+ return dev_err_probe(dev, PTR_ERR(hdmi->pixclk),
+ "Unable to get pixel clock\n");
+
+ hdmi->mainrst = devm_reset_control_get_exclusive_deasserted(dev, "main");
+ if (IS_ERR(hdmi->mainrst))
+ return dev_err_probe(dev, PTR_ERR(hdmi->mainrst),
+ "Unable to get main reset\n");
+
+ hdmi->prst = devm_reset_control_get_exclusive_deasserted(dev, "apb");
+ if (IS_ERR(hdmi->prst))
+ return dev_err_probe(dev, PTR_ERR(hdmi->prst),
+ "Unable to get apb reset\n");
+
+ plat_data->output_port = 1;
+ plat_data->mode_valid = th1520_hdmi_mode_valid;
+ plat_data->configure_phy = th1520_hdmi_phy_configure;
+ plat_data->priv_data = hdmi;
+
+ hdmi->dw_hdmi = dw_hdmi_probe(pdev, plat_data);
+ if (IS_ERR(hdmi))
+ return PTR_ERR(hdmi);
+
+ platform_set_drvdata(pdev, hdmi);
+
+ return 0;
+}
+
+static void th1520_dw_hdmi_remove(struct platform_device *pdev)
+{
+ struct dw_hdmi *hdmi = platform_get_drvdata(pdev);
+
+ dw_hdmi_remove(hdmi);
+}
+
+static const struct of_device_id th1520_dw_hdmi_of_table[] = {
+ { .compatible = "thead,th1520-dw-hdmi" },
+ { /* Sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, th1520_dw_hdmi_of_table);
+
+static struct platform_driver th1520_dw_hdmi_platform_driver = {
+ .probe = th1520_dw_hdmi_probe,
+ .remove = th1520_dw_hdmi_remove,
+ .driver = {
+ .name = "th1520-dw-hdmi",
+ .of_match_table = th1520_dw_hdmi_of_table,
+ },
+};
+
+module_platform_driver(th1520_dw_hdmi_platform_driver);
+
+MODULE_AUTHOR("Icenowy Zheng <uwu@icenowy.me>");
+MODULE_DESCRIPTION("T-Head TH1520 HDMI Encoder Driver");
+MODULE_LICENSE("GPL");
--
2.52.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 6/8] riscv: dts: thead: add DPU and HDMI device tree nodes
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
` (4 preceding siblings ...)
2026-01-29 2:39 ` [PATCH v7 5/8] drm/bridge: add a driver for T-Head " Icenowy Zheng
@ 2026-01-29 2:39 ` Icenowy Zheng
2026-01-29 20:39 ` Drew Fustini
2026-03-09 14:40 ` Luca Ceresoli
2026-01-29 2:39 ` [PATCH v7 7/8] riscv: dts: thead: lichee-pi-4a: enable HDMI Icenowy Zheng
` (2 subsequent siblings)
8 siblings, 2 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-01-29 2:39 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng, Icenowy Zheng
From: Icenowy Zheng <uwu@icenowy.me>
T-Head TH1520 SoC contains a Verisilicon DC8200 display controller
(called DPU in manual) and a Synopsys DesignWare HDMI TX controller.
Add device tree nodes to them.
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Tested-by: Han Gao <gaohan@iscas.ac.cn>
Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
No changes since v4.
Changes in v3:
- Adapting to the changed binding.
No changes in v2.
arch/riscv/boot/dts/thead/th1520.dtsi | 66 +++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
index bd5d33840884e..b663077428940 100644
--- a/arch/riscv/boot/dts/thead/th1520.dtsi
+++ b/arch/riscv/boot/dts/thead/th1520.dtsi
@@ -585,6 +585,72 @@ clk_vo: clock-controller@ffef528050 {
#clock-cells = <1>;
};
+ hdmi: hdmi@ffef540000 {
+ compatible = "thead,th1520-dw-hdmi";
+ reg = <0xff 0xef540000 0x0 0x40000>;
+ reg-io-width = <4>;
+ interrupts = <111 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk_vo CLK_HDMI_PCLK>,
+ <&clk_vo CLK_HDMI_SFR>,
+ <&clk_vo CLK_HDMI_CEC>,
+ <&clk_vo CLK_HDMI_PIXCLK>;
+ clock-names = "iahb", "isfr", "cec", "pix";
+ resets = <&rst TH1520_RESET_ID_HDMI>,
+ <&rst TH1520_RESET_ID_HDMI_APB>;
+ reset-names = "main", "apb";
+ status = "disabled";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+
+ hdmi_in: endpoint {
+ remote-endpoint = <&dpu_out_dp1>;
+ };
+ };
+
+ hdmi_out_port: port@1 {
+ reg = <1>;
+ };
+ };
+ };
+
+ dpu: display@ffef600000 {
+ compatible = "thead,th1520-dc8200", "verisilicon,dc";
+ reg = <0xff 0xef600000 0x0 0x100000>;
+ interrupts = <93 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk_vo CLK_DPU_CCLK>,
+ <&clk_vo CLK_DPU_ACLK>,
+ <&clk_vo CLK_DPU_HCLK>,
+ <&clk_vo CLK_DPU_PIXELCLK0>,
+ <&clk_vo CLK_DPU_PIXELCLK1>;
+ clock-names = "core", "axi", "ahb", "pix0", "pix1";
+ resets = <&rst TH1520_RESET_ID_DPU_CORE>,
+ <&rst TH1520_RESET_ID_DPU_AXI>,
+ <&rst TH1520_RESET_ID_DPU_AHB>;
+ reset-names = "core", "axi", "ahb";
+ status = "disabled";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ dpu_port1: port@1 {
+ reg = <1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ dpu_out_dp1: endpoint@1 {
+ reg = <1>;
+ remote-endpoint = <&hdmi_in>;
+ };
+ };
+ };
+ };
+
dmac0: dma-controller@ffefc00000 {
compatible = "snps,axi-dma-1.01a";
reg = <0xff 0xefc00000 0x0 0x1000>;
--
2.52.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 7/8] riscv: dts: thead: lichee-pi-4a: enable HDMI
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
` (5 preceding siblings ...)
2026-01-29 2:39 ` [PATCH v7 6/8] riscv: dts: thead: add DPU and HDMI device tree nodes Icenowy Zheng
@ 2026-01-29 2:39 ` Icenowy Zheng
2026-01-29 20:40 ` Drew Fustini
2026-03-09 14:40 ` Luca Ceresoli
2026-01-29 2:39 ` [PATCH v7 8/8] mailmap: map all Icenowy Zheng's mail addresses Icenowy Zheng
2026-02-05 9:30 ` [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Thomas Zimmermann
8 siblings, 2 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-01-29 2:39 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng, Icenowy Zheng
Lichee Pi 4A board features a HDMI Type-A connector connected to the
HDMI TX controller of TH1520 SoC.
Add a device tree node describing the connector, connect it to the HDMI
controller, and enable everything on this display pipeline.
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Tested-by: Han Gao <gaohan@iscas.ac.cn>
Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
No changes in v5.
Changes in v4:
- Rebased on top of v6.19-rc1.
No changes in v2, v3.
.../boot/dts/thead/th1520-lichee-pi-4a.dts | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
index c58c2085ca92a..7cb7d28683bce 100644
--- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
+++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
@@ -29,6 +29,17 @@ chosen {
stdout-path = "serial0:115200n8";
};
+ hdmi-connector {
+ compatible = "hdmi-connector";
+ type = "a";
+
+ port {
+ hdmi_con_in: endpoint {
+ remote-endpoint = <&hdmi_out_con>;
+ };
+ };
+ };
+
thermal-zones {
cpu-thermal {
polling-delay = <1000>;
@@ -121,6 +132,20 @@ rx-pins {
};
};
+&dpu {
+ status = "okay";
+};
+
+&hdmi {
+ status = "okay";
+};
+
+&hdmi_out_port {
+ hdmi_out_con: endpoint {
+ remote-endpoint = <&hdmi_con_in>;
+ };
+};
+
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins>;
--
2.52.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 8/8] mailmap: map all Icenowy Zheng's mail addresses
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
` (6 preceding siblings ...)
2026-01-29 2:39 ` [PATCH v7 7/8] riscv: dts: thead: lichee-pi-4a: enable HDMI Icenowy Zheng
@ 2026-01-29 2:39 ` Icenowy Zheng
2026-02-05 9:30 ` [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Thomas Zimmermann
8 siblings, 0 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-01-29 2:39 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng, Icenowy Zheng
From: Icenowy Zheng <uwu@icenowy.me>
Map all mail addresses Icenowy Zheng had used to the personal mailbox
prefixed "uwu".
All these mailboxes, except the one of Sipeed (which was only used
during a summer vacation internship), can accept mails now.
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
---
No changes since v4.
New patch in v3.
.mailmap | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.mailmap b/.mailmap
index 428d721ffbb16..ade2883f1c056 100644
--- a/.mailmap
+++ b/.mailmap
@@ -319,6 +319,10 @@ Henrik Rydberg <rydberg@bitmath.org>
Herbert Xu <herbert@gondor.apana.org.au>
Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com>
Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn>
+Icenowy Zheng <uwu@icenowy.me> <zhengxingda@iscas.ac.cn>
+Icenowy Zheng <uwu@icenowy.me> <icenowy@aosc.io>
+Icenowy Zheng <uwu@icenowy.me> <icenowy@aosc.xyz>
+Icenowy Zheng <uwu@icenowy.me> <icenowy@sipeed.com>
Ike Panhc <ikepanhc@gmail.com> <ike.pan@canonical.com>
J. Bruce Fields <bfields@fieldses.org> <bfields@redhat.com>
J. Bruce Fields <bfields@fieldses.org> <bfields@citi.umich.edu>
--
2.52.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 6/8] riscv: dts: thead: add DPU and HDMI device tree nodes
2026-01-29 2:39 ` [PATCH v7 6/8] riscv: dts: thead: add DPU and HDMI device tree nodes Icenowy Zheng
@ 2026-01-29 20:39 ` Drew Fustini
2026-03-09 14:40 ` Luca Ceresoli
1 sibling, 0 replies; 23+ messages in thread
From: Drew Fustini @ 2026-01-29 20:39 UTC (permalink / raw)
To: Icenowy Zheng
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Guo Ren, Fu Wei, Philipp Zabel,
Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng
On Thu, Jan 29, 2026 at 10:39:20AM +0800, Icenowy Zheng wrote:
> From: Icenowy Zheng <uwu@icenowy.me>
>
> T-Head TH1520 SoC contains a Verisilicon DC8200 display controller
> (called DPU in manual) and a Synopsys DesignWare HDMI TX controller.
>
> Add device tree nodes to them.
>
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> Tested-by: Han Gao <gaohan@iscas.ac.cn>
> Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
> No changes since v4.
>
> Changes in v3:
> - Adapting to the changed binding.
>
> No changes in v2.
>
> arch/riscv/boot/dts/thead/th1520.dtsi | 66 +++++++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
Reviewed-by: Drew Fustini <fustini@kernel.org>
I will create a pull request for the DTS patches if Thomas applies the
bindings and driver patches.
Thanks,
Drew
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 7/8] riscv: dts: thead: lichee-pi-4a: enable HDMI
2026-01-29 2:39 ` [PATCH v7 7/8] riscv: dts: thead: lichee-pi-4a: enable HDMI Icenowy Zheng
@ 2026-01-29 20:40 ` Drew Fustini
2026-03-09 14:40 ` Luca Ceresoli
1 sibling, 0 replies; 23+ messages in thread
From: Drew Fustini @ 2026-01-29 20:40 UTC (permalink / raw)
To: Icenowy Zheng
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Guo Ren, Fu Wei, Philipp Zabel,
Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng
On Thu, Jan 29, 2026 at 10:39:21AM +0800, Icenowy Zheng wrote:
> Lichee Pi 4A board features a HDMI Type-A connector connected to the
> HDMI TX controller of TH1520 SoC.
>
> Add a device tree node describing the connector, connect it to the HDMI
> controller, and enable everything on this display pipeline.
>
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> Tested-by: Han Gao <gaohan@iscas.ac.cn>
> Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
> No changes in v5.
>
> Changes in v4:
> - Rebased on top of v6.19-rc1.
>
> No changes in v2, v3.
>
> .../boot/dts/thead/th1520-lichee-pi-4a.dts | 25 +++++++++++++++++++
> 1 file changed, 25 insertions(+)
Reviewed-by: Drew Fustini <fustini@kernel.org>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520)
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
` (7 preceding siblings ...)
2026-01-29 2:39 ` [PATCH v7 8/8] mailmap: map all Icenowy Zheng's mail addresses Icenowy Zheng
@ 2026-02-05 9:30 ` Thomas Zimmermann
2026-02-05 9:31 ` Icenowy Zheng
2026-02-08 1:02 ` Drew Fustini
8 siblings, 2 replies; 23+ messages in thread
From: Thomas Zimmermann @ 2026-02-05 9:30 UTC (permalink / raw)
To: Icenowy Zheng, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Drew Fustini,
Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng
Hi,
patches 1 to 5 have been merged into drm-misc-next. In patch 3, I
replaced COMPILER_TEST with COMPILE_TEST in the Kconfig file.
Best regards
Thomas
Am 29.01.26 um 03:39 schrieb Icenowy Zheng:
> This patchset tries to add a driver for Verisilicon DC8200 driver, and
> demonstrates the driver on T-Head TH1520 with its HDMI output.
>
> This display controller IP is used on StarFive JH7110 too, but as the
> HDMI controller used there isn't as common as the DesignWare one, I
> choose to use TH1520 in this patchset.
>
> The DC driver is written with other DC-series (mainly DC8000, which is
> known to be used on Eswin EIC7700 SoC) display controllers in mind, and
> uses the identification registers available on all Vivante branded IPs.
> A known exception is DCNano display controller, which is unlikely to be
> supported by this driver because of totally different register map and
> no known identification registers. (P.S. the in-tree loongson DRM driver
> seems to be for some DCNano instances based on the register map.)
>
> The HDMI controller seems to come with some common PHY by Synopsys, the
> DesignWare HDMI TX 2.0 PHY. By searching a few register names from the
> BSP driver of that PHY, that PHY seems to be used by a in-tree dw-hdmi
> glue, rcar_dw_hdmi -- an updated downstream version of rcar_dw_hdmi
> contains all 6 registers set here in the th1520-dw-hdmi driver. Some
> more suprising thing is that RK3288 uses the same PHY too, but the
> in-tree dw_hdmi-rockchip driver writes the configuration data array in a
> weird way to reuse the HDMI 3D TX PHY configuring function. It might be
> valuable to add common configuring function and configuration data
> definition for this HDMI 2.0 PHY too, but the current driver in this
> patchset simply duplicated most configuration logic from rcar_dw_hdmi
> driver (but with 3 extra configuration registers configured, which is
> done by their downstream kernel).
>
> This revision contains only little code change -- only a Kconfig select
> is added. The other purpose is to collect Thomas Zimmermann's tags and
> squash MAINTAINERS change to real driver per his suggestion.
>
> Icenowy Zheng (8):
> dt-bindings: vendor-prefixes: add verisilicon
> dt-bindings: display: add verisilicon,dc
> drm: verisilicon: add a driver for Verisilicon display controllers
> dt-bindings: display/bridge: add binding for TH1520 HDMI controller
> drm/bridge: add a driver for T-Head TH1520 HDMI controller
> riscv: dts: thead: add DPU and HDMI device tree nodes
> riscv: dts: thead: lichee-pi-4a: enable HDMI
> mailmap: map all Icenowy Zheng's mail addresses
>
> .mailmap | 4 +
> .../display/bridge/thead,th1520-dw-hdmi.yaml | 120 ++++++
> .../bindings/display/verisilicon,dc.yaml | 122 ++++++
> .../devicetree/bindings/vendor-prefixes.yaml | 2 +
> MAINTAINERS | 8 +
> .../boot/dts/thead/th1520-lichee-pi-4a.dts | 25 ++
> arch/riscv/boot/dts/thead/th1520.dtsi | 66 ++++
> drivers/gpu/drm/Kconfig | 2 +
> drivers/gpu/drm/Makefile | 1 +
> drivers/gpu/drm/bridge/Kconfig | 10 +
> drivers/gpu/drm/bridge/Makefile | 1 +
> drivers/gpu/drm/bridge/th1520-dw-hdmi.c | 173 ++++++++
> drivers/gpu/drm/verisilicon/Kconfig | 16 +
> drivers/gpu/drm/verisilicon/Makefile | 5 +
> drivers/gpu/drm/verisilicon/vs_bridge.c | 371 ++++++++++++++++++
> drivers/gpu/drm/verisilicon/vs_bridge.h | 39 ++
> drivers/gpu/drm/verisilicon/vs_bridge_regs.h | 54 +++
> drivers/gpu/drm/verisilicon/vs_crtc.c | 191 +++++++++
> drivers/gpu/drm/verisilicon/vs_crtc.h | 31 ++
> drivers/gpu/drm/verisilicon/vs_crtc_regs.h | 60 +++
> drivers/gpu/drm/verisilicon/vs_dc.c | 207 ++++++++++
> drivers/gpu/drm/verisilicon/vs_dc.h | 38 ++
> drivers/gpu/drm/verisilicon/vs_dc_top_regs.h | 27 ++
> drivers/gpu/drm/verisilicon/vs_drm.c | 182 +++++++++
> drivers/gpu/drm/verisilicon/vs_drm.h | 28 ++
> drivers/gpu/drm/verisilicon/vs_hwdb.c | 150 +++++++
> drivers/gpu/drm/verisilicon/vs_hwdb.h | 29 ++
> drivers/gpu/drm/verisilicon/vs_plane.c | 124 ++++++
> drivers/gpu/drm/verisilicon/vs_plane.h | 72 ++++
> .../gpu/drm/verisilicon/vs_primary_plane.c | 173 ++++++++
> .../drm/verisilicon/vs_primary_plane_regs.h | 53 +++
> 31 files changed, 2384 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/display/bridge/thead,th1520-dw-hdmi.yaml
> create mode 100644 Documentation/devicetree/bindings/display/verisilicon,dc.yaml
> create mode 100644 drivers/gpu/drm/bridge/th1520-dw-hdmi.c
> create mode 100644 drivers/gpu/drm/verisilicon/Kconfig
> create mode 100644 drivers/gpu/drm/verisilicon/Makefile
> create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge.c
> create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge.h
> create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge_regs.h
> create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c
> create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h
> create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc_regs.h
> create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c
> create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h
> create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_top_regs.h
> create mode 100644 drivers/gpu/drm/verisilicon/vs_drm.c
> create mode 100644 drivers/gpu/drm/verisilicon/vs_drm.h
> create mode 100644 drivers/gpu/drm/verisilicon/vs_hwdb.c
> create mode 100644 drivers/gpu/drm/verisilicon/vs_hwdb.h
> create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c
> create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h
> create mode 100644 drivers/gpu/drm/verisilicon/vs_primary_plane.c
> create mode 100644 drivers/gpu/drm/verisilicon/vs_primary_plane_regs.h
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520)
2026-02-05 9:30 ` [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Thomas Zimmermann
@ 2026-02-05 9:31 ` Icenowy Zheng
2026-02-08 1:02 ` Drew Fustini
1 sibling, 0 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-02-05 9:31 UTC (permalink / raw)
To: Thomas Zimmermann, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Drew Fustini,
Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv
在 2026-02-05星期四的 10:30 +0100,Thomas Zimmermann写道:
> Hi,
>
> patches 1 to 5 have been merged into drm-misc-next. In patch 3, I
> replaced COMPILER_TEST with COMPILE_TEST in the Kconfig file.
Ah, Thanks for correcting this.
Thanks,
Icenowy
>
> Best regards
> Thomas
>
> Am 29.01.26 um 03:39 schrieb Icenowy Zheng:
> > This patchset tries to add a driver for Verisilicon DC8200 driver,
> > and
> > demonstrates the driver on T-Head TH1520 with its HDMI output.
> >
> > This display controller IP is used on StarFive JH7110 too, but as
> > the
> > HDMI controller used there isn't as common as the DesignWare one, I
> > choose to use TH1520 in this patchset.
> >
> > The DC driver is written with other DC-series (mainly DC8000, which
> > is
> > known to be used on Eswin EIC7700 SoC) display controllers in mind,
> > and
> > uses the identification registers available on all Vivante branded
> > IPs.
> > A known exception is DCNano display controller, which is unlikely
> > to be
> > supported by this driver because of totally different register map
> > and
> > no known identification registers. (P.S. the in-tree loongson DRM
> > driver
> > seems to be for some DCNano instances based on the register map.)
> >
> > The HDMI controller seems to come with some common PHY by Synopsys,
> > the
> > DesignWare HDMI TX 2.0 PHY. By searching a few register names from
> > the
> > BSP driver of that PHY, that PHY seems to be used by a in-tree dw-
> > hdmi
> > glue, rcar_dw_hdmi -- an updated downstream version of rcar_dw_hdmi
> > contains all 6 registers set here in the th1520-dw-hdmi driver.
> > Some
> > more suprising thing is that RK3288 uses the same PHY too, but the
> > in-tree dw_hdmi-rockchip driver writes the configuration data array
> > in a
> > weird way to reuse the HDMI 3D TX PHY configuring function. It
> > might be
> > valuable to add common configuring function and configuration data
> > definition for this HDMI 2.0 PHY too, but the current driver in
> > this
> > patchset simply duplicated most configuration logic from
> > rcar_dw_hdmi
> > driver (but with 3 extra configuration registers configured, which
> > is
> > done by their downstream kernel).
> >
> > This revision contains only little code change -- only a Kconfig
> > select
> > is added. The other purpose is to collect Thomas Zimmermann's tags
> > and
> > squash MAINTAINERS change to real driver per his suggestion.
> >
> > Icenowy Zheng (8):
> > dt-bindings: vendor-prefixes: add verisilicon
> > dt-bindings: display: add verisilicon,dc
> > drm: verisilicon: add a driver for Verisilicon display
> > controllers
> > dt-bindings: display/bridge: add binding for TH1520 HDMI
> > controller
> > drm/bridge: add a driver for T-Head TH1520 HDMI controller
> > riscv: dts: thead: add DPU and HDMI device tree nodes
> > riscv: dts: thead: lichee-pi-4a: enable HDMI
> > mailmap: map all Icenowy Zheng's mail addresses
> >
> > .mailmap | 4 +
> > .../display/bridge/thead,th1520-dw-hdmi.yaml | 120 ++++++
> > .../bindings/display/verisilicon,dc.yaml | 122 ++++++
> > .../devicetree/bindings/vendor-prefixes.yaml | 2 +
> > MAINTAINERS | 8 +
> > .../boot/dts/thead/th1520-lichee-pi-4a.dts | 25 ++
> > arch/riscv/boot/dts/thead/th1520.dtsi | 66 ++++
> > drivers/gpu/drm/Kconfig | 2 +
> > drivers/gpu/drm/Makefile | 1 +
> > drivers/gpu/drm/bridge/Kconfig | 10 +
> > drivers/gpu/drm/bridge/Makefile | 1 +
> > drivers/gpu/drm/bridge/th1520-dw-hdmi.c | 173 ++++++++
> > drivers/gpu/drm/verisilicon/Kconfig | 16 +
> > drivers/gpu/drm/verisilicon/Makefile | 5 +
> > drivers/gpu/drm/verisilicon/vs_bridge.c | 371
> > ++++++++++++++++++
> > drivers/gpu/drm/verisilicon/vs_bridge.h | 39 ++
> > drivers/gpu/drm/verisilicon/vs_bridge_regs.h | 54 +++
> > drivers/gpu/drm/verisilicon/vs_crtc.c | 191 +++++++++
> > drivers/gpu/drm/verisilicon/vs_crtc.h | 31 ++
> > drivers/gpu/drm/verisilicon/vs_crtc_regs.h | 60 +++
> > drivers/gpu/drm/verisilicon/vs_dc.c | 207 ++++++++++
> > drivers/gpu/drm/verisilicon/vs_dc.h | 38 ++
> > drivers/gpu/drm/verisilicon/vs_dc_top_regs.h | 27 ++
> > drivers/gpu/drm/verisilicon/vs_drm.c | 182 +++++++++
> > drivers/gpu/drm/verisilicon/vs_drm.h | 28 ++
> > drivers/gpu/drm/verisilicon/vs_hwdb.c | 150 +++++++
> > drivers/gpu/drm/verisilicon/vs_hwdb.h | 29 ++
> > drivers/gpu/drm/verisilicon/vs_plane.c | 124 ++++++
> > drivers/gpu/drm/verisilicon/vs_plane.h | 72 ++++
> > .../gpu/drm/verisilicon/vs_primary_plane.c | 173 ++++++++
> > .../drm/verisilicon/vs_primary_plane_regs.h | 53 +++
> > 31 files changed, 2384 insertions(+)
> > create mode 100644
> > Documentation/devicetree/bindings/display/bridge/thead,th1520-dw-
> > hdmi.yaml
> > create mode 100644
> > Documentation/devicetree/bindings/display/verisilicon,dc.yaml
> > create mode 100644 drivers/gpu/drm/bridge/th1520-dw-hdmi.c
> > create mode 100644 drivers/gpu/drm/verisilicon/Kconfig
> > create mode 100644 drivers/gpu/drm/verisilicon/Makefile
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge.c
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge.h
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_bridge_regs.h
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc_regs.h
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_top_regs.h
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_drm.c
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_drm.h
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_hwdb.c
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_hwdb.h
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h
> > create mode 100644 drivers/gpu/drm/verisilicon/vs_primary_plane.c
> > create mode 100644
> > drivers/gpu/drm/verisilicon/vs_primary_plane_regs.h
> >
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520)
2026-02-05 9:30 ` [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Thomas Zimmermann
2026-02-05 9:31 ` Icenowy Zheng
@ 2026-02-08 1:02 ` Drew Fustini
2026-02-09 8:03 ` Thomas Zimmermann
1 sibling, 1 reply; 23+ messages in thread
From: Drew Fustini @ 2026-02-08 1:02 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: Icenowy Zheng, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Guo Ren, Fu Wei,
Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng
On Thu, Feb 05, 2026 at 10:30:55AM +0100, Thomas Zimmermann wrote:
> Hi,
>
> patches 1 to 5 have been merged into drm-misc-next. In patch 3, I replaced
> COMPILER_TEST with COMPILE_TEST in the Kconfig file.
Hi, do you think there will be a pull request for the upcoming 6.20/7.0
merge window with these patches?
I'm trying to decide whether or not I need to send in a late
thead-dt-for-next pull request to the soc tree maintainers.
thanks,
drew
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520)
2026-02-08 1:02 ` Drew Fustini
@ 2026-02-09 8:03 ` Thomas Zimmermann
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Zimmermann @ 2026-02-09 8:03 UTC (permalink / raw)
To: Drew Fustini
Cc: Icenowy Zheng, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Guo Ren, Fu Wei,
Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Luca Ceresoli,
Han Gao, Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng
Hi
Am 08.02.26 um 02:02 schrieb Drew Fustini:
> On Thu, Feb 05, 2026 at 10:30:55AM +0100, Thomas Zimmermann wrote:
>> Hi,
>>
>> patches 1 to 5 have been merged into drm-misc-next. In patch 3, I replaced
>> COMPILER_TEST with COMPILE_TEST in the Kconfig file.
> Hi, do you think there will be a pull request for the upcoming 6.20/7.0
> merge window with these patches?
It's too late for 7.0. The driver will be in 7.1.
Best regards
Thomas
>
> I'm trying to decide whether or not I need to send in a late
> thead-dt-for-next pull request to the soc tree maintainers.
>
> thanks,
> drew
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers
2026-01-29 2:39 ` [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers Icenowy Zheng
@ 2026-03-09 12:47 ` Luca Ceresoli
2026-03-09 16:35 ` Icenowy Zheng
0 siblings, 1 reply; 23+ messages in thread
From: Luca Ceresoli @ 2026-03-09 12:47 UTC (permalink / raw)
To: Icenowy Zheng, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng
Hello Icenowy Zheng,
On Thu Jan 29, 2026 at 3:39 AM CET, Icenowy Zheng wrote:
> From: Icenowy Zheng <uwu@icenowy.me>
>
> This is a from-scratch driver targeting Verisilicon DC-series display
> controllers, which feature self-identification functionality like their
> GC-series GPUs.
>
> Only DC8200 is being supported now, and only the main framebuffer is set
> up (as the DRM primary plane). Support for more DC models and more
> features is my further targets.
>
> As the display controller is delivered to SoC vendors as a whole part,
> this driver does not use component framework and extra bridges inside a
> SoC is expected to be implemented as dedicated bridges (this driver
> properly supports bridge chaining).
>
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> Tested-by: Han Gao <gaohan@iscas.ac.cn>
> Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
I have reviewed the bridge part of this patch and have a few remarks, see
below.
[...]
> +++ b/drivers/gpu/drm/verisilicon/vs_bridge.c
> @@ -0,0 +1,371 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
> + */
> +
> +#include <linux/of.h>
> +#include <linux/regmap.h>
> +
> +#include <uapi/linux/media-bus-format.h>
> +
> +#include <drm/drm_atomic.h>
> +#include <drm/drm_atomic_helper.h>
> +#include <drm/drm_bridge.h>
> +#include <drm/drm_bridge_connector.h>
> +#include <drm/drm_connector.h>
> +#include <drm/drm_encoder.h>
> +#include <drm/drm_of.h>
> +#include <drm/drm_print.h>
> +#include <drm/drm_simple_kms_helper.h>
> +
> +#include "vs_bridge.h"
> +#include "vs_bridge_regs.h"
> +#include "vs_crtc.h"
> +#include "vs_dc.h"
> +
> +static int vs_bridge_attach(struct drm_bridge *bridge,
> + struct drm_encoder *encoder,
> + enum drm_bridge_attach_flags flags)
> +{
> + struct vs_bridge *vbridge = drm_bridge_to_vs_bridge(bridge);
> +
> + return drm_bridge_attach(encoder, vbridge->next_bridge,
> + bridge, flags);
> +}
> +
> +struct vsdc_dp_format {
> + u32 linux_fmt;
> + bool is_yuv;
> + u32 vsdc_fmt;
> +};
Moving the bool after the two 'u32's would be better for packing and
spatial locality (especially in case more fields are added in the future).
> +
> +static struct vsdc_dp_format vsdc_dp_supported_fmts[] = {
> + /* default to RGB888 */
> + { MEDIA_BUS_FMT_FIXED, false, VSDC_DISP_DP_CONFIG_FMT_RGB888 },
> + { MEDIA_BUS_FMT_RGB888_1X24, false, VSDC_DISP_DP_CONFIG_FMT_RGB888 },
> + { MEDIA_BUS_FMT_RGB565_1X16, false, VSDC_DISP_DP_CONFIG_FMT_RGB565 },
> + { MEDIA_BUS_FMT_RGB666_1X18, false, VSDC_DISP_DP_CONFIG_FMT_RGB666 },
> + { MEDIA_BUS_FMT_RGB101010_1X30,
> + false, VSDC_DISP_DP_CONFIG_FMT_RGB101010 },
You can put up to 100 chars per line and avoid the newline here to make
this table more readable. Same below.
> + { MEDIA_BUS_FMT_UYVY8_1X16, true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY8 },
> + { MEDIA_BUS_FMT_UYVY10_1X20, true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY10 },
> + { MEDIA_BUS_FMT_YUV8_1X24, true, VSDC_DISP_DP_CONFIG_YUV_FMT_YUV8 },
> + { MEDIA_BUS_FMT_YUV10_1X30, true, VSDC_DISP_DP_CONFIG_YUV_FMT_YUV10 },
> + { MEDIA_BUS_FMT_UYYVYY8_0_5X24,
> + true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY8 },
> + { MEDIA_BUS_FMT_UYYVYY10_0_5X30,
> + true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY10 },
> +};
> +
[...]
> +struct vs_bridge *vs_bridge_init(struct drm_device *drm_dev,
> + struct vs_crtc *crtc)
> +{
> + unsigned int output = crtc->id;
> + struct vs_bridge *bridge;
In common practice a variable named 'bridge' is used to point to a 'struct
drm_bridge', so it feels weird when it is used for another type. Can you
rename to 'vbridge' or 'vsbridge' or similar, to clarify it's the
"Verisilicon bridge"?
This is after all what you did in vs_bridge_attach() above, where the
ambiguity of the 'bridge' name used for a driver-specific struct is
evident.
> + struct drm_bridge *next;
> + enum vs_bridge_output_interface intf;
> + const struct drm_bridge_funcs *bridge_funcs;
> + int ret, enctype;
> +
> + intf = vs_bridge_detect_output_interface(drm_dev->dev->of_node,
> + output);
> + if (intf == -ENODEV) {
> + drm_dbg(drm_dev, "Skipping output %u\n", output);
> + return NULL;
> + }
> +
> + next = devm_drm_of_get_bridge(drm_dev->dev, drm_dev->dev->of_node,
> + output, intf);
> + if (IS_ERR(next)) {
> + ret = PTR_ERR(next);
> + if (ret != -EPROBE_DEFER)
> + drm_err(drm_dev,
> + "Cannot get downstream bridge of output %u\n",
> + output);
100 chars per line are allowed, so this could fit on a single line being
nicer to read. This applies to a lot places in this driver, of logging
calls in particular. I understand this would be annoying to change on an
already reviewed patch and at v7 so up to you, but it would be good to keep
it in mind for the future.
> + return ERR_PTR(ret);
> + }
> +
> + if (intf == VSDC_OUTPUT_INTERFACE_DPI)
> + bridge_funcs = &vs_dpi_bridge_funcs;
> + else
> + bridge_funcs = &vs_dp_bridge_funcs;
> +
> + bridge = devm_drm_bridge_alloc(drm_dev->dev, struct vs_bridge, base,
> + bridge_funcs);
The 'struct drm_bridge' field embedded in a driver-specific struct is
conventionally called 'bridge', so renaming it from 'base' to 'bridge'
would make it more consistent with other drivers. That would go in sync
with the coding convention I mentioned above: 'bridge' for struct
drm_bridge, <XYZ>bridge or just <XYZZ> for a custom driver struct embedding
a bridge.
> + if (IS_ERR(bridge))
> + return ERR_PTR(PTR_ERR(bridge));
> +
> + bridge->crtc = crtc;
> + bridge->intf = intf;
> + bridge->next_bridge = next;
There is now a next_bridge field in struct drm_bridge, which handles the
bridge lifetime in a safer way and more simply [0], so you could use it:
bridge->base.next_bridge = next;
Or, after the renames I suggested above:
vbridge->bridge.next_bridge = next;
[0] https://elixir.bootlin.com/linux/v7.0-rc2/source/include/drm/drm_bridge.h#L1269-L1278
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 6/8] riscv: dts: thead: add DPU and HDMI device tree nodes
2026-01-29 2:39 ` [PATCH v7 6/8] riscv: dts: thead: add DPU and HDMI device tree nodes Icenowy Zheng
2026-01-29 20:39 ` Drew Fustini
@ 2026-03-09 14:40 ` Luca Ceresoli
1 sibling, 0 replies; 23+ messages in thread
From: Luca Ceresoli @ 2026-03-09 14:40 UTC (permalink / raw)
To: Icenowy Zheng, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng
On Thu Jan 29, 2026 at 3:39 AM CET, Icenowy Zheng wrote:
> From: Icenowy Zheng <uwu@icenowy.me>
>
> T-Head TH1520 SoC contains a Verisilicon DC8200 display controller
> (called DPU in manual) and a Synopsys DesignWare HDMI TX controller.
>
> Add device tree nodes to them.
>
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> Tested-by: Han Gao <gaohan@iscas.ac.cn>
> Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 7/8] riscv: dts: thead: lichee-pi-4a: enable HDMI
2026-01-29 2:39 ` [PATCH v7 7/8] riscv: dts: thead: lichee-pi-4a: enable HDMI Icenowy Zheng
2026-01-29 20:40 ` Drew Fustini
@ 2026-03-09 14:40 ` Luca Ceresoli
1 sibling, 0 replies; 23+ messages in thread
From: Luca Ceresoli @ 2026-03-09 14:40 UTC (permalink / raw)
To: Icenowy Zheng, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv,
Icenowy Zheng
On Thu Jan 29, 2026 at 3:39 AM CET, Icenowy Zheng wrote:
> Lichee Pi 4A board features a HDMI Type-A connector connected to the
> HDMI TX controller of TH1520 SoC.
>
> Add a device tree node describing the connector, connect it to the HDMI
> controller, and enable everything on this display pipeline.
>
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> Tested-by: Han Gao <gaohan@iscas.ac.cn>
> Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers
2026-03-09 12:47 ` Luca Ceresoli
@ 2026-03-09 16:35 ` Icenowy Zheng
2026-03-09 16:51 ` Icenowy Zheng
` (2 more replies)
0 siblings, 3 replies; 23+ messages in thread
From: Icenowy Zheng @ 2026-03-09 16:35 UTC (permalink / raw)
To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv
在 2026-03-09一的 13:47 +0100,Luca Ceresoli写道:
> Hello Icenowy Zheng,
>
> On Thu Jan 29, 2026 at 3:39 AM CET, Icenowy Zheng wrote:
> > From: Icenowy Zheng <uwu@icenowy.me>
> >
> > This is a from-scratch driver targeting Verisilicon DC-series
> > display
> > controllers, which feature self-identification functionality like
> > their
> > GC-series GPUs.
> >
> > Only DC8200 is being supported now, and only the main framebuffer
> > is set
> > up (as the DRM primary plane). Support for more DC models and more
> > features is my further targets.
> >
> > As the display controller is delivered to SoC vendors as a whole
> > part,
> > this driver does not use component framework and extra bridges
> > inside a
> > SoC is expected to be implemented as dedicated bridges (this driver
> > properly supports bridge chaining).
> >
> > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> > Tested-by: Han Gao <gaohan@iscas.ac.cn>
> > Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
> > Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> I have reviewed the bridge part of this patch and have a few remarks,
> see
> below.
>
> [...]
>
> > +++ b/drivers/gpu/drm/verisilicon/vs_bridge.c
> > @@ -0,0 +1,371 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
> > + */
> > +
> > +#include <linux/of.h>
> > +#include <linux/regmap.h>
> > +
> > +#include <uapi/linux/media-bus-format.h>
> > +
> > +#include <drm/drm_atomic.h>
> > +#include <drm/drm_atomic_helper.h>
> > +#include <drm/drm_bridge.h>
> > +#include <drm/drm_bridge_connector.h>
> > +#include <drm/drm_connector.h>
> > +#include <drm/drm_encoder.h>
> > +#include <drm/drm_of.h>
> > +#include <drm/drm_print.h>
> > +#include <drm/drm_simple_kms_helper.h>
> > +
> > +#include "vs_bridge.h"
> > +#include "vs_bridge_regs.h"
> > +#include "vs_crtc.h"
> > +#include "vs_dc.h"
> > +
> > +static int vs_bridge_attach(struct drm_bridge *bridge,
> > + struct drm_encoder *encoder,
> > + enum drm_bridge_attach_flags flags)
> > +{
> > + struct vs_bridge *vbridge =
> > drm_bridge_to_vs_bridge(bridge);
> > +
> > + return drm_bridge_attach(encoder, vbridge->next_bridge,
> > + bridge, flags);
> > +}
> > +
> > +struct vsdc_dp_format {
> > + u32 linux_fmt;
> > + bool is_yuv;
> > + u32 vsdc_fmt;
> > +};
>
> Moving the bool after the two 'u32's would be better for packing and
> spatial locality (especially in case more fields are added in the
> future).
Yes this seems to sound right, but doing such rework sounds quite big
and unnecessary after it's applied...
>
> > +
> > +static struct vsdc_dp_format vsdc_dp_supported_fmts[] = {
> > + /* default to RGB888 */
> > + { MEDIA_BUS_FMT_FIXED, false,
> > VSDC_DISP_DP_CONFIG_FMT_RGB888 },
> > + { MEDIA_BUS_FMT_RGB888_1X24, false,
> > VSDC_DISP_DP_CONFIG_FMT_RGB888 },
> > + { MEDIA_BUS_FMT_RGB565_1X16, false,
> > VSDC_DISP_DP_CONFIG_FMT_RGB565 },
> > + { MEDIA_BUS_FMT_RGB666_1X18, false,
> > VSDC_DISP_DP_CONFIG_FMT_RGB666 },
> > + { MEDIA_BUS_FMT_RGB101010_1X30,
> > + false, VSDC_DISP_DP_CONFIG_FMT_RGB101010 },
>
> You can put up to 100 chars per line and avoid the newline here to
> make
> this table more readable. Same below.
Ah I prefer to keep 80 CPL when I can, and the `coding-style.rst`
document still suggests 80.
>
> > + { MEDIA_BUS_FMT_UYVY8_1X16, true,
> > VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY8 },
> > + { MEDIA_BUS_FMT_UYVY10_1X20, true,
> > VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY10 },
> > + { MEDIA_BUS_FMT_YUV8_1X24, true,
> > VSDC_DISP_DP_CONFIG_YUV_FMT_YUV8 },
> > + { MEDIA_BUS_FMT_YUV10_1X30, true,
> > VSDC_DISP_DP_CONFIG_YUV_FMT_YUV10 },
> > + { MEDIA_BUS_FMT_UYYVYY8_0_5X24,
> > + true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY8 },
> > + { MEDIA_BUS_FMT_UYYVYY10_0_5X30,
> > + true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY10 },
> > +};
> > +
>
> [...]
>
> > +struct vs_bridge *vs_bridge_init(struct drm_device *drm_dev,
> > + struct vs_crtc *crtc)
> > +{
> > + unsigned int output = crtc->id;
> > + struct vs_bridge *bridge;
>
> In common practice a variable named 'bridge' is used to point to a
> 'struct
> drm_bridge', so it feels weird when it is used for another type. Can
> you
> rename to 'vbridge' or 'vsbridge' or similar, to clarify it's the
> "Verisilicon bridge"?
This sounds right.
BTW where is such kind of common practice documented?
>
> This is after all what you did in vs_bridge_attach() above, where the
> ambiguity of the 'bridge' name used for a driver-specific struct is
> evident.
>
> > + struct drm_bridge *next;
> > + enum vs_bridge_output_interface intf;
> > + const struct drm_bridge_funcs *bridge_funcs;
> > + int ret, enctype;
> > +
> > + intf = vs_bridge_detect_output_interface(drm_dev->dev-
> > >of_node,
> > + output);
> > + if (intf == -ENODEV) {
> > + drm_dbg(drm_dev, "Skipping output %u\n", output);
> > + return NULL;
> > + }
> > +
> > + next = devm_drm_of_get_bridge(drm_dev->dev, drm_dev->dev-
> > >of_node,
> > + output, intf);
> > + if (IS_ERR(next)) {
> > + ret = PTR_ERR(next);
> > + if (ret != -EPROBE_DEFER)
> > + drm_err(drm_dev,
> > + "Cannot get downstream bridge of
> > output %u\n",
> > + output);
>
> 100 chars per line are allowed, so this could fit on a single line
> being
> nicer to read. This applies to a lot places in this driver, of
> logging
> calls in particular. I understand this would be annoying to change on
> an
> already reviewed patch and at v7 so up to you, but it would be good
> to keep
> it in mind for the future.
>
> > + return ERR_PTR(ret);
> > + }
> > +
> > + if (intf == VSDC_OUTPUT_INTERFACE_DPI)
> > + bridge_funcs = &vs_dpi_bridge_funcs;
> > + else
> > + bridge_funcs = &vs_dp_bridge_funcs;
> > +
> > + bridge = devm_drm_bridge_alloc(drm_dev->dev, struct
> > vs_bridge, base,
> > + bridge_funcs);
>
> The 'struct drm_bridge' field embedded in a driver-specific struct is
> conventionally called 'bridge', so renaming it from 'base' to
> 'bridge'
> would make it more consistent with other drivers. That would go in
> sync
> with the coding convention I mentioned above: 'bridge' for struct
> drm_bridge, <XYZ>bridge or just <XYZZ> for a custom driver struct
> embedding
> a bridge.
Ah, all subclasses in this driver call the base class `base`, and I
still wonder how such convention is documented.
>
> > + if (IS_ERR(bridge))
> > + return ERR_PTR(PTR_ERR(bridge));
> > +
> > + bridge->crtc = crtc;
> > + bridge->intf = intf;
> > + bridge->next_bridge = next;
>
> There is now a next_bridge field in struct drm_bridge, which handles
> the
> bridge lifetime in a safer way and more simply [0], so you could use
> it:
Glad to hear such a field exists now. Will more code about next_bridge
lifetime management being shared?
Thanks,
Icenowy
>
> bridge->base.next_bridge = next;
>
> Or, after the renames I suggested above:
>
> vbridge->bridge.next_bridge = next;
>
> [0]
> https://elixir.bootlin.com/linux/v7.0-rc2/source/include/drm/drm_bridge.h#L1269-L1278
>
> Luca
>
> --
> Luca Ceresoli, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers
2026-03-09 16:35 ` Icenowy Zheng
@ 2026-03-09 16:51 ` Icenowy Zheng
2026-03-10 10:25 ` Luca Ceresoli
2026-03-10 8:27 ` Thomas Zimmermann
2026-03-10 10:25 ` Luca Ceresoli
2 siblings, 1 reply; 23+ messages in thread
From: Icenowy Zheng @ 2026-03-09 16:51 UTC (permalink / raw)
To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv
在 2026-03-10二的 00:35 +0800,Icenowy Zheng写道:
================ 8< ==================
> > > + if (IS_ERR(bridge))
> > > + return ERR_PTR(PTR_ERR(bridge));
> > > +
> > > + bridge->crtc = crtc;
> > > + bridge->intf = intf;
> > > + bridge->next_bridge = next;
> >
> > There is now a next_bridge field in struct drm_bridge, which
> > handles
> > the
> > bridge lifetime in a safer way and more simply [0], so you could
> > use
> > it:
>
> Glad to hear such a field exists now. Will more code about
> next_bridge
> lifetime management being shared?
Looks like now many drivers can just share the .attach function,
because they're all doing the same thing:
```
int drm_bridge_attach_next(struct drm_bridge *bridge,
struct drm_encoder *encoder,
enum drm_bridge_attach_flags flags)
{
return drm_bridge_attach(encoder, bridge->next_bridge,
bridge, flags);
}
```
At least vs_bridge_attach here and meson_encoder_*_attach (named
encoder but they're bridge drivers now) match this pattern (the latter
does a cast from `struct drm_bridge *` to their subclasses, but then
only accessing the `bridge` field of the subclasses and doing the same
things here).
Thanks,
Icenowy
>
> Thanks,
> Icenowy
>
> >
> > bridge->base.next_bridge = next;
> >
> > Or, after the renames I suggested above:
> >
> > vbridge->bridge.next_bridge = next;
> >
> > [0]
> > https://elixir.bootlin.com/linux/v7.0-rc2/source/include/drm/drm_bridge.h#L1269-L1278
> >
> > Luca
> >
> > --
> > Luca Ceresoli, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers
2026-03-09 16:35 ` Icenowy Zheng
2026-03-09 16:51 ` Icenowy Zheng
@ 2026-03-10 8:27 ` Thomas Zimmermann
2026-03-10 10:25 ` Luca Ceresoli
2 siblings, 0 replies; 23+ messages in thread
From: Thomas Zimmermann @ 2026-03-10 8:27 UTC (permalink / raw)
To: Icenowy Zheng, Luca Ceresoli, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Drew Fustini,
Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv
Hi
Am 09.03.26 um 17:35 schrieb Icenowy Zheng:
> 在 2026-03-09一的 13:47 +0100,Luca Ceresoli写道:
>> Hello Icenowy Zheng,
>>
>> On Thu Jan 29, 2026 at 3:39 AM CET, Icenowy Zheng wrote:
>>> From: Icenowy Zheng <uwu@icenowy.me>
>>>
>>> This is a from-scratch driver targeting Verisilicon DC-series
>>> display
>>> controllers, which feature self-identification functionality like
>>> their
>>> GC-series GPUs.
>>>
>>> Only DC8200 is being supported now, and only the main framebuffer
>>> is set
>>> up (as the DRM primary plane). Support for more DC models and more
>>> features is my further targets.
>>>
>>> As the display controller is delivered to SoC vendors as a whole
>>> part,
>>> this driver does not use component framework and extra bridges
>>> inside a
>>> SoC is expected to be implemented as dedicated bridges (this driver
>>> properly supports bridge chaining).
>>>
>>> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
>>> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
>>> Tested-by: Han Gao <gaohan@iscas.ac.cn>
>>> Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
>>> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>> I have reviewed the bridge part of this patch and have a few remarks,
>> see
>> below.
>>
>> [...]
>>
>>> +++ b/drivers/gpu/drm/verisilicon/vs_bridge.c
>>> @@ -0,0 +1,371 @@
>>> +// SPDX-License-Identifier: GPL-2.0-only
>>> +/*
>>> + * Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
>>> + */
>>> +
>>> +#include <linux/of.h>
>>> +#include <linux/regmap.h>
>>> +
>>> +#include <uapi/linux/media-bus-format.h>
>>> +
>>> +#include <drm/drm_atomic.h>
>>> +#include <drm/drm_atomic_helper.h>
>>> +#include <drm/drm_bridge.h>
>>> +#include <drm/drm_bridge_connector.h>
>>> +#include <drm/drm_connector.h>
>>> +#include <drm/drm_encoder.h>
>>> +#include <drm/drm_of.h>
>>> +#include <drm/drm_print.h>
>>> +#include <drm/drm_simple_kms_helper.h>
>>> +
>>> +#include "vs_bridge.h"
>>> +#include "vs_bridge_regs.h"
>>> +#include "vs_crtc.h"
>>> +#include "vs_dc.h"
>>> +
>>> +static int vs_bridge_attach(struct drm_bridge *bridge,
>>> + struct drm_encoder *encoder,
>>> + enum drm_bridge_attach_flags flags)
>>> +{
>>> + struct vs_bridge *vbridge =
>>> drm_bridge_to_vs_bridge(bridge);
>>> +
>>> + return drm_bridge_attach(encoder, vbridge->next_bridge,
>>> + bridge, flags);
>>> +}
>>> +
>>> +struct vsdc_dp_format {
>>> + u32 linux_fmt;
>>> + bool is_yuv;
>>> + u32 vsdc_fmt;
>>> +};
>> Moving the bool after the two 'u32's would be better for packing and
>> spatial locality (especially in case more fields are added in the
>> future).
> Yes this seems to sound right, but doing such rework sounds quite big
> and unnecessary after it's applied...
Why? You are merely moving fields around, right? Just send a patch then.
Best regards
Thomas
>
>>> +
>>> +static struct vsdc_dp_format vsdc_dp_supported_fmts[] = {
>>> + /* default to RGB888 */
>>> + { MEDIA_BUS_FMT_FIXED, false,
>>> VSDC_DISP_DP_CONFIG_FMT_RGB888 },
>>> + { MEDIA_BUS_FMT_RGB888_1X24, false,
>>> VSDC_DISP_DP_CONFIG_FMT_RGB888 },
>>> + { MEDIA_BUS_FMT_RGB565_1X16, false,
>>> VSDC_DISP_DP_CONFIG_FMT_RGB565 },
>>> + { MEDIA_BUS_FMT_RGB666_1X18, false,
>>> VSDC_DISP_DP_CONFIG_FMT_RGB666 },
>>> + { MEDIA_BUS_FMT_RGB101010_1X30,
>>> + false, VSDC_DISP_DP_CONFIG_FMT_RGB101010 },
>> You can put up to 100 chars per line and avoid the newline here to
>> make
>> this table more readable. Same below.
> Ah I prefer to keep 80 CPL when I can, and the `coding-style.rst`
> document still suggests 80.
>
>>> + { MEDIA_BUS_FMT_UYVY8_1X16, true,
>>> VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY8 },
>>> + { MEDIA_BUS_FMT_UYVY10_1X20, true,
>>> VSDC_DISP_DP_CONFIG_YUV_FMT_UYVY10 },
>>> + { MEDIA_BUS_FMT_YUV8_1X24, true,
>>> VSDC_DISP_DP_CONFIG_YUV_FMT_YUV8 },
>>> + { MEDIA_BUS_FMT_YUV10_1X30, true,
>>> VSDC_DISP_DP_CONFIG_YUV_FMT_YUV10 },
>>> + { MEDIA_BUS_FMT_UYYVYY8_0_5X24,
>>> + true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY8 },
>>> + { MEDIA_BUS_FMT_UYYVYY10_0_5X30,
>>> + true, VSDC_DISP_DP_CONFIG_YUV_FMT_UYYVYY10 },
>>> +};
>>> +
>> [...]
>>
>>> +struct vs_bridge *vs_bridge_init(struct drm_device *drm_dev,
>>> + struct vs_crtc *crtc)
>>> +{
>>> + unsigned int output = crtc->id;
>>> + struct vs_bridge *bridge;
>> In common practice a variable named 'bridge' is used to point to a
>> 'struct
>> drm_bridge', so it feels weird when it is used for another type. Can
>> you
>> rename to 'vbridge' or 'vsbridge' or similar, to clarify it's the
>> "Verisilicon bridge"?
> This sounds right.
>
> BTW where is such kind of common practice documented?
>
>> This is after all what you did in vs_bridge_attach() above, where the
>> ambiguity of the 'bridge' name used for a driver-specific struct is
>> evident.
>>
>>> + struct drm_bridge *next;
>>> + enum vs_bridge_output_interface intf;
>>> + const struct drm_bridge_funcs *bridge_funcs;
>>> + int ret, enctype;
>>> +
>>> + intf = vs_bridge_detect_output_interface(drm_dev->dev-
>>>> of_node,
>>> + output);
>>> + if (intf == -ENODEV) {
>>> + drm_dbg(drm_dev, "Skipping output %u\n", output);
>>> + return NULL;
>>> + }
>>> +
>>> + next = devm_drm_of_get_bridge(drm_dev->dev, drm_dev->dev-
>>>> of_node,
>>> + output, intf);
>>> + if (IS_ERR(next)) {
>>> + ret = PTR_ERR(next);
>>> + if (ret != -EPROBE_DEFER)
>>> + drm_err(drm_dev,
>>> + "Cannot get downstream bridge of
>>> output %u\n",
>>> + output);
>> 100 chars per line are allowed, so this could fit on a single line
>> being
>> nicer to read. This applies to a lot places in this driver, of
>> logging
>> calls in particular. I understand this would be annoying to change on
>> an
>> already reviewed patch and at v7 so up to you, but it would be good
>> to keep
>> it in mind for the future.
>>
>>> + return ERR_PTR(ret);
>>> + }
>>> +
>>> + if (intf == VSDC_OUTPUT_INTERFACE_DPI)
>>> + bridge_funcs = &vs_dpi_bridge_funcs;
>>> + else
>>> + bridge_funcs = &vs_dp_bridge_funcs;
>>> +
>>> + bridge = devm_drm_bridge_alloc(drm_dev->dev, struct
>>> vs_bridge, base,
>>> + bridge_funcs);
>> The 'struct drm_bridge' field embedded in a driver-specific struct is
>> conventionally called 'bridge', so renaming it from 'base' to
>> 'bridge'
>> would make it more consistent with other drivers. That would go in
>> sync
>> with the coding convention I mentioned above: 'bridge' for struct
>> drm_bridge, <XYZ>bridge or just <XYZZ> for a custom driver struct
>> embedding
>> a bridge.
> Ah, all subclasses in this driver call the base class `base`, and I
> still wonder how such convention is documented.
>
>>> + if (IS_ERR(bridge))
>>> + return ERR_PTR(PTR_ERR(bridge));
>>> +
>>> + bridge->crtc = crtc;
>>> + bridge->intf = intf;
>>> + bridge->next_bridge = next;
>> There is now a next_bridge field in struct drm_bridge, which handles
>> the
>> bridge lifetime in a safer way and more simply [0], so you could use
>> it:
> Glad to hear such a field exists now. Will more code about next_bridge
> lifetime management being shared?
>
> Thanks,
> Icenowy
>
>> bridge->base.next_bridge = next;
>>
>> Or, after the renames I suggested above:
>>
>> vbridge->bridge.next_bridge = next;
>>
>> [0]
>> https://elixir.bootlin.com/linux/v7.0-rc2/source/include/drm/drm_bridge.h#L1269-L1278
>>
>> Luca
>>
>> --
>> Luca Ceresoli, Bootlin
>> Embedded Linux and Kernel engineering
>> https://bootlin.com
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers
2026-03-09 16:51 ` Icenowy Zheng
@ 2026-03-10 10:25 ` Luca Ceresoli
0 siblings, 0 replies; 23+ messages in thread
From: Luca Ceresoli @ 2026-03-10 10:25 UTC (permalink / raw)
To: Icenowy Zheng, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv
Hello Icenowy,
On Mon Mar 9, 2026 at 5:51 PM CET, Icenowy Zheng wrote:
> 在 2026-03-10二的 00:35 +0800,Icenowy Zheng写道:
> ================ 8< ==================
>> > > + if (IS_ERR(bridge))
>> > > + return ERR_PTR(PTR_ERR(bridge));
>> > > +
>> > > + bridge->crtc = crtc;
>> > > + bridge->intf = intf;
>> > > + bridge->next_bridge = next;
>> >
>> > There is now a next_bridge field in struct drm_bridge, which
>> > handles
>> > the
>> > bridge lifetime in a safer way and more simply [0], so you could
>> > use
>> > it:
>>
>> Glad to hear such a field exists now. Will more code about
>> next_bridge
>> lifetime management being shared?
>
> Looks like now many drivers can just share the .attach function,
> because they're all doing the same thing:
>
> ```
> int drm_bridge_attach_next(struct drm_bridge *bridge,
> struct drm_encoder *encoder,
> enum drm_bridge_attach_flags flags)
> {
> return drm_bridge_attach(encoder, bridge->next_bridge,
> bridge, flags);
> }
> ```
>
> At least vs_bridge_attach here and meson_encoder_*_attach (named
> encoder but they're bridge drivers now) match this pattern (the latter
> does a cast from `struct drm_bridge *` to their subclasses, but then
> only accessing the `bridge` field of the subclasses and doing the same
> things here).
Indeed, several drivers are more and more similar in this respect so a
helper could deduplicate a bit of code in an easy way here.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers
2026-03-09 16:35 ` Icenowy Zheng
2026-03-09 16:51 ` Icenowy Zheng
2026-03-10 8:27 ` Thomas Zimmermann
@ 2026-03-10 10:25 ` Luca Ceresoli
2 siblings, 0 replies; 23+ messages in thread
From: Luca Ceresoli @ 2026-03-10 10:25 UTC (permalink / raw)
To: Icenowy Zheng, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Drew Fustini, Guo Ren, Fu Wei
Cc: Philipp Zabel, Dmitry Baryshkov, Michal Wilczynski, Han Gao,
Yao Zi, linux-kernel, dri-devel, devicetree, linux-riscv
Hello Icenowy,
On Mon Mar 9, 2026 at 5:35 PM CET, Icenowy Zheng wrote:
>> > +struct vsdc_dp_format {
>> > + u32 linux_fmt;
>> > + bool is_yuv;
>> > + u32 vsdc_fmt;
>> > +};
>>
>> Moving the bool after the two 'u32's would be better for packing and
>> spatial locality (especially in case more fields are added in the
>> future).
>
> Yes this seems to sound right, but doing such rework sounds quite big
> and unnecessary after it's applied...
Ugh, apologies, I sent my reply without noticing this patch had been
applied already. Anyway, as Thomas pointed out, you can still do this
change as a separate patch ifi you want. Or just not do anything, this can
be done later in case new fields are added. Without new fields the
reordering would not produce much benefit anyway.
>> > +static struct vsdc_dp_format vsdc_dp_supported_fmts[] = {
>> > + /* default to RGB888 */
>> > + { MEDIA_BUS_FMT_FIXED, false,
>> > VSDC_DISP_DP_CONFIG_FMT_RGB888 },
>> > + { MEDIA_BUS_FMT_RGB888_1X24, false,
>> > VSDC_DISP_DP_CONFIG_FMT_RGB888 },
>> > + { MEDIA_BUS_FMT_RGB565_1X16, false,
>> > VSDC_DISP_DP_CONFIG_FMT_RGB565 },
>> > + { MEDIA_BUS_FMT_RGB666_1X18, false,
>> > VSDC_DISP_DP_CONFIG_FMT_RGB666 },
>> > + { MEDIA_BUS_FMT_RGB101010_1X30,
>> > + false, VSDC_DISP_DP_CONFIG_FMT_RGB101010 },
>>
>> You can put up to 100 chars per line and avoid the newline here to
>> make
>> this table more readable. Same below.
>
> Ah I prefer to keep 80 CPL when I can, and the `coding-style.rst`
> document still suggests 80.
coding-style.rst seems very vague about that, but checkpatch is clear:
my $max_line_length = 100;
(https://elixir.bootlin.com/linux/v6.19.6/source/scripts/checkpatch.pl#L60)
Anyway, non need to send a patch now that it's committed for this,
definitely. Again, sorry for the noise on an already applied patch.
>> > +struct vs_bridge *vs_bridge_init(struct drm_device *drm_dev,
>> > + struct vs_crtc *crtc)
>> > +{
>> > + unsigned int output = crtc->id;
>> > + struct vs_bridge *bridge;
>>
>> In common practice a variable named 'bridge' is used to point to a
>> 'struct
>> drm_bridge', so it feels weird when it is used for another type. Can
>> you
>> rename to 'vbridge' or 'vsbridge' or similar, to clarify it's the
>> "Verisilicon bridge"?
>
> This sounds right.
>
> BTW where is such kind of common practice documented?
As it often happens, in the code, I'm afraid.
I've been touching a lot of DRM bridge and related code recently as part of
the bridge hotplug work I'm doing, and I gathered an overall view of the
current common practice as well as which conventions are more readable than
others.
>> > + return ERR_PTR(ret);
>> > + }
>> > +
>> > + if (intf == VSDC_OUTPUT_INTERFACE_DPI)
>> > + bridge_funcs = &vs_dpi_bridge_funcs;
>> > + else
>> > + bridge_funcs = &vs_dp_bridge_funcs;
>> > +
>> > + bridge = devm_drm_bridge_alloc(drm_dev->dev, struct
>> > vs_bridge, base,
>> > + bridge_funcs);
>>
>> The 'struct drm_bridge' field embedded in a driver-specific struct is
>> conventionally called 'bridge', so renaming it from 'base' to
>> 'bridge'
>> would make it more consistent with other drivers. That would go in
>> sync
>> with the coding convention I mentioned above: 'bridge' for struct
>> drm_bridge, <XYZ>bridge or just <XYZZ> for a custom driver struct
>> embedding
>> a bridge.
>
> Ah, all subclasses in this driver call the base class `base`, and I
> still wonder how such convention is documented.
It's a gain the common practice in the code:
$ git grep -h -E '[[:space:]]struct drm_bridge \*[[:alnum:]_]*;' -- drivers/gpu/drm/ | \
sed 's/^[[:space:]]*//' | grep -v panel_bridge | sort | uniq -c | sort -nr
92 struct drm_bridge *bridge;
27 struct drm_bridge *next_bridge;
3 struct drm_bridge *companion;
2 struct drm_bridge *next;
2 struct drm_bridge *iter;
1 struct drm_bridge *tmp_bridge;
1 struct drm_bridge *out_bridge;
1 struct drm_bridge *ext_bridge;
1 struct drm_bridge *drm_bridge;
[...]
So 'bridge' is by far the most common, and 'base' does never appear.
>> There is now a next_bridge field in struct drm_bridge, which handles
>> the
>> bridge lifetime in a safer way and more simply [0], so you could use
>> it:
>
> Glad to hear such a field exists now. Will more code about next_bridge
> lifetime management being shared?
Not sure exactly what you mean here. If you are asking how next_bridge
works: it's very simple, all being in the declaration [0] (where I
explained it to the best I could in the comment) and its usage in the
destruction callback when the last reference is put [1].
[0] https://elixir.bootlin.com/linux/v7.0-rc3/source/include/drm/drm_bridge.h
[1] https://elixir.bootlin.com/linux/v7.0-rc3/source/drivers/gpu/drm/drm_bridge.c#L267
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2026-03-10 10:25 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 1/8] dt-bindings: vendor-prefixes: add verisilicon Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 2/8] dt-bindings: display: add verisilicon,dc Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers Icenowy Zheng
2026-03-09 12:47 ` Luca Ceresoli
2026-03-09 16:35 ` Icenowy Zheng
2026-03-09 16:51 ` Icenowy Zheng
2026-03-10 10:25 ` Luca Ceresoli
2026-03-10 8:27 ` Thomas Zimmermann
2026-03-10 10:25 ` Luca Ceresoli
2026-01-29 2:39 ` [PATCH v7 4/8] dt-bindings: display/bridge: add binding for TH1520 HDMI controller Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 5/8] drm/bridge: add a driver for T-Head " Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 6/8] riscv: dts: thead: add DPU and HDMI device tree nodes Icenowy Zheng
2026-01-29 20:39 ` Drew Fustini
2026-03-09 14:40 ` Luca Ceresoli
2026-01-29 2:39 ` [PATCH v7 7/8] riscv: dts: thead: lichee-pi-4a: enable HDMI Icenowy Zheng
2026-01-29 20:40 ` Drew Fustini
2026-03-09 14:40 ` Luca Ceresoli
2026-01-29 2:39 ` [PATCH v7 8/8] mailmap: map all Icenowy Zheng's mail addresses Icenowy Zheng
2026-02-05 9:30 ` [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Thomas Zimmermann
2026-02-05 9:31 ` Icenowy Zheng
2026-02-08 1:02 ` Drew Fustini
2026-02-09 8:03 ` Thomas Zimmermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox