[PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-09-06 Thread 李晨阳
This patch adds an initial DRM driver for the Loongson LS7A1000
bridge chip(LS7A). The Loongson 7A1000 bridge chip is Loongson’s
first dedicated chipset product, providing north-south bridge functionality
for Loongson processors. The bridge chip is connected to the Loongson
Series 3 processor via the HT high-speed bus interface and has an
integrated DisplayController, DDR3 SDRAM memory controller,
and PCIE, SATA, USB, GMAC, I2C, UART, GPIO, and other interfaces.
The display controller supports dual DVO signal output,dual routability
frame buffer. Each display supports up to 1920x1080@60Hz, RGB888 and
RGB565 color depths. And supports hardware cursor, gamma correction,
interrupt, soft reset, etc. The video memory interface uses 16-bit DDR3
SDRAM interface with a maximum data rate of 1333 Mbps.
At present, DC device detection and DRM driver registration are
completed, the crtc/plane/encoder/connector objects has been
implemented.
On Loongson 3A4000 CPU and 7A1000 system, we have achieved the use
of dual screen, and support dual screen clone mode and expansion
mode.
Link: 
https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html#display-controller

v12:
- Use drm_bridge_connector in driver.

v11:
- Remove a lot of useless code.
- Add help information.
- Delete unnecessary header files.

v10:
- Replace the drmm_ version functions.
- Replace the simple_encoder version function.
- Alphabetize file names.

v9:
- Optimize the error handling process.
- Remove the useless flags parameter.
- Fix some incorrect use of variables and constructs.

v8:
- Update the atomic_update function interface.

v7:
- The pixel clock is limited to less than 173000.

v6:
- Remove spin_lock in mmio reg read and write.
- TO_UNCAC is replac with ioremap.
- Fix error arguments in crtc_atomic_enable/disable/mode_valid.

v5:
- Change the name of the chip to LS7A.
- Change magic value in crtc to macros.
- Correct mistakes words.
- Change the register operation function prefix to ls7a.

v4:
- Move the mode_valid function to the crtc.

v3:
- Move the mode_valid function to the connector and optimize it.
- Fix num_crtc calculation method.

v2:
- Complete the case of 32-bit color in CRTC.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/Kconfig   |   2 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/loongson/Kconfig  |  13 +
 drivers/gpu/drm/loongson/Makefile |  13 +
 drivers/gpu/drm/loongson/loongson_connector.c |  25 ++
 drivers/gpu/drm/loongson/loongson_crtc.c  | 244 
 drivers/gpu/drm/loongson/loongson_device.c|  38 +++
 drivers/gpu/drm/loongson/loongson_drv.c   | 275 ++
 drivers/gpu/drm/loongson/loongson_drv.h   | 132 +
 drivers/gpu/drm/loongson/loongson_encoder.c   |  59 
 drivers/gpu/drm/loongson/loongson_plane.c |  97 ++
 11 files changed, 899 insertions(+)
 create mode 100644 drivers/gpu/drm/loongson/Kconfig
 create mode 100644 drivers/gpu/drm/loongson/Makefile
 create mode 100644 drivers/gpu/drm/loongson/loongson_connector.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_crtc.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_device.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.h
 create mode 100644 drivers/gpu/drm/loongson/loongson_encoder.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_plane.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f1422bee3dcc..d5547e492a3f 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -392,6 +392,8 @@ source "drivers/gpu/drm/vboxvideo/Kconfig"
 
 source "drivers/gpu/drm/lima/Kconfig"
 
+source "drivers/gpu/drm/loongson/Kconfig"
+
 source "drivers/gpu/drm/panfrost/Kconfig"
 
 source "drivers/gpu/drm/aspeed/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index c2ef5f9fce54..173b967e2884 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -125,6 +125,7 @@ obj-$(CONFIG_DRM_TVE200) += tve200/
 obj-$(CONFIG_DRM_XEN) += xen/
 obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/
 obj-$(CONFIG_DRM_LIMA)  += lima/
+obj-$(CONFIG_DRM_LOONGSON) += loongson/
 obj-$(CONFIG_DRM_PANFROST) += panfrost/
 obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/
 obj-$(CONFIG_DRM_MCDE) += mcde/
diff --git a/drivers/gpu/drm/loongson/Kconfig b/drivers/gpu/drm/loongson/Kconfig
new file mode 100644
index ..2484824fb50b
--- /dev/null
+++ b/drivers/gpu/drm/loongson/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_LOONGSON
+   tristate "DRM support for LS7A bridge chipset"
+   depends on DRM && PCI
+   depends on CPU_LOONGSON64 || COMPILE_TEST
+   select DRM_KMS_HELPER
+   select DRM_VRAM_HELPER
+   help
+ The loongson 7A bridge chip (LS7A) is a special chipset for
+ loongson CPU. LS7A internal integrated display

Re: [PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-06-25 Thread kernel test robot
Hi Chenyang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v5.19-rc3 next-20220624]
[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]

url:
https://github.com/intel-lab-lkp/linux/commits/Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220625-171037
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
config: powerpc-allmodconfig
compiler: powerpc-linux-gcc (GCC) 11.3.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/438d0791edb6352903bf09dfe214453526081075
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220625-171037
git checkout 438d0791edb6352903bf09dfe214453526081075
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 
O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/gpu/drm/loongson/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All error/warnings (new ones prefixed by >>):

   drivers/gpu/drm/loongson/loongson_crtc.c: In function 
'loongson_crtc_mode_set_nofb':
>> drivers/gpu/drm/loongson/loongson_crtc.c:128:42: error: invalid use of 
>> undefined type 'struct drm_framebuffer'
 128 | format = crtc->primary->state->fb->format;
 |  ^~
--
   drivers/gpu/drm/loongson/loongson_device.c: In function 
'loongson_gpu_offset':
>> drivers/gpu/drm/loongson/loongson_device.c:14:44: error: invalid use of 
>> undefined type 'struct drm_framebuffer'
  14 | gbo = drm_gem_vram_of_gem(state->fb->obj[0]);
 |^~
--
   In file included from include/linux/device.h:15,
from include/linux/pci.h:37,
from drivers/gpu/drm/loongson/loongson_drv.c:14:
   drivers/gpu/drm/loongson/loongson_drv.c: In function 'loongson_device_init':
>> include/drm/drm_print.h:425:39: warning: format '%llx' expects argument of 
>> type 'long long unsigned int', but argument 3 has type 'resource_size_t' 
>> {aka 'unsigned int'} [-Wformat=]
 425 | dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
 |   ^~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 
'dev_printk_index_wrap'
 110 | _p_func(dev, fmt, ##__VA_ARGS__);
   \
 |  ^~~
   include/linux/dev_printk.h:150:58: note: in expansion of macro 'dev_fmt'
 150 | dev_printk_index_wrap(_dev_info, KERN_INFO, dev, 
dev_fmt(fmt), ##__VA_ARGS__)
 |  ^~~
   include/drm/drm_print.h:425:9: note: in expansion of macro 'dev_info'
 425 | dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
 | ^~~~
   include/drm/drm_print.h:429:9: note: in expansion of macro '__drm_printk'
 429 | __drm_printk((drm), info,, fmt, ##__VA_ARGS__)
 | ^~~~
   drivers/gpu/drm/loongson/loongson_drv.c:91:9: note: in expansion of macro 
'drm_info'
  91 | drm_info(dev, "DC mmio base 0x%llx size 0x%llx io 0x%llx\n",
 | ^~~~
   include/drm/drm_print.h:425:39: warning: format '%llx' expects argument of 
type 'long long unsigned int', but argument 4 has type 'resource_size_t' {aka 
'unsigned int'} [-Wformat=]
 425 | dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
 |   ^~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 
'dev_printk_index_wrap'
 110 | _p_func(dev, fmt, ##__VA_ARGS__);
   \
 |  ^~~
   include/linux/dev_printk.h:150:58: note: in expansion of macro 'dev_fmt'
 150 | dev_printk_index_wrap(_dev_info, KERN_INFO, dev, 
dev_fmt(fmt), ##__VA_ARGS__)
 |  ^~~
   include/drm/drm_print.h:425:9: note: in expansion of macro 'dev_info'
 425 | dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
 | ^~~~
   include/drm/drm_print.h:429:9: note: in expansion of macro '__drm_printk'
 429 | __drm_printk((drm), info,, fmt, ##__VA_ARGS__)
 | ^~~~
   drivers/gpu/drm/loongson/loongson_drv.c:

[PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-06-25 Thread Chenyang Li
This patch adds an initial DRM driver for the Loongson LS7A1000
bridge chip(LS7A). The Loongson 7A1000 bridge chip is Loongson’s
first dedicated chipset product, providing north-south bridge functionality
for Loongson processors. The bridge chip is connected to the Loongson
Series 3 processor via the HT high-speed bus interface and has an
integrated DisplayController, DDR3 SDRAM memory controller,
and PCIE, SATA, USB, GMAC, I2C, UART, GPIO, and other interfaces.
The display controller supports dual DVO signal output,dual routability
frame buffer. Each display supports up to 1920x1080@60Hz, RGB888 and
RGB565 color depths. And supports hardware cursor, gamma correction,
interrupt, soft reset, etc. The video memory interface uses 16-bit DDR3
SDRAM interface with a maximum data rate of 1333 Mbps.
At present, DC device detection and DRM driver registration are
completed, the crtc/plane/encoder/connector objects has been
implemented.
On Loongson 3A4000 CPU and 7A1000 system, we have achieved the use
of dual screen, and support dual screen clone mode and expansion
mode.
Link: 
https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html#display-controller

v12:
- Use drm_bridge_connector in driver.

v11:
- Remove a lot of useless code.
- Add help information.
- Delete unnecessary header files.

v10:
- Replace the drmm_ version functions.
- Replace the simple_encoder version function.
- Alphabetize file names.

v9:
- Optimize the error handling process.
- Remove the useless flags parameter.
- Fix some incorrect use of variables and constructs.

v8:
- Update the atomic_update function interface.

v7:
- The pixel clock is limited to less than 173000.

v6:
- Remove spin_lock in mmio reg read and write.
- TO_UNCAC is replac with ioremap.
- Fix error arguments in crtc_atomic_enable/disable/mode_valid.

v5:
- Change the name of the chip to LS7A.
- Change magic value in crtc to macros.
- Correct mistakes words.
- Change the register operation function prefix to ls7a.

v4:
- Move the mode_valid function to the crtc.

v3:
- Move the mode_valid function to the connector and optimize it.
- Fix num_crtc calculation method.

v2:
- Complete the case of 32-bit color in CRTC.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/Kconfig   |   2 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/loongson/Kconfig  |  13 +
 drivers/gpu/drm/loongson/Makefile |  13 +
 drivers/gpu/drm/loongson/loongson_connector.c |  25 ++
 drivers/gpu/drm/loongson/loongson_crtc.c  | 244 
 drivers/gpu/drm/loongson/loongson_device.c|  38 +++
 drivers/gpu/drm/loongson/loongson_drv.c   | 275 ++
 drivers/gpu/drm/loongson/loongson_drv.h   | 132 +
 drivers/gpu/drm/loongson/loongson_encoder.c   |  59 
 drivers/gpu/drm/loongson/loongson_plane.c |  97 ++
 11 files changed, 899 insertions(+)
 create mode 100644 drivers/gpu/drm/loongson/Kconfig
 create mode 100644 drivers/gpu/drm/loongson/Makefile
 create mode 100644 drivers/gpu/drm/loongson/loongson_connector.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_crtc.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_device.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.h
 create mode 100644 drivers/gpu/drm/loongson/loongson_encoder.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_plane.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f1422bee3dcc..d5547e492a3f 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -392,6 +392,8 @@ source "drivers/gpu/drm/vboxvideo/Kconfig"
 
 source "drivers/gpu/drm/lima/Kconfig"
 
+source "drivers/gpu/drm/loongson/Kconfig"
+
 source "drivers/gpu/drm/panfrost/Kconfig"
 
 source "drivers/gpu/drm/aspeed/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index c2ef5f9fce54..173b967e2884 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -125,6 +125,7 @@ obj-$(CONFIG_DRM_TVE200) += tve200/
 obj-$(CONFIG_DRM_XEN) += xen/
 obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/
 obj-$(CONFIG_DRM_LIMA)  += lima/
+obj-$(CONFIG_DRM_LOONGSON) += loongson/
 obj-$(CONFIG_DRM_PANFROST) += panfrost/
 obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/
 obj-$(CONFIG_DRM_MCDE) += mcde/
diff --git a/drivers/gpu/drm/loongson/Kconfig b/drivers/gpu/drm/loongson/Kconfig
new file mode 100644
index ..2484824fb50b
--- /dev/null
+++ b/drivers/gpu/drm/loongson/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_LOONGSON
+   tristate "DRM support for LS7A bridge chipset"
+   depends on DRM && PCI
+   depends on CPU_LOONGSON64 || COMPILE_TEST
+   select DRM_KMS_HELPER
+   select DRM_VRAM_HELPER
+   help
+ The loongson 7A bridge chip (LS7A) is a special chipset for
+ loongson CPU. LS7A internal integrated display

Re: [PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-04-22 Thread kernel test robot
Hi Chenyang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm/drm-next]
[also build test WARNING on v5.18-rc3 next-20220422]
[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]

url:
https://github.com/intel-lab-lkp/linux/commits/Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220422-161914
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: arm-randconfig-s031-20220422 
(https://download.01.org/0day-ci/archive/20220423/202204230030.kzgmtgoq-...@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# 
https://github.com/intel-lab-lkp/linux/commit/e9a9964d58e6cc797a113fa47f54583c10908d63
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220422-161914
git checkout e9a9964d58e6cc797a113fa47f54583c10908d63
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm 
SHELL=/bin/bash drivers/gpu/drm/loongson/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/loongson/loongson_drv.c:91:9: sparse: sparse: cast removes 
>> address space '__iomem' of expression
   drivers/gpu/drm/loongson/loongson_drv.c:99:5: sparse: sparse: symbol 
'loongson_modeset_init' was not declared. Should it be static?

vim +/__iomem +91 drivers/gpu/drm/loongson/loongson_drv.c

36  
37  static int loongson_device_init(struct drm_device *dev)
38  {
39  struct loongson_device *ldev = to_loongson_device(dev);
40  struct pci_dev *pdev = to_pci_dev(dev->dev);
41  struct pci_dev *gpu_pdev;
42  resource_size_t aper_base;
43  resource_size_t aper_size;
44  resource_size_t mmio_base;
45  resource_size_t mmio_size;
46  int ret;
47  
48  /* GPU MEM */
49  /* We need get 7A-gpu pci device information for ldev->gpu_pdev 
*/
50  /* dev->pdev save 7A-dc pci device information */
51  gpu_pdev = pci_get_device(PCI_VENDOR_ID_LOONGSON,
52PCI_DEVICE_ID_LOONGSON_GPU, NULL);
53  ret = pci_enable_device(gpu_pdev);
54  if (ret)
55  return ret;
56  pci_set_drvdata(gpu_pdev, dev);
57  
58  aper_base = pci_resource_start(gpu_pdev, 2);
59  aper_size = pci_resource_len(gpu_pdev, 2);
60  ldev->vram_start = aper_base;
61  ldev->vram_size = aper_size;
62  
63  if (!devm_request_mem_region(dev->dev, ldev->vram_start,
64   ldev->vram_size, "loongson_vram")) 
{
65  drm_err(dev, "Can't reserve VRAM\n");
66  return -ENXIO;
67  }
68  
69  /* DC MEM */
70  mmio_base = pci_resource_start(pdev, 0);
71  mmio_size = pci_resource_len(pdev, 0);
72  ldev->mmio = devm_ioremap(dev->dev, mmio_base, mmio_size);
73  if (!ldev->mmio) {
74  drm_err(dev, "Cannot map mmio region\n");
75  return -ENOMEM;
76  }
77  
78  if (!devm_request_mem_region(dev->dev, mmio_base,
79   mmio_size, "loongson_mmio")) {
80  drm_err(dev, "Can't reserve mmio registers\n");
81  return -ENOMEM;
82  }
83  
84  /* DC IO */
85  ldev->io = devm_ioremap(dev->dev, LS7A_CHIPCFG_REG_BASE, 0xf);
86  if (!ldev->io)
87  return -ENOMEM;
88  
89  ldev->num_crtc = 2;
90  
  > 91  drm_info(dev, "DC mmio base 0x%llx size 0x%llx io 0x%llx\n",
92   mmio_base, mmio_size, *(u64 *)ldev->io);
93  drm_info(dev, "GPU vram start = 0x%x size = 0x%x\n",
94   ldev->vram_start, ldev->vram_size);
95  
96  return 0;
97  }
98  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-04-22 Thread Chenyang Li
This patch adds an initial DRM driver for the Loongson LS7A1000
bridge chip(LS7A). The Loongson 7A1000 bridge chip is Loongson’s
first dedicated chipset product, providing north-south bridge functionality
for Loongson processors. The bridge chip is connected to the Loongson
Series 3 processor via the HT high-speed bus interface and has an
integrated DisplayController, DDR3 SDRAM memory controller,
and PCIE, SATA, USB, GMAC, I2C, UART, GPIO, and other interfaces.
The display controller supports dual DVO signal output,dual routability
frame buffer. Each display supports up to 1920x1080@60Hz, RGB888 and
RGB565 color depths. And supports hardware cursor, gamma correction,
interrupt, soft reset, etc. The video memory interface uses 16-bit DDR3
SDRAM interface with a maximum data rate of 1333 Mbps.
At present, DC device detection and DRM driver registration are
completed, the crtc/plane/encoder/connector objects has been
implemented.
On Loongson 3A4000 CPU and 7A1000 system, we have achieved the use
of dual screen, and support dual screen clone mode and expansion
mode.
Link: 
https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html#display-controller

v12:
- Use drm_bridge_connector in driver.

v11:
- Remove a lot of useless code.
- Add help information.
- Delete unnecessary header files.

v10:
- Replace the drmm_ version functions.
- Replace the simple_encoder version function.
- Alphabetize file names.

v9:
- Optimize the error handling process.
- Remove the useless flags parameter.
- Fix some incorrect use of variables and constructs.

v8:
- Update the atomic_update function interface.

v7:
- The pixel clock is limited to less than 173000.

v6:
- Remove spin_lock in mmio reg read and write.
- TO_UNCAC is replac with ioremap.
- Fix error arguments in crtc_atomic_enable/disable/mode_valid.

v5:
- Change the name of the chip to LS7A.
- Change magic value in crtc to macros.
- Correct mistakes words.
- Change the register operation function prefix to ls7a.

v4:
- Move the mode_valid function to the crtc.

v3:
- Move the mode_valid function to the connector and optimize it.
- Fix num_crtc calculation method.

v2:
- Complete the case of 32-bit color in CRTC.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/Kconfig   |   2 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/loongson/Kconfig  |  13 +
 drivers/gpu/drm/loongson/Makefile |  13 +
 drivers/gpu/drm/loongson/loongson_connector.c |  25 ++
 drivers/gpu/drm/loongson/loongson_crtc.c  | 244 
 drivers/gpu/drm/loongson/loongson_device.c|  38 +++
 drivers/gpu/drm/loongson/loongson_drv.c   | 275 ++
 drivers/gpu/drm/loongson/loongson_drv.h   | 132 +
 drivers/gpu/drm/loongson/loongson_encoder.c   |  59 
 drivers/gpu/drm/loongson/loongson_plane.c |  97 ++
 11 files changed, 899 insertions(+)
 create mode 100644 drivers/gpu/drm/loongson/Kconfig
 create mode 100644 drivers/gpu/drm/loongson/Makefile
 create mode 100644 drivers/gpu/drm/loongson/loongson_connector.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_crtc.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_device.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.h
 create mode 100644 drivers/gpu/drm/loongson/loongson_encoder.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_plane.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f1422bee3dcc..d5547e492a3f 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -392,6 +392,8 @@ source "drivers/gpu/drm/vboxvideo/Kconfig"
 
 source "drivers/gpu/drm/lima/Kconfig"
 
+source "drivers/gpu/drm/loongson/Kconfig"
+
 source "drivers/gpu/drm/panfrost/Kconfig"
 
 source "drivers/gpu/drm/aspeed/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index c2ef5f9fce54..173b967e2884 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -125,6 +125,7 @@ obj-$(CONFIG_DRM_TVE200) += tve200/
 obj-$(CONFIG_DRM_XEN) += xen/
 obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/
 obj-$(CONFIG_DRM_LIMA)  += lima/
+obj-$(CONFIG_DRM_LOONGSON) += loongson/
 obj-$(CONFIG_DRM_PANFROST) += panfrost/
 obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/
 obj-$(CONFIG_DRM_MCDE) += mcde/
diff --git a/drivers/gpu/drm/loongson/Kconfig b/drivers/gpu/drm/loongson/Kconfig
new file mode 100644
index ..2484824fb50b
--- /dev/null
+++ b/drivers/gpu/drm/loongson/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_LOONGSON
+   tristate "DRM support for LS7A bridge chipset"
+   depends on DRM && PCI
+   depends on CPU_LOONGSON64 || COMPILE_TEST
+   select DRM_KMS_HELPER
+   select DRM_VRAM_HELPER
+   help
+ The loongson 7A bridge chip (LS7A) is a special chipset for
+ loongson CPU. LS7A internal integrated display