Register Type-C mode-switch in DP bridge endpoints
Subsystems (10)
v9 cover Register Type-C mode-switch in DP bridge endpoints
This series introduces bindings for anx7625/it6505 to register Type-C mode-switch in their output endpoints, and use data-lanes property to describe the pin connections.
The first two patch modifies fwnode_graph_devcon_matches and cros_typec_init_ports to enable the registration of the switches.
Patch 4~6 introduce the bindings for anx7625 and the corresponding driver modifications.
Patch 7~9 add similar bindings and driver changes for it6505.
v7: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/linux-usb/[email protected]/
Changes in v9:
- Collected Reviewed-by tag
- Fixed subject prefix again
- Changed the naming of the example node for it6505
Changes in v8:
- Fixed the build issue when CONFIG_TYPEC=m
- Fixed some style issues
- Fixed the subject prefixes for the bindings patch
- Fixed the bindings for data-lanes properties
Changes in v7:
- Fix the long comment lines
- Extracted the common codes to a helper function
- Fixed style issues in anx7625 driver
- Removed DT property validation in anx7625 driver.
- Fixed style issues in it6505 driver
- Removed the redundant sleep in it6505 driver
- Removed DT property validation in it6505 driver
- Rebased to drm-misc-next
- Fixed indentations in bindings patches
- Added a new patch to fix indentations in Kconfig
Changes in v6:
- Changed it6505_typec_mux_set callback function to accommodate with the latest drm-misc patches
- Changed the driver implementation to accommodate with the new binding
- Dropped typec-switch binding and use endpoints and data-lanes properties to describe the pin connections
- Added new patches (patch 1,2,4) to fix probing issues
- Changed the bindings of it6505/anx7625 and modified the drivers accordingly
- Merged it6505/anx7625 driver changes into a single patch
Pin-yen Lin (7):
drm/display: Add Type-C switch helpers
dt-bindings: display: bridge: anx7625: Add mode-switch support drm/bridge: anx7625: Check for Type-C during panel registration drm/bridge: anx7625: Register Type C mode switches
dt-bindings: display: bridge: it6505: Add mode-switch support drm/bridge: it6505: Fix Kconfig indentation drm/bridge: it6505: Register Type C mode switches
Prashant Malani (2):
device property: Add remote endpoint to devcon matcher platform/chrome: cros_ec_typec: Purge blocking switch devlinks
.../display/bridge/analogix,anx7625.yaml | 99 ++++++++++++- .../bindings/display/bridge/ite,it6505.yaml | 93 ++++++++++-- drivers/base/property.c | 15 ++ drivers/gpu/drm/bridge/Kconfig | 21 +-- drivers/gpu/drm/bridge/analogix/Kconfig | 1 + drivers/gpu/drm/bridge/analogix/anx7625.c | 101 +++++++++++++- drivers/gpu/drm/bridge/analogix/anx7625.h | 13 ++ drivers/gpu/drm/bridge/ite-it6505.c | 119 +++++++++++++++- drivers/gpu/drm/display/drm_dp_helper.c | 132 ++++++++++++++++++ drivers/platform/chrome/cros_ec_typec.c | 10 ++ include/drm/display/drm_dp_helper.h | 16 +++ 11 files changed, 591 insertions(+), 29 deletions(-)
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
PATCH v9 1/9 device property: Add remote endpoint to devcon matcher
From: Prashant Malani <[email protected]>
When searching the device graph for device matches, check the remote-endpoint itself for a match.
Some drivers register devices for individual endpoints. This allows the matcher code to evaluate those for a match too, instead of only looking at the remote parent devices. This is required when a device supports two mode switches in its endpoints, so we can't simply register the mode switch with the parent node.
---
(no changes since v6)
Changes in v6:
- New in v6
drivers/base/property.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/base/property.c +15 -0
@@ -1223,6 +1223,21 @@ static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode,break ; } +/* +* Some drivers may register devices for endpoints. Check +* the remote-endpoints for matches in addition to the remote +* port parent. +*/ + node =fwnode_graph_get_remote_endpoint (ep); +if (fwnode_device_is_available (node)) { + ret =match (node, con_id, data); +if (ret) { +if (matches) + matches[count] = ret; + count++; + } + } + node =fwnode_graph_get_remote_port_parent (ep);if (!fwnode_device_is_available (node)) {fwnode_handle_put (node);
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH v9 1/9] device property: Add remote endpoint to devcon matcher
Quoted 6 lines · Pin-yen Lin
From: Prashant Malani <[email protected]>
When searching the device graph for device matches, check the remote-endpoint itself for a match.
Quoted 8 lines
Some drivers register devices for individual endpoints. This allows the matcher code to evaluate those for a match too, instead of only looking at the remote parent devices. This is required when a device supports two mode switches in its endpoints, so we can't simply register the mode switch with the parent node.
Signed-off-by Prashant Malani <[email protected]>Signed-off-by Pin-yen Lin <[email protected]>
on MT8192 based Hayato (ASUS Chromebook Flip CM3200).
PATCH v9 2/9 platform/chrome: cros_ec_typec: Purge blocking switch devlinks
In reply to Pin-yen LinFrom: Prashant Malani <[email protected]>
When using OF graph, the fw_devlink code will create links between the individual port driver (cros-ec-typec here) and the parent device for a Type-C switch (like mode-switch). Since the mode-switch will in turn have the usb-c-connector (i.e the child of the port driver) as a supplier, fw_devlink will not be able to resolve the cyclic dependency correctly.
As a result, the mode-switch driver probe() never runs, so mode-switches are never registered. Because of that, the port driver probe constantly fails with -EPROBE_DEFER, because the Type-C connector class requires all switch devices to be registered prior to port registration.
To break this deadlock and allow the mode-switch registration to occur, purge all the usb-c-connector nodes' absent suppliers. This eliminates the connector as a supplier for a switch and allows it to be probed.
---
(no changes since v7)
Changes in v7:
- Fix the long comment lines
Changes in v6:
- New in v6
drivers/platform/chrome/cros_ec_typec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/platform/chrome/cros_ec_typec.c +10 -0
@@ -382,6 +382,16 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)return -EINVAL ; } +/* +* OF graph may have set up some device links with switches, +* since connectors have their own compatible. Purge these +* to avoid a deadlock in switch probe (the switch mistakenly +* assumes the connector is a supplier). +*/ +if (dev_of_node (dev)) +device_for_each_child_node (dev, fwnode) +fw_devlink_purge_absent_suppliers (fwnode); +/* DT uses "reg" to specify port number. */ port_prop = dev->of_node ?"reg" :"port-number" ;device_for_each_child_node (dev, fwnode) {
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH v9 2/9] platform/chrome: cros_ec_typec: Purge blocking switch devlinks
Quoted 15 lines · Pin-yen Lin
From: Prashant Malani <[email protected]>
When using OF graph, the
fw_devlinkcode will create links between the individual port driver (cros-ec-typec here) and the parent device for a Type-C switch (like mode-switch). Since the mode-switch will in turn have the usb-c-connector (i.e the child of the port driver) as a supplier,fw_devlinkwill not be able to resolve the cyclic dependency correctly.As a result, the mode-switch driver
probe()never runs, so mode-switches are never registered. Because of that, the port driver probe constantly fails with -EPROBE_DEFER, because the Type-C connector class requires all switch devices to be registered prior to port registration.
Quoted 6 lines
To break this deadlock and allow the mode-switch registration to occur, purge all the usb-c-connector nodes' absent suppliers. This eliminates the connector as a supplier for a switch and allows it to be probed.
Signed-off-by Prashant Malani <[email protected]>Signed-off-by Pin-yen Lin <[email protected]>
on MT8192 based Hayato (ASUS Chromebook Flip CM3200).
PATCH v9 3/9 drm/display: Add Type-C switch helpers
In reply to Pin-yen LinAdd helpers to register and unregister Type-C "switches" for bridges capable of switching their output between two downstream devices.
The helper registers USB Type-C mode switches when the "mode-switch" and the "data-lanes" properties are available in Device Tree.
---
(no changes since v8)
Changes in v8:
- Fixed the build issue when CONFIG_TYPEC=m
- Fixed some style issues
Changes in v7:
- Extracted the common codes to a helper function
- New in v7
drivers/gpu/drm/display/drm_dp_helper.c | 132 ++++++++++++++++++++++++ include/drm/display/drm_dp_helper.h | 16 +++ 2 files changed, 148 insertions(+)
drivers/gpu/drm/display/drm_dp_helper.c +132 -0
@@ -30,11 +30,13 @@#include <linux/sched.h> #include <linux/seq_file.h> #include <linux/string_helpers.h> +#include <linux/usb/typec_mux.h> #include <linux/dynamic_debug.h> #include <drm/display/drm_dp_helper.h> #include <drm/display/drm_dp_mst_helper.h> #include <drm/drm_edid.h> +#include <drm/drm_of.h> #include <drm/drm_print.h> #include <drm/drm_vblank.h> #include <drm/drm_panel.h>
@@ -3891,3 +3893,133 @@ int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux)EXPORT_SYMBOL (drm_panel_dp_aux_backlight);#endif + +#if IS_REACHABLE (CONFIG_TYPEC ) +static int drm_dp_register_mode_switch (struct device *dev,struct device_node *node, +struct drm_dp_typec_switch_desc *switch_desc, +void *data,void *mux_set) +{ +struct drm_dp_typec_port_data *port_data; +struct typec_mux_desc mux_desc = {}; +char name[32 ]; +u32 dp_lanes[2 ]; +int ret, num_lanes, port_num =-1 ; + + num_lanes =drm_of_get_data_lanes_count (node,0 ,2 ); +if (num_lanes <=0 ) { +dev_err (dev,"Error on getting data lanes count: %d\n" , + num_lanes); +return num_lanes; + } + + ret =of_property_read_u32_array (node,"data-lanes" , dp_lanes, num_lanes); +if (ret) { +dev_err (dev,"Failed to read the data-lanes variable: %d\n" , + ret); +return ret; + } + + port_num = dp_lanes[0 ] /2 ; + + port_data = &switch_desc->typec_ports[port_num]; + port_data->data = data; + mux_desc.fwnode = &node->fwnode; + mux_desc.drvdata = port_data; +snprintf (name,sizeof (name),"%s-%u" , node->name, port_num); + mux_desc.name = name; + mux_desc.set = mux_set; + + port_data->typec_mux =typec_mux_register (dev, &mux_desc); +if (IS_ERR (port_data->typec_mux)) { + ret =PTR_ERR (port_data->typec_mux); +dev_err (dev,"Mode switch register for port %d failed: %d\n" , + port_num, ret); + } + +return ret; +} + +/** +* drm_dp_register_typec_switches() - register Type-C switches +* @dev: Device that registers Type-C switches +* @port: Device node for the switch +* @switch_desc: A Type-C switch descriptor +* @data: Private data for the switches +* @mux_set: Callback function for typec_mux_set +* +* This function registers USB Type-C switches for DP bridges that can switch +* the output signal between their output pins. +* +* Currently only mode switches are implemented, and the function assumes the +* given @port device node has endpoints with "mode-switch" property. +* Register the endpoint as port 0 if the "data-lanes" property falls in 0/1, +* and register it as port 1 if "data-lanes" falls in 2/3. +*/ +int drm_dp_register_typec_switches (struct device *dev,struct device_node *port, +struct drm_dp_typec_switch_desc *switch_desc, +void *data,void *mux_set) +{ +struct device_node *sw; +int ret; + +for_each_child_of_node (port, sw) { +if (of_property_read_bool (sw,"mode-switch" )) + switch_desc->num_typec_switches++; + } + +if (!switch_desc->num_typec_switches) { +dev_warn (dev,"No Type-C switches node found\n" ); +return 0 ; + } + + switch_desc->typec_ports =devm_kcalloc ( + dev, switch_desc->num_typec_switches, +sizeof (struct drm_dp_typec_port_data ),GFP_KERNEL ); + +if (!switch_desc->typec_ports) +return -ENOMEM ; + +/* Register switches for each connector. */ +for_each_child_of_node (port, sw) { +if (!of_property_read_bool (sw,"mode-switch" )) +continue ; + ret =drm_dp_register_mode_switch (dev, sw, switch_desc, data, mux_set); +if (ret) + goto err_unregister_typec_switches; + } + +return 0 ; + +err_unregister_typec_switches: +of_node_put (sw); +drm_dp_unregister_typec_switches (switch_desc); +dev_err (dev,"Failed to register mode switch: %d\n" , ret); +return ret; +} +EXPORT_SYMBOL (drm_dp_register_typec_switches); + +/** +* drm_dp_unregister_typec_switches() - unregister Type-C switches +* @switch_desc: A Type-C switch descriptor +*/ +void drm_dp_unregister_typec_switches (struct drm_dp_typec_switch_desc *switch_desc) +{ +int i; + +for (i =0 ; i < switch_desc->num_typec_switches; i++) +typec_mux_unregister (switch_desc->typec_ports[i].typec_mux); +} +EXPORT_SYMBOL (drm_dp_unregister_typec_switches); +#else +void drm_dp_unregister_typec_switches (struct drm_dp_typec_switch_desc *switch_desc) +{ +} +EXPORT_SYMBOL (drm_dp_register_typec_switches); +int drm_dp_register_typec_switches (struct device *dev,struct device_node *port, +struct drm_dp_typec_switch_desc *switch_desc, +void *data,void *mux_set) +{ +return 0 ; +} +EXPORT_SYMBOL (drm_dp_unregister_typec_switches); +#endif
include/drm/display/drm_dp_helper.h +16 -0
@@ -763,4 +763,20 @@ bool drm_dp_downstream_rgb_to_ycbcr_conversion(const u8 dpcd[DP_RECEIVER_CAP_SIZ const u8 port_cap[4], u8 color_spc);int drm_dp_pcon_convert_rgb_to_ycbcr (struct drm_dp_aux *aux,u8 color_spc); +struct drm_dp_typec_port_data { +struct typec_mux_dev *typec_mux; +void *data; +bool dp_connected; +}; + +struct drm_dp_typec_switch_desc { +int num_typec_switches; +struct drm_dp_typec_port_data *typec_ports; +}; + +void drm_dp_unregister_typec_switches (struct drm_dp_typec_switch_desc *switch_desc); +int drm_dp_register_typec_switches (struct device *dev,struct device_node *port, +struct drm_dp_typec_switch_desc *switch_desc, +void *data,void *mux_set); +#endif /* _DRM_DP_HELPER_H_ */
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH v9 3/9] drm/display: Add Type-C switch helpers
Quoted 8 lines · Pin-yen Lin
Add helpers to register and unregister Type-C "switches" for bridges capable of switching their output between two downstream devices.
The helper registers USB Type-C mode switches when the "mode-switch" and the "data-lanes" properties are available in Device Tree.
Signed-off-by Pin-yen Lin <[email protected]>
on MT8192 based Hayato (ASUS Chromebook Flip CM3200).
Quoted 44 lines
---
(no changes since v8)
Changes in v8:
- Fixed the build issue whenCONFIG_TYPEC=m
- Fixed some style issuesChanges in v7:
- Extracted the common codes to a helper function
- New in v7drivers/gpu/drm/display/drm_dp_helper.c | 132 ++++++++++++++++++++++++ include/drm/display/drm_dp_helper.h | 16 +++ 2 files changed, 148 insertions(+)drivers/gpu/drm/display/drm_dp_helper.c +8
-0@@ -30,11 +30,13 @@#include <linux/sched.h> #include <linux/seq_file.h> #include <linux/string_helpers.h> +#include <linux/usb/typec_mux.h> #include <linux/dynamic_debug.h> #include <drm/display/drm_dp_helper.h> #include <drm/display/drm_dp_mst_helper.h> #include <drm/drm_edid.h> +#include <drm/drm_of.h> #include <drm/drm_print.h> #include <drm/drm_vblank.h> #include <drm/drm_panel.h> @@ -3891,3 +3893,133 @@ int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux)EXPORT_SYMBOL (drm_panel_dp_aux_backlight);#endif + +#if IS_REACHABLE (CONFIG_TYPEC ) +static int drm_dp_register_mode_switch (struct device *dev,struct device_node *node, +struct drm_dp_typec_switch_desc *switch_desc, +void *data,void *mux_set) +{
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3911
Quoted 10 lines
drivers/gpu/drm/display/drm_dp_helper.c +10
-0+struct drm_dp_typec_port_data *port_data; +struct typec_mux_desc mux_desc = {}; +char name[32 ]; +u32 dp_lanes[2 ]; +int ret, num_lanes, port_num =-1 ; + + num_lanes =drm_of_get_data_lanes_count (node,0 ,2 ); +if (num_lanes <=0 ) { +dev_err (dev,"Error on getting data lanes count: %d\n" , + num_lanes);
Also printing out the full node name (endpoint@N) would be more helpful.
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3918
Quoted 7 lines
drivers/gpu/drm/display/drm_dp_helper.c +7
-0+return num_lanes; + } + + ret =of_property_read_u32_array (node,"data-lanes" , dp_lanes, num_lanes); +if (ret) { +dev_err (dev,"Failed to read the data-lanes variable: %d\n" , + ret);
Same here.
Quoted 43 lines
drivers/gpu/drm/display/drm_dp_helper.c +43
-0+return ret; + } + + port_num = dp_lanes[0 ] /2 ; + + port_data = &switch_desc->typec_ports[port_num]; + port_data->data = data; + mux_desc.fwnode = &node->fwnode; + mux_desc.drvdata = port_data; +snprintf (name,sizeof (name),"%s-%u" , node->name, port_num); + mux_desc.name = name; + mux_desc.set = mux_set; + + port_data->typec_mux =typec_mux_register (dev, &mux_desc); +if (IS_ERR (port_data->typec_mux)) { + ret =PTR_ERR (port_data->typec_mux); +dev_err (dev,"Mode switch register for port %d failed: %d\n" , + port_num, ret); + } + +return ret; +} + +/** +* drm_dp_register_typec_switches() - register Type-C switches +* @dev: Device that registers Type-C switches +* @port: Device node for the switch +* @switch_desc: A Type-C switch descriptor +* @data: Private data for the switches +* @mux_set: Callback function for typec_mux_set +* +* This function registers USB Type-C switches for DP bridges that can switch +* the output signal between their output pins. +* +* Currently only mode switches are implemented, and the function assumes the +* given @port device node has endpoints with "mode-switch" property. +* Register the endpoint as port 0 if the "data-lanes" property falls in 0/1, +* and register it as port 1 if "data-lanes" falls in 2/3. +*/ +int drm_dp_register_typec_switches (struct device *dev,struct device_node *port, +struct drm_dp_typec_switch_desc *switch_desc, +void *data,void *mux_set) +{
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3971
Quoted 10 lines
drivers/gpu/drm/display/drm_dp_helper.c +10
-0+struct device_node *sw; +int ret; + +for_each_child_of_node (port, sw) { +if (of_property_read_bool (sw,"mode-switch" )) + switch_desc->num_typec_switches++; + } + +if (!switch_desc->num_typec_switches) { +dev_warn (dev,"No Type-C switches node found\n" );
Maybe change this to dev_info or even dev_debug? A warning would be too noisy if the bridge drivers are calling this helper unconditionally.
Otherwise,
Re: [PATCH v9 3/9] drm/display: Add Type-C switch helpers
Quoted 52 lines · Chen-Yu Tsai
Quoted 8 lines · Pin-yen Lin
Add helpers to register and unregister Type-C "switches" for bridges capable of switching their output between two downstream devices.
The helper registers USB Type-C mode switches when the "mode-switch" and the "data-lanes" properties are available in Device Tree.
Signed-off-by Pin-yen Lin <[email protected]>Tested-by Chen-Yu Tsai <[email protected]>on MT8192 based Hayato (ASUS Chromebook Flip CM3200).
Quoted 37 lines
---
(no changes since v8)
Changes in v8:
- Fixed the build issue whenCONFIG_TYPEC=m
- Fixed some style issuesChanges in v7:
- Extracted the common codes to a helper function
- New in v7drivers/gpu/drm/display/drm_dp_helper.c | 132 ++++++++++++++++++++++++ include/drm/display/drm_dp_helper.h | 16 +++ 2 files changed, 148 insertions(+)drivers/gpu/drm/display/drm_dp_helper.c +2
-0@@ -30,11 +30,13 @@#include <linux/sched.h> #include <linux/seq_file.h> #include <linux/string_helpers.h> +#include <linux/usb/typec_mux.h> #include <linux/dynamic_debug.h> #include <drm/display/drm_dp_helper.h> #include <drm/display/drm_dp_mst_helper.h> #include <drm/drm_edid.h> +#include <drm/drm_of.h> #include <drm/drm_print.h> #include <drm/drm_vblank.h> #include <drm/drm_panel.h> @@ -3891,3 +3893,133 @@ int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux)EXPORT_SYMBOL (drm_panel_dp_aux_backlight);
Quoted 6 lines
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3900
Quoted 6 lines
drivers/gpu/drm/display/drm_dp_helper.c +5
-0#endif + +#if IS_REACHABLE (CONFIG_TYPEC ) +static int drm_dp_register_mode_switch (struct device *dev,struct device_node *node, +struct drm_dp_typec_switch_desc *switch_desc, +void *data,void *mux_set)
Using "typec_mux_set_fn_t" instead of "void *" for mux_set would be more explicit. Same for all the other instances where this parameter gets declared.
ChenYu
Quoted 84 lines
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3911
Quoted 11 lines
drivers/gpu/drm/display/drm_dp_helper.c +11
-0+{ +struct drm_dp_typec_port_data *port_data; +struct typec_mux_desc mux_desc = {}; +char name[32 ]; +u32 dp_lanes[2 ]; +int ret, num_lanes, port_num =-1 ; + + num_lanes =drm_of_get_data_lanes_count (node,0 ,2 ); +if (num_lanes <=0 ) { +dev_err (dev,"Error on getting data lanes count: %d\n" , + num_lanes);Also printing out the full node name (endpoint@N) would be more helpful.
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3918
Quoted 7 lines
drivers/gpu/drm/display/drm_dp_helper.c +7
-0+return num_lanes; + } + + ret =of_property_read_u32_array (node,"data-lanes" , dp_lanes, num_lanes); +if (ret) { +dev_err (dev,"Failed to read the data-lanes variable: %d\n" , + ret);Same here.
Quoted 43 lines
drivers/gpu/drm/display/drm_dp_helper.c +43
-0+return ret; + } + + port_num = dp_lanes[0 ] /2 ; + + port_data = &switch_desc->typec_ports[port_num]; + port_data->data = data; + mux_desc.fwnode = &node->fwnode; + mux_desc.drvdata = port_data; +snprintf (name,sizeof (name),"%s-%u" , node->name, port_num); + mux_desc.name = name; + mux_desc.set = mux_set; + + port_data->typec_mux =typec_mux_register (dev, &mux_desc); +if (IS_ERR (port_data->typec_mux)) { + ret =PTR_ERR (port_data->typec_mux); +dev_err (dev,"Mode switch register for port %d failed: %d\n" , + port_num, ret); + } + +return ret; +} + +/** +* drm_dp_register_typec_switches() - register Type-C switches +* @dev: Device that registers Type-C switches +* @port: Device node for the switch +* @switch_desc: A Type-C switch descriptor +* @data: Private data for the switches +* @mux_set: Callback function for typec_mux_set +* +* This function registers USB Type-C switches for DP bridges that can switch +* the output signal between their output pins. +* +* Currently only mode switches are implemented, and the function assumes the +* given @port device node has endpoints with "mode-switch" property. +* Register the endpoint as port 0 if the "data-lanes" property falls in 0/1, +* and register it as port 1 if "data-lanes" falls in 2/3. +*/ +int drm_dp_register_typec_switches (struct device *dev,struct device_node *port, +struct drm_dp_typec_switch_desc *switch_desc, +void *data,void *mux_set) +{drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3971
Quoted 10 lines
drivers/gpu/drm/display/drm_dp_helper.c +10
-0+struct device_node *sw; +int ret; + +for_each_child_of_node (port, sw) { +if (of_property_read_bool (sw,"mode-switch" )) + switch_desc->num_typec_switches++; + } + +if (!switch_desc->num_typec_switches) { +dev_warn (dev,"No Type-C switches node found\n" );Maybe change this to
dev_infoor evendev_debug? A warning would be too noisy if the bridge drivers are calling this helper unconditionally.Otherwise,
Reviewed-by Chen-Yu Tsai <[email protected]>
Re: [PATCH v9 3/9] drm/display: Add Type-C switch helpers
In reply to Pin-yen LinIl 09/01/23 09:40, Pin-yen Lin ha scritto:
Quoted 74 lines
Add helpers to register and unregister Type-C "switches" for bridges capable of switching their output between two downstream devices.
The helper registers USB Type-C mode switches when the "mode-switch" and the "data-lanes" properties are available in Device Tree.
Signed-off-by Pin-yen Lin <[email protected]>---
(no changes since v8)
Changes in v8:
- Fixed the build issue whenCONFIG_TYPEC=m
- Fixed some style issuesChanges in v7:
- Extracted the common codes to a helper function
- New in v7drivers/gpu/drm/display/drm_dp_helper.c | 132 ++++++++++++++++++++++++ include/drm/display/drm_dp_helper.h | 16 +++ 2 files changed, 148 insertions(+)drivers/gpu/drm/display/drm_dp_helper.c +30
-0@@ -30,11 +30,13 @@#include <linux/sched.h> #include <linux/seq_file.h> #include <linux/string_helpers.h> +#include <linux/usb/typec_mux.h> #include <linux/dynamic_debug.h> #include <drm/display/drm_dp_helper.h> #include <drm/display/drm_dp_mst_helper.h> #include <drm/drm_edid.h> +#include <drm/drm_of.h> #include <drm/drm_print.h> #include <drm/drm_vblank.h> #include <drm/drm_panel.h> @@ -3891,3 +3893,133 @@ int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux)EXPORT_SYMBOL (drm_panel_dp_aux_backlight);#endif + +#if IS_REACHABLE (CONFIG_TYPEC ) +static int drm_dp_register_mode_switch (struct device *dev,struct device_node *node, +struct drm_dp_typec_switch_desc *switch_desc, +void *data,void *mux_set) +{ +struct drm_dp_typec_port_data *port_data; +struct typec_mux_desc mux_desc = {}; +char name[32 ]; +u32 dp_lanes[2 ]; +int ret, num_lanes, port_num =-1 ; + + num_lanes =drm_of_get_data_lanes_count (node,0 ,2 ); +if (num_lanes <=0 ) { +dev_err (dev,"Error on getting data lanes count: %d\n" , + num_lanes); +return num_lanes; + } + + ret =of_property_read_u32_array (node,"data-lanes" , dp_lanes, num_lanes); +if (ret) { +dev_err (dev,"Failed to read the data-lanes variable: %d\n" , + ret); +return ret; + } + + port_num = dp_lanes[0 ] /2 ; +
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3933
Quoted 10 lines
drivers/gpu/drm/display/drm_dp_helper.c +10
-0+ port_data = &switch_desc->typec_ports[port_num]; + port_data->data = data; + mux_desc.fwnode = &node->fwnode; + mux_desc.drvdata = port_data; +snprintf (name,sizeof (name),"%s-%u" , node->name, port_num); + mux_desc.name = name; + mux_desc.set = mux_set; + + port_data->typec_mux =typec_mux_register (dev, &mux_desc); +if (IS_ERR (port_data->typec_mux)) {
I would propose, instead...
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3936
Quoted 3 lines
drivers/gpu/drm/display/drm_dp_helper.c +3
-0+ ret =PTR_ERR (port_data->typec_mux); +dev_err (dev,"Mode switch register for port %d failed: %d\n" , + port_num, ret);
return ret;
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3919
Quoted 3 lines
drivers/gpu/drm/display/drm_dp_helper.c +3
-0+ } + +return ret;
return 0;
drivers/gpu/drm/display/drm_dp_helper.c int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) · line 3941
Quoted 2 lines
drivers/gpu/drm/display/drm_dp_helper.c +2
-0+} +
...but I don't have strong opinions, so regardless of that:
PATCH v9 4/9 dt-bindings: display: bridge: anx7625: Add mode-switch support
In reply to Pin-yen LinAnalogix 7625 can be used in systems to switch the DP traffic between two downstreams, which can be USB Type-C DisplayPort alternate mode lane or regular DisplayPort output ports.
Update the binding to accommodate this usage by introducing a data-lanes and a mode-switch property on endpoints.
Also include the link to the product brief in the bindings.
---
Changes in v9:
- Collected Reviewed-by tag
Changes in v8:
- Updated anx7625 bindings for data-lane property
- Fixed the subject prefix
Changes in v7:
- Fixed issues reported by dt_binding_check
- Updated the schema and the example dts for data-lanes.
- Changed to generic naming for the example dts node.
Changes in v6:
- Remove switches node and use endpoints and data-lanes property to describe the connections.
.../display/bridge/analogix,anx7625.yaml | 99 ++++++++++++++++++- 1 file changed, 96 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml +96 -3
@@ -12,7 +12,8 @@ maintainers: description: | The ANX7625 is an ultra-low power 4K Mobile HD Transmitter - designed for portable devices. + designed for portable devices. Product brief is available at + https://www.analogix.com/en/system/files/AA-002291-PB-6-ANX7625_ProductBrief.pdf properties: compatible:
@@ -112,10 +113,48 @@ properties: data-lanes: true port@1: - $ref: /schemas/graph.yaml#/properties/port + $ref: /schemas/graph.yaml#/$defs/port-base description: Video port for panel or connector. + patternProperties: + "^endpoint@[01]$": + $ref: /schemas/graph.yaml#/$defs/endpoint-base + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + remote-endpoint: true + + data-lanes: + oneOf: + - items: + - enum: [0, 1, 2, 3] + + - items: + - const: 0 + - const: 1 + + - items: + - const: 2 + - const: 3 + + - items: + - const: 0 + - const: 1 + - const: 2 + - const: 3 + + mode-switch: + type: boolean + description: Register this node as a Type-C mode switch or not. + + required: + - reg + - remote-endpoint + required: - port@0 - port@1
@@ -164,8 +203,12 @@ examples: }; mipi2dp_bridge_out: port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; - anx7625_out: endpoint { + anx7625_out: endpoint@0 { + reg = <0>; remote-endpoint = <&panel_in>; }; };
@@ -186,3 +229,53 @@ examples: }; }; }; + - | + i2c3 { + #address-cells = <1>; + #size-cells = <0>; + + encoder@58 { + compatible = "analogix,anx7625"; + reg = <0x58>; + pinctrl-names = "default"; + pinctrl-0 = <&anx7625_dp_pins>; + enable-gpios = <&pio 176 GPIO_ACTIVE_HIGH>; + reset-gpios = <&pio 177 GPIO_ACTIVE_HIGH>; + vdd10-supply = <&pp1100_dpbrdg>; + vdd18-supply = <&pp1800_dpbrdg_dx>; + vdd33-supply = <&pp3300_dpbrdg_dx>; + analogix,audio-enable; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + anx7625_dp_in: endpoint { + bus-type = <7>; + remote-endpoint = <&dpi_out>; + }; + }; + + port@1 { + #address-cells = <1>; + #size-cells = <0>; + + reg = <1>; + anx_typec0: endpoint@0 { + reg = <0>; + mode-switch; + data-lanes = <0 1>; + remote-endpoint = <&typec_port0>; + }; + anx_typec1: endpoint@1 { + reg = <1>; + mode-switch; + data-lanes = <2 3>; + remote-endpoint = <&typec_port1>; + }; + }; + }; + }; + };
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH v9 4/9] dt-bindings: display: bridge: anx7625: Add mode-switch support
Quoted 5 lines · Pin-yen Lin
Analogix 7625 can be used in systems to switch the DP traffic between two downstreams, which can be USB Type-C DisplayPort alternate mode lane or regular DisplayPort output ports.
Quoted 7 lines
Update the binding to accommodate this usage by introducing a data-lanes and a mode-switch property on endpoints.
Also include the link to the product brief in the bindings.
Signed-off-by Pin-yen Lin <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>
on MT8192 based Hayato (ASUS Chromebook Flip CM3200).
Re: [PATCH v9 4/9] dt-bindings: display: bridge: anx7625: Add mode-switch support
In reply to Pin-yen LinIl 09/01/23 09:40, Pin-yen Lin ha scritto:
Quoted 4 lines
Analogix 7625 can be used in systems to switch the DP traffic between two downstreams, which can be USB Type-C DisplayPort alternate mode lane or regular DisplayPort output ports.
Quoted 8 lines
Update the binding to accommodate this usage by introducing a data-lanes and a mode-switch property on endpoints.
Also include the link to the product brief in the bindings.
Signed-off-by Pin-yen Lin <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>
PATCH v9 5/9 drm/bridge: anx7625: Check for Type-C during panel registration
In reply to Pin-yen LinThe output port endpoints can be connected to USB-C connectors. Running drm_of_find_panel_or_bridge() with such endpoints leads to a continuous return value of -EPROBE_DEFER, even though there is no panel present.
To avoid this, check for the existence of a "mode-switch" property in the port endpoint, and skip panel registration completely if so.
---
(no changes since v6)
Changes in v6:
- New in v6
drivers/gpu/drm/bridge/analogix/anx7625.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/analogix/anx7625.c +12 -1
@@ -1649,7 +1649,7 @@ static int anx7625_get_swing_setting(struct device *dev,static int anx7625_parse_dt (struct device *dev,struct anx7625_platform_data *pdata) { -struct device_node *np = dev->of_node, *ep0; +struct device_node *np = dev->of_node, *ep0, *sw;int bus_type, mipi_lanes;anx7625_get_swing_setting (dev, pdata);
@@ -1688,6 +1688,17 @@ static int anx7625_parse_dt(struct device *dev,if (of_property_read_bool (np,"analogix,audio-enable" )) pdata->audio_en =1 ; +/* +* Don't bother finding a panel if a Type-C `mode-switch` property is +* present in one of the endpoints. +*/ +for_each_endpoint_of_node (np, sw) { +if (of_property_read_bool (sw,"mode-switch" )) { +of_node_put (sw); +return 0 ; + } + } + pdata->panel_bridge =devm_drm_of_get_bridge (dev, np,1 ,0 );if (IS_ERR (pdata->panel_bridge)) {if (PTR_ERR (pdata->panel_bridge) == -ENODEV ) {
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH v9 5/9] drm/bridge: anx7625: Check for Type-C during panel registration
Quoted 10 lines · Pin-yen Lin
The output port endpoints can be connected to USB-C connectors. Running
drm_of_find_panel_or_bridge()with such endpoints leads to a continuous return value of -EPROBE_DEFER, even though there is no panel present.To avoid this, check for the existence of a "mode-switch" property in the port endpoint, and skip panel registration completely if so.
Signed-off-by Pin-yen Lin <[email protected]>
on MT8192 based Hayato (ASUS Chromebook Flip CM3200).
PATCH v9 6/9 drm/bridge: anx7625: Register Type C mode switches
In reply to Pin-yen LinRegister USB Type-C mode switches when the "mode-switch" property and relevant port are available in Device Tree. Configure the crosspoint switch based on the entered alternate mode for a specific Type-C connector.
---
(no changes since v7)
Changes in v7:
- Fixed style issues in anx7625 driver
- Removed DT property validation in anx7625 driver.
- Extracted common codes to another commit.
Changes in v6:
- Squashed to a single patch
drivers/gpu/drm/bridge/analogix/Kconfig | 1 + drivers/gpu/drm/bridge/analogix/anx7625.c | 88 +++++++++++++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.h | 13 ++++ 3 files changed, 102 insertions(+)
drivers/gpu/drm/bridge/analogix/Kconfig +1 -0
@@ -34,6 +34,7 @@ config DRM_ANALOGIX_ANX7625 tristate "Analogix Anx7625 MIPI to DP interface support" depends on DRM depends on OF + depends on TYPEC || TYPEC=n select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDCP_HELPER select DRM_DISPLAY_HELPER
drivers/gpu/drm/bridge/analogix/anx7625.c +88 -0
112 lines not on this page · raw message
drivers/gpu/drm/bridge/analogix/anx7625.h +13 -0
@@ -55,6 +55,18 @@#define HPD_STATUS_CHANGE 0x80#define HPD_STATUS 0x80 +#define TCPC_SWITCH_0 0xB4 +#define SW_SEL1_DPTX0_RX2 BIT(0) +#define SW_SEL1_DPTX0_RX1 BIT(1) +#define SW_SEL1_SSRX_RX2 BIT(4) +#define SW_SEL1_SSRX_RX1 BIT(5) + +#define TCPC_SWITCH_1 0xB5 +#define SW_SEL2_DPTX1_TX2 BIT(0) +#define SW_SEL2_DPTX1_TX1 BIT(1) +#define SW_SEL2_SSTX_TX2 BIT(4) +#define SW_SEL2_SSTX_TX1 BIT(5) +/******** END of I2C Address 0x58 ********/ /***************************************************************/
@@ -479,6 +491,7 @@ struct anx7625_data {struct drm_connector *connector;struct mipi_dsi_device *dsi;struct drm_dp_aux aux; + struct drm_dp_typec_switch_desc switch_desc; };#endif /* __ANX7625_H__ */
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH v9 6/9] drm/bridge: anx7625: Register Type C mode switches
Quoted 3 lines · Pin-yen Lin
Register USB Type-C mode switches when the "mode-switch" property and relevant port are available in Device Tree. Configure the crosspoint
^ ports
Quoted 2 lines
switch based on the entered alternate mode for a specific Type-C connector.
You should also mention that the "one mode switch" scenario is not covered in this implementation, due to lack of actual hardware.
Quoted 76 lines
Signed-off-by Pin-yen Lin <[email protected]>---
(no changes since v7)
Changes in v7:
- Fixed style issues in anx7625 driver
- Removed DT property validation in anx7625 driver.
- Extracted common codes to another commit.Changes in v6:
- Squashed to a single patchdrivers/gpu/drm/bridge/analogix/Kconfig | 1 + drivers/gpu/drm/bridge/analogix/anx7625.c | 88 +++++++++++++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.h | 13 ++++ 3 files changed, 102 insertions(+)drivers/gpu/drm/bridge/analogix/Kconfig +1
-0@@ -34,6 +34,7 @@ config DRM_ANALOGIX_ANX7625 tristate "Analogix Anx7625 MIPI to DP interface support" depends on DRM depends on OF + depends on TYPEC || TYPEC=n select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDCP_HELPER select DRM_DISPLAY_HELPERdrivers/gpu/drm/bridge/analogix/anx7625.c +30
-0@@ -15,6 +15,8 @@#include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/usb/typec_dp.h> +#include <linux/usb/typec_mux.h> #include <linux/workqueue.h> #include <linux/of_gpio.h> @@ -2572,6 +2574,86 @@ static void anx7625_runtime_disable(void *data)pm_runtime_disable (data); } +static void anx7625_set_crosspoint_switch (struct anx7625_data *ctx, +enum typec_orientation orientation) +{ +if (orientation ==TYPEC_ORIENTATION_NORMAL ) { +anx7625_reg_write (ctx, ctx->i2c.tcpc_client,TCPC_SWITCH_0 , +SW_SEL1_SSRX_RX1 |SW_SEL1_DPTX0_RX2 ); +anx7625_reg_write (ctx, ctx->i2c.tcpc_client,TCPC_SWITCH_1 , +SW_SEL2_SSTX_TX1 |SW_SEL2_DPTX1_TX2 ); + }else if (orientation ==TYPEC_ORIENTATION_REVERSE ) { +anx7625_reg_write (ctx, ctx->i2c.tcpc_client,TCPC_SWITCH_0 , +SW_SEL1_SSRX_RX2 |SW_SEL1_DPTX0_RX1 ); +anx7625_reg_write (ctx, ctx->i2c.tcpc_client,TCPC_SWITCH_1 , +SW_SEL2_SSTX_TX2 |SW_SEL2_DPTX1_TX1 ); + } +} + +static void anx7625_typec_two_ports_update (struct anx7625_data *ctx) +{ +struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc; +/* Check if both ports available and do nothing to retain the current one */ +if (switch_desc.typec_ports[0 ].dp_connected && switch_desc.typec_ports[1 ].dp_connected) +return ; + +if (switch_desc.typec_ports[0 ].dp_connected) +anx7625_set_crosspoint_switch (ctx,TYPEC_ORIENTATION_NORMAL ); +else if (switch_desc.typec_ports[1 ].dp_connected) +anx7625_set_crosspoint_switch (ctx,TYPEC_ORIENTATION_REVERSE ); +}
drivers/gpu/drm/bridge/analogix/anx7625.c static void anx7625_runtime_disable(void *data) · line 2614
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/anx7625.c +10
-0+ +static int anx7625_typec_mux_set (struct typec_mux_dev *mux, +struct typec_mux_state *state) +{ +struct drm_dp_typec_port_data *port_data =typec_mux_get_drvdata (mux); +struct anx7625_data *ctx = (struct anx7625_data *) port_data->data; +struct device *dev = &ctx->client->dev; +struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc; +bool new_dp_connected, old_dp_connected; +
And place a TODO note here.
Otherwise this looks OK.
Also,
on MT8192 based Hayato (ASUS Chromebook Flip CM3200).
And this also uncovered a deadlock in the unplug & disable path. I'll send a fix for that later once I figure out all the details.
Re: [PATCH v9 6/9] drm/bridge: anx7625: Register Type C mode switches
Hi Chen-Yu,
Thanks for the review.
Quoted 7 lines · Chen-Yu Tsai
Quoted 3 lines · Pin-yen Lin
Register USB Type-C mode switches when the "mode-switch" property and relevant port are available in Device Tree. Configure the crosspoint
^ ports
Thanks for catching this. I'll fix in v10.
Quoted 5 lines
Quoted 2 lines
switch based on the entered alternate mode for a specific Type-C connector.
You should also mention that the "one mode switch" scenario is not covered in this implementation, due to lack of actual hardware.
If I understand correctly, we should use "orientation-switch"[1] instead when the crosspoint switch on anx7625 is used to support different orientations of the Type-C connector.
I'll add some explanations around this in the commit message in v10.
[1]: https://docs.kernel.org/driver-api/usb/typec.html#multiplexer-demultiplexer-switches
Quoted 81 lines
Quoted 81 lines
Signed-off-by Pin-yen Lin <[email protected]>---
(no changes since v7)
Changes in v7:
- Fixed style issues in anx7625 driver
- Removed DT property validation in anx7625 driver.
- Extracted common codes to another commit.Changes in v6:
- Squashed to a single patchdrivers/gpu/drm/bridge/analogix/Kconfig | 1 + drivers/gpu/drm/bridge/analogix/anx7625.c | 88 +++++++++++++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.h | 13 ++++ 3 files changed, 102 insertions(+)drivers/gpu/drm/bridge/analogix/Kconfig +1
-0@@ -34,6 +34,7 @@ config DRM_ANALOGIX_ANX7625 tristate "Analogix Anx7625 MIPI to DP interface support" depends on DRM depends on OF + depends on TYPEC || TYPEC=n select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDCP_HELPER select DRM_DISPLAY_HELPERdrivers/gpu/drm/bridge/analogix/anx7625.c +34
-0@@ -15,6 +15,8 @@#include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/usb/typec_dp.h> +#include <linux/usb/typec_mux.h> #include <linux/workqueue.h> #include <linux/of_gpio.h> @@ -2572,6 +2574,86 @@ static void anx7625_runtime_disable(void *data)pm_runtime_disable (data); } +static void anx7625_set_crosspoint_switch (struct anx7625_data *ctx, +enum typec_orientation orientation) +{ +if (orientation ==TYPEC_ORIENTATION_NORMAL ) { +anx7625_reg_write (ctx, ctx->i2c.tcpc_client,TCPC_SWITCH_0 , +SW_SEL1_SSRX_RX1 |SW_SEL1_DPTX0_RX2 ); +anx7625_reg_write (ctx, ctx->i2c.tcpc_client,TCPC_SWITCH_1 , +SW_SEL2_SSTX_TX1 |SW_SEL2_DPTX1_TX2 ); + }else if (orientation ==TYPEC_ORIENTATION_REVERSE ) { +anx7625_reg_write (ctx, ctx->i2c.tcpc_client,TCPC_SWITCH_0 , +SW_SEL1_SSRX_RX2 |SW_SEL1_DPTX0_RX1 ); +anx7625_reg_write (ctx, ctx->i2c.tcpc_client,TCPC_SWITCH_1 , +SW_SEL2_SSTX_TX2 |SW_SEL2_DPTX1_TX1 ); + } +} + +static void anx7625_typec_two_ports_update (struct anx7625_data *ctx) +{ +struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc; +/* Check if both ports available and do nothing to retain the current one */ +if (switch_desc.typec_ports[0 ].dp_connected && switch_desc.typec_ports[1 ].dp_connected) +return ; + +if (switch_desc.typec_ports[0 ].dp_connected) +anx7625_set_crosspoint_switch (ctx,TYPEC_ORIENTATION_NORMAL ); +else if (switch_desc.typec_ports[1 ].dp_connected) +anx7625_set_crosspoint_switch (ctx,TYPEC_ORIENTATION_REVERSE ); +} + +static int anx7625_typec_mux_set (struct typec_mux_dev *mux, +struct typec_mux_state *state) +{
Quoted 8 lines
drivers/gpu/drm/bridge/analogix/anx7625.c static void anx7625_runtime_disable(void *data) · line 2614
Quoted 6 lines
drivers/gpu/drm/bridge/analogix/anx7625.c +6
-0+struct drm_dp_typec_port_data *port_data =typec_mux_get_drvdata (mux); +struct anx7625_data *ctx = (struct anx7625_data *) port_data->data; +struct device *dev = &ctx->client->dev; +struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc; +bool new_dp_connected, old_dp_connected; +And place a TODO note here.
I'll add it in v10.
Quoted 10 lines
Otherwise this looks OK.
Also,
Tested-by Chen-Yu Tsai <[email protected]>on MT8192 based Hayato (ASUS Chromebook Flip CM3200).
And this also uncovered a deadlock in the unplug & disable path. I'll send a fix for that later once I figure out all the details.
Thank you so much for this!
PATCH v9 7/9 dt-bindings: display: bridge: it6505: Add mode-switch support
In reply to Pin-yen LinITE IT6505 can be used in systems to switch the DP traffic between two downstreams, which can be USB Type-C DisplayPort alternate mode lane or regular DisplayPort output ports.
Update the binding to accommodate this usage by introducing a data-lanes and a mode-switch property on endpoints.
---
Changes in v9:
- Fixed subject prefix again
- Changed the naming of the example node for it6505
Changes in v8:
- Updated bindings for data-lanes property
- Fixed subject prefix
Changes in v7:
- Fixed issues reported by dt_binding_check.
- Updated the schema and the example dts for data-lanes.
- Changed to generic naming for the example dts node.
Changes in v6:
- Remove switches node and use endpoints and data-lanes property to describe the connections.
.../bindings/display/bridge/ite,it6505.yaml | 93 ++++++++++++++++--- 1 file changed, 82 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml +82 -11
@@ -77,20 +77,43 @@ properties: unevaluatedProperties: false description: Video port for DP output - properties: - endpoint: + patternProperties: + "^endpoint@[01]$": $ref: /schemas/graph.yaml#/$defs/endpoint-base unevaluatedProperties: false properties: + reg: + maxItems: 1 + + remote-endpoint: true + data-lanes: - minItems: 1 - uniqueItems: true - items: - - enum: [ 0, 1 ] - - const: 1 - - const: 2 - - const: 3 + oneOf: + - items: + - enum: [0, 1, 2, 3] + + - items: + - const: 0 + - const: 1 + + - items: + - const: 2 + - const: 3 + + - items: + - const: 0 + - const: 1 + - const: 2 + - const: 3 + + mode-switch: + type: boolean + description: Register this node as a Type-C mode switch or not. + + required: + - reg + - remote-endpoint required: - port@0
@@ -102,7 +125,6 @@ required: - pwr18-supply - interrupts - reset-gpios - - extcon - ports additionalProperties: false
@@ -139,8 +161,11 @@ examples: }; port@1 { + #address-cells = <1>; + #size-cells = <0>; reg = <1>; - it6505_out: endpoint { + it6505_out: endpoint@0 { + reg = <0>; remote-endpoint = <&dp_in>; data-lanes = <0 1>; };
@@ -148,3 +173,49 @@ examples: }; }; }; + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + dp-bridge@5c { + compatible = "ite,it6505"; + interrupts = <8 IRQ_TYPE_LEVEL_LOW 8 0>; + reg = <0x5c>; + pinctrl-names = "default"; + pinctrl-0 = <&it6505_pins>; + ovdd-supply = <&mt6366_vsim2_reg>; + pwr18-supply = <&pp1800_dpbrdg_dx>; + reset-gpios = <&pio 177 0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + it6505_dpi_in: endpoint { + remote-endpoint = <&dpi_out>; + }; + }; + port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + ite_typec0: endpoint@0 { + reg = <0>; + mode-switch; + data-lanes = <0 1>; + remote-endpoint = <&typec_port0>; + }; + ite_typec1: endpoint@1 { + reg = <1>; + mode-switch; + data-lanes = <2 3>; + remote-endpoint = <&typec_port1>; + }; + }; + }; + }; + };
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
PATCH v9 8/9 drm/bridge: it6505: Fix Kconfig indentation
In reply to Pin-yen LinReplace the spaces with tab characters in the Kconfig file.
---
(no changes since v7)
Changes in v7:
- New in v7
drivers/gpu/drm/bridge/Kconfig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/bridge/Kconfig +10 -10
@@ -85,19 +85,19 @@ config DRM_FSL_LDB Support for i.MX8MP DPI-to-LVDS on-SoC encoder. config DRM_ITE_IT6505 - tristate "ITE IT6505 DisplayPort bridge" - depends on OF + tristate "ITE IT6505 DisplayPort bridge" + depends on OF select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDCP_HELPER select DRM_DISPLAY_HELPER - select DRM_DP_AUX_BUS - select DRM_KMS_HELPER - select DRM_DP_HELPER - select EXTCON - select CRYPTO - select CRYPTO_HASH - help - ITE IT6505 DisplayPort bridge chip driver. + select DRM_DP_AUX_BUS + select DRM_KMS_HELPER + select DRM_DP_HELPER + select EXTCON + select CRYPTO + select CRYPTO_HASH + help + ITE IT6505 DisplayPort bridge chip driver. config DRM_LONTIUM_LT8912B tristate "Lontium LT8912B DSI/HDMI bridge"
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH v9 8/9] drm/bridge: it6505: Fix Kconfig indentation
Il 09/01/23 09:41, Pin-yen Lin ha scritto:
Quoted 3 lines
Replace the spaces with tab characters in the
Kconfigfile.Signed-off-by Pin-yen Lin <[email protected]>
PATCH v9 9/9 drm/bridge: it6505: Register Type C mode switches
In reply to Pin-yen LinRegister USB Type-C mode switches when the "mode-switch" property and relevant port are available in Device Tree. Configure the "lane_swap" state based on the entered alternate mode for a specific Type-C connector, which ends up updating the lane swap registers of the it6505 chip.
---
(no changes since v7)
Changes in v7:
- Fixed style issues in it6505 driver
- Removed the redundant sleep in it6505 driver
- Removed DT property validation in it6505 driver
- Rebased to drm-misc-next
- Extracted common codes to another commit
Changes in v6:
- Changed it6505_typec_mux_set callback function to accommodate with the latest drm-misc patches
- Changed the driver implementation to accommodate with the new binding
- Squashed to a single patch
drivers/gpu/drm/bridge/Kconfig | 1 + drivers/gpu/drm/bridge/ite-it6505.c | 119 +++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/Kconfig +1 -0
@@ -87,6 +87,7 @@ config DRM_FSL_LDB config DRM_ITE_IT6505 tristate "ITE IT6505 DisplayPort bridge" depends on OF + depends on TYPEC || TYPEC=n select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDCP_HELPER select DRM_DISPLAY_HELPER
drivers/gpu/drm/bridge/ite-it6505.c +115 -4
162 lines not on this page · raw message
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Don't know if this still needs reviews from me (feel free to respond if it does!), but I wanted to say nice work! This is something I've wanted to see added to DRM for a while ♥
Quoted 76 lines · Pin-yen Lin
This series introduces bindings for anx7625/it6505 to register Type-C mode-switch in their output endpoints, and use data-lanes property to describe the pin connections.
The first two patch modifies
fwnode_graph_devcon_matchesandcros_typec_init_portsto enable the registration of the switches.Patch 4~6 introduce the bindings for anx7625 and the corresponding driver modifications.
Patch 7~9 add similar bindings and driver changes for it6505.
v7: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/linux-usb/[email protected]/Changes in v9:
- Collected Reviewed-by tag
- Fixed subject prefix again
- Changed the naming of the example node for it6505Changes in v8:
- Fixed the build issue whenCONFIG_TYPEC=m
- Fixed some style issues
- Fixed the subject prefixes for the bindings patch
- Fixed the bindings for data-lanes propertiesChanges in v7:
- Fix the long comment lines
- Extracted the common codes to a helper function
- Fixed style issues in anx7625 driver
- Removed DT property validation in anx7625 driver.
- Fixed style issues in it6505 driver
- Removed the redundant sleep in it6505 driver
- Removed DT property validation in it6505 driver
- Rebased to drm-misc-next
- Fixed indentations in bindings patches
- Added a new patch to fix indentations inKconfigChanges in v6:
- Changedit6505_typec_mux_setcallback function to accommodate with the latest drm-misc patches
- Changed the driver implementation to accommodate with the new binding
- Dropped typec-switch binding and use endpoints and data-lanes properties to describe the pin connections
- Added new patches (patch 1,2,4) to fix probing issues
- Changed the bindings of it6505/anx7625 and modified the drivers accordingly
- Merged it6505/anx7625 driver changes into a single patchPin-yen Lin (7):
drm/display: Add Type-C switch helpers
dt-bindings: display: bridge: anx7625: Add mode-switch support drm/bridge: anx7625: Check for Type-C during panel registration drm/bridge: anx7625: Register Type C mode switches
dt-bindings: display: bridge: it6505: Add mode-switch support drm/bridge: it6505: FixKconfigindentation drm/bridge: it6505: Register Type C mode switchesPrashant Malani (2):
device property: Add remote endpoint to devcon matcher platform/chrome:cros_ec_typec: Purge blocking switch devlinks.../display/bridge/analogix,anx7625.yaml | 99 ++++++++++++- .../bindings/display/bridge/ite,it6505.yaml | 93 ++++++++++-- drivers/base/property.c | 15 ++ drivers/gpu/drm/bridge/Kconfig | 21 +-- drivers/gpu/drm/bridge/analogix/Kconfig | 1 + drivers/gpu/drm/bridge/analogix/anx7625.c | 101 +++++++++++++- drivers/gpu/drm/bridge/analogix/anx7625.h | 13 ++ drivers/gpu/drm/bridge/ite-it6505.c | 119 +++++++++++++++- drivers/gpu/drm/display/drm_dp_helper.c | 132 ++++++++++++++++++ drivers/platform/chrome/cros_ec_typec.c | 10 ++ include/drm/display/drm_dp_helper.h | 16 +++ 11 files changed, 591 insertions(+), 29 deletions(-)
Signature · 3 lines
Cheers, Lyude Paul (she/her) Software Engineer at Red Hat
Hi Lyude,
Thanks for letting me know!
I just sent out a v11 and already received some review comments, but reviews are always welcomed if you have time to take a look.
Regards,
Pin-yen
Quoted 89 lines · Lyude Paul
Don't know if this still needs reviews from me (feel free to respond if it does!), but I wanted to say nice work! This is something I've wanted to see added to DRM for a while ♥
Quoted 63 lines · Pin-yen Lin
This series introduces bindings for anx7625/it6505 to register Type-C mode-switch in their output endpoints, and use data-lanes property to describe the pin connections.
The first two patch modifies
fwnode_graph_devcon_matchesandcros_typec_init_portsto enable the registration of the switches.Patch 4~6 introduce the bindings for anx7625 and the corresponding driver modifications.
Patch 7~9 add similar bindings and driver changes for it6505.
v7: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/linux-usb/[email protected]/Changes in v9:
- Collected Reviewed-by tag
- Fixed subject prefix again
- Changed the naming of the example node for it6505Changes in v8:
- Fixed the build issue whenCONFIG_TYPEC=m
- Fixed some style issues
- Fixed the subject prefixes for the bindings patch
- Fixed the bindings for data-lanes propertiesChanges in v7:
- Fix the long comment lines
- Extracted the common codes to a helper function
- Fixed style issues in anx7625 driver
- Removed DT property validation in anx7625 driver.
- Fixed style issues in it6505 driver
- Removed the redundant sleep in it6505 driver
- Removed DT property validation in it6505 driver
- Rebased to drm-misc-next
- Fixed indentations in bindings patches
- Added a new patch to fix indentations inKconfigChanges in v6:
- Changedit6505_typec_mux_setcallback function to accommodate with the latest drm-misc patches
- Changed the driver implementation to accommodate with the new binding
- Dropped typec-switch binding and use endpoints and data-lanes properties to describe the pin connections
- Added new patches (patch 1,2,4) to fix probing issues
- Changed the bindings of it6505/anx7625 and modified the drivers accordingly
- Merged it6505/anx7625 driver changes into a single patchPin-yen Lin (7):
drm/display: Add Type-C switch helpers
dt-bindings: display: bridge: anx7625: Add mode-switch support drm/bridge: anx7625: Check for Type-C during panel registration drm/bridge: anx7625: Register Type C mode switches
dt-bindings: display: bridge: it6505: Add mode-switch support drm/bridge: it6505: FixKconfigindentation drm/bridge: it6505: Register Type C mode switchesPrashant Malani (2):
device property: Add remote endpoint to devcon matcher platform/chrome:cros_ec_typec: Purge blocking switch devlinksQuoted 13 lines
.../display/bridge/analogix,anx7625.yaml | 99 ++++++++++++- .../bindings/display/bridge/ite,it6505.yaml | 93 ++++++++++-- drivers/base/property.c | 15 ++ drivers/gpu/drm/bridge/Kconfig | 21 +-- drivers/gpu/drm/bridge/analogix/Kconfig | 1 + drivers/gpu/drm/bridge/analogix/anx7625.c | 101 +++++++++++++- drivers/gpu/drm/bridge/analogix/anx7625.h | 13 ++ drivers/gpu/drm/bridge/ite-it6505.c | 119 +++++++++++++++- drivers/gpu/drm/display/drm_dp_helper.c | 132 ++++++++++++++++++ drivers/platform/chrome/cros_ec_typec.c | 10 ++ include/drm/display/drm_dp_helper.h | 16 +++ 11 files changed, 591 insertions(+), 29 deletions(-)--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat