2023-01-09 08:55:49

by Pin-yen Lin

[permalink] [raw]
Subject: [PATCH v9 0/9] 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(-)

--
2.39.0.314.g84b9a713c41-goog


2023-01-09 09:03:08

by Pin-yen Lin

[permalink] [raw]
Subject: [PATCH v9 4/9] dt-bindings: display: bridge: anx7625: Add mode-switch support

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.

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]>

---

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(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
index 4590186c4a0b..b49a350c40e3 100644
--- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -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>;
+ };
+ };
+ };
+ };
+ };
--
2.39.0.314.g84b9a713c41-goog

2023-01-09 09:03:22

by Pin-yen Lin

[permalink] [raw]
Subject: [PATCH v9 5/9] drm/bridge: anx7625: Check for Type-C during panel registration

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]>

---

(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(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index b375887e655d..1cf242130b91 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -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) {
--
2.39.0.314.g84b9a713c41-goog

2023-01-09 09:03:54

by Pin-yen Lin

[permalink] [raw]
Subject: [PATCH v9 8/9] drm/bridge: it6505: Fix Kconfig indentation

Replace the spaces with tab characters in the Kconfig file.

Signed-off-by: Pin-yen Lin <[email protected]>
---

(no changes since v7)

Changes in v7:
- New in v7

drivers/gpu/drm/bridge/Kconfig | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 57946d80b02d..737578dd57ed 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -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"
--
2.39.0.314.g84b9a713c41-goog

2023-01-09 09:07:02

by Pin-yen Lin

[permalink] [raw]
Subject: [PATCH v9 7/9] dt-bindings: display: bridge: it6505: Add mode-switch support

ITE 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.

Signed-off-by: Pin-yen Lin <[email protected]>

---

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(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml
index b16a9d9127dd..94182f131f86 100644
--- a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml
@@ -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>;
+ };
+ };
+ };
+ };
+ };
--
2.39.0.314.g84b9a713c41-goog

2023-01-09 09:24:30

by Pin-yen Lin

[permalink] [raw]
Subject: [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.

Signed-off-by: Prashant Malani <[email protected]>
Signed-off-by: Pin-yen Lin <[email protected]>

---

(no changes since v6)

Changes in v6:
- New in v6

drivers/base/property.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 2a5a37fcd998..48877af4e444 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -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);
--
2.39.0.314.g84b9a713c41-goog

2023-01-09 09:24:35

by Pin-yen Lin

[permalink] [raw]
Subject: [PATCH v9 6/9] drm/bridge: anx7625: Register Type C mode switches

Register 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.

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 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(+)

diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/bridge/analogix/Kconfig
index 173dada218ec..992b43ed1dd7 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -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
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 1cf242130b91..2bb504a8d789 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -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)
+{
+ 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;
+
+ if (switch_desc.num_typec_switches == 1)
+ return 0;
+
+ old_dp_connected = switch_desc.typec_ports[0].dp_connected ||
+ switch_desc.typec_ports[1].dp_connected;
+
+ port_data->dp_connected = state->alt &&
+ state->alt->svid == USB_TYPEC_DP_SID &&
+ state->alt->mode == USB_TYPEC_DP_MODE;
+
+ dev_dbg(dev, "mux_set dp_connected: c0=%d, c1=%d\n",
+ switch_desc.typec_ports[0].dp_connected, switch_desc.typec_ports[1].dp_connected);
+
+ new_dp_connected = switch_desc.typec_ports[0].dp_connected ||
+ switch_desc.typec_ports[1].dp_connected;
+
+ /* dp on, power on first */
+ if (!old_dp_connected && new_dp_connected)
+ pm_runtime_get_sync(dev);
+
+ anx7625_typec_two_ports_update(ctx);
+
+ /* dp off, power off last */
+ if (old_dp_connected && !new_dp_connected)
+ pm_runtime_put_sync(dev);
+
+ return 0;
+}
+
+static void anx7625_unregister_typec_switches(struct anx7625_data *ctx)
+{
+ drm_dp_unregister_typec_switches(&ctx->switch_desc);
+}
+
+static int anx7625_register_typec_switches(struct device *dev, struct anx7625_data *ctx)
+{
+ struct device_node *port = of_graph_get_port_by_id(dev->of_node, 1);
+
+ return drm_dp_register_typec_switches(dev, port, &ctx->switch_desc,
+ ctx, anx7625_typec_mux_set);
+}
+
static int anx7625_i2c_probe(struct i2c_client *client)
{
struct anx7625_data *platform;
@@ -2679,6 +2761,10 @@ static int anx7625_i2c_probe(struct i2c_client *client)
if (platform->pdata.intp_irq)
queue_work(platform->workqueue, &platform->work);

+ ret = anx7625_register_typec_switches(dev, platform);
+ if (ret && ret != -ENODEV)
+ dev_warn(dev, "Didn't register Type-C switches, err: %d\n", ret);
+
platform->bridge.funcs = &anx7625_bridge_funcs;
platform->bridge.of_node = client->dev.of_node;
if (!anx7625_of_panel_on_aux_bus(&client->dev))
@@ -2730,6 +2816,8 @@ static void anx7625_i2c_remove(struct i2c_client *client)

drm_bridge_remove(&platform->bridge);

+ anx7625_unregister_typec_switches(platform);
+
if (platform->pdata.intp_irq)
destroy_workqueue(platform->workqueue);

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/analogix/anx7625.h
index 14f33d6be289..38abbd3d6b36 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.h
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.h
@@ -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__ */
--
2.39.0.314.g84b9a713c41-goog

2023-01-09 09:29:06

by Pin-yen Lin

[permalink] [raw]
Subject: [PATCH v9 9/9] drm/bridge: it6505: Register Type C mode switches

Register 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.

Signed-off-by: Pin-yen Lin <[email protected]>

---

(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(-)

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 737578dd57ed..33803f581562 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -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
diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 9cda2df21b88..d9be09e889e2 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -17,6 +17,8 @@
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/types.h>
+#include <linux/usb/typec_dp.h>
+#include <linux/usb/typec_mux.h>
#include <linux/wait.h>

#include <crypto/hash.h>
@@ -28,6 +30,7 @@
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_edid.h>
+#include <drm/drm_of.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>

@@ -455,6 +458,7 @@ struct it6505 {
struct delayed_work delayed_audio;
struct it6505_audio_data audio;
struct dentry *debugfs;
+ struct drm_dp_typec_switch_desc switch_desc;

/* it6505 driver hold option */
bool enable_drv_hold;
@@ -3346,12 +3350,105 @@ static void it6505_shutdown(struct i2c_client *client)
it6505_lane_off(it6505);
}

+static void it6505_typec_ports_update(struct it6505 *it6505)
+{
+ struct drm_dp_typec_switch_desc switch_desc = it6505->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)
+ it6505->lane_swap = false;
+ else if (switch_desc.typec_ports[1].dp_connected)
+ it6505->lane_swap = true;
+}
+
+static int it6505_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 it6505 *it6505 = (struct it6505 *) port_data->data;
+ struct device *dev = &it6505->client->dev;
+ struct drm_dp_typec_switch_desc switch_desc = it6505->switch_desc;
+ bool old_dp_connected, new_dp_connected;
+
+ if (switch_desc.num_typec_switches == 1)
+ return 0;
+
+ mutex_lock(&it6505->extcon_lock);
+
+ old_dp_connected = switch_desc.typec_ports[0].dp_connected ||
+ switch_desc.typec_ports[1].dp_connected;
+
+ port_data->dp_connected = state->alt &&
+ state->alt->svid == USB_TYPEC_DP_SID &&
+ state->alt->mode == USB_TYPEC_DP_MODE;
+
+ dev_dbg(dev, "mux_set dp_connected: c0=%d, c1=%d\n",
+ switch_desc.typec_ports[0].dp_connected, switch_desc.typec_ports[1].dp_connected);
+
+ new_dp_connected = switch_desc.typec_ports[0].dp_connected ||
+ switch_desc.typec_ports[1].dp_connected;
+
+ if (it6505->enable_drv_hold) {
+ dev_dbg(dev, "enable driver hold\n");
+ goto unlock;
+ }
+
+ it6505_typec_ports_update(it6505);
+
+ if (!old_dp_connected && new_dp_connected) {
+ int ret = pm_runtime_get_sync(dev);
+
+ /*
+ * pm_runtime_force_suspend() disables runtime PM when the
+ * system enters suspend state. But on system resume, mux_set
+ * can be triggered before pm_runtime_force_resume() re-enables
+ * runtime PM. This makes the bridge stay powered off if the
+ * downstream display is connected when the system is suspended.
+ * Handling the error here to make sure the bridge is powered
+ * on, and leave the PM runtime usage count incremented so
+ * the future runtime PM calls is balanced.
+ */
+ if (ret < 0)
+ it6505_poweron(it6505);
+
+ complete_all(&it6505->extcon_completion);
+ }
+
+ if (old_dp_connected && !new_dp_connected) {
+ reinit_completion(&it6505->extcon_completion);
+ pm_runtime_put_sync(dev);
+ if (it6505->bridge.dev)
+ drm_helper_hpd_irq_event(it6505->bridge.dev);
+ memset(it6505->dpcd, 0, sizeof(it6505->dpcd));
+ }
+
+unlock:
+ mutex_unlock(&it6505->extcon_lock);
+ return 0;
+}
+
+static void it6505_unregister_typec_switches(struct it6505 *it6505)
+{
+ drm_dp_unregister_typec_switches(&it6505->switch_desc);
+}
+
+static int it6505_register_typec_switches(struct device *dev, struct it6505 *it6505)
+{
+ struct device_node *port = of_graph_get_port_by_id(dev->of_node, 1);
+
+ return drm_dp_register_typec_switches(dev, port, &it6505->switch_desc,
+ it6505, it6505_typec_mux_set);
+}
+
static int it6505_i2c_probe(struct i2c_client *client)
{
struct it6505 *it6505;
struct device *dev = &client->dev;
struct extcon_dev *extcon;
- int err, intp_irq;
+ int err, intp_irq, ret;

it6505 = devm_kzalloc(&client->dev, sizeof(*it6505), GFP_KERNEL);
if (!it6505)
@@ -3371,11 +3468,24 @@ static int it6505_i2c_probe(struct i2c_client *client)
if (PTR_ERR(extcon) == -EPROBE_DEFER)
return -EPROBE_DEFER;
if (IS_ERR(extcon)) {
- dev_err(dev, "can not get extcon device!");
- return PTR_ERR(extcon);
+ if (PTR_ERR(extcon) != -ENODEV)
+ dev_warn(dev, "Cannot get extcon device: %ld\n",
+ PTR_ERR(extcon));
+ it6505->extcon = NULL;
+ } else {
+ it6505->extcon = extcon;
}

- it6505->extcon = extcon;
+ ret = it6505_register_typec_switches(dev, it6505);
+ if (ret) {
+ if (ret != -ENODEV)
+ dev_warn(dev, "Didn't register Type-C switches, err: %d\n",
+ ret);
+ if (!it6505->extcon) {
+ dev_err(dev, "Both extcon and typec-switch are not registered.\n");
+ return -EINVAL;
+ }
+ }

it6505->regmap = devm_regmap_init_i2c(client, &it6505_regmap_config);
if (IS_ERR(it6505->regmap)) {
@@ -3447,6 +3557,7 @@ static void it6505_i2c_remove(struct i2c_client *client)
it6505_debugfs_remove(it6505);
it6505_poweroff(it6505);
it6505_remove_edid(it6505);
+ it6505_unregister_typec_switches(it6505);
}

static const struct i2c_device_id it6505_id[] = {
--
2.39.0.314.g84b9a713c41-goog

2023-01-09 09:55:54

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v9 1/9] device property: Add remote endpoint to devcon matcher

On Mon, Jan 9, 2023 at 4:41 PM Pin-yen Lin <[email protected]> wrote:
>
> 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.
>
> Signed-off-by: Prashant Malani <[email protected]>
> Signed-off-by: Pin-yen Lin <[email protected]>

Reviewed-by: Chen-Yu Tsai <[email protected]>
Tested-by: Chen-Yu Tsai <[email protected]>

on MT8192 based Hayato (ASUS Chromebook Flip CM3200).

2023-01-09 09:56:31

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v9 4/9] dt-bindings: display: bridge: anx7625: Add mode-switch support

