[PATCH v7 2/9] drm/bridge: Implement generic USB Type-C DP HPD bridge
Heikki Krogerus
heikki.krogerus at linux.intel.com
Fri Oct 24 01:01:01 PDT 2025
On Thu, Oct 23, 2025 at 11:30:02AM +0800, Chaoyi Chen wrote:
> +static int drm_typec_bus_event(struct notifier_block *nb,
> + unsigned long action, void *data)
> +{
> + struct typec_altmode *alt = (struct typec_altmode *)data;
> +
> + if (action != TYPEC_ALTMODE_REGISTERED)
> + goto done;
> +
> + if (alt->svid != USB_TYPEC_DP_SID)
> + goto done;
> +
> + /*
> + * alt->dev.parent->parent : USB-C controller device
> + * alt->dev.parent : USB-C connector device
> + */
> + drm_dp_hpd_bridge_register(alt->dev.parent->parent,
> + to_of_node(alt->dev.parent->fwnode));
Okay, this explains it. So you do need the port altmode.
So you'll need to export the device types and check that the parent of
the altmode is the port instead of partner.
if (!is_typec_port(alt->dev.parent) || alt->svid != USB_TYPEC_DP_SID)
return NOTIFY_DONE;
I think we might as well export all the types while at it. Check the
attachment.
thanks,
--
heikki
-------------- next part --------------
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 9b2647cb199b..f0704d605595 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -790,6 +790,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)
{
@@ -1144,6 +1145,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
@@ -1292,6 +1294,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
@@ -2031,6 +2034,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 */
diff --git a/drivers/usb/typec/class.h b/drivers/usb/typec/class.h
index db2fe96c48ff..f04f6987bed8 100644
--- a/drivers/usb/typec/class.h
+++ b/drivers/usb/typec/class.h
@@ -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;
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 309251572e2e..02fed8293415 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -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;
More information about the linux-phy
mailing list