Re: [PATCH] drm: add kms driver for loongson display controller
Hi suijingfeng, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on drm-misc/drm-misc-next] [also build test WARNING on linus/master v6.2-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/suijingfeng/drm-add-kms-driver-for-loongson-display-controller/20230202-011138 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230201170403.167665-1-15330273260%40189.cn patch subject: [PATCH] drm: add kms driver for loongson display controller config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20230203/202302031525.a4udcuh1-...@intel.com/config) compiler: mips-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/ff8d5959f6dcf4abbbdbf2951345f552dc3bea46 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review suijingfeng/drm-add-kms-driver-for-loongson-display-controller/20230202-011138 git checkout ff8d5959f6dcf4abbbdbf2951345f552dc3bea46 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/gpu/drm/lsdc/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot All warnings (new ones prefixed by >>): >> drivers/gpu/drm/lsdc/lsdc_drv.c:227:1: warning: no previous prototype for >> 'lsdc_detect_chip' [-Wmissing-prototypes] 227 | lsdc_detect_chip(struct pci_dev *pdev, const struct pci_device_id * const ent) | ^~~~ >> drivers/gpu/drm/lsdc/lsdc_drv.c:295:21: warning: no previous prototype for >> 'lsdc_create_device' [-Wmissing-prototypes] 295 | struct lsdc_device *lsdc_create_device(struct pci_dev *pdev, | ^~ In file included from include/linux/device.h:15, from include/linux/pci.h:37, from drivers/gpu/drm/lsdc/lsdc_drv.c:11: drivers/gpu/drm/lsdc/lsdc_drv.c: In function 'lsdc_create_device': >> drivers/gpu/drm/lsdc/lsdc_drv.c:325:46: warning: cast from pointer to >> integer of different size [-Wpointer-to-int-cast] 325 | drm_info(ddev, "reg base: 0x%llx\n", (u64)ldev->reg_base); | ^ include/linux/dev_printk.h:110:37: note: in definition of macro 'dev_printk_index_wrap' 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ | ^~~ include/drm/drm_print.h:456:9: note: in expansion of macro 'dev_info' 456 | dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__) | ^~~~ include/drm/drm_print.h:460:9: note: in expansion of macro '__drm_printk' 460 | __drm_printk((drm), info,, fmt, ##__VA_ARGS__) | ^~~~ drivers/gpu/drm/lsdc/lsdc_drv.c:325:9: note: in expansion of macro 'drm_info' 325 | drm_info(ddev, "reg base: 0x%llx\n", (u64)ldev->reg_base); | ^~~~ drivers/gpu/drm/lsdc/lsdc_drv.c: At top level: drivers/gpu/drm/lsdc/lsdc_drv.c:52:31: warning: 'dc_in_ls2k1000' defined but not used [-Wunused-const-variable=] 52 | static const struct lsdc_desc dc_in_ls2k1000 = { | ^~ drivers/gpu/drm/lsdc/lsdc_drv.c:34:31: warning: 'dc_in_ls2k0500' defined but not used [-Wunused-const-variable=] 34 | static const struct lsdc_desc dc_in_ls2k0500 = { | ^~ vim +/lsdc_detect_chip +227 drivers/gpu/drm/lsdc/lsdc_drv.c 222 223 /* 224 * lsdc_detect_chip - a function to tell different chips apart. 225 */ 226 const struct lsdc_desc * > 227 lsdc_detect_chip(struct pci_dev *pdev, const struct pci_device_id * > const ent) 228 { 229 if (ent) { 230 struct lsdc_desc *dc_descp; 231 232 dc_descp = (struct lsdc_desc *)ent->driver_data; 233 if (dc_descp->chip == CHIP_LS7A1000) 234 dev_info(>dev, "LS7A1000 Found, revision: %u\n", pdev->revision); 235 else if (dc_descp->chip == CHIP_LS7
[PATCH] drm: add kms driver for loongson display controller
From: suijingfeng The display controller is a PCI device and It has two display pipe. Loongson display controllers are simple which require scanout buffers to be physically contiguous. For LS7A1000 bridge chip, each way has a DVO interface which provide RGB888 signals, vertical & horizontal synchronisations, and the pixel clock. Each CRTC is able to support 1920x1080 resolution at 60Hz, the maximum resolution is 2048x2048 according to the hardware spec. For the DC in LS7A2000 bridge chip, each way is connected with a built-in HDMI encoder which support 3840x2160@30. Signed-off-by: suijingfeng Signed-off-by: suijingfeng <15330273...@189.cn> --- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile| 1 + drivers/gpu/drm/lsdc/Kconfig| 18 + drivers/gpu/drm/lsdc/Makefile | 14 + drivers/gpu/drm/lsdc/lsdc_crtc.c| 437 + drivers/gpu/drm/lsdc/lsdc_debugfs.c | 243 drivers/gpu/drm/lsdc/lsdc_drv.c | 535 ++ drivers/gpu/drm/lsdc/lsdc_drv.h | 274 + drivers/gpu/drm/lsdc/lsdc_i2c.c | 187 + drivers/gpu/drm/lsdc/lsdc_irq.c | 81 drivers/gpu/drm/lsdc/lsdc_output.c | 366 ++ drivers/gpu/drm/lsdc/lsdc_plane.c | 447 ++ drivers/gpu/drm/lsdc/lsdc_pll.c | 571 drivers/gpu/drm/lsdc/lsdc_pll.h | 78 drivers/gpu/drm/lsdc/lsdc_regs.c| 29 ++ drivers/gpu/drm/lsdc/lsdc_regs.h| 294 ++ 16 files changed, 3577 insertions(+) create mode 100644 drivers/gpu/drm/lsdc/Kconfig create mode 100644 drivers/gpu/drm/lsdc/Makefile create mode 100644 drivers/gpu/drm/lsdc/lsdc_crtc.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_debugfs.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_drv.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_drv.h create mode 100644 drivers/gpu/drm/lsdc/lsdc_i2c.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_irq.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_output.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_plane.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_pll.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_pll.h create mode 100644 drivers/gpu/drm/lsdc/lsdc_regs.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_regs.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 663ea8f9966d..bb256a1ae24a 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -368,6 +368,8 @@ source "drivers/gpu/drm/solomon/Kconfig" source "drivers/gpu/drm/sprd/Kconfig" +source "drivers/gpu/drm/lsdc/Kconfig" + config DRM_HYPERV tristate "DRM Support for Hyper-V synthetic video device" depends on DRM && PCI && MMU && HYPERV diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 496fa5a6147a..7fd6412ffbfa 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -197,3 +197,4 @@ obj-y += gud/ obj-$(CONFIG_DRM_HYPERV) += hyperv/ obj-y += solomon/ obj-$(CONFIG_DRM_SPRD) += sprd/ +obj-$(CONFIG_DRM_LSDC) += lsdc/ diff --git a/drivers/gpu/drm/lsdc/Kconfig b/drivers/gpu/drm/lsdc/Kconfig new file mode 100644 index ..56a50014df9d --- /dev/null +++ b/drivers/gpu/drm/lsdc/Kconfig @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0 + +config DRM_LSDC + tristate "DRM support for loongson display controller" + depends on DRM && PCI && (MACH_LOONGSON64 || LOONGARCH || MIPS) + select OF + select DRM_KMS_HELPER + select DRM_TTM + select DRM_TTM_HELPER + select DRM_VRAM_HELPER + select VIDEOMODE_HELPERS + default m + help + This is a KMS driver for loongson display controller in the + LS7A1000/LS7A2000 bridge chip and LS2K1000/LS2K0500 SoC. + If "M" is selected, the module will be called lsdc. + + If in doubt, say "Y". diff --git a/drivers/gpu/drm/lsdc/Makefile b/drivers/gpu/drm/lsdc/Makefile new file mode 100644 index ..d4b901ec09cf --- /dev/null +++ b/drivers/gpu/drm/lsdc/Makefile @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 + +lsdc-y := \ + lsdc_drv.o \ + lsdc_crtc.o \ + lsdc_irq.o \ + lsdc_plane.o \ + lsdc_pll.o \ + lsdc_i2c.o \ + lsdc_output.o \ + lsdc_regs.o \ + lsdc_debugfs.o + +obj-$(CONFIG_DRM_LSDC) += lsdc.o diff --git a/drivers/gpu/drm/lsdc/lsdc_crtc.c b/drivers/gpu/drm/lsdc/lsdc_crtc.c new file mode 100644 index ..0737b3c3084f --- /dev/null +++ b/drivers/gpu/drm/lsdc/lsdc_crtc.c @@ -0,0 +1,437 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include + +#include "lsdc_drv.h" +#include "lsdc_regs.h" +#include "lsdc_pll.h" + +static int lsdc_crtc_enable_vblank(struct drm_crtc *crtc) +{ + struct lsdc_device *ldev = to_lsdc(crtc->dev); + unsigned int index = drm_crtc_index(crtc); + u32 val; + + val = lsdc_rreg32(ldev, LSDC_INT_REG); + +