On Mon, Jan 9, 2023 at 4:41 PM Pin-yen Lin <[email protected]> wrote:
>
> 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.
>
> 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]>

Reviewed-by: Chen-Yu Tsai <[email protected]>
Tested-by: Chen-Yu Tsai <[email protected]>

on MT8192 based Hayato (ASUS Chromebook Flip CM3200).

2023-01-09 10:42:56

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v9 5/9] drm/bridge: anx7625: Check for Type-C during panel registration

On Mon, Jan 9, 2023 at 4:41 PM Pin-yen Lin <[email protected]> wrote:
>
> 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]>

Reviewed-by: Chen-Yu Tsai <[email protected]>
Tested-by: Chen-Yu Tsai <[email protected]>

on MT8192 based Hayato (ASUS Chromebook Flip CM3200).

2023-01-09 11:40:38

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v9 6/9] drm/bridge: anx7625: Register Type C mode switches

On Mon, Jan 9, 2023 at 4:41 PM Pin-yen Lin <[email protected]> wrote:
>
> Register USB Type-C mode switches when the "mode-switch" property and
> relevant port are available in Device Tree. Configure the crosspoint
^ ports

> 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.

> 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 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(+)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/bridge/analogix/Kconfig
> index 173dada218ec..992b43ed1dd7 100644
> --- a/drivers/gpu/drm/bridge/analogix/Kconfig
> +++ b/drivers/gpu/drm/bridge/analogix/Kconfig
> @@ -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
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index 1cf242130b91..2bb504a8d789 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -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)
> +{
> + 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,

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.

Subject: Re: [PATCH v9 8/9] drm/bridge: it6505: Fix Kconfig indentation

Il 09/01/23 09:41, Pin-yen Lin ha scritto:
> Replace the spaces with tab characters in the Kconfig file.
>
> Signed-off-by: Pin-yen Lin <[email protected]>

Reviewed-by: AngeloGioacchino Del Regno <[email protected]>


Subject: Re: [PATCH v9 4/9] dt-bindings: display: bridge: anx7625: Add mode-switch support

Il 09/01/23 09:40, Pin-yen Lin ha scritto:
> 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.
>
> 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]>
>

