From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8272AD116F3 for ; Fri, 28 Nov 2025 02:05:24 +0000 (UTC) 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=3MISRI47AblsRszJTdcaVZYi9/V0SQciGufvHGmDj5E=; b=Zw8PXPagDQ+ic7 GtPZ5EEFOt4Sf7OfiGID8frTXcyzZ5ljGmq/8COaDIyRhD20gCGlhkJBo1OLnlS5CLgKCG0YOi+x4 E1p/+XDncgBe6a4bjs2D+5omEG2pu40oyfpTVTIJrgJatLt/0uYdvXcFWd10GNiH2lp0ni5XC/Rzw 737M6qVGZtr1qgtDeYq7gy4tIJMo7Ko1IaIgL4inUv19/NosJFRTpEBgyVIUbk1umnxjdPBFKzKXh Mpr1mlP9qPhx0WGzAx5LMkTSHTPEUFzQuf99CtUQ4eiF8Qe57Zg7lsjy96uwVTpdcKCV0v9HCbnFR PrSuFZ0XvJRpa4BhK7Wg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vOnrQ-0000000HQOF-16BF; Fri, 28 Nov 2025 02:05:24 +0000 Received: from smtpbg154.qq.com ([15.184.224.54]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vOnrH-0000000HQHE-3Obc; Fri, 28 Nov 2025 02:05:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=airkyi.com; s=altu2504; t=1764295472; bh=tnGvdgabwSIu+i1OtiOksigRJkfBAJHpGnwVCXS2P5o=; h=From:To:Subject:Date:Message-Id; b=JXhYUp/G3zsknmqYc/HdFl007Yc0RQM5TLzO4dwUCdywfBkgaGEfsogBOjgQouawt tgG0J/LiEAa2scqWWLM9CUjbMh7qJUydh+B4Cm1Wd9cUQnxE6TvVXsEmVEO0oqf61y I3xEomKDwaaahbmQFtwLFFDapPVztjhlG45lihtU= X-QQ-mid: esmtpsz21t1764295470t9a833963 X-QQ-Originating-IP: KmjC1p7wgm4O2w5KPVe71cTZBwPgfvBw9u/6lI4+MDo= Received: from DESKTOP-8BT1A2O.localdomain ( [58.22.7.114]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 28 Nov 2025 10:04:27 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 12748416008944445316 From: Chaoyi Chen To: Heikki Krogerus , Greg Kroah-Hartman , Dmitry Baryshkov , Peter Chen , Luca Ceresoli , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner , Sandy Huang , Andy Yan , Yubing Zhang , Frank Wang , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Amit Sunil Dhamne , Chaoyi Chen , Dragan Simic , Johan Jonker , Diederik de Haas , Peter Robinson Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH v11 03/11] drm/bridge: Implement generic USB Type-C DP HPD bridge Date: Fri, 28 Nov 2025 10:03:57 +0800 Message-Id: <20251128020405.90-4-kernel@airkyi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20251128020405.90-1-kernel@airkyi.com> References: <20251128020405.90-1-kernel@airkyi.com> X-QQ-SENDSIZE: 520 Feedback-ID: esmtpsz:airkyi.com:qybglogicsvrgz:qybglogicsvrgz6b-0 X-QQ-XMAILINFO: OW8nL0XA5GqlUhPJoOErPUM4s6MRsEwJRkG69fsNtdYVce3ogos/mQTu qiHalZQvw6a93jZ9zdVi7JNou1eU+PWbv3auNm/Zh2fClqW70SySYzqgzYDFY+aFuzk1uGT EHqM+sOpphCOTOZObnN+d8bq3rx6WabfHhbMQqOGKmi6qxxUbxuOx/wwFGDXTYZGHJj8RqZ 5X0jqaDFiKmL1m05sMwd8y+Uen6TVwjpThMcgTvcey4DtJmHBs/U9BFa29Dijt2pQRA+AH6 aRfPLw56P5rqOq88Nx3qba2nfeDWa8rPbXmWVncrIc3Z+Xhn3O8XlWbO4KlxDfS9Nlhft6B j9/UKQBc1nx0axjgi4GRhrtGu6y/S1IElPu+yWPxbEAI1YNNyUlKMKA9fTaIXdvUhkuRF9H 3+/6bIj9XfPEU6zH02BrA2Y9NNzbYAgcDUXSnndEoh25HOtRPY8i4TKjTCz1x2pumK/xde8 wkOYpXzgNdyfaZXX5MbOPk4tTlGGjr1kinBY2hKJJncvp8tPMMIHcgf30kXas/LhrIopvNI qH0lqz+h/soeyfxf5vZ+azgagOSY7/szO4od5yLzZafH5NBz7TSiDZcfaIVSq+HcE38Vx+0 zPsfzS/Q+1ZaCM9nOolQD8BO1XvnXY9u3G4bs/QX0Q01QdvhwMfIADoi6QNYHm4PEy1PuUi /6unaamXVkqJ6alwatx8HB7SQX/KYuTbybjIbNBmgF1chfGIsvSY8kKYAoeyYDKQqTXk+sX hCBrFn027GP1Pmwcu5dg2IS722Mj9xAf+uQ6exhilLinAHLpRN8LHcsXQHxdw6CrlDG5p6o 3VeGLq/xv+NeJn/8auLa+dIv+lAeuEDMGKeMb9+5ap/WjhrkdQtsOK7cwdljjwfHFtiwwew /MXDQsyh85uLETjAcD9ftMl6EhmLYsGj5/gaR4X1UT3FFtZ66ZeTyyAgbmn7mFo9TFflt/b tbU57pr89n9EnsL9+1c4OqeHkgt70/qQxPxEWiFKWIEQ2Y2A1X4yV1r9zWtRgmKn6JGFDXU U88/hVDZtkj8FVCC/C1szwovEcGP+Av3sOC7AMAA== X-QQ-XMRINFO: NI4Ajvh11aEj8Xl/2s1/T8w= X-QQ-RECHKSPAM: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251127_180516_454931_4B477CED X-CRM114-Status: GOOD ( 20.58 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org From: Chaoyi Chen The HPD function of Type-C DP is implemented through drm_connector_oob_hotplug_event(). For embedded DP, it is required that the DRM connector fwnode corresponds to the Type-C port fwnode. To describe the relationship between the DP controller and the Type-C port device, we usually using drm_bridge to build a bridge chain. Now several USB-C controller drivers have already implemented the DP HPD bridge function provided by aux-hpd-bridge.c, it will build a DP HPD bridge on USB-C connector port device. But this requires the USB-C controller driver to manually register the HPD bridge. If the driver does not implement this feature, the bridge will not be create. So this patch implements a generic DP HPD bridge based on aux-hpd-bridge.c. It will monitor Type-C bus events, and when a Type-C port device containing the DP svid is registered, it will create an HPD bridge for it without the need for the USB-C controller driver to implement it. Signed-off-by: Chaoyi Chen --- Changes in v11: - Switch to using typec bus notifiers. (no changes since v10) Changes in v9: - Remove the exposed DRM_AUX_HPD_BRIDGE option, and select DRM_AUX_HPD_TYPEC_BRIDGE when it is available. - Add more commit comment about problem background. Changes in v8: - Merge generic DP HPD bridge into one module. drivers/gpu/drm/bridge/Kconfig | 10 ++++ drivers/gpu/drm/bridge/Makefile | 1 + .../gpu/drm/bridge/aux-hpd-typec-dp-bridge.c | 51 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index a250afd8d662..559487aa09a9 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -30,6 +30,16 @@ config DRM_AUX_HPD_BRIDGE Simple bridge that terminates the bridge chain and provides HPD support. +if DRM_AUX_HPD_BRIDGE +config DRM_AUX_HPD_TYPEC_BRIDGE + tristate + depends on TYPEC || !TYPEC + default TYPEC + help + Simple bridge that terminates the bridge chain and provides HPD + support. It build bridge on each USB-C connector device node. +endif + menu "Display Interface Bridges" depends on DRM && DRM_BRIDGE diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index c7dc03182e59..a3a0393d2e72 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o +obj-$(CONFIG_DRM_AUX_HPD_TYPEC_BRIDGE) += aux-hpd-typec-dp-bridge.o obj-$(CONFIG_DRM_CHIPONE_ICN6211) += chipone-icn6211.o obj-$(CONFIG_DRM_CHRONTEL_CH7033) += chrontel-ch7033.o obj-$(CONFIG_DRM_CROS_EC_ANX7688) += cros-ec-anx7688.o diff --git a/drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file mode 100644 index 000000000000..94be3d5f69e9 --- /dev/null +++ b/drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0+ +#include +#include +#include + +#include + +static int drm_typec_bus_event(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct device *dev = (struct device *)data; + struct typec_altmode *alt = to_typec_altmode(dev); + + if (action != BUS_NOTIFY_ADD_DEVICE) + goto done; + + if (is_typec_partner_altmode(&alt->dev) || alt->svid != USB_TYPEC_DP_SID) + goto done; + + /* + * alt->dev.parent->parent : USB-C controller device + * alt->dev.parent : USB-C connector device + */ + drm_dp_hpd_bridge_register(alt->dev.parent->parent, + to_of_node(alt->dev.parent->fwnode)); + +done: + return NOTIFY_OK; +} + +static struct notifier_block drm_typec_event_nb = { + .notifier_call = drm_typec_bus_event, +}; + +static void drm_aux_hpd_typec_dp_bridge_module_exit(void) +{ + bus_unregister_notifier(&typec_bus, &drm_typec_event_nb); +} + +static int __init drm_aux_hpd_typec_dp_bridge_module_init(void) +{ + bus_register_notifier(&typec_bus, &drm_typec_event_nb); + + return 0; +} + +module_init(drm_aux_hpd_typec_dp_bridge_module_init); +module_exit(drm_aux_hpd_typec_dp_bridge_module_exit); + +MODULE_DESCRIPTION("DRM TYPEC DP HPD BRIDGE"); +MODULE_LICENSE("GPL"); -- 2.51.1 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy