Skip to contentSkip to conversation

Add Type-C DP support for RK3399 EVB IND board

PATCH Superseded Chaoyi Chen 6 participants 32 messages Oct 29, 2025 – Nov 6, 2025

Subsystems (9)

v8 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v8 cover Add Type-C DP support for RK3399 EVB IND board

From: Chaoyi Chen <[email protected]>

This series focuses on adding Type-C DP support for USBDP PHY and DP driver. The USBDP PHY and DP will perceive the changes in cable status based on the USB PD and Type-C state machines provided by TCPM. Before this, the USBDP PHY and DP controller of RK3399 sensed cable state changes through extcon, and devices such as the RK3399 Gru-Chromebook rely on them. This series should not break them.

====
1. DisplayPort HPD status notify

Before v7, I implemented a variety of DP HPD status notify. However, they all had various problems and it was difficult to become a generic solution.

Under the guidance of Heikki and Dmitry, a decoupled notification method between the TypeC and DRM subsystems was introduced in v7. First, a notification is sent when TypeC registers a new altmode. Then, a generic DP AUX HPD bridge is implemented on the DRM side.

That makes it redundant for each Type-C controller driver to implement a similar DP AUX HPD bridge in embedded scenarios.

====
2. Altmode switching and orientation switching for USBDP PHY

For USB Type-C interfaces, an external Type-C controller chip assists by detecting cable attachment, determining plug orientation, and reporting USB PD message. The USB/DP combo PHY supports software configurable pin mapping and DisplayPort lane assignment. Based on these message, the combo PHY can perform both altmode switching and orientation switching via software.

The RK3399 EVB IND board has a Type-C interface DisplayPort. It use fusb302 chip as Type-C controller. The connection diagram is shown below:

fusb302 chip +---> USB2.0 PHY ----> DWC3 USB controller

             |
             +---> USB/DP PHY0 +--> CDN-DP controller
                               |
                               +--> DWC3 USB controller

====
3. Multiple bridge model for RK3399 CDN-DP

The RK3399 has two USB/DP combo PHY and one CDN-DP controller. And the CDN-DP can be switched to output to one of the PHYs.

USB/DP PHY0 ---+

               | <----> CDN-DP controller

USB/DP PHY1 ---+

In previous versions, if both PHY ports were connected to DP, the CDN-DP driver would select the first PHY port for output.

On Dmitry's suggestion, we introduced a multi-bridge model to support flexible selection of the output PHY port. For each PHY port, a separate encoder and bridge are registered.

The change is based on the DRM AUX HPD bridge, rather than the extcon approach. This requires the DT to correctly describe the connections between the first bridge in bridge chain and DP controller. And Once the first bridge is obtained, we can get the last bridge corresponding to the USB-C connector, and then set the DRM connector's fwnode to the corresponding one to enable HPD notification.

====
Patch1 add notifier functions for Type-C core.
Patch2 export all Type-C device types for identification. Patch3 add generic USB Type-C DP HPD bridge.
Patch4 add new Type-C mode switch for RK3399 USBDP phy binding. Patch5 add typec_mux and typec_switch for RK3399 USBDP PHY. Patch6 add DRM AUX bridge support for RK3399 USBDP PHY. Patch7 drops CDN-DP's extcon dependency when Type-C is present. Patch8 add multiple bridges to support PHY port selection. Patch9 add missing dp_out port for RK3399 CDN-DP. Patch10 add Type-C DP support for RK3399 EVB IND board.

Changes in v8:
- Link to V7: https://lore.kernel.org/all/[email protected]/
- Export all typec device types for identification.
- Merge generic DP HPD bridge into one module.
- Fix coding style.

Changes in v7:
- Link to V6: https://lore.kernel.org/all/[email protected]/
- Add notifier functions for Type-C core.
- Add generic USB Type-C DP HPD bridge.

Changes in v6:
- Link to V5: https://lore.kernel.org/all/[email protected]/
- Fix depend in Kconfig.
- Check DP svid in tcphy_typec_mux_set().
- Remove mode setting in tcphy_orien_sw_set().
- Rename some variable names.
- Attach the DP bridge to the next bridge.

Changes in v5:
- Link to V4: https://lore.kernel.org/all/[email protected]/
- Remove the calls related to drm_aux_hpd_bridge_notify().
- Place the helper functions in the same compilation unit.
- Add more comments about parent device.
- Add DRM AUX bridge support for RK3399 USBDP PHY
- By parsing the HPD bridge chain, set the connector's of_node to the of_node corresponding to the USB-C connector.
- Return EDID cache when other port is already enabled.

Changes in v4:
- Link to V3: https://lore.kernel.org/all/[email protected]/
- Add default HPD device for DisplayPort altmode.
- Introduce multiple bridges for CDN-DP.
- ...

Changes in v3:
- Link to V2: https://lore.kernel.org/all/[email protected]/
- Add more descriptions to clarify the role of the PHY in switching.
- Fix wrong vdo value.
- Fix port node in usb-c-connector.

Changes in v2:
- Link to V1: https://lore.kernel.org/all/[email protected]/
- Reuse dp-port/usb3-port in rk3399-typec-phy binding.
- Fix compile error when CONFIG_TYPEC is not enabled.
- Notify DP HPD state by USB/DP PHY.
- Ignore duplicate HPD events.
- Add endpoint to link DP PHY and DP controller.
- Fix devicetree coding style.

Chaoyi Chen (10):
usb: typec: Add notifier functions
usb: typec: Export all typec device types
drm/bridge: Implement generic USB Type-C DP HPD bridge
dt-bindings: phy: rockchip: rk3399-typec-phy: Support mode-switch
phy: rockchip: phy-rockchip-typec: Add typec_mux/typec_switch support
phy: rockchip: phy-rockchip-typec: Add DRM AUX bridge drm/rockchip: cdn-dp: Support handle lane info without extcon drm/rockchip: cdn-dp: Add multiple bridges to support PHY port
selection
arm64: dts: rockchip: Add missing dp_out port for RK3399 CDN-DP
arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

 .../phy/rockchip,rk3399-typec-phy.yaml        |   6 +
 arch/arm64/boot/dts/rockchip/rk3399-base.dtsi |  10 +-
 .../boot/dts/rockchip/rk3399-evb-ind.dts      | 146 ++++++
 drivers/gpu/drm/bridge/Kconfig                |   5 +-
 drivers/gpu/drm/bridge/Makefile               |   8 +-
 drivers/gpu/drm/bridge/aux-hpd-bridge.c       |  23 +-
 drivers/gpu/drm/bridge/aux-hpd-bridge.h       |  13 +
 .../gpu/drm/bridge/aux-hpd-typec-dp-bridge.c  |  47 ++
 drivers/gpu/drm/rockchip/cdn-dp-core.c        | 354 ++++++++++++---
 drivers/gpu/drm/rockchip/cdn-dp-core.h        |  24 +-
 drivers/phy/rockchip/Kconfig                  |   3 +
 drivers/phy/rockchip/phy-rockchip-typec.c     | 420 +++++++++++++++++-
 drivers/usb/typec/Makefile                    |   2 +-
 drivers/usb/typec/bus.h                       |   2 +
 drivers/usb/typec/class.c                     |   7 +
 drivers/usb/typec/class.h                     |  10 -
 drivers/usb/typec/notify.c                    |  24 +
 include/linux/usb/typec.h                     |  10 +
 include/linux/usb/typec_notify.h              |  16 +
 19 files changed, 1034 insertions(+), 96 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.h
 create mode 100644 drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c
 create mode 100644 drivers/usb/typec/notify.c
 create mode 100644 include/linux/usb/typec_notify.h
Signature · 1 line
2.49.0
#4 lore raw

PATCH v8 2/10 usb: typec: Export all typec device types

From: Chaoyi Chen <[email protected]>

Export all typec device types for identification.

---
 drivers/usb/typec/class.c |  4 ++++
 drivers/usb/typec/class.h | 10 ----------
 include/linux/usb/typec.h | 10 ++++++++++
 3 files changed, 14 insertions(+), 10 deletions(-)
drivers/usb/typec/class.c +4 -0
index 51e971bc68d1..04b55f066b06 100644
@@ -793,6 +793,7 @@ const struct device_type typec_partner_dev_type = {
 	.groups = typec_partner_groups,
 	.release = typec_partner_release,
 };
+EXPORT_SYMBOL_GPL(typec_partner_dev_type);
 
 static void typec_partner_link_device(struct typec_partner *partner, struct device *dev)
 {
@@ -1147,6 +1148,7 @@ const struct device_type typec_plug_dev_type = {
 	.groups = typec_plug_groups,
 	.release = typec_plug_release,
 };
+EXPORT_SYMBOL_GPL(typec_plug_dev_type);
 
 /**
  * typec_plug_set_num_altmodes - Set the number of available plug altmodes
@@ -1295,6 +1297,7 @@ const struct device_type typec_cable_dev_type = {
 	.groups = typec_cable_groups,
 	.release = typec_cable_release,
 };
+EXPORT_SYMBOL_GPL(typec_cable_dev_type);
 
 /**
  * typec_cable_get - Get a reference to the USB Type-C cable
@@ -2034,6 +2037,7 @@ const struct device_type typec_port_dev_type = {
 	.uevent = typec_uevent,
 	.release = typec_release,
 };
+EXPORT_SYMBOL_GPL(typec_port_dev_type);
 
 /* --------------------------------------- */
 /* Driver callbacks to report role updates */
drivers/usb/typec/class.h +0 -10
index db2fe96c48ff..f04f6987bed8 100644
@@ -87,16 +87,6 @@ struct typec_port {
 #define to_typec_cable(_dev_) container_of(_dev_, struct typec_cable, dev)
 #define to_typec_partner(_dev_) container_of(_dev_, struct typec_partner, dev)
 
-extern const struct device_type typec_partner_dev_type;
-extern const struct device_type typec_cable_dev_type;
-extern const struct device_type typec_plug_dev_type;
-extern const struct device_type typec_port_dev_type;
-
-#define is_typec_partner(dev) ((dev)->type == &typec_partner_dev_type)
-#define is_typec_cable(dev) ((dev)->type == &typec_cable_dev_type)
-#define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type)
-#define is_typec_port(dev) ((dev)->type == &typec_port_dev_type)
-
 extern const struct class typec_mux_class;
 extern const struct class retimer_class;
 extern const struct class typec_class;
include/linux/usb/typec.h +10 -0
index 309251572e2e..02fed8293415 100644
@@ -56,6 +56,16 @@ enum typec_role {
 	TYPEC_SOURCE,
 };
 
+extern const struct device_type typec_partner_dev_type;
+extern const struct device_type typec_cable_dev_type;
+extern const struct device_type typec_plug_dev_type;
+extern const struct device_type typec_port_dev_type;
+
+#define is_typec_partner(dev) ((dev)->type == &typec_partner_dev_type)
+#define is_typec_cable(dev) ((dev)->type == &typec_cable_dev_type)
+#define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type)
+#define is_typec_port(dev) ((dev)->type == &typec_port_dev_type)
+
 static inline int is_sink(enum typec_role role)
 {
 	return role == TYPEC_SINK;
Signature · 1 line
2.49.0
#1 lore raw

PATCH v8 1/10 usb: typec: Add notifier functions

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

Some other part of kernel may want to know the event of typec bus.

This patch add common notifier function to notify these event.

---

Changes in v8:
- Fix coding style.

 drivers/usb/typec/Makefile       |  2 +-
 drivers/usb/typec/bus.h          |  2 ++
 drivers/usb/typec/class.c        |  3 +++
 drivers/usb/typec/notify.c       | 24 ++++++++++++++++++++++++
 include/linux/usb/typec_notify.h | 16 ++++++++++++++++
 5 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/typec/notify.c
 create mode 100644 include/linux/usb/typec_notify.h
drivers/usb/typec/Makefile +1 -1
index 7a368fea61bc..20d09c5314d7 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_TYPEC)		+= typec.o
-typec-y				:= class.o mux.o bus.o pd.o retimer.o
+typec-y				:= class.o mux.o notify.o bus.o pd.o retimer.o
 typec-$(CONFIG_ACPI)		+= port-mapper.o
 obj-$(CONFIG_TYPEC)		+= altmodes/
 obj-$(CONFIG_TYPEC_TCPM)	+= tcpm/
drivers/usb/typec/bus.h +2 -0
index 643b8c81786d..820b59b6d434 100644
@@ -26,6 +26,8 @@ struct altmode {
 	struct altmode			*plug[2];
 };
 
+void typec_notify_event(unsigned long event, void *data);
+
 #define to_altmode(d) container_of(d, struct altmode, adev)
 
 extern const struct bus_type typec_bus;
drivers/usb/typec/class.c +3 -0
index 9b2647cb199b..51e971bc68d1 100644
@@ -13,6 +13,7 @@
 #include <linux/string_choices.h>
 #include <linux/usb/pd_vdo.h>
 #include <linux/usb/typec_mux.h>
+#include <linux/usb/typec_notify.h>
 #include <linux/usb/typec_retimer.h>
 #include <linux/usb.h>
 
@@ -600,6 +601,8 @@ typec_register_altmode(struct device *parent,
 		return ERR_PTR(ret);
 	}
 
+	typec_notify_event(TYPEC_ALTMODE_REGISTERED, &alt->adev);
+
 	return &alt->adev;
 }
 
drivers/usb/typec/notify.c new file +24 -0
new file mode 100644
index 000000000000..0a14d3ae224e
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/notifier.h>
+#include <linux/usb/typec_notify.h>
+
+#include "bus.h"
+
+static BLOCKING_NOTIFIER_HEAD(typec_notifier_list);
+
+int typec_altmode_register_notify(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&typec_notifier_list, nb);
+}
+EXPORT_SYMBOL_GPL(typec_altmode_register_notify);
+
+int typec_altmode_unregister_notify(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_unregister(&typec_notifier_list, nb);
+}
+EXPORT_SYMBOL_GPL(typec_altmode_unregister_notify);
+
+void typec_notify_event(unsigned long event, void *data)
+{
+	blocking_notifier_call_chain(&typec_notifier_list, event, data);
+}
include/linux/usb/typec_notify.h new file +16 -0
new file mode 100644
index 000000000000..f3a7b5f5b05b
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __USB_TYPEC_NOTIFY
+#define __USB_TYPEC_NOTIFY
+
+#include <linux/notifier.h>
+
+enum usb_typec_event {
+	TYPEC_ALTMODE_REGISTERED,
+	TYPEC_ALTMODE_UNREGISTERED,
+};
+
+int typec_altmode_register_notify(struct notifier_block *nb);
+int typec_altmode_unregister_notify(struct notifier_block *nb);
+
+#endif /* __USB_TYPEC_NOTIFY */
Signature · 1 line
2.49.0
#14 lore raw

PATCH v8 4/10 dt-bindings: phy: rockchip: rk3399-typec-phy: Support mode-switch

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

The RK3399 SoC integrates two USB/DP combo PHYs, each of which supports software-configurable pin mapping and DisplayPort lane assignment. These capabilities enable the PHY itself to handle both mode switching and orientation switching, based on the Type-C plug orientation and USB PD negotiation results.

While an external Type-C controller is still required to detect cable attachment and report USB PD events, the actual mode and orientation switching is performed internally by the PHY through software configuration. This allows the PHY to act as a Type-C multiplexer for both data role and DP altmode configuration.

To reflect this hardware design, this patch introduces a new "mode-switch" property for the dp-port node in the device tree bindings. This property indicates that the connected PHY is capable of handling Type-C mode switching itself.

---

(no changes since v5)

Changes in v4:
- Remove "|" in description.

Changes in v3:
- Add more descriptions to clarify the role of the PHY in switching.

Changes in v2:
- Reuse dp-port/usb3-port in rk3399-typec-phy binding.

 .../devicetree/bindings/phy/rockchip,rk3399-typec-phy.yaml  | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/phy/rockchip,rk3399-typec-phy.yaml +6 -0
index 91c011f68cd0..83ebcde096ea 100644
@@ -51,6 +51,12 @@ properties:
       '#phy-cells':
         const: 0
 
+      mode-switch:
+        description:
+          Indicates the PHY can handle altmode switching. In this case,
+          requires an external USB Type-C controller to report USB PD message.
+        type: boolean
+
       port:
         $ref: /schemas/graph.yaml#/properties/port
         description: Connection to USB Type-C connector
Signature · 1 line
2.49.0
#6 lore raw