Reviewed-by: AngeloGioacchino Del Regno <[email protected]>


2023-01-11 04:11:33

by Pin-yen Lin

[permalink] [raw]
Subject: Re: [PATCH v9 6/9] drm/bridge: anx7625: Register Type C mode switches

Hi Chen-Yu,

Thanks for the review.

On Mon, Jan 9, 2023 at 7:26 PM Chen-Yu Tsai <[email protected]> wrote:
>
> On Mon, Jan 9, 2023 at 4:41 PM Pin-yen Lin <[email protected]> wrote:
> >
> > 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.
> > 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
>
> > 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 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(+)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/bridge/analogix/Kconfig
> > index 173dada218ec..992b43ed1dd7 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Kconfig
> > +++ b/drivers/gpu/drm/bridge/analogix/Kconfig
> > @@ -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
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 1cf242130b91..2bb504a8d789 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -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)
> > +{
> > + 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.
>
> 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!

2023-01-30 23:11:31

by Lyude Paul

[permalink] [raw]
Subject: Re: [PATCH v9 0/9] Register Type-C mode-switch in DP bridge endpoints

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 ♥


On Mon, 2023-01-09 at 16:40 +0800, Pin-yen Lin wrote:
> 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(-)
>

--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat


2023-02-07 10:12:08

by Pin-yen Lin

[permalink] [raw]
Subject: Re: [PATCH v9 0/9] Register Type-C mode-switch in DP bridge endpoints

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

On Tue, Jan 31, 2023 at 7:10 AM Lyude Paul <[email protected]> wrote:
>
> 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 ♥
>
>
> On Mon, 2023-01-09 at 16:40 +0800, Pin-yen Lin wrote:
> > 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(-)
> >
>
> --
> Cheers,
> Lyude Paul (she/her)
> Software Engineer at Red Hat
>