From: Chaoyi Chen <[email protected]> Several USB-C controller drivers have already implemented the DP HPD bridge function provided by aux-hpd-bridge.c, but there are still some USB-C controller driver that have not yet implemented it.
This patch implements a generic DP HPD bridge based on aux-hpd-bridge.c, so that other USB-C controller drivers don't need to implement it again. Signed-off-by: Chaoyi Chen <[email protected]> --- drivers/gpu/drm/bridge/Kconfig | 11 ++++ drivers/gpu/drm/bridge/Makefile | 1 + .../gpu/drm/bridge/aux-hpd-typec-dp-bridge.c | 51 +++++++++++++++++++ 3 files changed, 63 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 b9e0ca85226a..9f31540d3ad8 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -33,6 +33,17 @@ config DRM_AUX_HPD_BRIDGE menu "Display Interface Bridges" depends on DRM && DRM_BRIDGE +config DRM_AUX_TYPEC_DP_HPD_BRIDGE + tristate "TypeC DP HPD bridge" + depends on DRM_BRIDGE && OF && TYPEC + select DRM_AUX_HPD_BRIDGE + help + Simple USB Type-C DP bridge that terminates the bridge chain and + provides HPD support. + + If the USB-C controller driver has not implemented this and you need + the DP HPD support, say "Y" or "m" here. + config DRM_CHIPONE_ICN6211 tristate "Chipone ICN6211 MIPI-DSI/RGB Converter bridge" depends on OF diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index 245e8a27e3fc..e91736829167 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_TYPEC_DP_HPD_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..2235b7438fe9 --- /dev/null +++ b/drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0+ +#include <linux/of.h> +#include <linux/usb/typec_altmode.h> +#include <linux/usb/typec_dp.h> +#include <linux/usb/typec_notify.h> + +#include <drm/bridge/aux-bridge.h> + +static int drm_typec_bus_event(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct typec_altmode *alt = (struct typec_altmode *)data; + + if (action != TYPEC_ALTMODE_REGISTERED) + goto done; + + if (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) +{ + typec_unregister_notify(&drm_typec_event_nb); +} + +static int __init drm_aux_hpd_typec_dp_bridge_module_init(void) +{ + typec_register_notify(&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.49.0
