From 54a67c08000a4e0b3bb39280cddd05be22a51d20 Mon Sep 17 00:00:00 2001 From: "sw.multimedia" Date: Tue, 31 Aug 2021 16:48:57 +0800 Subject: drm/starfive: Add StarFive drm driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add starfive DRM Display driver framework Signed-off-by: jack.zhu Signed-off-by: keith.zhao Signed-off-by: Geert Uytterhoeven Signed-off-by: José Expósito Signed-off-by: Emil Renner Berthing --- drivers/cache/sifive_ccache.c | 6 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/starfive/Kconfig | 17 + drivers/gpu/drm/starfive/Makefile | 13 + drivers/gpu/drm/starfive/README.txt | 56 ++ drivers/gpu/drm/starfive/starfive_drm_crtc.c | 511 ++++++++++++++++ drivers/gpu/drm/starfive/starfive_drm_crtc.h | 86 +++ drivers/gpu/drm/starfive/starfive_drm_drv.c | 262 ++++++++ drivers/gpu/drm/starfive/starfive_drm_drv.h | 25 + drivers/gpu/drm/starfive/starfive_drm_encoder.c | 129 ++++ drivers/gpu/drm/starfive/starfive_drm_encoder.h | 18 + drivers/gpu/drm/starfive/starfive_drm_gem.c | 348 +++++++++++ drivers/gpu/drm/starfive/starfive_drm_gem.h | 40 ++ drivers/gpu/drm/starfive/starfive_drm_lcdc.c | 512 ++++++++++++++++ drivers/gpu/drm/starfive/starfive_drm_lcdc.h | 160 +++++ drivers/gpu/drm/starfive/starfive_drm_plane.c | 227 +++++++ drivers/gpu/drm/starfive/starfive_drm_plane.h | 12 + drivers/gpu/drm/starfive/starfive_drm_vpp.c | 766 ++++++++++++++++++++++++ drivers/gpu/drm/starfive/starfive_drm_vpp.h | 201 +++++++ include/soc/sifive/sifive_ccache.h | 2 + 21 files changed, 3394 insertions(+) create mode 100644 drivers/gpu/drm/starfive/Kconfig create mode 100644 drivers/gpu/drm/starfive/Makefile create mode 100644 drivers/gpu/drm/starfive/README.txt create mode 100644 drivers/gpu/drm/starfive/starfive_drm_crtc.c create mode 100644 drivers/gpu/drm/starfive/starfive_drm_crtc.h create mode 100644 drivers/gpu/drm/starfive/starfive_drm_drv.c create mode 100644 drivers/gpu/drm/starfive/starfive_drm_drv.h create mode 100644 drivers/gpu/drm/starfive/starfive_drm_encoder.c create mode 100644 drivers/gpu/drm/starfive/starfive_drm_encoder.h create mode 100644 drivers/gpu/drm/starfive/starfive_drm_gem.c create mode 100644 drivers/gpu/drm/starfive/starfive_drm_gem.h create mode 100644 drivers/gpu/drm/starfive/starfive_drm_lcdc.c create mode 100644 drivers/gpu/drm/starfive/starfive_drm_lcdc.h create mode 100644 drivers/gpu/drm/starfive/starfive_drm_plane.c create mode 100644 drivers/gpu/drm/starfive/starfive_drm_plane.h create mode 100644 drivers/gpu/drm/starfive/starfive_drm_vpp.c create mode 100644 drivers/gpu/drm/starfive/starfive_drm_vpp.h diff --git a/drivers/cache/sifive_ccache.c b/drivers/cache/sifive_ccache.c index 6874b72ec59d..9a3bf329b023 100644 --- a/drivers/cache/sifive_ccache.c +++ b/drivers/cache/sifive_ccache.c @@ -161,6 +161,12 @@ static void ccache_flush_range(phys_addr_t start, size_t len) } } +void sifive_ccache_flush_range(phys_addr_t start, size_t len) +{ + ccache_flush_range(start, len); +} +EXPORT_SYMBOL_GPL(sifive_ccache_flush_range); + static const struct riscv_nonstd_cache_ops ccache_mgmt_ops __initconst = { .wback = &ccache_flush_range, .inv = &ccache_flush_range, diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index d0aa277fc3bf..64b3297e404c 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -347,6 +347,8 @@ source "drivers/gpu/drm/renesas/Kconfig" source "drivers/gpu/drm/sun4i/Kconfig" +source "drivers/gpu/drm/starfive/Kconfig" + source "drivers/gpu/drm/omapdrm/Kconfig" source "drivers/gpu/drm/tilcdc/Kconfig" diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index f9ca4f8fa6c5..3e1dd7b8d347 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -182,6 +182,7 @@ obj-$(CONFIG_DRM_ATMEL_HLCDC) += atmel-hlcdc/ obj-y += renesas/ obj-y += omapdrm/ obj-$(CONFIG_DRM_SUN4I) += sun4i/ +obj-$(CONFIG_DRM_STARFIVE) += starfive/ obj-y += tilcdc/ obj-$(CONFIG_DRM_QXL) += qxl/ obj-$(CONFIG_DRM_VIRTIO_GPU) += virtio/ diff --git a/drivers/gpu/drm/starfive/Kconfig b/drivers/gpu/drm/starfive/Kconfig new file mode 100644 index 000000000000..99181d43c8f0 --- /dev/null +++ b/drivers/gpu/drm/starfive/Kconfig @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2021 StarFive Technology Co., Ltd. + +config DRM_STARFIVE + tristate "DRM Support for StarFive SoCs" + depends on DRM + depends on SIFIVE_CCACHE && RISCV_NONSTANDARD_CACHE_OPS + depends on SOC_STARFIVE || COMPILE_TEST + select DRM_GEM_DMA_HELPER + select DRM_KMS_HELPER + select DRM_MIPI_DSI + select DRM_PANEL + help + Choose this option if you have a StarFive SoCs. + The module will be called starfive-drm + This driver provides kernel mode setting and + buffer management to userspace. diff --git a/drivers/gpu/drm/starfive/Makefile b/drivers/gpu/drm/starfive/Makefile new file mode 100644 index 000000000000..8ef9e5f469fd --- /dev/null +++ b/drivers/gpu/drm/starfive/Makefile @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2021 StarFive Technology Co., Ltd. +# +starfive-drm-y := starfive_drm_drv.o \ + starfive_drm_gem.o \ + starfive_drm_crtc.o \ + starfive_drm_encoder.o \ + starfive_drm_plane.o \ + starfive_drm_lcdc.o \ + starfive_drm_vpp.o + +obj-$(CONFIG_DRM_STARFIVE) += starfive-drm.o diff --git a/drivers/gpu/drm/starfive/README.txt b/drivers/gpu/drm/starfive/README.txt new file mode 100644 index 000000000000..dadec80c98bf --- /dev/null +++ b/drivers/gpu/drm/starfive/README.txt @@ -0,0 +1,56 @@ +Display Subsystem:(default FBdev) + +Steps switch to DRM: +1、Disable fbdev,close below config items: +CONFIG_FB_STARFIVE=y +CONFIG_FB_STARFIVE_HDMI_TDA998X=y +CONFIG_FB_STARFIVE_VIDEO=y + +2、open DRM hdmi pipeline,enable items: +CONFIG_DRM_I2C_NXP_TDA998X=y +CONFIG_DRM_I2C_NXP_TDA9950=y +CONFIG_DRM_STARFIVE=y +CONFIG_FRAMEBUFFER_CONSOLE=y + +Precautions:when use DRM hdmi pipeline,please make sure CONFIG_DRM_STARFIVE_MIPI_DSI is disable , + or will cause color abnormal. + +3、open DRM mipi pipeline + +enable items: + CONFIG_PHY_M31_DPHY_RX0=y + CONFIG_DRM_STARFIVE_MIPI_DSI=y + + +change jh7100.dtsi display-encoder as below: + + display-encoder { + compatible = "starfive,display-encoder"; + encoder-type = <6>; //2-TMDS, 3-LVDS, 6-DSI, 8-DPI + status = "okay"; + + ports { + port@0 { + endpoint { + remote-endpoint = <&dsi_out_port>; + }; + }; + + port@1 { + endpoint { + remote-endpoint = <&crtc_0_out>; + }; + }; + }; + }; + +install libdrm: +make buildroot_initramfs-menuconfig +choose: +BR2_PACKAGE_LIBDRM=y +BR2_PACKAGE_LIBDRM_RADEON=y +BR2_PACKAGE_LIBDRM_AMDGPU=y +BR2_PACKAGE_LIBDRM_NOUVEAU=y +BR2_PACKAGE_LIBDRM_ETNAVIV=y +BR2_PACKAGE_LIBDRM_INSTALL_TESTS=y + diff --git a/drivers/gpu/drm/starfive/starfive_drm_crtc.c b/drivers/gpu/drm/starfive/starfive_drm_crtc.c new file mode 100644 index 000000000000..64907cc8f66d --- /dev/null +++ b/drivers/gpu/drm/starfive/starfive_drm_crtc.c @@ -0,0 +1,511 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 StarFive Technology Co., Ltd. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "starfive_drm_drv.h" +#include "starfive_drm_crtc.h" +#include "starfive_drm_plane.h" +#include "starfive_drm_lcdc.h" +#include "starfive_drm_vpp.h" +//#include