From patchwork Mon Oct 11 09:46:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 12549591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 300C0C433EF for ; Mon, 11 Oct 2021 09:58:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD59F60F22 for ; Mon, 11 Oct 2021 09:58:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DD59F60F22 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WknGoYBuBxhamjtWooyG1h09OSfHan/YOL940PHB9rc=; b=Wzil4LETJeGPXj nRo7vkOl9EL4qWmUPSCs55TaSvAPeCLxiDdk7sRnU1kIAVcBUPHwcrirQSkYQBhV4H11gHw9ksMSY 5j4yIs2N4an5dzEaCETuDeaAKLH9cobtsHPXYvHcotVU4R3UU8OdQUgv3TdVgKkEB2WfD2VyJIXe+ /YfYFGgbuyVIRoxdXYk+YUOBDs/KHKD5VWmCwrvM5MQGH/MedwDNojkNDSMDMyPAIMSeB2sQZ3zqK lMm7rCuTy8Me9mdpHimsDfS6OFhoPydgong5DNCYp66WyZVZCdt+0NwJRHSfa0SCrWFYgPoC/mQ4M CkH1hZxU3nRrSGk30lyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZs4H-008hQj-De; Mon, 11 Oct 2021 09:58:01 +0000 Received: from desiato.infradead.org ([90.155.92.199]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZrtN-008cWw-SJ for linux-mediatek@bombadil.infradead.org; Mon, 11 Oct 2021 09:46:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=t16nz6o7QVOrX6xeDclDHFNbLfIjSYS5rEolMuZp2PU=; b=IZsYVsXTHpPEORyKCgxAtayjed 8PBk74jOfHl99X1wKleVvp9rkap4avhFp41ST1KfiL+WFc3SB6BekM7Mcv0VeEg27QNcozE4ABWbq Cr2Lie5RQh+rh7PoSEA+cnSsDEd3e44hH2Yc/i35BXB6G2eJoR4xHuhOtDmXHouv3HKN+lpSN12lU 6kqXUhXd5HegvpBM7c+hJSia8GTtI9mzA0LYvBtnOsGmFL74hZb61wqMt5q+WiX4DTkNPkjl7iwSX Ol+3rjzHuOkpo/ju/vHmJpshJnHe40T8DBdkrFuOKz1H1kKKGSuLv65TWTjdZvdve3i0f5f6/fyu4 fkAIAJqw==; Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZrtG-009Bsr-CW for linux-mediatek@lists.infradead.org; Mon, 11 Oct 2021 09:46:44 +0000 Received: by mail-wr1-x435.google.com with SMTP id e3so20591346wrc.11 for ; Mon, 11 Oct 2021 02:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t16nz6o7QVOrX6xeDclDHFNbLfIjSYS5rEolMuZp2PU=; b=dYT42wAF4EPTx6tbONr47pVgYE1dsh/KcBiIgYr5XZSh6TONmykYb50CbF4cli8pDs 6nq13hlUS7b3VGnVirRV0gXnVfegRnJKUVD8SsINu6P3C6o13Sd/k9fZNaZAuSI2dQ3f oI046mpWA1EWaIxo6lBtnPfeY/bZ7dZOmE9zCotrp+M450xky1MT0WbnskB5esANmIiO zSeuTR5vao6K3wZa/X9i3+HCKKg/yegXy07YhTeylq5N4HMwQVJ80HkZgA/LpDlGeYJy JdYarx5jXvtGOv0QHobCVfw1Cw0m0fAOCP9SI+nOH9Lsz0MagSqrfLu4LIMLOeS8RG3l LBvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t16nz6o7QVOrX6xeDclDHFNbLfIjSYS5rEolMuZp2PU=; b=KYBqFz5LZgpKz8zg7XU/3I40nHqdJLVdGuH+5nkqmbuLig9jwBZIB31Kl5QQRoWeXr IZ4XXAYX+7p/M3vuxqlgqq6BdoeVKwYrdd8xTzK/f1eK+SudLqZf0F20OHR0kGs5F3Wv wb8of6QZ+wG1Pxm185rEKRGVB4WC4cMByyUADrtQoH0P/cq38SJzvLxRsZZ5hu4mr1ia pCh0qHZEcBjWZYgKlHICOfTnHB2cfKXJI/CJm18PdA+UQOe5YgNtLrkxfHpLncbfYp3h nojOLUnkbubzuDtIRQuoEQHrsY/Um3SW2+tRneP9E68AUQ0qX2Dgm8upwf/ShdrcG2td woEQ== X-Gm-Message-State: AOAM530HSdqoorvllKyRrNsVqOYb1EAPFwI1XhKUraBXzNeupe9Uyzkq 98mAuAdawla+3bzuGEZh5tkp7w== X-Google-Smtp-Source: ABdhPJw+G+cMYacL989KHkRq6d+7c3b6cnWMHYoNYw55sL55x1wwdK5xBB4BYS7gtUGCWK6DPXDYJA== X-Received: by 2002:a7b:c442:: with SMTP id l2mr19999137wmi.131.1633945596357; Mon, 11 Oct 2021 02:46:36 -0700 (PDT) Received: from blmsp.lan ([2a02:2454:3e6:c900::97e]) by smtp.gmail.com with ESMTPSA id o8sm21349291wme.38.2021.10.11.02.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Oct 2021 02:46:36 -0700 (PDT) From: Markus Schneider-Pargmann To: Chun-Kuang Hu , Philipp Zabel , Rob Herring , Vinod Koul Cc: Sam Ravnborg , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v4 7/7] drm/mediatek: Add mt8195 DisplayPort driver Date: Mon, 11 Oct 2021 11:46:24 +0200 Message-Id: <20211011094624.3416029-8-msp@baylibre.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011094624.3416029-1-msp@baylibre.com> References: <20211011094624.3416029-1-msp@baylibre.com> MIME-Version: 1.0 X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org This patch adds a DisplayPort driver for the Mediatek mt8195 SoC and a according phy driver mediatek-dp-phy. It supports both functional units on the mt8195, the embedded DisplayPort as well as the external DisplayPort units. It offers hot-plug-detection, audio up to 8 channels, and DisplayPort 1.4 with up to 4 lanes. The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that both can work with the same register range. The phy driver sets device data that is read by the parent to get the phy device that can be used to control the phy properties. This driver is based on an initial version by Jason-JH.Lin . Signed-off-by: Markus Schneider-Pargmann Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot --- Notes: Changes v2 -> v3: - Solve TODOs and add defines for undescribed registers - Remove TODOs that were irrelevant Changes v1 -> v2: - Fix checkpatch --strict suggestions - General cleanups of the code. - Remove all remaining non-atomic functions. - Remove unused includes and sort them. - Remove unused select GENERIC_PHY - Rename phy registers DP_PHY -> MTK_DP_PHY - Replace usage of delays with usleep_range. - Split the phy register accesses into a separate phy driver. - Use a lock to guard access to mtk_dp->edid as it can be allocated/used/freed in different threads - use struct dp_sdp for sdp packets. Changes RFC -> v1: - Removed unused register definitions. - Replaced workqueue with threaded irq. - Removed connector code. - Move to atomic_* drm functions. - General cleanups of the code. - Remove unused select GENERIC_PHY. drivers/gpu/drm/mediatek/Kconfig | 7 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_dp.c | 2825 ++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 535 +++++ drivers/gpu/drm/mediatek/mtk_drm_drv.c | 1 + drivers/gpu/drm/mediatek/mtk_drm_drv.h | 1 + 6 files changed, 3371 insertions(+) create mode 100644 drivers/gpu/drm/mediatek/mtk_dp.c create mode 100644 drivers/gpu/drm/mediatek/mtk_dp_reg.h diff --git a/drivers/gpu/drm/mediatek/Kconfig b/drivers/gpu/drm/mediatek/Kconfig index 2976d21e9a34..029b94c71613 100644 --- a/drivers/gpu/drm/mediatek/Kconfig +++ b/drivers/gpu/drm/mediatek/Kconfig @@ -28,3 +28,10 @@ config DRM_MEDIATEK_HDMI select PHY_MTK_HDMI help DRM/KMS HDMI driver for Mediatek SoCs + +config MTK_DPTX_SUPPORT + tristate "DRM DPTX Support for Mediatek SoCs" + depends on DRM_MEDIATEK + select PHY_MTK_DP + help + DRM/KMS Display Port driver for Mediatek SoCs. diff --git a/drivers/gpu/drm/mediatek/Makefile b/drivers/gpu/drm/mediatek/Makefile index 29098d7c8307..d86a6406055e 100644 --- a/drivers/gpu/drm/mediatek/Makefile +++ b/drivers/gpu/drm/mediatek/Makefile @@ -21,3 +21,5 @@ mediatek-drm-hdmi-objs := mtk_cec.o \ mtk_hdmi_ddc.o obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o + +obj-$(CONFIG_MTK_DPTX_SUPPORT) += mtk_dp.o diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c new file mode 100644 index 000000000000..8a5d03b8c5ff --- /dev/null +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -0,0 +1,2825 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. + * Copyright (c) 2021 BayLibre + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include