Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5573564pxb; Mon, 14 Feb 2022 02:19:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTiM5T4Sw1+1bQisy87irBjXYZGEA8qfBrKdgG5PgUdoJckynQsI4GEOJmgSIoUzb4KFLj X-Received: by 2002:a17:90b:4a8d:: with SMTP id lp13mr13725470pjb.206.1644833994386; Mon, 14 Feb 2022 02:19:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644833994; cv=none; d=google.com; s=arc-20160816; b=ibKbGiMnCu5EkCCzYAEOF3lGXjn4OpxE4DNiWS3M8mvVKVg81ZrUinIbVOE3mvvsHS C0lReMof4F440hs3LfeTk8cfNERw6wbjSYy8TT8L2TR2nRSXEsUmcSt7ve2iIjoIkocu GIee7zGRTFaVn/TdErw24OZeiRiY5E1kvPyFyeFGmM3lKXE625RTJqwgHe1QaE+92YF4 cM+nG3cgXvwBS205/8ZUf8VmVOrk1KragsYaeuysPy2IgHetT8fcLOL0GnYEDqQTnXZD wubGwnS500BYoZHmi5MImC0cxsLbadixo/3XdeL3Z4zcQPRd7MCTAKU035yRc4zUXq1J 4y9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:sender:hmm_source_type :hmm_attache_num:hmm_source_ip; bh=JUBZD7Zv1t/1c21jh0OUMrBoq0wt5iHjGLyKP2AHMuk=; b=mRU/cqu6Top1Wj8yzT7UuEB51J8InReZEhmpNdyFt6hN8/94OkjP9c1bAPrceQy9Wv LwZeLFrJzgHUk0l5bRonHiTEjjvrCP3uQ7ZyVMraGZEathWbKtuWE5VOWyMWF9b68XHi Ohg7Pei24MfugEhhBvZC+MHOkgcbMfinCexuhiTqD3BdKOPiInfs9mcJwGXl6f2xJt0p Cca03ApHrpa9twZGTxVvO9tK/eOY3FoIUo94tFPKsqURAGjPQ1tF7lwnsyf1CJcjpjg/ wlFczt6xDGcYz4KcxJ8ClKw81Rir3kofIozjsIV++4fCANn/hdVsGRlyL0bLJ5cUE7Pu 8kqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12si29877361pfv.107.2022.02.14.02.19.39; Mon, 14 Feb 2022 02:19:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236416AbiBMORD (ORCPT + 99 others); Sun, 13 Feb 2022 09:17:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbiBMORC (ORCPT ); Sun, 13 Feb 2022 09:17:02 -0500 Received: from 189.cn (ptr.189.cn [183.61.185.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C374A5F257; Sun, 13 Feb 2022 06:16:54 -0800 (PST) HMM_SOURCE_IP: 10.64.8.41:34274.536114013 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.41]) by 189.cn (HERMES) with SMTP id A882C100139; Sun, 13 Feb 2022 22:16:51 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-b7fbf7d79-9vctg with ESMTP id ebba22aeed614101910b8b306142232d for mripard@kernel.org; Sun, 13 Feb 2022 22:16:52 CST X-Transaction-ID: ebba22aeed614101910b8b306142232d X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn From: Sui Jingfeng <15330273260@189.cn> To: Maxime Ripard , Thomas Zimmermann , Roland Scheidegger , Zack Rusin , Christian Gmeiner , David Airlie , Daniel Vetter , Rob Herring , Thomas Bogendoerfer , Dan Carpenter , Krzysztof Kozlowski , Andrey Zhizhikin , Sam Ravnborg , "David S . Miller" , Jiaxun Yang , Lucas Stach , Maarten Lankhorst , Ilia Mirkin , Qing Zhang , Li Yi , suijingfeng Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v7 0/7] drm/lsdc: add drm driver for loongson display controller Date: Sun, 13 Feb 2022 22:16:42 +0800 Message-Id: <20220213141649.1115987-1-15330273260@189.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FROM_LOCAL_DIGITS, FROM_LOCAL_HEX,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a display controller in loongson's LS2K1000 SoC and LS7A1000 bridge chip, the DC is a PCI device in those chips. It has two display pipes but with only one hardware cursor. Each way has a DVO interface which provide RGB888 signals, vertical & horizontal synchronisations, data enable and the pixel clock. Each CRTC is able to scanout from 1920x1080 resolution at 60Hz. The maxmium resolution is 2048x2048 according to the hardware spec. Loongson display controllers are simple which require scanout buffers to be physically contiguous. LS2K1000 is a SOC, Only system memory is available. Therefore CMA helper based driver is intended to be use, although it is possible to use VRAM helper based solution by carving out part of system memory as VRAM. On LS7A1000/LS7A2000 bridge chip, the DC is equipped with a dedicated video memory which is typically 64MB or more. In this case, VRAM helper based solution which scanout from local VRAM is reconmended to use. It is reliable to use for massive production, but CMA based helper solution is still usable on ls7a1000 and ls7a2000, at the price of the CRTC must access the FB in RAM through the PCIe bus and HT3.0 bus. This causes continuous traffic on the bus regardless of whether the FB image is updating or not. Sadly, it suffer from screen flickering under RAM pressure on LS7A1000. Luckily, It show extremely good condition on LS7A2000 even under stressapptest, Maybe the hardware engineer resolve this issue. Integrating two distict helpers based driver into one piece allow code sharing. We have also implemented demage update on top of CMA helper which copy the demaged region from the shadow framebuffer in system RAM to the real framebuffer in VRAM manually. This is intend to overcome the screen flicking issue on LS7A1000, but the performance is not good. Using "lsdc.dirty_update=1" in the kernel commmand line if you would like to have a try. For LS7A1000, there are 4 dedicated GPIOs whose control register is located at the DC register space, They are used to emulate two way i2c. One for DVO0, another for DVO1. This is the reason why this driver is not switch to drm bridge framework yet. LS2K1000 and LS2K0500 SoC don't have such GPIO hardwared, they grab i2c adapter from other module, either general purpose GPIO emulated i2c or hardware i2c adapter. Drm bridge and drm panel driver for the external encoder is suitable for those SoC. We have already implemented this on our downstream 4.19.190 kernel. But due to the GPIO, PWM and I2C device driver support for LS2K1000 is not upstreamed yet, this driver still can be use to bring the graphic environment up by providing display timings or similar things in the device tree. The DC in LS7A1000 has only one hardware cursor, we simply let the two CRTC share it. The DC in LS7A2000 have two cursor, two built-in hdmi encoder and one transparent vga encoder and more, surport for LS7A2000 is on the way. In short, we have built-in gpio emulated i2c support, we also have hardware cursor support. LS7A2000 The kind of tiny drivers in drm/tiny is not suitable for us. +------+ +-----------------------------------+ | DDR4 | | +-------------------+ | +------+ | | PCIe Root complex | LS7A1000 | || MC0 | +--++---------++----+ | +----------+ HT 3.0 | || || | | LS3A4000 |<-------->| +---++---+ +--++--+ +---------+ +------+ | CPU |<-------->| | GC1000 | | LSDC |<-->| DDR3 MC |<->| VRAM | +----------+ | +--------+ +-+--+-+ +---------+ +------+ || MC1 +---------------|--|----------------+ +------+ | | | DDR4 | +-------+ DVO0 | | DVO1 +------+ +------+ VGA <--|ADV7125|<--------+ +-------->|TFP410|--> DVI/HDMI +-------+ +------+ The above picture give a simple usage of LS7A1000, note that the encoder is not necessary adv7125 or tfp410, it is a choice of the downstream board manufacturer. Other candicate encoders can be ch7034b, sil9022 and ite66121 lt8618 etc. Besides, the DC in both ls2k1000 and ls7k1000 has the same of PCI vendor id and pci device id. Both is 0x0014:0x7a06, the reverison id is also same. This is the firmware engineer's mistake, but such firmware and various boards ship with such firmware already released. We choose to deduce the chip's identification from information provided by device tree. For lsdc, there is only a 1:1 mapping of encoders and connectors. Below is a brief introduction of loongson's CPU, bridge chip and SoC. LS2K1000 is a double core 1.0Ghz mips64r2 compatible SoC[1]. LS7A1000 is a bridge chip made by Loongson corporation which act as north and/or south bridge of loongson's desktop and server level processor. It is equivalent to AMD RS780E+SB710 or something like that. More details can be read from its user manual[2]. This bridge chip is typically use with LS3A3000, LS3A4000 and LS3A5000 cpu. LS3A3000 is 4 core 1.45gHz mips64r2 compatible cpu. LS3A4000 is 4 core 1.8gHz mips64r5 compatible cpu. LS3A5000 is 4 core 2.5gHz loongarch cpu[3]. Nearly all loongson cpu has the hardware maintain the cache coherency, except for early version of ls2k1000 or ls3a2000. This is the most distinct feature from other mips cpu. [1] https://wiki.debian.org/InstallingDebianOn/Lemote/Loongson2K1000 [2] https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html [3] https://loongson.github.io/LoongArch-Documentation/Loongson-3A5000-usermanual-EN.html suijingfeng (7): drm/lsdc: add drm driver for loongson display controller MIPS: Loongson: ls7a-pch.dtsi: add has_dedicated_vram property MIPS: Loongson: introduce dts for ls3A4000 evaluation board MIPS: Loongson: introduce dts for lemote A1901 3a4000 motherboard MIPS: Loongson: ls2k1000: add the display controller device node MIPS: Loongson: Add dts for ls2k1000 pai evaluation board MAINTAINERS: add maintainers for DRM LSDC driver MAINTAINERS | 9 + arch/mips/boot/dts/loongson/lemote_a1901.dts | 59 ++ .../boot/dts/loongson/loongson64-2k1000.dtsi | 11 + arch/mips/boot/dts/loongson/ls2k1000_pai.dts | 69 ++ .../boot/dts/loongson/ls3a4000_7a1000_evb.dts | 61 ++ arch/mips/boot/dts/loongson/ls7a-pch.dtsi | 3 +- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/lsdc/Kconfig | 39 + drivers/gpu/drm/lsdc/Makefile | 13 + drivers/gpu/drm/lsdc/lsdc_connector.c | 334 ++++++++ drivers/gpu/drm/lsdc/lsdc_connector.h | 38 + drivers/gpu/drm/lsdc/lsdc_crtc.c | 341 ++++++++ drivers/gpu/drm/lsdc/lsdc_drv.c | 776 ++++++++++++++++++ drivers/gpu/drm/lsdc/lsdc_drv.h | 217 +++++ drivers/gpu/drm/lsdc/lsdc_encoder.c | 54 ++ drivers/gpu/drm/lsdc/lsdc_i2c.c | 198 +++++ drivers/gpu/drm/lsdc/lsdc_i2c.h | 40 + drivers/gpu/drm/lsdc/lsdc_irq.c | 60 ++ drivers/gpu/drm/lsdc/lsdc_irq.h | 20 + drivers/gpu/drm/lsdc/lsdc_plane.c | 572 +++++++++++++ drivers/gpu/drm/lsdc/lsdc_pll.c | 580 +++++++++++++ drivers/gpu/drm/lsdc/lsdc_pll.h | 90 ++ drivers/gpu/drm/lsdc/lsdc_regs.h | 202 +++++ 24 files changed, 3788 insertions(+), 1 deletion(-) create mode 100644 arch/mips/boot/dts/loongson/lemote_a1901.dts create mode 100644 arch/mips/boot/dts/loongson/ls2k1000_pai.dts create mode 100644 arch/mips/boot/dts/loongson/ls3a4000_7a1000_evb.dts create mode 100644 drivers/gpu/drm/lsdc/Kconfig create mode 100644 drivers/gpu/drm/lsdc/Makefile create mode 100644 drivers/gpu/drm/lsdc/lsdc_connector.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_connector.h create mode 100644 drivers/gpu/drm/lsdc/lsdc_crtc.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_encoder.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_i2c.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_i2c.h create mode 100644 drivers/gpu/drm/lsdc/lsdc_irq.c create mode 100644 drivers/gpu/drm/lsdc/lsdc_irq.h 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.h -- 2.25.1