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 66C5CC433F5 for ; Fri, 1 Oct 2021 09:45:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 3342C61A58 for ; Fri, 1 Oct 2021 09:45:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3342C61A58 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.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 09AB46ED83; Fri, 1 Oct 2021 09:45:02 +0000 (UTC) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by gabe.freedesktop.org (Postfix) with ESMTPS id E16906ED99 for ; Fri, 1 Oct 2021 09:44:58 +0000 (UTC) Received: by mail-wm1-x332.google.com with SMTP id s24so6760789wmh.4 for ; Fri, 01 Oct 2021 02:44:58 -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=h9LxerkBrYYTi/OjGWeLRBK9mA8TQ4bBdsKteC4afH0=; b=VadRDQNr0+Ve9zozDALqNni/1iO2eJ5eKqV5UYpfLjA5z75xyMFDC2KhpRJ9gev8ur ZL0+kUFpE6PfKFSdeWJnuIytgrlX511W6FD1aQgleOKbkHEVHLBizYjyGgk6HIDprg4s CmpTSeTYfGFsgJo3k3/ZOElcjOU/jRQ8tg36bX2qZ9zoSbGSyn9ute0XNFLLgA6wrK88 JJ5m3glTRO6joLVn5HcGfPrIuAyONhnK2zdqB+1BvyoW8E3n/pyM4eZv8fW5ikpTQT3j RpTlNZ9QTfzm0dg37IzzVINJoUMn/XI2H1mYIdmSIrGRMbsOebl9OO6n18HGjVhbV7YH i8Tw== 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=h9LxerkBrYYTi/OjGWeLRBK9mA8TQ4bBdsKteC4afH0=; b=eLdPo84WYOjXnJ/0rDI6YjEBkr/egGiIjFOKxbeeFsjOLi4JwwB2QkqFYo+q7K/0mw VvS5Tf1wA0ixrcOaH5BMq/RzmJXOAHKgmmClY5j1TR6bLs763gYYPbKm5K1G/q89DfWr T3qz6TdsAThz/zXdIfRCWsS32Vz79U/+nKnLp1amYKJwNmBzRBQvckELoQZk9tBR2t5r scQImse8k2mP8qWJWtQrmQaIHsUd4ptyubTCA7sXvaQ8LALdgVZz0N9uU4HjgciKnbTs OLD2SzHDZ1ESPG85Ik5bR1IcmYQ986b8na9xOi428nLd0r+FrDazx/tWNx1eCUtHK46F Uz+A== X-Gm-Message-State: AOAM533cNAJC7idoIVTzrFjtehFBqGqLitKNuvEKqUKIaFV5qWW9RF1S VOhjUliK5xvGBB7ywoFQJMgFRg== X-Google-Smtp-Source: ABdhPJyALZwM6wrXmCoa9J0DaZUaEQS1hd4EtZ0bEveehVRZaJNDa5HE8zCRj6urzCB0L5YCAuEqcQ== X-Received: by 2002:a1c:2209:: with SMTP id i9mr3565796wmi.67.1633081496436; Fri, 01 Oct 2021 02:44:56 -0700 (PDT) Received: from blmsp.lan ([2a02:2454:3e6:c900::97e]) by smtp.gmail.com with ESMTPSA id l21sm7181620wme.39.2021.10.01.02.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 02:44:56 -0700 (PDT) From: Markus Schneider-Pargmann To: Chun-Kuang Hu , Philipp Zabel Cc: Sam Ravnborg , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Markus Schneider-Pargmann Subject: [PATCH v3 6/6] drm/mediatek: Add mt8195 DisplayPort driver Date: Fri, 1 Oct 2021 11:44:43 +0200 Message-Id: <20211001094443.2770169-7-msp@baylibre.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211001094443.2770169-1-msp@baylibre.com> References: <20211001094443.2770169-1-msp@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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 + drivers/phy/mediatek/Kconfig | 8 + drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-dp.c | 218 ++ include/linux/soc/mediatek/mtk-mmsys.h | 2 + 10 files changed, 3600 insertions(+) create mode 100644 drivers/gpu/drm/mediatek/mtk_dp.c create mode 100644 drivers/gpu/drm/mediatek/mtk_dp_reg.h create mode 100644 drivers/phy/mediatek/phy-mtk-dp.c 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