drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip
Subsystems (3)
PATCH v7 1/4 drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip
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.
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.
--- 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
drivers/gpu/drm/Kconfig +2 -0
@@ -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"
drivers/gpu/drm/Makefile +1 -0
@@ -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/
drivers/gpu/drm/loongson/Kconfig new file +13 -0
@@ -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 controllers, + support two display channels. + If compiled as a module it will be called loongson.
drivers/gpu/drm/loongson/Makefile new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for loongson drm drivers. +# This driver provides support for the +# Direct Rendering Infrastructure (DRI) + +loongson-y := loongson_connector.o \ + loongson_crtc.o \ + loongson_device.o \ + loongson_drv.o \ + loongson_encoder.o \ + loongson_plane.o +obj-$(CONFIG_DRM_LOONGSON) += loongson.o
drivers/gpu/drm/loongson/loongson_connector.c new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2020-2022 Loongson Technology Corporation Limited +*/ + +#include <drm/drm_probe_helper.h> +#include <drm/drm_bridge_connector.h> + +#include "loongson_drv.h" + +int loongson_bridge_connector_init (struct loongson_device *ldev,int index) +{ +struct drm_device *dev = &ldev->dev; +struct drm_connector *connector; +struct drm_encoder *encoder = &ldev->mode_info[index].encoder->base; + + connector =drm_bridge_connector_init (dev, encoder); +if (IS_ERR (connector)) { +dev_err (dev->dev,"Unable to create bridge connector\n" ); +return PTR_ERR (connector); + } +drm_connector_attach_encoder (connector, encoder); + +return 0 ; +}
drivers/gpu/drm/loongson/loongson_crtc.c new file +244 -0
244 lines not on this page · raw message
drivers/gpu/drm/loongson/loongson_device.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2020-2022 Loongson Technology Corporation Limited +*/ + +#include "loongson_drv.h" + +u32 loongson_gpu_offset (struct drm_plane_state *state, +struct loongson_device *ldev) +{ +struct drm_gem_vram_object *gbo; +u32 gpu_addr; + + gbo =drm_gem_vram_of_gem (state->fb->obj[0 ]); + gpu_addr = ldev->vram_start +drm_gem_vram_offset (gbo); + +return gpu_addr; +} + +u32 ls7a_io_rreg (struct loongson_device *ldev,u32 offset) +{ +return readl (ldev->io + offset); +} + +void ls7a_io_wreg (struct loongson_device *ldev,u32 offset,u32 val) +{ +writel (val, ldev->io + offset); +} + +u32 ls7a_mm_rreg (struct loongson_device *ldev,u32 offset) +{ +return readl (ldev->mmio + offset); +} + +void ls7a_mm_wreg (struct loongson_device *ldev,u32 offset,u32 val) +{ +writel (val, ldev->mmio + offset); +}
drivers/gpu/drm/loongson/loongson_drv.c new file +275 -0
275 lines not on this page · raw message
drivers/gpu/drm/loongson/loongson_drv.h new file +132 -0
132 lines not on this page · raw message
drivers/gpu/drm/loongson/loongson_encoder.c new file +59 -0
59 lines not on this page · raw message
drivers/gpu/drm/loongson/loongson_plane.c new file +97 -0
97 lines not on this page · raw message
Signature · 5 lines
2.25.1 本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。 This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it.