PATCH v8 3/10 drm/bridge: Implement generic USB Type-C DP HPD bridge

In reply to Chaoyi Chen

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.

---

Changes in v8:
- Merge generic DP HPD bridge into one module.

 drivers/gpu/drm/bridge/Kconfig                |  5 +-
 drivers/gpu/drm/bridge/Makefile               |  8 +++-
 drivers/gpu/drm/bridge/aux-hpd-bridge.c       | 23 ++++++++-
 drivers/gpu/drm/bridge/aux-hpd-bridge.h       | 13 +++++
 .../gpu/drm/bridge/aux-hpd-typec-dp-bridge.c  | 47 +++++++++++++++++++
 5 files changed, 93 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.h
 create mode 100644 drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c
drivers/gpu/drm/bridge/Kconfig +4 -1
index a250afd8d662..17257b223a28 100644
@@ -23,13 +23,16 @@ config DRM_AUX_BRIDGE
 	  build bridges chain.
 
 config DRM_AUX_HPD_BRIDGE
-	tristate
+	tristate "AUX HPD bridge support"
 	depends on DRM_BRIDGE && OF
 	select AUXILIARY_BUS
 	help
 	  Simple bridge that terminates the bridge chain and provides HPD
 	  support.
 
+	  Specifically, if you want a default Type-C DisplayPort HPD bridge for
+	  each port of the Type-C controller, say Y here.
+
 menu "Display Interface Bridges"
 	depends on DRM && DRM_BRIDGE
 
drivers/gpu/drm/bridge/Makefile +7 -1
index c7dc03182e59..2998937444bc 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o
-obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o
+
+hpd-bridge-y := aux-hpd-bridge.o
+ifneq ($(CONFIG_TYPEC),)
+hpd-bridge-y += aux-hpd-typec-dp-bridge.o
+endif
+obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += hpd-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
drivers/gpu/drm/bridge/aux-hpd-bridge.c +22 -1
index 2e9c702c7087..11ad6dc776c7 100644
@@ -12,6 +12,8 @@
 #include <drm/drm_bridge.h>
 #include <drm/bridge/aux-bridge.h>
 
+#include "aux-hpd-bridge.h"
+
 static DEFINE_IDA(drm_aux_hpd_bridge_ida);
 
 struct drm_aux_hpd_bridge_data {
@@ -204,7 +206,26 @@ static struct auxiliary_driver drm_aux_hpd_bridge_drv = {
 	.id_table = drm_aux_hpd_bridge_table,
 	.probe = drm_aux_hpd_bridge_probe,
 };
-module_auxiliary_driver(drm_aux_hpd_bridge_drv);
+
+static int drm_aux_hpd_bridge_mod_init(void)
+{
+	int ret;
+
+	ret = auxiliary_driver_register(&drm_aux_hpd_bridge_drv);
+	if (ret)
+		return ret;
+
+	return drm_aux_hpd_typec_dp_bridge_init();
+}
+
+static void drm_aux_hpd_bridge_mod_exit(void)
+{
+	drm_aux_hpd_typec_dp_bridge_exit();
+	auxiliary_driver_unregister(&drm_aux_hpd_bridge_drv);
+}
+
+module_init(drm_aux_hpd_bridge_mod_init);
+module_exit(drm_aux_hpd_bridge_mod_exit);
 
 MODULE_AUTHOR("Dmitry Baryshkov <[email protected]>");
 MODULE_DESCRIPTION("DRM HPD bridge");
drivers/gpu/drm/bridge/aux-hpd-bridge.h new file +13 -0
new file mode 100644
index 000000000000..69364731c2f1
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef AUX_HPD_BRIDGE_H
+#define AUX_HPD_BRIDGE_H
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+int drm_aux_hpd_typec_dp_bridge_init(void);
+void drm_aux_hpd_typec_dp_bridge_exit(void);
+#else
+static inline int drm_aux_hpd_typec_dp_bridge_init(void) { return 0; }
+static inline void drm_aux_hpd_typec_dp_bridge_exit(void) { }
+#endif /* IS_REACHABLE(CONFIG_TYPEC) */
+
+#endif /* AUX_HPD_BRIDGE_H */
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.49.0
#15 lore raw

PATCH v8 5/10 phy: rockchip: phy-rockchip-typec: Add typec_mux/typec_switch support

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

This patch add support for Type-C Port Controller Manager. Each PHY will register typec_mux and typec_switch when external Type-C controller is present. Type-C events are handled by TCPM without extcon.

The extcon device should still be supported.

---

(no changes since v7)

Changes in v6:
- Fix depend in Kconfig.
- Check DP svid in tcphy_typec_mux_set().
- Remove mode setting in tcphy_orien_sw_set().

(no changes since v5)

Changes in v4:
- Remove notify DP HPD state by USB/DP PHY.

(no changes since v3)

Changes in v2:
- Fix compile error when CONFIG_TYPEC is not enabled.
- Notify DP HPD state by USB/DP PHY.

 drivers/phy/rockchip/Kconfig              |   1 +
 drivers/phy/rockchip/phy-rockchip-typec.c | 368 +++++++++++++++++++++-
 2 files changed, 353 insertions(+), 16 deletions(-)
drivers/phy/rockchip/Kconfig +1 -0
index 14698571b607..db4adc7c53da 100644
@@ -119,6 +119,7 @@ config PHY_ROCKCHIP_SNPS_PCIE3
 config PHY_ROCKCHIP_TYPEC
 	tristate "Rockchip TYPEC PHY Driver"
 	depends on OF && (ARCH_ROCKCHIP || COMPILE_TEST)
+	depends on TYPEC || TYPEC=n
 	select EXTCON
 	select GENERIC_PHY
 	select RESET_CONTROLLER
drivers/phy/rockchip/phy-rockchip-typec.c +352 -16

507 lines not on this page · raw message

Signature · 1 line
2.49.0
#16 lore raw

PATCH v8 6/10 phy: rockchip: phy-rockchip-typec: Add DRM AUX bridge

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

Using the DRM_AUX_BRIDGE helper to create the transparent DRM bridge device.

---

(no changes since v7)

Changes in v6:
- Fix depend in Kconfig.

 drivers/phy/rockchip/Kconfig              |  2 +
 drivers/phy/rockchip/phy-rockchip-typec.c | 52 +++++++++++++++++++++++
 2 files changed, 54 insertions(+)
drivers/phy/rockchip/Kconfig +2 -0
index db4adc7c53da..bcb5476222fc 100644
@@ -120,6 +120,8 @@ config PHY_ROCKCHIP_TYPEC
 	tristate "Rockchip TYPEC PHY Driver"
 	depends on OF && (ARCH_ROCKCHIP || COMPILE_TEST)
 	depends on TYPEC || TYPEC=n
+	depends on DRM || DRM=n
+	select DRM_AUX_BRIDGE if DRM_BRIDGE
 	select EXTCON
 	select GENERIC_PHY
 	select RESET_CONTROLLER
drivers/phy/rockchip/phy-rockchip-typec.c +52 -0

82 lines not on this page · raw message

Signature · 1 line
2.49.0
#18 lore raw

PATCH v8 8/10 drm/rockchip: cdn-dp: Add multiple bridges to support PHY port selection

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

The RK3399 has two USB/DP combo PHY and one CDN-DP controller. And the CDN-DP can be switched to output to one of the PHYs. If both ports are plugged into DP, DP will select the first port for output.

This patch adds support for multiple bridges, enabling users to flexibly select the output port. For each PHY port, a separate encoder and bridge are registered.

The change is based on the DRM AUX HPD bridge, rather than the extcon approach. This requires the DT to correctly describe the connections between the first bridge in bridge chain and DP controller. For example, the bridge chain may be like this:

PHY aux birdge -> fsa4480 analog audio switch bridge -> onnn,nb7vpq904m USB reminder bridge -> USB-C controller AUX HPD bridge

In this case, the connection relationships among the PHY aux bridge and the DP contorller need to be described in DT.

In addition, the cdn_dp_parse_next_bridge_dt() will parses it and determines whether to register one or two bridges.

Since there is only one DP controller, only one of the PHY ports can output at a time. The key is how to switch between different PHYs, which is handled by cdn_dp_switch_port() and cdn_dp_enable().

There are two cases:

1. Neither bridge is enabled. In this case, both bridges can independently read the EDID, and the PHY port may switch before reading the EDID.

2. One bridge is already enabled. In this case, other bridges are not allowed to read the EDID. So we will try to return the cached EDID.

Since the scenario of two ports plug in at the same time is rare, I don't have a board which support two TypeC connector to test this. Therefore, I tested forced switching on a single PHY port, as well as output using a fake PHY port alongside a real PHY port.

---

(no changes since v7)

Changes in v6:
- Rename some variable names.
- Attach the DP bridge to the next bridge.

Changes in v5:
- By parsing the HPD bridge chain, set the connector's of_node to the of_node corresponding to the USB-C connector.
- Return EDID cache when other port is already enabled.

 drivers/gpu/drm/rockchip/cdn-dp-core.c | 329 ++++++++++++++++++++-----
 drivers/gpu/drm/rockchip/cdn-dp-core.h |  24 +-
 2 files changed, 296 insertions(+), 57 deletions(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +274 -55
index 1e27301584a4..5c0e5209d3b8 100644
@@ -27,16 +27,17 @@
 #include "cdn-dp-core.h"
 #include "cdn-dp-reg.h"
 
-static inline struct cdn_dp_device *bridge_to_dp(struct drm_bridge *bridge)
+static int cdn_dp_switch_port(struct cdn_dp_device *dp, struct cdn_dp_port *prev_port,
+			      struct cdn_dp_port *port);
+
+static inline struct cdn_dp_bridge *bridge_to_dp_bridge(struct drm_bridge *bridge)
 {
-	return container_of(bridge, struct cdn_dp_device, bridge);
+	return container_of(bridge, struct cdn_dp_bridge, bridge);
 }
 
-static inline struct cdn_dp_device *encoder_to_dp(struct drm_encoder *encoder)
+static inline struct cdn_dp_device *bridge_to_dp(struct drm_bridge *bridge)
 {
-	struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);
-
-	return container_of(rkencoder, struct cdn_dp_device, encoder);
+	return bridge_to_dp_bridge(bridge)->parent;
 }
 
 #define GRF_SOC_CON9		0x6224
@@ -191,14 +192,27 @@ static int cdn_dp_get_sink_count(struct cdn_dp_device *dp, u8 *sink_count)
 static struct cdn_dp_port *cdn_dp_connected_port(struct cdn_dp_device *dp)
 {
 	struct cdn_dp_port *port;
-	int i, lanes;
+	int i, lanes[MAX_PHY];
 
 	for (i = 0; i < dp->ports; i++) {
 		port = dp->port[i];
-		lanes = cdn_dp_get_port_lanes(port);
-		if (lanes)
+		lanes[i] = cdn_dp_get_port_lanes(port);
+		if (!dp->next_bridge_valid)
 			return port;
 	}
+
+	if (dp->next_bridge_valid) {
+		/* If more than one port is available, pick the last active port */
+		if (dp->active_port > 0 && lanes[dp->active_port])
+			return dp->port[dp->active_port];
+
+		/* If the last active port is not available, pick an available port in order */
+		for (i = 0; i < dp->bridge_count; i++) {
+			if (lanes[i])
+				return dp->port[i];
+		}
+	}
+
 	return NULL;
 }
 
@@ -253,12 +267,45 @@ static const struct drm_edid *
 cdn_dp_bridge_edid_read(struct drm_bridge *bridge, struct drm_connector *connector)
 {
 	struct cdn_dp_device *dp = bridge_to_dp(bridge);
-	const struct drm_edid *drm_edid;
+	struct cdn_dp_bridge *dp_bridge = bridge_to_dp_bridge(bridge);
+	struct cdn_dp_port *port = dp->port[dp_bridge->id];
+	struct cdn_dp_port *prev_port;
+	const struct drm_edid *drm_edid = NULL;
+	int i, ret;
 
 	mutex_lock(&dp->lock);
+
+	/* More than one port is available */
+	if (dp->bridge_count > 1 && !port->phy_enabled) {
+		for (i = 0; i < dp->bridge_count; i++) {
+			/* Another port already enable */
+			if (dp->bridge_list[i] != dp_bridge && dp->bridge_list[i]->enabled)
+				goto get_cache;
+			/* Find already enabled port */
+			if (dp->port[i]->phy_enabled)
+				prev_port = dp->port[i];
+		}
+
+		/* Switch to current port */
+		if (prev_port) {
+			ret = cdn_dp_switch_port(dp, prev_port, port);
+			if (ret)
+				goto get_cache;
+		}
+	}
+
 	drm_edid = drm_edid_read_custom(connector, cdn_dp_get_edid_block, dp);
+	/* replace edid cache */
+	if (dp->edid_cache[dp_bridge->id])
+		drm_edid_free(dp->edid_cache[dp_bridge->id]);
+	dp->edid_cache[dp_bridge->id] = drm_edid_dup(drm_edid);
+
 	mutex_unlock(&dp->lock);
+	return drm_edid;
 
+get_cache:
+	drm_edid = drm_edid_dup(dp->edid_cache[dp_bridge->id]);
+	mutex_unlock(&dp->lock);
 	return drm_edid;
 }
 
@@ -267,12 +314,13 @@ cdn_dp_bridge_mode_valid(struct drm_bridge *bridge,
 			 const struct drm_display_info *display_info,
 			 const struct drm_display_mode *mode)
 {
+	struct cdn_dp_bridge *dp_bridge = bridge_to_dp_bridge(bridge);
 	struct cdn_dp_device *dp = bridge_to_dp(bridge);
 	u32 requested, actual, rate, sink_max, source_max = 0;
 	u8 lanes, bpc;
 
 	/* If DP is disconnected, every mode is invalid */
-	if (!dp->connected)
+	if (!dp_bridge->connected || !dp->connected)
 		return MODE_BAD;
 
 	switch (display_info->bpc) {
@@ -550,6 +598,54 @@ static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
 	return drm_dp_channel_eq_ok(link_status, min(port->lanes, sink_lanes));
 }
 
+static int cdn_dp_switch_port(struct cdn_dp_device *dp, struct cdn_dp_port *prev_port,
+			      struct cdn_dp_port *port)
+{
+	int ret;
+
+	if (dp->active)
+		return 0;
+
+	ret = cdn_dp_disable_phy(dp, prev_port);
+	if (ret)
+		goto out;
+	ret = cdn_dp_enable_phy(dp, port);
+	if (ret)
+		goto out;
+
+	ret = cdn_dp_get_sink_capability(dp);
+	if (ret) {
+		cdn_dp_disable_phy(dp, port);
+		goto out;
+	}
+
+	dp->active = true;
+	dp->lanes = port->lanes;
+
+	if (!cdn_dp_check_link_status(dp)) {
+		dev_info(dp->dev, "Connected with sink; re-train link\n");
+
+		ret = cdn_dp_train_link(dp);
+		if (ret) {
+			dev_err(dp->dev, "Training link failed: %d\n", ret);
+			goto out;
+		}
+
+		ret = cdn_dp_set_video_status(dp, CONTROL_VIDEO_IDLE);
+		if (ret) {
+			dev_err(dp->dev, "Failed to idle video %d\n", ret);
+			goto out;
+		}
+
+		ret = cdn_dp_config_video(dp);
+		if (ret)
+			dev_err(dp->dev, "Failed to configure video: %d\n", ret);
+	}
+
+out:
+	return ret;
+}
+
 static void cdn_dp_display_info_update(struct cdn_dp_device *dp,
 				       struct drm_display_info *display_info)
 {
@@ -571,6 +667,7 @@ static void cdn_dp_display_info_update(struct cdn_dp_device *dp,
 static void cdn_dp_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_atomic_state *state)
 {
 	struct cdn_dp_device *dp = bridge_to_dp(bridge);
+	struct cdn_dp_bridge *dp_bridge = bridge_to_dp_bridge(bridge);
 	struct drm_connector *connector;
 	int ret, val;
 
@@ -580,7 +677,7 @@ static void cdn_dp_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_at
 
 	cdn_dp_display_info_update(dp, &connector->display_info);
 
-	ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, &dp->encoder.encoder);
+	ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, &dp_bridge->encoder.encoder);
 	if (ret < 0) {
 		DRM_DEV_ERROR(dp->dev, "Could not get vop id, %d", ret);
 		return;
@@ -599,6 +696,9 @@ static void cdn_dp_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_at
 
 	mutex_lock(&dp->lock);
 
+	if (dp->next_bridge_valid)
+		dp->active_port = dp_bridge->id;
+
 	ret = cdn_dp_enable(dp);
 	if (ret) {
 		DRM_DEV_ERROR(dp->dev, "Failed to enable bridge %d\n",
@@ -631,6 +731,7 @@ static void cdn_dp_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_at
 		goto out;
 	}
 
+	dp_bridge->enabled = true;
 out:
 	mutex_unlock(&dp->lock);
 }
@@ -638,9 +739,11 @@ static void cdn_dp_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_at
 static void cdn_dp_bridge_atomic_disable(struct drm_bridge *bridge, struct drm_atomic_state *state)
 {
 	struct cdn_dp_device *dp = bridge_to_dp(bridge);
+	struct cdn_dp_bridge *dp_bridge = bridge_to_dp_bridge(bridge);
 	int ret;
 
 	mutex_lock(&dp->lock);
+	dp_bridge->enabled = false;
 
 	if (dp->active) {
 		ret = cdn_dp_disable(dp);
@@ -827,6 +930,16 @@ static int cdn_dp_audio_mute_stream(struct drm_bridge *bridge,
 	return ret;
 }
 
+static void cdn_dp_bridge_hpd_notify(struct drm_bridge *bridge,
+			   enum drm_connector_status status)
+{
+	struct cdn_dp_bridge *dp_bridge = bridge_to_dp_bridge(bridge);
+	struct cdn_dp_device *dp = bridge_to_dp(bridge);
+
+	dp->bridge_list[dp_bridge->id]->connected = status == connector_status_connected;
+	schedule_work(&dp->event_work);
+}
+
 static const struct drm_bridge_funcs cdn_dp_bridge_funcs = {
 	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
@@ -837,6 +950,7 @@ static const struct drm_bridge_funcs cdn_dp_bridge_funcs = {
 	.atomic_disable = cdn_dp_bridge_atomic_disable,
 	.mode_valid = cdn_dp_bridge_mode_valid,
 	.mode_set = cdn_dp_bridge_mode_set,
+	.hpd_notify = cdn_dp_bridge_hpd_notify,
 
 	.dp_audio_prepare = cdn_dp_audio_prepare,
 	.dp_audio_mute_stream = cdn_dp_audio_mute_stream,
@@ -885,7 +999,8 @@ static void cdn_dp_pd_event_work(struct work_struct *work)
 {
 	struct cdn_dp_device *dp = container_of(work, struct cdn_dp_device,
 						event_work);
-	int ret;
+	bool connected;
+	int i, ret;
 
 	mutex_lock(&dp->lock);
 
@@ -944,9 +1059,12 @@ static void cdn_dp_pd_event_work(struct work_struct *work)
 
 out:
 	mutex_unlock(&dp->lock);
-	drm_bridge_hpd_notify(&dp->bridge,
-			      dp->connected ? connector_status_connected
-					    : connector_status_disconnected);
+	for (i = 0; i < dp->bridge_count; i++) {
+		connected = dp->connected && dp->bridge_list[i]->connected;
+		drm_bridge_hpd_notify(&dp->bridge_list[i]->bridge,
+				      connected ? connector_status_connected
+						: connector_status_disconnected);
+	}
 }
 
 static int cdn_dp_pd_event(struct notifier_block *nb,
@@ -966,28 +1084,16 @@ static int cdn_dp_pd_event(struct notifier_block *nb,
 	return NOTIFY_DONE;
 }
 
-static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
+static int cdn_bridge_add(struct device *dev,
+			  struct drm_bridge *bridge,
+			  struct drm_bridge *next_bridge,
+			  struct drm_encoder *encoder)
 {
 	struct cdn_dp_device *dp = dev_get_drvdata(dev);
-	struct drm_encoder *encoder;
+	struct drm_device *drm_dev = dp->drm_dev;
+	struct drm_bridge *last_bridge = NULL;
 	struct drm_connector *connector;
-	struct cdn_dp_port *port;
-	struct drm_device *drm_dev = data;
-	int ret, i;
-
-	ret = cdn_dp_parse_dt(dp);
-	if (ret < 0)
-		return ret;
-
-	dp->drm_dev = drm_dev;
-	dp->connected = false;
-	dp->active = false;
-	dp->active_port = -1;
-	dp->fw_loaded = false;
-
-	INIT_WORK(&dp->event_work, cdn_dp_pd_event_work);
-
-	encoder = &dp->encoder.encoder;
+	int ret;
 
 	encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev,
 							     dev->of_node);
@@ -1002,26 +1108,38 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
 
 	drm_encoder_helper_add(encoder, &cdn_dp_encoder_helper_funcs);
 
-	dp->bridge.ops =
-			DRM_BRIDGE_OP_DETECT |
-			DRM_BRIDGE_OP_EDID |
-			DRM_BRIDGE_OP_HPD |
-			DRM_BRIDGE_OP_DP_AUDIO;
-	dp->bridge.of_node = dp->dev->of_node;
-	dp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;
-	dp->bridge.hdmi_audio_dev = dp->dev;
-	dp->bridge.hdmi_audio_max_i2s_playback_channels = 8;
-	dp->bridge.hdmi_audio_spdif_playback = 1;
-	dp->bridge.hdmi_audio_dai_port = -1;
-
-	ret = devm_drm_bridge_add(dev, &dp->bridge);
+
+	bridge->ops =
+		DRM_BRIDGE_OP_DETECT |
+		DRM_BRIDGE_OP_EDID |
+		DRM_BRIDGE_OP_HPD |
+		DRM_BRIDGE_OP_DP_AUDIO;
+	bridge->of_node = dp->dev->of_node;
+	bridge->type = DRM_MODE_CONNECTOR_DisplayPort;
+	bridge->hdmi_audio_dev = dp->dev;
+	bridge->hdmi_audio_max_i2s_playback_channels = 8;
+	bridge->hdmi_audio_spdif_playback = 1;
+	bridge->hdmi_audio_dai_port = -1;
+
+	ret = devm_drm_bridge_add(dev, bridge);
 	if (ret)
 		return ret;
 
-	ret = drm_bridge_attach(encoder, &dp->bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
+	ret = drm_bridge_attach(encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret)
 		return ret;
 
+	if (next_bridge) {
+		ret = drm_bridge_attach(encoder, next_bridge, bridge,
+					DRM_BRIDGE_ATTACH_NO_CONNECTOR);
+		if (ret)
+			return ret;
+
+		last_bridge = next_bridge;
+		while (drm_bridge_get_next_bridge(last_bridge))
+			last_bridge = drm_bridge_get_next_bridge(last_bridge);
+	}
+
 	connector = drm_bridge_connector_init(drm_dev, encoder);
 	if (IS_ERR(connector)) {
 		ret = PTR_ERR(connector);
@@ -1029,8 +1147,102 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
 		return ret;
 	}
 
+	if (last_bridge)
+		connector->fwnode = fwnode_handle_get(of_fwnode_handle(last_bridge->of_node));
+
 	drm_connector_attach_encoder(connector, encoder);
 
+	return 0;
+}
+
+static int cdn_dp_parse_next_bridge_dt(struct cdn_dp_device *dp)
+{
+	struct device_node *np = dp->dev->of_node;
+	struct device_node *port __free(device_node) = of_graph_get_port_by_id(np, 1);
+	struct drm_bridge *bridge;
+	int count = 0;
+	int ret = 0;
+	int i;
+
+	/* If device use extcon, do not use hpd bridge */
+	for (i = 0; i < dp->ports; i++) {
+		if (dp->port[i]->extcon) {
+			dp->bridge_count = 1;
+			return 0;
+		}
+	}
+
+
+	/* One endpoint may correspond to one next bridge. */
+	for_each_of_graph_port_endpoint(port, dp_ep) {
+		struct device_node *next_bridge_node __free(device_node) =
+			of_graph_get_remote_port_parent(dp_ep);
+
+		bridge = of_drm_find_bridge(next_bridge_node);
+		if (!bridge) {
+			ret = -EPROBE_DEFER;
+			goto out;
+		}
+
+		dp->next_bridge_valid = true;
+		dp->next_bridge_list[count].bridge = bridge;
+		dp->next_bridge_list[count].parent = dp;
+		dp->next_bridge_list[count].id = count;
+		count++;
+	}
+
+out:
+	dp->bridge_count = count ? count : 1;
+	return ret;
+}
+
+static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
+{
+	struct cdn_dp_device *dp = dev_get_drvdata(dev);
+	struct drm_bridge *bridge, *next_bridge;
+	struct drm_encoder *encoder;
+	struct cdn_dp_port *port;
+	struct drm_device *drm_dev = data;
+	struct cdn_dp_bridge *dp_bridge;
+	int ret, i;
+
+	ret = cdn_dp_parse_dt(dp);
+	if (ret < 0)
+		return ret;
+
+	ret = cdn_dp_parse_next_bridge_dt(dp);
+	if (ret)
+		return ret;
+
+	dp->drm_dev = drm_dev;
+	dp->connected = false;
+	dp->active = false;
+	dp->active_port = -1;
+	dp->fw_loaded = false;
+
+	for (i = 0; i < dp->bridge_count; i++) {
+		dp_bridge = devm_drm_bridge_alloc(dev, struct cdn_dp_bridge, bridge,
+						    &cdn_dp_bridge_funcs);
+		if (IS_ERR(dp_bridge))
+			return PTR_ERR(dp_bridge);
+		dp_bridge->id = i;
+		dp_bridge->parent = dp;
+		if (!dp->next_bridge_valid)
+			dp_bridge->connected = true;
+		dp->bridge_list[i] = dp_bridge;
+	}
+
+	for (i = 0; i < dp->bridge_count; i++) {
+		encoder = &dp->bridge_list[i]->encoder.encoder;
+		bridge = &dp->bridge_list[i]->bridge;
+		next_bridge = dp->next_bridge_list[i].bridge;
+		ret = cdn_bridge_add(dev, bridge, next_bridge, encoder);
+		if (ret)
+			return ret;
+	}
+
+	INIT_WORK(&dp->event_work, cdn_dp_pd_event_work);
+
 	for (i = 0; i < dp->ports; i++) {
 		port = dp->port[i];
 
@@ -1058,10 +1270,17 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
 static void cdn_dp_unbind(struct device *dev, struct device *master, void *data)
 {
 	struct cdn_dp_device *dp = dev_get_drvdata(dev);
-	struct drm_encoder *encoder = &dp->encoder.encoder;
+	struct drm_encoder *encoder;
+	int i;
 
 	cancel_work_sync(&dp->event_work);
-	encoder->funcs->destroy(encoder);
+	for (i = 0; i < dp->bridge_count; i++) {
+		encoder = &dp->bridge_list[i]->encoder.encoder;
+		encoder->funcs->destroy(encoder);
+	}
+
+	for (i = 0; i < MAX_PHY; i++)
+		drm_edid_free(dp->edid_cache[i]);
 
 	pm_runtime_disable(dev);
 	if (dp->fw_loaded)
@@ -1112,10 +1331,10 @@ static int cdn_dp_probe(struct platform_device *pdev)
 	int ret;
 	int i;
 
-	dp = devm_drm_bridge_alloc(dev, struct cdn_dp_device, bridge,
-				   &cdn_dp_bridge_funcs);
-	if (IS_ERR(dp))
-		return PTR_ERR(dp);
+	dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
+	if (!dp)
+		return -ENOMEM;
+
 	dp->dev = dev;
 
 	match = of_match_node(cdn_dp_dt_ids, pdev->dev.of_node);
drivers/gpu/drm/rockchip/cdn-dp-core.h +22 -2
index e9c30b9fd543..ce1707a5c746 100644
@@ -38,6 +38,8 @@ enum vic_pxl_encoding_format {
 	Y_ONLY = 0x10,
 };
 
+struct cdn_dp_device;
+
 struct video_info {
 	bool h_sync_polarity;
 	bool v_sync_polarity;
@@ -63,16 +65,34 @@ struct cdn_dp_port {
 	u8 id;
 };
 
+struct cdn_dp_bridge {
+	struct cdn_dp_device *parent;
+	struct drm_bridge bridge;
+	struct rockchip_encoder encoder;
+	bool connected;
+	bool enabled;
+	int id;
+};
+
+struct cdn_dp_next_bridge {
+	struct cdn_dp_device *parent;
+	struct drm_bridge *bridge;
+	int id;
+};
+
 struct cdn_dp_device {
 	struct device *dev;
 	struct drm_device *drm_dev;
-	struct drm_bridge bridge;
-	struct rockchip_encoder encoder;
+	int bridge_count;
+	struct cdn_dp_bridge *bridge_list[MAX_PHY];
+	struct cdn_dp_next_bridge next_bridge_list[MAX_PHY];
+	const struct drm_edid *edid_cache[MAX_PHY];
 	struct drm_display_mode mode;
 	struct platform_device *audio_pdev;
 	struct work_struct event_work;
 
 	struct mutex lock;
+	bool next_bridge_valid;
 	bool connected;
 	bool active;
 	bool suspended;
Signature · 1 line
2.49.0
#17 lore raw

PATCH v8 7/10 drm/rockchip: cdn-dp: Support handle lane info without extcon

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

This patch add support for get PHY lane info without help of extcon.

There is no extcon needed if the Type-C controller is present. In this case, the lane info can be get from PHY instead of extcon.

The extcon device should still be supported if Type-C controller is not present.

---

(no changes since v5)

Changes in v4:
- Remove cdn_dp_hpd_notify().

(no changes since v3)

Changes in v2:
- Ignore duplicate HPD events.

 drivers/gpu/drm/rockchip/cdn-dp-core.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +17 -8
index b7e3f5dcf8d5..1e27301584a4 100644
@@ -156,6 +156,9 @@ static int cdn_dp_get_port_lanes(struct cdn_dp_port *port)
 	int dptx;
 	u8 lanes;
 
+	if (!edev)
+		return phy_get_bus_width(port->phy);
+
 	dptx = extcon_get_state(edev, EXTCON_DISP_DP);
 	if (dptx > 0) {
 		extcon_get_property(edev, EXTCON_DISP_DP,
@@ -219,7 +222,7 @@ static bool cdn_dp_check_sink_connection(struct cdn_dp_device *dp)
 	 * some docks need more time to power up.
 	 */
 	while (time_before(jiffies, timeout)) {
-		if (!extcon_get_state(port->extcon, EXTCON_DISP_DP))
+		if (port->extcon && !extcon_get_state(port->extcon, EXTCON_DISP_DP))
 			return false;
 
 		if (!cdn_dp_get_sink_count(dp, &sink_count))
@@ -385,11 +388,14 @@ static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port)
 		goto err_power_on;
 	}
 
-	ret = extcon_get_property(port->extcon, EXTCON_DISP_DP,
-				  EXTCON_PROP_USB_TYPEC_POLARITY, &property);
-	if (ret) {
-		DRM_DEV_ERROR(dp->dev, "get property failed\n");
-		goto err_power_on;
+	property.intval = 0;
+	if (port->extcon) {
+		ret = extcon_get_property(port->extcon, EXTCON_DISP_DP,
+					  EXTCON_PROP_USB_TYPEC_POLARITY, &property);
+		if (ret) {
+			DRM_DEV_ERROR(dp->dev, "get property failed\n");
+			goto err_power_on;
+		}
 	}
 
 	port->lanes = cdn_dp_get_port_lanes(port);
@@ -1028,6 +1034,9 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
 	for (i = 0; i < dp->ports; i++) {
 		port = dp->port[i];
 
+		if (!port->extcon)
+			continue;
+
 		port->event_nb.notifier_call = cdn_dp_pd_event;
 		ret = devm_extcon_register_notifier(dp->dev, port->extcon,
 						    EXTCON_DISP_DP,
@@ -1120,14 +1129,14 @@ static int cdn_dp_probe(struct platform_device *pdev)
 		    PTR_ERR(phy) == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
 
-		if (IS_ERR(extcon) || IS_ERR(phy))
+		if (IS_ERR(phy) || PTR_ERR(extcon) != -ENODEV)
 			continue;
 
 		port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
 		if (!port)
 			return -ENOMEM;
 
-		port->extcon = extcon;
+		port->extcon = IS_ERR(extcon) ? NULL : extcon;
 		port->phy = phy;
 		port->dp = dp;
 		port->id = i;
Signature · 1 line
2.49.0
#19 lore raw

PATCH v8 9/10 arm64: dts: rockchip: Add missing dp_out port for RK3399 CDN-DP

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

Let's make the ports nodes of cdn_dp in the same style as the other display interface, and match the style of ports's yaml.

---

(no changes since v5)

Changes in v4:
- Remove unnecessary #address/#size-cells

(no changes since v1)

 arch/arm64/boot/dts/rockchip/rk3399-base.dtsi | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3399-base.dtsi +9 -1
index 4dcceb9136b7..93b42820998f 100644
@@ -618,7 +618,11 @@ cdn_dp: dp@fec00000 {
 		status = "disabled";
 
 		ports {
-			dp_in: port {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			dp_in: port@0 {
+				reg = <0>;
 				#address-cells = <1>;
 				#size-cells = <0>;
 
@@ -632,6 +636,10 @@ dp_in_vopl: endpoint@1 {
 					remote-endpoint = <&vopl_out_dp>;
 				};
 			};
+
+			dp_out: port@1 {
+				reg = <1>;
+			};
 		};
 	};
 
Signature · 1 line
2.49.0
#20 lore raw

PATCH v8 10/10 arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

The RK3399 EVB IND board has a Type-C interface DisplayPort. It use fusb302 chip as Type-C controller.

fusb302 chip ---> USB/DP PHY0 <----> CDN-DP controller

---

(no changes since v4)

Changes in v3:
- Fix wrong vdo value.
- Fix port node in usb-c-connector.

Changes in v2:
- Add endpoint to link DP PHY and DP controller.
- Fix devicetree coding style.

 .../boot/dts/rockchip/rk3399-evb-ind.dts      | 146 ++++++++++++++++++
 1 file changed, 146 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +146 -0
index 70aee1ab904c..aeeee6bd2973 100644
@@ -4,6 +4,7 @@
  */
 
 /dts-v1/;
+#include <dt-bindings/usb/pd.h>
 #include "rk3399.dtsi"
 
 / {
@@ -19,6 +20,21 @@ chosen {
 		stdout-path = "serial2:1500000n8";
 	};
 
+	sound: sound {
+		compatible = "rockchip,rk3399-gru-sound";
+		rockchip,cpu = <&i2s0 &spdif>;
+	};
+
+	vbus_typec: regulator-vbus-typec {
+		compatible = "regulator-fixed";
+		enable-active-high;
+		gpio = <&gpio1 RK_PC2 GPIO_ACTIVE_HIGH>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&vcc5v0_typec0_en>;
+		regulator-name = "vbus_typec";
+		vin-supply = <&vcc5v0_sys>;
+	};
+
 	vcc5v0_sys: regulator-vcc5v0-sys {
 		compatible = "regulator-fixed";
 		enable-active-high;
@@ -31,6 +47,11 @@ vcc5v0_sys: regulator-vcc5v0-sys {
 	};
 };
 
+&cdn_dp {
+	phys = <&tcphy0_dp>;
+	status = "okay";
+};
+
 &cpu_b0 {
 	cpu-supply = <&vdd_cpu_b>;
 };
@@ -55,6 +76,12 @@ &cpu_l3 {
 	cpu-supply = <&vdd_cpu_l>;
 };
 
+&dp_out {
+	dp_controller_output: endpoint {
+		remote-endpoint = <&dp_phy_in>;
+	};
+};
+
 &emmc_phy {
 	status = "okay";
 };
@@ -341,6 +368,71 @@ regulator-state-mem {
 	};
 };
 
+&i2c4 {
+	i2c-scl-rising-time-ns = <475>;
+	i2c-scl-falling-time-ns = <26>;
+	status = "okay";
+
+	usbc0: typec-portc@22 {
+		compatible = "fcs,fusb302";
+		reg = <0x22>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <RK_PA2 IRQ_TYPE_LEVEL_LOW>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&usbc0_int>;
+		vbus-supply = <&vbus_typec>;
+
+		usb_con: connector {
+			compatible = "usb-c-connector";
+			label = "USB-C";
+			data-role = "dual";
+			power-role = "dual";
+			try-power-role = "sink";
+			op-sink-microwatt = <1000000>;
+			sink-pdos =
+				<PDO_FIXED(5000, 2500, PDO_FIXED_USB_COMM)>;
+			source-pdos =
+				<PDO_FIXED(5000, 1500, PDO_FIXED_USB_COMM)>;
+
+			altmodes {
+				displayport {
+					svid = /bits/ 16 <0xff01>;
+					vdo = <0x00001c46>;
+				};
+			};
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+
+					usbc_hs: endpoint {
+						remote-endpoint = <&u2phy0_typec_hs>;
+					};
+				};
+
+				port@1 {
+					reg = <1>;
+
+					usbc_ss: endpoint {
+						remote-endpoint = <&tcphy0_typec_ss>;
+					};
+				};
+
+				port@2 {
+					reg = <2>;
+
+					usbc_dp: endpoint {
+						remote-endpoint = <&tcphy0_typec_dp>;
+					};
+				};
+			};
+		};
+	};
+};
+
 &i2s2 {
 	status = "okay";
 };
@@ -354,6 +446,16 @@ &io_domains {
 };
 
 &pinctrl {
+	usb-typec {
+		usbc0_int: usbc0-int {
+			rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>;
+		};
+
+		vcc5v0_typec0_en: vcc5v0-typec0-en {
+			rockchip,pins = <1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
+
 	pmic {
 		pmic_int_l: pmic-int-l {
 			rockchip,pins = <1 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>;
@@ -400,10 +502,48 @@ &sdmmc {
 	status = "okay";
 };
 
+&sound {
+	rockchip,codec = <&cdn_dp>;
+	status = "okay";
+};
+
+&spdif {
+	status = "okay";
+};
+
 &tcphy0 {
 	status = "okay";
 };
 
+&tcphy0_dp {
+	mode-switch;
+
+	port {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		tcphy0_typec_dp: endpoint@0 {
+			reg = <0>;
+			remote-endpoint = <&usbc_dp>;
+		};
+
+		dp_phy_in: endpoint@1 {
+			reg = <1>;
+			remote-endpoint = <&dp_controller_output>;
+		};
+	};
+};
+
+&tcphy0_usb3 {
+	orientation-switch;
+
+	port {
+		tcphy0_typec_ss: endpoint {
+			remote-endpoint = <&usbc_ss>;
+		};
+	};
+};
+
 &tcphy1 {
 	status = "okay";
 };
@@ -418,6 +558,12 @@ &tsadc {
 
 &u2phy0 {
 	status = "okay";
+
+	port {
+		u2phy0_typec_hs: endpoint {
+			remote-endpoint = <&usbc_hs>;
+		};
+	};
 };
 
 &u2phy0_host {
Signature · 1 line
2.49.0
#21 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Quoted 35 lines

+&i2c4 {

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +34 -0
+       i2c-scl-rising-time-ns = <475>;
+       i2c-scl-falling-time-ns = <26>;
+       status = "okay";
+
+       usbc0: typec-portc@22 {
+               compatible = "fcs,fusb302";
+               reg = <0x22>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <RK_PA2 IRQ_TYPE_LEVEL_LOW>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&usbc0_int>;
+               vbus-supply = <&vbus_typec>;
+
+               usb_con: connector {
+                       compatible = "usb-c-connector";
+                       label = "USB-C";
+                       data-role = "dual";
+                       power-role = "dual";
+                       try-power-role = "sink";
+                       op-sink-microwatt = <1000000>;
+                       sink-pdos =
+                               <PDO_FIXED(5000, 2500, PDO_FIXED_USB_COMM)>;
+                       source-pdos =
+                               <PDO_FIXED(5000, 1500, PDO_FIXED_USB_COMM)>;
+
+                       altmodes {
+                               displayport {
+                                       svid = /bits/ 16 <0xff01>;
+                                       vdo = <0x00001c46>;
+                               };
+                       };
+
+                       ports {
+                               #address-cells = <1>;

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts regulator-state-mem { · line 415

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +10 -0
+                               #size-cells = <0>;
+
+                               port@0 {
+                                       reg = <0>;
+
+                                       usbc_hs: endpoint {
+                                               remote-endpoint = <&u2phy0_typec_hs>;
+                                       };
+                               };
+

Why USB2 PHY needs to be notified for Type-C connection?

Quoted 20 lines
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +20 -0
+                               port@1 {
+                                       reg = <1>;
+
+                                       usbc_ss: endpoint {
+                                               remote-endpoint = <&tcphy0_typec_ss>;
+                                       };
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+
+                                       usbc_dp: endpoint {
+                                               remote-endpoint = <&tcphy0_typec_dp>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+

.....

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts &tsadc { · line 567

Quoted 11 lines
 &u2phy0 {
        status = "okay";
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +6 -0
+
+       port {
+               u2phy0_typec_hs: endpoint {
+                       remote-endpoint = <&usbc_hs>;
+               };
+       };
 };

There is no switch and mux, how to co-work with Type-C?

Best regards,
Peter

#22 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Hi Peter,

Quoted 38 lines · Peter Chen
Quoted 38 lines

+&i2c4 {

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +37 -0
+       i2c-scl-rising-time-ns = <475>;
+       i2c-scl-falling-time-ns = <26>;
+       status = "okay";
+
+       usbc0: typec-portc@22 {
+               compatible = "fcs,fusb302";
+               reg = <0x22>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <RK_PA2 IRQ_TYPE_LEVEL_LOW>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&usbc0_int>;
+               vbus-supply = <&vbus_typec>;
+
+               usb_con: connector {
+                       compatible = "usb-c-connector";
+                       label = "USB-C";
+                       data-role = "dual";
+                       power-role = "dual";
+                       try-power-role = "sink";
+                       op-sink-microwatt = <1000000>;
+                       sink-pdos =
+                               <PDO_FIXED(5000, 2500, PDO_FIXED_USB_COMM)>;
+                       source-pdos =
+                               <PDO_FIXED(5000, 1500, PDO_FIXED_USB_COMM)>;
+
+                       altmodes {
+                               displayport {
+                                       svid = /bits/ 16 <0xff01>;
+                                       vdo = <0x00001c46>;
+                               };
+                       };
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@0 {
Quoted 8 lines

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts regulator-state-mem { · line 415

Quoted 7 lines
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +7 -0
+                                       reg = <0>;
+
+                                       usbc_hs: endpoint {
+                                               remote-endpoint = <&u2phy0_typec_hs>;
+                                       };
+                               };
+

Why USB2 PHY needs to be notified for Type-C connection?

I think the USB-connector binding require a port@0 for High Speed.  So I filled in USB2 PHY here. And I have looked up boards with the same usage, and some of the results are as follows:

- rk3399-firefly.dts

- rk3399-pinebook-pro.dts

- rk3399-eaidk-610.dts

Quoted 32 lines
Quoted 21 lines
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +20 -0
+                               port@1 {
+                                       reg = <1>;
+
+                                       usbc_ss: endpoint {
+                                               remote-endpoint = <&tcphy0_typec_ss>;
+                                       };
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+
+                                       usbc_dp: endpoint {
+                                               remote-endpoint = <&tcphy0_typec_dp>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+

.....

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts &tsadc { · line 567

Quoted 10 lines
  &u2phy0 {
         status = "okay";
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +6 -0
+
+       port {
+               u2phy0_typec_hs: endpoint {
+                       remote-endpoint = <&usbc_hs>;
+               };
+       };
  };
Quoted 1 line

There is no switch and mux, how to co-work with Type-C?

I checked the phy-rockchip-inno-usb2.c but did not find any switch or mux. Does this mean that we need to implement them? Thank you.

Quoted 5 lines

Best regards,
Peter

Signature · 2 lines
Best,
Chaoyi
#23 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Quoted 91 lines · Chaoyi Chen

Hi Peter,

Quoted 38 lines · Peter Chen
Quoted 38 lines

+&i2c4 {
+       i2c-scl-rising-time-ns = <475>;
+       i2c-scl-falling-time-ns = <26>;
+       status = "okay";

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +34 -0
+
+       usbc0: typec-portc@22 {
+               compatible = "fcs,fusb302";
+               reg = <0x22>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <RK_PA2 IRQ_TYPE_LEVEL_LOW>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&usbc0_int>;
+               vbus-supply = <&vbus_typec>;
+
+               usb_con: connector {
+                       compatible = "usb-c-connector";
+                       label = "USB-C";
+                       data-role = "dual";
+                       power-role = "dual";
+                       try-power-role = "sink";
+                       op-sink-microwatt = <1000000>;
+                       sink-pdos =
+                               <PDO_FIXED(5000, 2500, PDO_FIXED_USB_COMM)>;
+                       source-pdos =
+                               <PDO_FIXED(5000, 1500, PDO_FIXED_USB_COMM)>;
+
+                       altmodes {
+                               displayport {
+                                       svid = /bits/ 16 <0xff01>;
+                                       vdo = <0x00001c46>;
+                               };
+                       };
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@0 {
Quoted 8 lines

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts regulator-state-mem { · line 415

Quoted 7 lines

+                                       reg = <0>;

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +6 -0
+
+                                       usbc_hs: endpoint {
+ remote-endpoint = <&u2phy0_typec_hs>;
+                                       };
+                               };
+

Why USB2 PHY needs to be notified for Type-C connection?

I think the USB-connector binding require a port@0 for High Speed.  So I filled in USB2 PHY here. And I have looked up boards with the same usage, and some of the results are as follows:

- rk3399-firefly.dts

- rk3399-pinebook-pro.dts

- rk3399-eaidk-610.dts

Quoted 32 lines
Quoted 21 lines

+                               port@1 {
+                                       reg = <1>;

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +18 -0
+
+                                       usbc_ss: endpoint {
+ remote-endpoint = <&tcphy0_typec_ss>;
+                                       };
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+
+                                       usbc_dp: endpoint {
+ remote-endpoint = <&tcphy0_typec_dp>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+

.....

Quoted 10 lines

  &u2phy0 {
         status = "okay";
+
+       port {
+               u2phy0_typec_hs: endpoint {
+                       remote-endpoint = <&usbc_hs>; +               };
+       };
  };

Quoted 3 lines
Quoted 1 line

There is no switch and mux, how to co-work with Type-C?

I checked the phy-rockchip-inno-usb2.c but did not find any switch or mux. Does this mean that we need to implement them? Thank you.

Wait a minute, actually we have multiple hardware interfaces, one of which is Type-C, eventually connected to USBDPPHY, and the other is micro-usb connected to U2PHY.

Quoted 7 lines
Quoted 7 lines

Best regards,
Peter

Signature · 2 lines
Best,
Chaoyi
#24 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Quoted 53 lines · Chaoyi Chen
Quoted 50 lines · Chaoyi Chen

Hi Peter,

Quoted 46 lines · Peter Chen
Quoted 35 lines

+&i2c4 {

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +34 -0
+       i2c-scl-rising-time-ns = <475>;
+       i2c-scl-falling-time-ns = <26>;
+       status = "okay";
+
+       usbc0: typec-portc@22 {
+               compatible = "fcs,fusb302";
+               reg = <0x22>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <RK_PA2 IRQ_TYPE_LEVEL_LOW>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&usbc0_int>;
+               vbus-supply = <&vbus_typec>;
+
+               usb_con: connector {
+                       compatible = "usb-c-connector";
+                       label = "USB-C";
+                       data-role = "dual";
+                       power-role = "dual";
+                       try-power-role = "sink";
+                       op-sink-microwatt = <1000000>;
+                       sink-pdos =
+                               <PDO_FIXED(5000, 2500, PDO_FIXED_USB_COMM)>;
+                       source-pdos =
+                               <PDO_FIXED(5000, 1500, PDO_FIXED_USB_COMM)>;
+
+                       altmodes {
+                               displayport {
+                                       svid = /bits/ 16 <0xff01>;
+                                       vdo = <0x00001c46>;
+                               };
+                       };
+
+                       ports {
+                               #address-cells = <1>;

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts regulator-state-mem { · line 415

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +10 -0
+                               #size-cells = <0>;
+
+                               port@0 {
+                                       reg = <0>;
+
+                                       usbc_hs: endpoint {
+ remote-endpoint = <&u2phy0_typec_hs>;
+                                       };
+                               };
+

Why USB2 PHY needs to be notified for Type-C connection?

Quoted 8 lines
Quoted 8 lines

I think the USB-connector binding require a port@0 for High Speed. So I filled in USB2 PHY here. And I have looked up boards with the same usage, and some of the results are as follows:

- rk3399-firefly.dts

- rk3399-pinebook-pro.dts

- rk3399-eaidk-610.dts

Okay. My question is basic: USB2 PHY supplies DP/DM, and the DP/DM is short for Type-C connector,
and no control is needed for Type-C application.
Why is there a remote-endpoint connection between USB2 PHY and Type-C connector?

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 22 lines
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +20 -0
+                               port@1 {
+                                       reg = <1>;
+
+                                       usbc_ss: endpoint {
+ remote-endpoint = <&tcphy0_typec_ss>;
+                                       };
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+
+                                       usbc_dp: endpoint {
+ remote-endpoint = <&tcphy0_typec_dp>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+

.....

Quoted 10 lines
  &u2phy0 {
         status = "okay";
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +6 -0
+
+       port {
+               u2phy0_typec_hs: endpoint {
+                       remote-endpoint = <&usbc_hs>;
+               };
+       };
  };
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

There is no switch and mux, how to co-work with Type-C?

I checked the phy-rockchip-inno-usb2.c but did not find any switch or mux. Does this mean that we need to implement them? Thank you.

Wait a minute, actually we have multiple hardware interfaces, one of which is Type-C, eventually connected to USBDPPHY, and the other is micro-usb connected to U2PHY.

I assume the Micro-USB connector does not use Type-C/PD IC, is it right? Does it relate to this patch?

Best regards,
Peter

#25 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Hi Peter,

Quoted 56 lines · Peter Chen
Quoted 55 lines · Chaoyi Chen
Quoted 53 lines · Chaoyi Chen

Hi Peter,

Quoted 38 lines · Peter Chen
Quoted 38 lines

+&i2c4 {

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +37 -0
+       i2c-scl-rising-time-ns = <475>;
+       i2c-scl-falling-time-ns = <26>;
+       status = "okay";
+
+       usbc0: typec-portc@22 {
+               compatible = "fcs,fusb302";
+               reg = <0x22>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <RK_PA2 IRQ_TYPE_LEVEL_LOW>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&usbc0_int>;
+               vbus-supply = <&vbus_typec>;
+
+               usb_con: connector {
+                       compatible = "usb-c-connector";
+                       label = "USB-C";
+                       data-role = "dual";
+                       power-role = "dual";
+                       try-power-role = "sink";
+                       op-sink-microwatt = <1000000>;
+                       sink-pdos =
+                               <PDO_FIXED(5000, 2500, PDO_FIXED_USB_COMM)>;
+                       source-pdos =
+                               <PDO_FIXED(5000, 1500, PDO_FIXED_USB_COMM)>;
+
+                       altmodes {
+                               displayport {
+                                       svid = /bits/ 16 <0xff01>;
+                                       vdo = <0x00001c46>;
+                               };
+                       };
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@0 {
Quoted 8 lines

arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts regulator-state-mem { · line 415

Quoted 7 lines
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +7 -0
+                                       reg = <0>;
+
+                                       usbc_hs: endpoint {
+ remote-endpoint = <&u2phy0_typec_hs>;
+                                       };
+                               };
+

Why USB2 PHY needs to be notified for Type-C connection?

I think the USB-connector binding require a port@0 for High Speed. So I filled in USB2 PHY here. And I have looked up boards with the same usage, and some of the results are as follows:

- rk3399-firefly.dts

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

- rk3399-pinebook-pro.dts

- rk3399-eaidk-610.dts

Okay. My question is basic: USB2 PHY supplies DP/DM, and the DP/DM is short for Type-C connector,
and no control is needed for Type-C application.
Why is there a remote-endpoint connection between USB2 PHY and Type-C connector?

From the perspective of Type-C, this should not be added.  Is the approach in v2 correct [0] ?

[0]: https://lore.kernel.org/all/[email protected]/

Or is the following approach correct?

port@0 {
    reg = <0>;

    usbc_hs: endpoint {
        remote-endpoint = <&tcphy0>;
    };
};

port@1 {
    reg = <1>;

    usbc_ss: endpoint {
        remote-endpoint = <&tcphy0>;
    };
};

port@2 {
    reg = <2>;

    usbc_dp: endpoint {
        remote-endpoint = <&tcphy0_typec_dp>;
    };
};

Quoted 41 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 21 lines
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +20 -0
+                               port@1 {
+                                       reg = <1>;
+
+                                       usbc_ss: endpoint {
+ remote-endpoint = <&tcphy0_typec_ss>;
+                                       };
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+
+                                       usbc_dp: endpoint {
+ remote-endpoint = <&tcphy0_typec_dp>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+

.....

Quoted 10 lines
   &u2phy0 {
          status = "okay";
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +6 -0
+
+       port {
+               u2phy0_typec_hs: endpoint {
+                       remote-endpoint = <&usbc_hs>;
+               };
+       };
   };
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

There is no switch and mux, how to co-work with Type-C?

I checked the phy-rockchip-inno-usb2.c but did not find any switch or mux. Does this mean that we need to implement them? Thank you.

Wait a minute, actually we have multiple hardware interfaces, one of which is Type-C, eventually connected to USBDPPHY, and the other is micro-usb connected to U2PHY.

I assume the Micro-USB connector does not use Type-C/PD IC, is it right? Does it relate to this patch?

Best regards,
Peter

#26 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Quoted 7 lines
Quoted 4 lines

Okay. My question is basic: USB2 PHY supplies DP/DM, and the DP/DM is short for Type-C connector,
and no control is needed for Type-C application.
Why is there a remote-endpoint connection between USB2 PHY and Type-C connector?

From the perspective of Type-C, this should not be added. Is the approach in v2 correct [0] ?

Have you tried debugging based on upstream code?
v2 is correct, but the dts needs to improve.
- There is a remote-endpoint connection for USB role switch between Type-C connector
device and USB controller device
- There is a remote-endpoint connection for orientation and lane configuration between Type-C connector device and USB/DP PHY device.

Peter

Quoted 72 lines

[0]: https://lore.kernel.org/all/[email protected]/

Or is the following approach correct?

port@0 {
     reg = <0>;

     usbc_hs: endpoint {
         remote-endpoint = <&tcphy0>;
     };
};
port@1 {
     reg = <1>;

     usbc_ss: endpoint {
         remote-endpoint = <&tcphy0>;
     };
};
port@2 {
     reg = <2>;

     usbc_dp: endpoint {
         remote-endpoint = <&tcphy0_typec_dp>;
     };
};
Quoted 41 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 21 lines
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +20 -0
+                               port@1 {
+                                       reg = <1>;
+
+                                       usbc_ss: endpoint {
+ remote-endpoint = <&tcphy0_typec_ss>;
+                                       };
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+
+                                       usbc_dp: endpoint {
+ remote-endpoint = <&tcphy0_typec_dp>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+

.....

Quoted 10 lines
   &u2phy0 {
          status = "okay";
arch/arm64/boot/dts/rockchip/rk3399-evb-ind.dts +6 -0
+
+       port {
+               u2phy0_typec_hs: endpoint {
+                       remote-endpoint = <&usbc_hs>;
+               };
+       };
   };
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

There is no switch and mux, how to co-work with Type-C?

I checked the phy-rockchip-inno-usb2.c but did not find any switch or mux. Does this mean that we need to implement them? Thank you.

Wait a minute, actually we have multiple hardware interfaces, one of which is Type-C, eventually connected to USBDPPHY, and the other is micro-usb connected to U2PHY.

I assume the Micro-USB connector does not use Type-C/PD IC, is it right? Does it relate to this patch?

Best regards,
Peter

#27 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Quoted 7 lines · Peter Chen
Quoted 6 lines
Quoted 4 lines

Okay. My question is basic: USB2 PHY supplies DP/DM, and the DP/DM is short for Type-C connector,
and no control is needed for Type-C application.
Why is there a remote-endpoint connection between USB2 PHY and Type-C connector?

From the perspective of Type-C, this should not be added. Is the approach in v2 correct [0] ?

Have you tried debugging based on upstream code?

Yes, I have tried both the v2 and v8 approaches, and both can work.

Quoted 6 lines

v2 is correct, but the dts needs to improve.
- There is a remote-endpoint connection for USB role switch between Type-C connector
device and USB controller device
- There is a remote-endpoint connection for orientation and lane configuration between Type-C connector device and USB/DP PHY device.

In v8 patch5, we implemented typec_mux and typec_switch in the USB/DP PHY.

I think the current remote-endpoint connections are all child node of the USB/DP PHY. That is:

&tcphy0_dp {
    mode-switch;
    ...
};

&tcphy0_usb3 {
    orientation-switch;
    ...
};

Does this still need to be improved? Thank you.

Quoted 74 lines

Peter

Quoted 70 lines

[0]: https://lore.kernel.org/all/[email protected]/

Or is the following approach correct?

port@0 {
      reg = <0>;

      usbc_hs: endpoint {
          remote-endpoint = <&tcphy0>;
      };
};
port@1 {
      reg = <1>;

      usbc_ss: endpoint {
          remote-endpoint = <&tcphy0>;
      };
};
port@2 {
      reg = <2>;

      usbc_dp: endpoint {
          remote-endpoint = <&tcphy0_typec_dp>;
      };
};
Quoted 40 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 20 lines
(quoted diff) +20 -0
+                               port@1 {
+                                       reg = <1>;
+
+                                       usbc_ss: endpoint {
+ remote-endpoint = <&tcphy0_typec_ss>;
+                                       };
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+
+                                       usbc_dp: endpoint {
+ remote-endpoint = <&tcphy0_typec_dp>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+

.....

Quoted 10 lines
    &u2phy0 {
           status = "okay";
(quoted diff) +6 -0
+
+       port {
+               u2phy0_typec_hs: endpoint {
+                       remote-endpoint = <&usbc_hs>;
+               };
+       };
    };
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

There is no switch and mux, how to co-work with Type-C?

I checked the phy-rockchip-inno-usb2.c but did not find any switch or mux. Does this mean that we need to implement them? Thank you.

Wait a minute, actually we have multiple hardware interfaces, one of which is Type-C, eventually connected to USBDPPHY, and the other is micro-usb connected to U2PHY.

I assume the Micro-USB connector does not use Type-C/PD IC, is it right? Does it relate to this patch?

Best regards,
Peter

Signature · 2 lines
Best,
Chaoyi
#28 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Quoted 32 lines · Chaoyi Chen
Quoted 7 lines · Peter Chen
Quoted 6 lines
Quoted 4 lines

Okay. My question is basic: USB2 PHY supplies DP/DM, and the DP/DM is short for Type-C connector,
and no control is needed for Type-C application.
Why is there a remote-endpoint connection between USB2 PHY and Type-C connector?

From the perspective of Type-C, this should not be added. Is the approach in v2 correct [0] ?

Have you tried debugging based on upstream code?

Yes, I have tried both the v2 and v8 approaches, and both can work.

Quoted 6 lines

v2 is correct, but the dts needs to improve.
- There is a remote-endpoint connection for USB role switch between Type-C connector
device and USB controller device
- There is a remote-endpoint connection for orientation and lane configuration between Type-C connector device and USB/DP PHY device.

In v8 patch5, we implemented typec_mux and typec_switch in the USB/DP PHY.

I think the current remote-endpoint connections are all child node of the USB/DP PHY. That is:

&tcphy0_dp {
     mode-switch;
     ...
};
Quoted 8 lines
&tcphy0_usb3 {
     orientation-switch;
     ...
};

Does this still need to be improved? Thank you.

Hi Chaoyi,

There are two questions I have still not seen the answer to:
- Why USB2 PHY is related to your Type-C patch?
- How does the USB role switch event notify the USB controller driver, eg dwc3?

Peter

Quoted 79 lines
Quoted 75 lines

Peter

Quoted 70 lines

[0]: https://lore.kernel.org/all/[email protected]/

Or is the following approach correct?

port@0 {
      reg = <0>;

      usbc_hs: endpoint {
          remote-endpoint = <&tcphy0>;
      };
};
port@1 {
      reg = <1>;

      usbc_ss: endpoint {
          remote-endpoint = <&tcphy0>;
      };
};
port@2 {
      reg = <2>;

      usbc_dp: endpoint {
          remote-endpoint = <&tcphy0_typec_dp>;
      };
};
Quoted 40 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 20 lines
(quoted diff) +20 -0
+                               port@1 {
+                                       reg = <1>;
+
+                                       usbc_ss: endpoint {
+ remote-endpoint = <&tcphy0_typec_ss>;
+                                       };
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+
+                                       usbc_dp: endpoint {
+ remote-endpoint = <&tcphy0_typec_dp>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+

.....

Quoted 10 lines
    &u2phy0 {
           status = "okay";
(quoted diff) +6 -0
+
+       port {
+               u2phy0_typec_hs: endpoint {
+                       remote-endpoint = <&usbc_hs>;
+               };
+       };
    };
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

There is no switch and mux, how to co-work with Type-C?

I checked the phy-rockchip-inno-usb2.c but did not find any switch or mux. Does this mean that we need to implement them? Thank you.

Wait a minute, actually we have multiple hardware interfaces, one of which is Type-C, eventually connected to USBDPPHY, and the other is micro-usb connected to U2PHY.

I assume the Micro-USB connector does not use Type-C/PD IC, is it right? Does it relate to this patch?

Best regards,
Peter

--
Best,
Chaoyi

#29 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Quoted 36 lines · Peter Chen
Quoted 35 lines · Chaoyi Chen
Quoted 7 lines · Peter Chen
Quoted 6 lines
Quoted 4 lines

Okay. My question is basic: USB2 PHY supplies DP/DM, and the DP/DM is short for Type-C connector,
and no control is needed for Type-C application.
Why is there a remote-endpoint connection between USB2 PHY and Type-C connector?

From the perspective of Type-C, this should not be added. Is the approach in v2 correct [0] ?

Have you tried debugging based on upstream code?

Yes, I have tried both the v2 and v8 approaches, and both can work.

Quoted 6 lines

v2 is correct, but the dts needs to improve.
- There is a remote-endpoint connection for USB role switch between Type-C connector
device and USB controller device
- There is a remote-endpoint connection for orientation and lane configuration between Type-C connector device and USB/DP PHY device.

In v8 patch5, we implemented typec_mux and typec_switch in the USB/DP PHY.

I think the current remote-endpoint connections are all child node of the USB/DP PHY. That is:

&tcphy0_dp {
      mode-switch;
      ...
};
&tcphy0_usb3 {
      orientation-switch;
      ...
};
Quoted 6 lines
Quoted 2 lines

Does this still need to be improved? Thank you.

Hi Chaoyi,

There are two questions I have still not seen the answer to:
- Why USB2 PHY is related to your Type-C patch?

I was just following other people's approach. Sorry, this should be removed from the dts.

Quoted 1 line

- How does the USB role switch event notify the USB controller driver, eg dwc3?

Sorry, I misunderstood what you said before. There is indeed a missing usb-role-switch now. I referred to the approach in rk3588-evb1-v10.dts. Is the following way of writing correct?

&usbc_connector {
    ports {
        #address-cells = <1>;
        #size-cells = <0>;

        port@0 {
            reg = <0>;

            usbc_orien_sw: endpoint { remote-endpoint = <&tcphy0_typec_orien_sw>; };
        };

        port@1 {
            reg = <1>;

            usbc_role_sw: endpoint { remote-endpoint = <&dwc3_0_role_switch>; };
        };

        port@2 {
            reg = <2>;

            usbc_dp: endpoint { remote-endpoint = <&tcphy0_typec_dp>; };
        };
    };
};

&usbdrd_dwc3_0 {
    status = "okay";
    usb-role-switch;

    port {
        #address-cells = <1>;
        #size-cells = <0>;
        dwc3_0_role_switch: endpoint@0 {
            reg = <0>;
            remote-endpoint = <&usbc_role_sw>;
        };
    };
};

&tcphy0_usb3 {
    orientation-switch;

    port {
        tcphy0_typec_orien_sw: endpoint {
            remote-endpoint = <&usbc_orien_sw>;
        };
    };
};

&tcphy0_dp {
    mode-switch;

    port {
        #address-cells = <1>;
        #size-cells = <0>;

        tcphy0_typec_dp: endpoint@0 {
            reg = <0>;
            remote-endpoint = <&usbc_dp>;
        };
    };
};

Quoted 78 lines

Peter

Quoted 76 lines
Quoted 72 lines

Peter

Quoted 70 lines

[0]: https://lore.kernel.org/all/[email protected]/

Or is the following approach correct?

port@0 {
       reg = <0>;

       usbc_hs: endpoint {
           remote-endpoint = <&tcphy0>;
       };
};
port@1 {
       reg = <1>;

       usbc_ss: endpoint {
           remote-endpoint = <&tcphy0>;
       };
};
port@2 {
       reg = <2>;

       usbc_dp: endpoint {
           remote-endpoint = <&tcphy0_typec_dp>;
       };
};
Quoted 40 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 20 lines
(quoted diff) +20 -0
+                               port@1 {
+                                       reg = <1>;
+
+                                       usbc_ss: endpoint {
+ remote-endpoint = <&tcphy0_typec_ss>;
+                                       };
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+
+                                       usbc_dp: endpoint {
+ remote-endpoint = <&tcphy0_typec_dp>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+

.....

Quoted 10 lines
     &u2phy0 {
            status = "okay";
(quoted diff) +6 -0
+
+       port {
+               u2phy0_typec_hs: endpoint {
+                       remote-endpoint = <&usbc_hs>;
+               };
+       };
     };
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

There is no switch and mux, how to co-work with Type-C?

I checked the phy-rockchip-inno-usb2.c but did not find any switch or mux. Does this mean that we need to implement them? Thank you.

Wait a minute, actually we have multiple hardware interfaces, one of which is Type-C, eventually connected to USBDPPHY, and the other is micro-usb connected to U2PHY.

I assume the Micro-USB connector does not use Type-C/PD IC, is it right? Does it relate to this patch?

Best regards,
Peter

--
Best,
Chaoyi

Signature · 2 lines
Best,
Chaoyi
#30 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Quoted 75 lines · Chaoyi Chen
Quoted 4 lines

Hi Chaoyi,

There are two questions I have still not seen the answer to:
- Why USB2 PHY is related to your Type-C patch?

I was just following other people's approach. Sorry, this should be removed from the dts.

Quoted 1 line

- How does the USB role switch event notify the USB controller driver, eg dwc3?

Sorry, I misunderstood what you said before. There is indeed a missing usb-role-switch now. I referred to the approach in rk3588-evb1-v10.dts. Is the following way of writing correct?

&usbc_connector {
    ports {
        #address-cells = <1>;
        #size-cells = <0>;

        port@0 {
            reg = <0>;

            usbc_orien_sw: endpoint { remote-endpoint = <&tcphy0_typec_orien_sw>; };
        };

        port@1 {
            reg = <1>;

            usbc_role_sw: endpoint { remote-endpoint = <&dwc3_0_role_switch>; };
        };

        port@2 {
            reg = <2>;

            usbc_dp: endpoint { remote-endpoint = <&tcphy0_typec_dp>; };
        };
    };
};

&usbdrd_dwc3_0 {
    status = "okay";
    usb-role-switch;

    port {
        #address-cells = <1>;
        #size-cells = <0>;
        dwc3_0_role_switch: endpoint@0 {
            reg = <0>;
            remote-endpoint = <&usbc_role_sw>;
        };
    };
};

&tcphy0_usb3 {
    orientation-switch;

    port {
        tcphy0_typec_orien_sw: endpoint {
            remote-endpoint = <&usbc_orien_sw>;
        };
    };
};

&tcphy0_dp {
    mode-switch;

    port {
        #address-cells = <1>;
        #size-cells = <0>;

Quoted 7 lines

        tcphy0_typec_dp: endpoint@0 {
            reg = <0>;
            remote-endpoint = <&usbc_dp>;
        };
    };
};

The general hierarchy is okay, just need to fix some dts coding style issue.

Signature · 2 lines
Best regards,
Peter
#31 lore raw

Re: [PATCH v8 10/10] arm64: dts: rockchip: rk3399-evb-ind: Add support for DisplayPort

Hi Peter,

Quoted 81 lines · Peter Chen (CIX)
Quoted 73 lines · Chaoyi Chen
Quoted 4 lines

Hi Chaoyi,

There are two questions I have still not seen the answer to:
- Why USB2 PHY is related to your Type-C patch?

I was just following other people's approach. Sorry, this should be removed from the dts.

Quoted 1 line

- How does the USB role switch event notify the USB controller driver, eg dwc3?

Sorry, I misunderstood what you said before. There is indeed a missing usb-role-switch now. I referred to the approach in rk3588-evb1-v10.dts. Is the following way of writing correct?

&usbc_connector {
    ports {
        #address-cells = <1>;
        #size-cells = <0>;

        port@0 {
            reg = <0>;

            usbc_orien_sw: endpoint { remote-endpoint = <&tcphy0_typec_orien_sw>; };
        };

        port@1 {
            reg = <1>;

            usbc_role_sw: endpoint { remote-endpoint = <&dwc3_0_role_switch>; };
        };

        port@2 {
            reg = <2>;

            usbc_dp: endpoint { remote-endpoint = <&tcphy0_typec_dp>; };
        };
    };
};

&usbdrd_dwc3_0 {
    status = "okay";
    usb-role-switch;

    port {
        #address-cells = <1>;
        #size-cells = <0>;
        dwc3_0_role_switch: endpoint@0 {
            reg = <0>;
            remote-endpoint = <&usbc_role_sw>;
        };
    };
};

&tcphy0_usb3 {
    orientation-switch;

    port {
        tcphy0_typec_orien_sw: endpoint {
            remote-endpoint = <&usbc_orien_sw>;
        };
    };
};

&tcphy0_dp {
    mode-switch;

    port {
        #address-cells = <1>;
        #size-cells = <0>;

Quoted 7 lines

        tcphy0_typec_dp: endpoint@0 {
            reg = <0>;
            remote-endpoint = <&usbc_dp>;
        };
    };
};

Quoted 2 lines

The general hierarchy is okay, just need to fix some dts coding style issue.

Thank you for your explanation. I will fix this in v9.

Quoted 1 line
maintainer
#2 lore raw

Re: [PATCH v8 01/10] usb: typec: Add notifier functions

In reply to Chaoyi Chen

Hi,

include/linux/usb/typec_notify.h line 6

Quoted 12 lines
include/linux/usb/typec_notify.h new file +6 -0
new file mode 100644
index 000000000000..f3a7b5f5b05b
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __USB_TYPEC_NOTIFY
+#define __USB_TYPEC_NOTIFY
+
+#include <linux/notifier.h>

Replace that include with a forward declaration:

struct notifier_block;

include/linux/usb/typec_notify.h line 16

Quoted 9 lines
include/linux/usb/typec_notify.h new file +9 -0
+enum usb_typec_event {
+	TYPEC_ALTMODE_REGISTERED,
+	TYPEC_ALTMODE_UNREGISTERED,
+};
+
+int typec_altmode_register_notify(struct notifier_block *nb);
+int typec_altmode_unregister_notify(struct notifier_block *nb);
+
+#endif /* __USB_TYPEC_NOTIFY */

I don't see any need for a separate header file for this. Intoduce those in typec_altmode.h.

thanks,

Signature · 1 line
heikki
maintainer Reviewed-by on v8 2/10
#5 lore raw

Re: [PATCH v8 02/10] usb: typec: Export all typec device types

In reply to Chaoyi Chen

Wed, Oct 29, 2025 at 03:14:27PM +0800, Chaoyi Chen kirjoitti:

Quoted 5 lines

From: Chaoyi Chen <[email protected]>

Export all typec device types for identification.

Quoted 86 lines
---
 drivers/usb/typec/class.c |  4 ++++
 drivers/usb/typec/class.h | 10 ----------
 include/linux/usb/typec.h | 10 ++++++++++
 3 files changed, 14 insertions(+), 10 deletions(-)
drivers/usb/typec/class.c +4 -0
index 51e971bc68d1..04b55f066b06 100644
@@ -793,6 +793,7 @@ const struct device_type typec_partner_dev_type = {
 	.groups = typec_partner_groups,
 	.release = typec_partner_release,
 };
+EXPORT_SYMBOL_GPL(typec_partner_dev_type);
 
 static void typec_partner_link_device(struct typec_partner *partner, struct device *dev)
 {
@@ -1147,6 +1148,7 @@ const struct device_type typec_plug_dev_type = {
 	.groups = typec_plug_groups,
 	.release = typec_plug_release,
 };
+EXPORT_SYMBOL_GPL(typec_plug_dev_type);
 
 /**
  * typec_plug_set_num_altmodes - Set the number of available plug altmodes
@@ -1295,6 +1297,7 @@ const struct device_type typec_cable_dev_type = {
 	.groups = typec_cable_groups,
 	.release = typec_cable_release,
 };
+EXPORT_SYMBOL_GPL(typec_cable_dev_type);
 
 /**
  * typec_cable_get - Get a reference to the USB Type-C cable
@@ -2034,6 +2037,7 @@ const struct device_type typec_port_dev_type = {
 	.uevent = typec_uevent,
 	.release = typec_release,
 };
+EXPORT_SYMBOL_GPL(typec_port_dev_type);
 
 /* --------------------------------------- */
 /* Driver callbacks to report role updates */
drivers/usb/typec/class.h +0 -10
index db2fe96c48ff..f04f6987bed8 100644
@@ -87,16 +87,6 @@ struct typec_port {
 #define to_typec_cable(_dev_) container_of(_dev_, struct typec_cable, dev)
 #define to_typec_partner(_dev_) container_of(_dev_, struct typec_partner, dev)
 
-extern const struct device_type typec_partner_dev_type;
-extern const struct device_type typec_cable_dev_type;
-extern const struct device_type typec_plug_dev_type;
-extern const struct device_type typec_port_dev_type;
-
-#define is_typec_partner(dev) ((dev)->type == &typec_partner_dev_type)
-#define is_typec_cable(dev) ((dev)->type == &typec_cable_dev_type)
-#define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type)
-#define is_typec_port(dev) ((dev)->type == &typec_port_dev_type)
-
 extern const struct class typec_mux_class;
 extern const struct class retimer_class;
 extern const struct class typec_class;
include/linux/usb/typec.h +10 -0
index 309251572e2e..02fed8293415 100644
@@ -56,6 +56,16 @@ enum typec_role {
 	TYPEC_SOURCE,
 };
 
+extern const struct device_type typec_partner_dev_type;
+extern const struct device_type typec_cable_dev_type;
+extern const struct device_type typec_plug_dev_type;
+extern const struct device_type typec_port_dev_type;
+
+#define is_typec_partner(dev) ((dev)->type == &typec_partner_dev_type)
+#define is_typec_cable(dev) ((dev)->type == &typec_cable_dev_type)
+#define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type)
+#define is_typec_port(dev) ((dev)->type == &typec_port_dev_type)
+
 static inline int is_sink(enum typec_role role)
 {
 	return role == TYPEC_SINK;
Signature · 1 line
2.49.0
Signature · 1 line
heikki
maintainer
#7 lore raw

Re: [PATCH v8 03/10] drm/bridge: Implement generic USB Type-C DP HPD bridge

In reply to Chaoyi Chen

Wed, Oct 29, 2025 at 03:14:28PM +0800, Chaoyi Chen kirjoitti:

Quoted 29 lines

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.

---

Changes in v8:
- Merge generic DP HPD bridge into one module.

 drivers/gpu/drm/bridge/Kconfig                |  5 +-
 drivers/gpu/drm/bridge/Makefile               |  8 +++-
 drivers/gpu/drm/bridge/aux-hpd-bridge.c       | 23 ++++++++-
 drivers/gpu/drm/bridge/aux-hpd-bridge.h       | 13 +++++
 .../gpu/drm/bridge/aux-hpd-typec-dp-bridge.c  | 47 +++++++++++++++++++
 5 files changed, 93 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.h
 create mode 100644 drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c
drivers/gpu/drm/bridge/Kconfig +0 -0
index a250afd8d662..17257b223a28 100644

drivers/gpu/drm/bridge/Kconfig config DRM_AUX_BRIDGE · line 26

Quoted 5 lines
drivers/gpu/drm/bridge/Kconfig +1 -1
@@ -23,13 +23,16 @@ config DRM_AUX_BRIDGE
 	  build bridges chain.
 
 config DRM_AUX_HPD_BRIDGE
-	tristate
+	tristate "AUX HPD bridge support"

Don't you now need:

        depends on TYPEC || !TYPEC
Quoted 97 lines
drivers/gpu/drm/bridge/Kconfig +3 -0
 	depends on DRM_BRIDGE && OF
 	select AUXILIARY_BUS
 	help
 	  Simple bridge that terminates the bridge chain and provides HPD
 	  support.
 
+	  Specifically, if you want a default Type-C DisplayPort HPD bridge for
+	  each port of the Type-C controller, say Y here.
+
 menu "Display Interface Bridges"
 	depends on DRM && DRM_BRIDGE
 
drivers/gpu/drm/bridge/Makefile +7 -1
index c7dc03182e59..2998937444bc 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o
-obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o
+
+hpd-bridge-y := aux-hpd-bridge.o
+ifneq ($(CONFIG_TYPEC),)
+hpd-bridge-y += aux-hpd-typec-dp-bridge.o
+endif
+obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += hpd-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
drivers/gpu/drm/bridge/aux-hpd-bridge.c +22 -1
index 2e9c702c7087..11ad6dc776c7 100644
@@ -12,6 +12,8 @@
 #include <drm/drm_bridge.h>
 #include <drm/bridge/aux-bridge.h>
 
+#include "aux-hpd-bridge.h"
+
 static DEFINE_IDA(drm_aux_hpd_bridge_ida);
 
 struct drm_aux_hpd_bridge_data {
@@ -204,7 +206,26 @@ static struct auxiliary_driver drm_aux_hpd_bridge_drv = {
 	.id_table = drm_aux_hpd_bridge_table,
 	.probe = drm_aux_hpd_bridge_probe,
 };
-module_auxiliary_driver(drm_aux_hpd_bridge_drv);
+
+static int drm_aux_hpd_bridge_mod_init(void)
+{
+	int ret;
+
+	ret = auxiliary_driver_register(&drm_aux_hpd_bridge_drv);
+	if (ret)
+		return ret;
+
+	return drm_aux_hpd_typec_dp_bridge_init();
+}
+
+static void drm_aux_hpd_bridge_mod_exit(void)
+{
+	drm_aux_hpd_typec_dp_bridge_exit();
+	auxiliary_driver_unregister(&drm_aux_hpd_bridge_drv);
+}
+
+module_init(drm_aux_hpd_bridge_mod_init);
+module_exit(drm_aux_hpd_bridge_mod_exit);
 
 MODULE_AUTHOR("Dmitry Baryshkov <[email protected]>");
 MODULE_DESCRIPTION("DRM HPD bridge");
drivers/gpu/drm/bridge/aux-hpd-bridge.h new file +13 -0
new file mode 100644
index 000000000000..69364731c2f1
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef AUX_HPD_BRIDGE_H
+#define AUX_HPD_BRIDGE_H
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+int drm_aux_hpd_typec_dp_bridge_init(void);
+void drm_aux_hpd_typec_dp_bridge_exit(void);
+#else
+static inline int drm_aux_hpd_typec_dp_bridge_init(void) { return 0; }
+static inline void drm_aux_hpd_typec_dp_bridge_exit(void) { }
+#endif /* IS_REACHABLE(CONFIG_TYPEC) */
+
+#endif /* AUX_HPD_BRIDGE_H */
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +1 -0
new file mode 100644
index 000000000000..6f2a1fca0fc5
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0+

drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c line 11

Quoted 10 lines
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +10 -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>
+
+#include "aux-hpd-bridge.h"
+
+#if IS_REACHABLE(CONFIG_TYPEC)

You don't need that. You should not use ifdefs in .c files.

Quoted 38 lines
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +36 -0
+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 (is_typec_partner(&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,
+};
+
+int drm_aux_hpd_typec_dp_bridge_init(void)
+{
+	return typec_altmode_register_notify(&drm_typec_event_nb);
+}
+
+void drm_aux_hpd_typec_dp_bridge_exit(void)
+{
+	typec_altmode_unregister_notify(&drm_typec_event_nb);
+}
+#endif
Signature · 1 line
2.49.0
Signature · 1 line
heikki
#3 lore raw

Re: [PATCH v8 01/10] usb: typec: Add notifier functions

In reply to Heikki Krogerus
Quoted 18 lines · Heikki Krogerus

Hi,

include/linux/usb/typec_notify.h line 6

Quoted 12 lines
include/linux/usb/typec_notify.h new file +6 -0
new file mode 100644
index 000000000000..f3a7b5f5b05b
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __USB_TYPEC_NOTIFY
+#define __USB_TYPEC_NOTIFY
+
+#include <linux/notifier.h>

Replace that include with a forward declaration:

struct notifier_block;

Quoted 11 lines

include/linux/usb/typec_notify.h line 16

Quoted 9 lines
include/linux/usb/typec_notify.h new file +9 -0
+enum usb_typec_event {
+	TYPEC_ALTMODE_REGISTERED,
+	TYPEC_ALTMODE_UNREGISTERED,
+};
+
+int typec_altmode_register_notify(struct notifier_block *nb);
+int typec_altmode_unregister_notify(struct notifier_block *nb);
+
+#endif /* __USB_TYPEC_NOTIFY */

I don't see any need for a separate header file for this. Intoduce those in typec_altmode.h.

Will fix these in v9. Thank you.

Quoted 3 lines

thanks,

Signature · 8 lines
Best,
Chaoyi


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#8 lore raw

Re: [PATCH v8 03/10] drm/bridge: Implement generic USB Type-C DP HPD bridge

In reply to Heikki Krogerus
Quoted 139 lines · Heikki Krogerus

Wed, Oct 29, 2025 at 03:14:28PM +0800, Chaoyi Chen kirjoitti:

Quoted 29 lines

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.

---

Changes in v8:
- Merge generic DP HPD bridge into one module.

  drivers/gpu/drm/bridge/Kconfig                |  5 +-
  drivers/gpu/drm/bridge/Makefile               |  8 +++-
  drivers/gpu/drm/bridge/aux-hpd-bridge.c       | 23 ++++++++-
  drivers/gpu/drm/bridge/aux-hpd-bridge.h       | 13 +++++
  .../gpu/drm/bridge/aux-hpd-typec-dp-bridge.c  | 47 +++++++++++++++++++
  5 files changed, 93 insertions(+), 3 deletions(-)

create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.h create mode 100644 drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c

drivers/gpu/drm/bridge/Kconfig +0 -0
index a250afd8d662..17257b223a28 100644

drivers/gpu/drm/bridge/Kconfig config DRM_AUX_BRIDGE · line 26

Quoted 5 lines
drivers/gpu/drm/bridge/Kconfig +1 -1
@@ -23,13 +23,16 @@ config DRM_AUX_BRIDGE
  	  build bridges chain.
 
  config DRM_AUX_HPD_BRIDGE
-	tristate
+	tristate "AUX HPD bridge support"

Don't you now need:

         depends on TYPEC || !TYPEC
Quoted 100 lines
drivers/gpu/drm/bridge/Kconfig +3 -0
  	depends on DRM_BRIDGE && OF
  	select AUXILIARY_BUS
  	help
  	  Simple bridge that terminates the bridge chain and provides HPD
  	  support.
 
+	  Specifically, if you want a default Type-C DisplayPort HPD bridge for
+	  each port of the Type-C controller, say Y here.
+
  menu "Display Interface Bridges"
  	depends on DRM && DRM_BRIDGE
 
drivers/gpu/drm/bridge/Makefile +7 -1
index c7dc03182e59..2998937444bc 100644
@@ -1,6 +1,12 @@
  # SPDX-License-Identifier: GPL-2.0
  obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o
-obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o
+
+hpd-bridge-y := aux-hpd-bridge.o
+ifneq ($(CONFIG_TYPEC),)
+hpd-bridge-y += aux-hpd-typec-dp-bridge.o
+endif
+obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += hpd-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
drivers/gpu/drm/bridge/aux-hpd-bridge.c +22 -1
index 2e9c702c7087..11ad6dc776c7 100644
@@ -12,6 +12,8 @@
  #include <drm/drm_bridge.h>
  #include <drm/bridge/aux-bridge.h>
 
+#include "aux-hpd-bridge.h"
+
  static DEFINE_IDA(drm_aux_hpd_bridge_ida);
 
  struct drm_aux_hpd_bridge_data {
@@ -204,7 +206,26 @@ static struct auxiliary_driver drm_aux_hpd_bridge_drv = {
  	.id_table = drm_aux_hpd_bridge_table,
  	.probe = drm_aux_hpd_bridge_probe,
  };
-module_auxiliary_driver(drm_aux_hpd_bridge_drv);
+
+static int drm_aux_hpd_bridge_mod_init(void)
+{
+	int ret;
+
+	ret = auxiliary_driver_register(&drm_aux_hpd_bridge_drv);
+	if (ret)
+		return ret;
+
+	return drm_aux_hpd_typec_dp_bridge_init();
+}
+
+static void drm_aux_hpd_bridge_mod_exit(void)
+{
+	drm_aux_hpd_typec_dp_bridge_exit();
+	auxiliary_driver_unregister(&drm_aux_hpd_bridge_drv);
+}
+
+module_init(drm_aux_hpd_bridge_mod_init);
+module_exit(drm_aux_hpd_bridge_mod_exit);
 
  MODULE_AUTHOR("Dmitry Baryshkov <[email protected]>");
  MODULE_DESCRIPTION("DRM HPD bridge");
drivers/gpu/drm/bridge/aux-hpd-bridge.h new file +13 -0
new file mode 100644
index 000000000000..69364731c2f1
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef AUX_HPD_BRIDGE_H
+#define AUX_HPD_BRIDGE_H
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+int drm_aux_hpd_typec_dp_bridge_init(void);
+void drm_aux_hpd_typec_dp_bridge_exit(void);
+#else
+static inline int drm_aux_hpd_typec_dp_bridge_init(void) { return 0; }
+static inline void drm_aux_hpd_typec_dp_bridge_exit(void) { }
+#endif /* IS_REACHABLE(CONFIG_TYPEC) */
+
+#endif /* AUX_HPD_BRIDGE_H */
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +4 -0
new file mode 100644
index 000000000000..6f2a1fca0fc5
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0+
+#include <linux/of.h>
+#include <linux/usb/typec_altmode.h>
+#include <linux/usb/typec_dp.h>
Quoted 9 lines

drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c line 11

Quoted 7 lines
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +7 -0
+#include <linux/usb/typec_notify.h>
+
+#include <drm/bridge/aux-bridge.h>
+
+#include "aux-hpd-bridge.h"
+
+#if IS_REACHABLE(CONFIG_TYPEC)

You don't need that. You should not use ifdefs in .c files.

Oh yes, this should be handled by depend on. I will fix it in v9.

Signature · 2 lines
Best,
Chaoyi
#9 lore raw

Re: [PATCH v8 03/10] drm/bridge: Implement generic USB Type-C DP HPD bridge

In reply to Chaoyi Chen
Quoted 8 lines · Chaoyi Chen

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.

This doesn't describe the problem that you are trying to solve.

Quoted 21 lines

---

Changes in v8:
- Merge generic DP HPD bridge into one module.

 drivers/gpu/drm/bridge/Kconfig                |  5 +-
 drivers/gpu/drm/bridge/Makefile               |  8 +++-
 drivers/gpu/drm/bridge/aux-hpd-bridge.c       | 23 ++++++++-
 drivers/gpu/drm/bridge/aux-hpd-bridge.h       | 13 +++++
 .../gpu/drm/bridge/aux-hpd-typec-dp-bridge.c  | 47 +++++++++++++++++++
 5 files changed, 93 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.h
 create mode 100644 drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c
drivers/gpu/drm/bridge/Kconfig +0 -0
index a250afd8d662..17257b223a28 100644

drivers/gpu/drm/bridge/Kconfig config DRM_AUX_BRIDGE · line 26

Quoted 5 lines
drivers/gpu/drm/bridge/Kconfig +1 -1
@@ -23,13 +23,16 @@ config DRM_AUX_BRIDGE
 	  build bridges chain.
 
 config DRM_AUX_HPD_BRIDGE
-	tristate
+	tristate "AUX HPD bridge support"

Why? No, this is supposed to be selected by other drivers. Users don't know an wouldn't know what is this.

Quoted 100 lines
drivers/gpu/drm/bridge/Kconfig +3 -0
 	depends on DRM_BRIDGE && OF
 	select AUXILIARY_BUS
 	help
 	  Simple bridge that terminates the bridge chain and provides HPD
 	  support.
 
+	  Specifically, if you want a default Type-C DisplayPort HPD bridge for
+	  each port of the Type-C controller, say Y here.
+
 menu "Display Interface Bridges"
 	depends on DRM && DRM_BRIDGE
 
drivers/gpu/drm/bridge/Makefile +7 -1
index c7dc03182e59..2998937444bc 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o
-obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o
+
+hpd-bridge-y := aux-hpd-bridge.o
+ifneq ($(CONFIG_TYPEC),)
+hpd-bridge-y += aux-hpd-typec-dp-bridge.o
+endif
+obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += hpd-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
drivers/gpu/drm/bridge/aux-hpd-bridge.c +22 -1
index 2e9c702c7087..11ad6dc776c7 100644
@@ -12,6 +12,8 @@
 #include <drm/drm_bridge.h>
 #include <drm/bridge/aux-bridge.h>
 
+#include "aux-hpd-bridge.h"
+
 static DEFINE_IDA(drm_aux_hpd_bridge_ida);
 
 struct drm_aux_hpd_bridge_data {
@@ -204,7 +206,26 @@ static struct auxiliary_driver drm_aux_hpd_bridge_drv = {
 	.id_table = drm_aux_hpd_bridge_table,
 	.probe = drm_aux_hpd_bridge_probe,
 };
-module_auxiliary_driver(drm_aux_hpd_bridge_drv);
+
+static int drm_aux_hpd_bridge_mod_init(void)
+{
+	int ret;
+
+	ret = auxiliary_driver_register(&drm_aux_hpd_bridge_drv);
+	if (ret)
+		return ret;
+
+	return drm_aux_hpd_typec_dp_bridge_init();
+}
+
+static void drm_aux_hpd_bridge_mod_exit(void)
+{
+	drm_aux_hpd_typec_dp_bridge_exit();
+	auxiliary_driver_unregister(&drm_aux_hpd_bridge_drv);
+}
+
+module_init(drm_aux_hpd_bridge_mod_init);
+module_exit(drm_aux_hpd_bridge_mod_exit);
 
 MODULE_AUTHOR("Dmitry Baryshkov <[email protected]>");
 MODULE_DESCRIPTION("DRM HPD bridge");
drivers/gpu/drm/bridge/aux-hpd-bridge.h new file +13 -0
new file mode 100644
index 000000000000..69364731c2f1
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef AUX_HPD_BRIDGE_H
+#define AUX_HPD_BRIDGE_H
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+int drm_aux_hpd_typec_dp_bridge_init(void);
+void drm_aux_hpd_typec_dp_bridge_exit(void);
+#else
+static inline int drm_aux_hpd_typec_dp_bridge_init(void) { return 0; }
+static inline void drm_aux_hpd_typec_dp_bridge_exit(void) { }
+#endif /* IS_REACHABLE(CONFIG_TYPEC) */
+
+#endif /* AUX_HPD_BRIDGE_H */
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +4 -0
new file mode 100644
index 000000000000..6f2a1fca0fc5
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0+
+#include <linux/of.h>
+#include <linux/usb/typec_altmode.h>
+#include <linux/usb/typec_dp.h>

drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c line 14

Quoted 10 lines
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +10 -0
+#include <linux/usb/typec_notify.h>
+
+#include <drm/bridge/aux-bridge.h>
+
+#include "aux-hpd-bridge.h"
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+static int drm_typec_bus_event(struct notifier_block *nb,
+			       unsigned long action, void *data)
+{

This feels like this should be a part of the Type-C subsystem rather than DRM.

Quoted 36 lines
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +33 -0
+	struct typec_altmode *alt = (struct typec_altmode *)data;
+
+	if (action != TYPEC_ALTMODE_REGISTERED)
+		goto done;
+
+	if (is_typec_partner(&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,
+};
+
+int drm_aux_hpd_typec_dp_bridge_init(void)
+{
+	return typec_altmode_register_notify(&drm_typec_event_nb);
+}
+
+void drm_aux_hpd_typec_dp_bridge_exit(void)
+{
+	typec_altmode_unregister_notify(&drm_typec_event_nb);
+}
+#endif
Signature · 1 line
2.49.0
Signature · 2 lines
With best wishes
Dmitry
#10 lore raw

Re: [PATCH v8 03/10] drm/bridge: Implement generic USB Type-C DP HPD bridge

Quoted 10 lines · Dmitry Baryshkov
Quoted 8 lines · Chaoyi Chen

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.

This doesn't describe the problem that you are trying to solve.

I'll try to describe the information more accurately. Thank you.

Quoted 23 lines
Quoted 23 lines

---

Changes in v8:
- Merge generic DP HPD bridge into one module.

  drivers/gpu/drm/bridge/Kconfig                |  5 +-
  drivers/gpu/drm/bridge/Makefile               |  8 +++-
  drivers/gpu/drm/bridge/aux-hpd-bridge.c       | 23 ++++++++-
  drivers/gpu/drm/bridge/aux-hpd-bridge.h       | 13 +++++
  .../gpu/drm/bridge/aux-hpd-typec-dp-bridge.c  | 47 +++++++++++++++++++
  5 files changed, 93 insertions(+), 3 deletions(-)

create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.h create mode 100644 drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c

drivers/gpu/drm/bridge/Kconfig +0 -0
index a250afd8d662..17257b223a28 100644
@@ -23,13 +23,16 @@ config DRM_AUX_BRIDGE
  	  build bridges chain.
 
Quoted 5 lines

drivers/gpu/drm/bridge/Kconfig config DRM_AUX_BRIDGE · line 26

Quoted 3 lines
drivers/gpu/drm/bridge/Kconfig +1 -1
  config DRM_AUX_HPD_BRIDGE
-	tristate
+	tristate "AUX HPD bridge support"

Why? No, this is supposed to be selected by other drivers. Users don't know an wouldn't know what is this.

In v7, I implemented an additional module for selecting this option. But Heikki believes that it would be better to merge the two modules into one.

Quoted 105 lines
Quoted 105 lines
drivers/gpu/drm/bridge/Kconfig +3 -0
  	depends on DRM_BRIDGE && OF
  	select AUXILIARY_BUS
  	help
  	  Simple bridge that terminates the bridge chain and provides HPD
  	  support.
 
+	  Specifically, if you want a default Type-C DisplayPort HPD bridge for
+	  each port of the Type-C controller, say Y here.
+
  menu "Display Interface Bridges"
  	depends on DRM && DRM_BRIDGE
 
drivers/gpu/drm/bridge/Makefile +7 -1
index c7dc03182e59..2998937444bc 100644
@@ -1,6 +1,12 @@
  # SPDX-License-Identifier: GPL-2.0
  obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o
-obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o
+
+hpd-bridge-y := aux-hpd-bridge.o
+ifneq ($(CONFIG_TYPEC),)
+hpd-bridge-y += aux-hpd-typec-dp-bridge.o
+endif
+obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += hpd-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
drivers/gpu/drm/bridge/aux-hpd-bridge.c +22 -1
index 2e9c702c7087..11ad6dc776c7 100644
@@ -12,6 +12,8 @@
  #include <drm/drm_bridge.h>
  #include <drm/bridge/aux-bridge.h>
 
+#include "aux-hpd-bridge.h"
+
  static DEFINE_IDA(drm_aux_hpd_bridge_ida);
 
  struct drm_aux_hpd_bridge_data {
@@ -204,7 +206,26 @@ static struct auxiliary_driver drm_aux_hpd_bridge_drv = {
  	.id_table = drm_aux_hpd_bridge_table,
  	.probe = drm_aux_hpd_bridge_probe,
  };
-module_auxiliary_driver(drm_aux_hpd_bridge_drv);
+
+static int drm_aux_hpd_bridge_mod_init(void)
+{
+	int ret;
+
+	ret = auxiliary_driver_register(&drm_aux_hpd_bridge_drv);
+	if (ret)
+		return ret;
+
+	return drm_aux_hpd_typec_dp_bridge_init();
+}
+
+static void drm_aux_hpd_bridge_mod_exit(void)
+{
+	drm_aux_hpd_typec_dp_bridge_exit();
+	auxiliary_driver_unregister(&drm_aux_hpd_bridge_drv);
+}
+
+module_init(drm_aux_hpd_bridge_mod_init);
+module_exit(drm_aux_hpd_bridge_mod_exit);
 
  MODULE_AUTHOR("Dmitry Baryshkov <[email protected]>");
  MODULE_DESCRIPTION("DRM HPD bridge");
drivers/gpu/drm/bridge/aux-hpd-bridge.h new file +13 -0
new file mode 100644
index 000000000000..69364731c2f1
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef AUX_HPD_BRIDGE_H
+#define AUX_HPD_BRIDGE_H
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+int drm_aux_hpd_typec_dp_bridge_init(void);
+void drm_aux_hpd_typec_dp_bridge_exit(void);
+#else
+static inline int drm_aux_hpd_typec_dp_bridge_init(void) { return 0; }
+static inline void drm_aux_hpd_typec_dp_bridge_exit(void) { }
+#endif /* IS_REACHABLE(CONFIG_TYPEC) */
+
+#endif /* AUX_HPD_BRIDGE_H */
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +8 -0
new file mode 100644
index 000000000000..6f2a1fca0fc5
@@ -0,0 +1,47 @@
+// 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>
+
Quoted 8 lines

drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c line 14

Quoted 6 lines
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +6 -0
+#include "aux-hpd-bridge.h"
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+static int drm_typec_bus_event(struct notifier_block *nb,
+			       unsigned long action, void *data)
+{

This feels like this should be a part of the Type-C subsystem rather than DRM.

In v7, this used to be a part of the Type-C subsystem. I'm not sure what Heikki thinks about this.

Quoted 37 lines
Quoted 37 lines
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +33 -0
+	struct typec_altmode *alt = (struct typec_altmode *)data;
+
+	if (action != TYPEC_ALTMODE_REGISTERED)
+		goto done;
+
+	if (is_typec_partner(&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,
+};
+
+int drm_aux_hpd_typec_dp_bridge_init(void)
+{
+	return typec_altmode_register_notify(&drm_typec_event_nb);
+}
+
+void drm_aux_hpd_typec_dp_bridge_exit(void)
+{
+	typec_altmode_unregister_notify(&drm_typec_event_nb);
+}
+#endif
Signature · 1 line
2.49.0
Signature · 2 lines
Best,
Chaoyi
maintainer
#11 lore raw

Re: [PATCH v8 03/10] drm/bridge: Implement generic USB Type-C DP HPD bridge

Quoted 12 lines
Quoted 11 lines

drivers/gpu/drm/bridge/Kconfig config DRM_AUX_BRIDGE · line 25

Quoted 9 lines
drivers/gpu/drm/bridge/Kconfig +1 -1
index a250afd8d662..17257b223a28 100644
@@ -23,13 +23,16 @@ config DRM_AUX_BRIDGE
  	  build bridges chain.
  config DRM_AUX_HPD_BRIDGE
-	tristate
+	tristate "AUX HPD bridge support"

Why? No, this is supposed to be selected by other drivers. Users don't know an wouldn't know what is this.

Quoted 2 lines

In v7, I implemented an additional module for selecting this option. But Heikki believes that it would be better to merge the two modules into one.

Like I said before, I was merely curious why not just squash the support into that AUX_PD_HPD_BRIDGE. If that does not make sense, then so be it - make it a "Display Interface Bridge" driver like you originally proposed.

Quoted 108 lines
Quoted 99 lines
Quoted 99 lines
drivers/gpu/drm/bridge/Kconfig +3 -0
  	depends on DRM_BRIDGE && OF
  	select AUXILIARY_BUS
  	help
  	  Simple bridge that terminates the bridge chain and provides HPD
  	  support.
+	  Specifically, if you want a default Type-C DisplayPort HPD bridge for
+	  each port of the Type-C controller, say Y here.
+
  menu "Display Interface Bridges"
  	depends on DRM && DRM_BRIDGE
drivers/gpu/drm/bridge/Makefile +7 -1
index c7dc03182e59..2998937444bc 100644
@@ -1,6 +1,12 @@
  # SPDX-License-Identifier: GPL-2.0
  obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o
-obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o
+
+hpd-bridge-y := aux-hpd-bridge.o
+ifneq ($(CONFIG_TYPEC),)
+hpd-bridge-y += aux-hpd-typec-dp-bridge.o
+endif
+obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += hpd-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
drivers/gpu/drm/bridge/aux-hpd-bridge.c +22 -1
index 2e9c702c7087..11ad6dc776c7 100644
@@ -12,6 +12,8 @@
  #include <drm/drm_bridge.h>
  #include <drm/bridge/aux-bridge.h>
+#include "aux-hpd-bridge.h"
+
  static DEFINE_IDA(drm_aux_hpd_bridge_ida);
  struct drm_aux_hpd_bridge_data {
@@ -204,7 +206,26 @@ static struct auxiliary_driver drm_aux_hpd_bridge_drv = {
  	.id_table = drm_aux_hpd_bridge_table,
  	.probe = drm_aux_hpd_bridge_probe,
  };
-module_auxiliary_driver(drm_aux_hpd_bridge_drv);
+
+static int drm_aux_hpd_bridge_mod_init(void)
+{
+	int ret;
+
+	ret = auxiliary_driver_register(&drm_aux_hpd_bridge_drv);
+	if (ret)
+		return ret;
+
+	return drm_aux_hpd_typec_dp_bridge_init();
+}
+
+static void drm_aux_hpd_bridge_mod_exit(void)
+{
+	drm_aux_hpd_typec_dp_bridge_exit();
+	auxiliary_driver_unregister(&drm_aux_hpd_bridge_drv);
+}
+
+module_init(drm_aux_hpd_bridge_mod_init);
+module_exit(drm_aux_hpd_bridge_mod_exit);
  MODULE_AUTHOR("Dmitry Baryshkov <[email protected]>");
  MODULE_DESCRIPTION("DRM HPD bridge");
drivers/gpu/drm/bridge/aux-hpd-bridge.h new file +13 -0
new file mode 100644
index 000000000000..69364731c2f1
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef AUX_HPD_BRIDGE_H
+#define AUX_HPD_BRIDGE_H
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+int drm_aux_hpd_typec_dp_bridge_init(void);
+void drm_aux_hpd_typec_dp_bridge_exit(void);
+#else
+static inline int drm_aux_hpd_typec_dp_bridge_init(void) { return 0; }
+static inline void drm_aux_hpd_typec_dp_bridge_exit(void) { }
+#endif /* IS_REACHABLE(CONFIG_TYPEC) */
+
+#endif /* AUX_HPD_BRIDGE_H */
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +8 -0
new file mode 100644
index 000000000000..6f2a1fca0fc5
@@ -0,0 +1,47 @@
+// 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>
+
Quoted 8 lines

drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c line 14

Quoted 6 lines
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +6 -0
+#include "aux-hpd-bridge.h"
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+static int drm_typec_bus_event(struct notifier_block *nb,
+			       unsigned long action, void *data)
+{

This feels like this should be a part of the Type-C subsystem rather than DRM.

Quoted 2 lines

In v7, this used to be a part of the Type-C subsystem. I'm not sure what Heikki thinks about this.

Your original proposal of making the entire TYPEC subsystem depend on DRM is _not_ going to happen. In general, if I've now understood this correctly, this thing probable should be a "display interface bridge driver", similar to what you proposed in the previous version.

Note also that you could make it selected automatically, so there is no need for user selectable option if that's the preference. Kconfig and Makefile gives you options on how to do that. For example, maybe this Kconfig works (or does not, but something like it will):

drivers/gpu/drm/bridge/Kconfig +9 -0
index a250afd8d662..7487024ba2ce 100644
@@ -30,6 +30,15 @@ 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
+
+endif /* DRM_AUX_HPD_BRIDGE */
+
 menu "Display Interface Bridges"
        depends on DRM && DRM_BRIDGE
 

thanks,

Signature · 1 line
heikki
#12 lore raw

Re: [PATCH v8 03/10] drm/bridge: Implement generic USB Type-C DP HPD bridge

Quoted 11 lines · Heikki Krogerus
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/bridge/Kconfig config DRM_AUX_BRIDGE · line 25

Quoted 9 lines
drivers/gpu/drm/bridge/Kconfig +1 -1
index a250afd8d662..17257b223a28 100644
@@ -23,13 +23,16 @@ config DRM_AUX_BRIDGE
   	  build bridges chain.
   config DRM_AUX_HPD_BRIDGE
-	tristate
+	tristate "AUX HPD bridge support"

Why? No, this is supposed to be selected by other drivers. Users don't know an wouldn't know what is this.

Quoted 6 lines
Quoted 2 lines

In v7, I implemented an additional module for selecting this option. But Heikki believes that it would be better to merge the two modules into one.

Like I said before, I was merely curious why not just squash the support into that AUX_PD_HPD_BRIDGE. If that does not make sense, then so be it - make it a "Display Interface Bridge" driver like you originally proposed.

Yes, it is.

Quoted 128 lines
Quoted 107 lines
Quoted 99 lines
Quoted 99 lines
drivers/gpu/drm/bridge/Kconfig +3 -0
   	depends on DRM_BRIDGE && OF
   	select AUXILIARY_BUS
   	help
   	  Simple bridge that terminates the bridge chain and provides HPD
   	  support.
+	  Specifically, if you want a default Type-C DisplayPort HPD bridge for
+	  each port of the Type-C controller, say Y here.
+
   menu "Display Interface Bridges"
   	depends on DRM && DRM_BRIDGE
drivers/gpu/drm/bridge/Makefile +7 -1
index c7dc03182e59..2998937444bc 100644
@@ -1,6 +1,12 @@
   # SPDX-License-Identifier: GPL-2.0
   obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o
-obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o
+
+hpd-bridge-y := aux-hpd-bridge.o
+ifneq ($(CONFIG_TYPEC),)
+hpd-bridge-y += aux-hpd-typec-dp-bridge.o
+endif
+obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += hpd-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
drivers/gpu/drm/bridge/aux-hpd-bridge.c +22 -1
index 2e9c702c7087..11ad6dc776c7 100644
@@ -12,6 +12,8 @@
   #include <drm/drm_bridge.h>
   #include <drm/bridge/aux-bridge.h>
+#include "aux-hpd-bridge.h"
+
   static DEFINE_IDA(drm_aux_hpd_bridge_ida);
   struct drm_aux_hpd_bridge_data {
@@ -204,7 +206,26 @@ static struct auxiliary_driver drm_aux_hpd_bridge_drv = {
   	.id_table = drm_aux_hpd_bridge_table,
   	.probe = drm_aux_hpd_bridge_probe,
   };
-module_auxiliary_driver(drm_aux_hpd_bridge_drv);
+
+static int drm_aux_hpd_bridge_mod_init(void)
+{
+	int ret;
+
+	ret = auxiliary_driver_register(&drm_aux_hpd_bridge_drv);
+	if (ret)
+		return ret;
+
+	return drm_aux_hpd_typec_dp_bridge_init();
+}
+
+static void drm_aux_hpd_bridge_mod_exit(void)
+{
+	drm_aux_hpd_typec_dp_bridge_exit();
+	auxiliary_driver_unregister(&drm_aux_hpd_bridge_drv);
+}
+
+module_init(drm_aux_hpd_bridge_mod_init);
+module_exit(drm_aux_hpd_bridge_mod_exit);
   MODULE_AUTHOR("Dmitry Baryshkov <[email protected]>");
   MODULE_DESCRIPTION("DRM HPD bridge");
drivers/gpu/drm/bridge/aux-hpd-bridge.h new file +13 -0
new file mode 100644
index 000000000000..69364731c2f1
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef AUX_HPD_BRIDGE_H
+#define AUX_HPD_BRIDGE_H
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+int drm_aux_hpd_typec_dp_bridge_init(void);
+void drm_aux_hpd_typec_dp_bridge_exit(void);
+#else
+static inline int drm_aux_hpd_typec_dp_bridge_init(void) { return 0; }
+static inline void drm_aux_hpd_typec_dp_bridge_exit(void) { }
+#endif /* IS_REACHABLE(CONFIG_TYPEC) */
+
+#endif /* AUX_HPD_BRIDGE_H */
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +8 -0
new file mode 100644
index 000000000000..6f2a1fca0fc5
@@ -0,0 +1,47 @@
+// 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>
+
Quoted 8 lines

drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c line 14

Quoted 6 lines
drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c new file +6 -0
+#include "aux-hpd-bridge.h"
+
+#if IS_REACHABLE(CONFIG_TYPEC)
+static int drm_typec_bus_event(struct notifier_block *nb,
+			       unsigned long action, void *data)
+{

This feels like this should be a part of the Type-C subsystem rather than DRM.

Quoted 2 lines

In v7, this used to be a part of the Type-C subsystem. I'm not sure what Heikki thinks about this.

Your original proposal of making the entire TYPEC subsystem depend on DRM is _not_ going to happen. In general, if I've now understood this correctly, this thing probable should be a "display interface bridge driver", similar to what you proposed in the previous version.

Note also that you could make it selected automatically, so there is no need for user selectable option if that's the preference. Kconfig and Makefile gives you options on how to do that. For example, maybe this Kconfig works (or does not, but something like it will):

drivers/gpu/drm/bridge/Kconfig +1 -0
index a250afd8d662..7487024ba2ce 100644
@@ -30,6 +30,15 @@ config DRM_AUX_HPD_BRIDGE
           Simple bridge that terminates the bridge chain and provides HPD
           support.
 
+if DRM_AUX_HPD_BRIDGE

drivers/gpu/drm/bridge/Kconfig config DRM_AUX_HPD_BRIDGE · line 43

Quoted 10 lines
drivers/gpu/drm/bridge/Kconfig +8 -0
+
+config DRM_AUX_HPD_TYPEC_BRIDGE
+       tristate
+       depends on TYPEC || !TYPEC
+       default TYPEC
+
+endif /* DRM_AUX_HPD_BRIDGE */
+
  menu "Display Interface Bridges"
         depends on DRM && DRM_BRIDGE

Thank you for your code. I think both of your points make sense. So choosing the approach you mentioned now (similar to v7) might be a reasonable compromise.

Quoted 5 lines
drivers/gpu/drm/bridge/Kconfig +0 -0
 thanks,
Signature · 2 lines
Best,
Chaoyi
#13 lore raw

Re: [PATCH v8 03/10] drm/bridge: Implement generic USB Type-C DP HPD bridge

In reply to Dmitry Baryshkov
Quoted 33 lines · Dmitry Baryshkov
Quoted 8 lines · Chaoyi Chen

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.

This doesn't describe the problem that you are trying to solve.

Quoted 22 lines

---

Changes in v8:
- Merge generic DP HPD bridge into one module.

  drivers/gpu/drm/bridge/Kconfig                |  5 +-
  drivers/gpu/drm/bridge/Makefile               |  8 +++-
  drivers/gpu/drm/bridge/aux-hpd-bridge.c       | 23 ++++++++-
  drivers/gpu/drm/bridge/aux-hpd-bridge.h       | 13 +++++
  .../gpu/drm/bridge/aux-hpd-typec-dp-bridge.c  | 47 +++++++++++++++++++
  5 files changed, 93 insertions(+), 3 deletions(-)

create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.h create mode 100644 drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c

drivers/gpu/drm/bridge/Kconfig +0 -0
index a250afd8d662..17257b223a28 100644
@@ -23,13 +23,16 @@ config DRM_AUX_BRIDGE
  	  build bridges chain.
 
Quoted 6 lines

drivers/gpu/drm/bridge/Kconfig config DRM_AUX_BRIDGE · line 26

Quoted 3 lines
drivers/gpu/drm/bridge/Kconfig +1 -1
  config DRM_AUX_HPD_BRIDGE
-	tristate
+	tristate "AUX HPD bridge support"

Why? No, this is supposed to be selected by other drivers. Users don't know an wouldn't know what is this.

Sorry, I might have misunderstood you point. In v7, I added a new DRM_AUX_TYPEC_DP_HPD_BRIDGE module to select DRM_AUX_HPD_BRIDGE. This seems to fit the "selected by other drivers" scenario, but I think you might not want to expose any information to the users.

And the other one is what Heikki said:

+if DRM_AUX_HPD_BRIDGE + +config DRM_AUX_HPD_TYPEC_BRIDGE + tristate + depends on TYPEC || !TYPEC + default TYPEC + +endif /* DRM_AUX_HPD_BRIDGE */ + menu "Display Interface Bridges" depends on DRM && DRM_BRIDGE

If I understand correctly, in this scenario we need to select DRM_AUX_HPD_BRIDGE in the DP driver. When Type-C is available, DRM_AUX_HPD_TYPEC_BRIDGE will be selected automatically.

Is the method mentioned by Heikki what you want? Thank you.

Signature · 2 lines
Best,
Chaoyi