Skip to contentSkip to conversation

drm/bridge: lt9611c: improve HPD handling and driver robustness

PATCH New [email protected] 1 participant 6 messages Jun 27

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/bridge: lt9611c: improve HPD handling and driver robustness

From: Mohit Dsor <[email protected]>

This series improves HPD handling and overall robustness of the lt9611c bridge driver.

The HPD status read from the internal MCU may fail when the device is not fully initialized, leading to spurious disconnect events. This series mitigates such issues by falling back to a cached HPD state and adds support for explicit HPD enable handling.

Additionally, it fixes DT parsing and bridge refcount handling, corrects chip type initialization, and cleans up probe and remove paths.

Tested on LT9611UXD platforms.

Mohit Dsor (5):
drm/bridge: lt9611c: fallback to cached HPD status on read failure drm/bridge: lt9611c: implement hpd_enable callback drm/bridge: lt9611c: fix DT parsing and bridge refcount drm/bridge: lt9611c: fix chip type initialization drm/bridge: lt9611c: clean up probe error and remove paths

 drivers/gpu/drm/bridge/lontium-lt9611c.c | 39 +++++++++++++++++++-----
 1 file changed, 32 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/5 drm/bridge: lt9611c: fallback to cached HPD status on read failure

From: Mohit Dsor <[email protected]>

HPD status is retrieved via an MCU command. In some cases the command may fail, for example when the MCU is not yet ready, leading to incorrect disconnect reporting.

Instead of returning an error state, fall back to the last known HPD status to provide a more stable detection result.

This avoids spurious disconnect events during initialization.

---
 drivers/gpu/drm/bridge/lontium-lt9611c.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611c.c +4 -2
index 5d67bb7391fb..81ca9d62eae3 100644
@@ -711,10 +711,12 @@ lt9611c_bridge_detect(struct drm_bridge *bridge, struct drm_connector *connector
 	guard(mutex)(&lt9611c->ocm_lock);
 
 	ret = lt9611c_read_write_flow(lt9611c, cmd, ARRAY_SIZE(cmd), data, ARRAY_SIZE(data));
-	if (ret)
+	if (ret) {
 		dev_err(dev, "failed to read HPD status (err=%d)\n", ret);
-	else
+		connected = lt9611c->hdmi_connected;
+	} else {
 		connected = (data[4] == 0x02);
+	}
 
 	lt9611c->hdmi_connected = connected;
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/5 drm/bridge: lt9611c: implement hpd_enable callback

In reply to [email protected]

From: Mohit Dsor <[email protected]>

Implement the .hpd_enable callback to trigger HPD status update and schedule event propagation.

---
 drivers/gpu/drm/bridge/lontium-lt9611c.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/gpu/drm/bridge/lontium-lt9611c.c +18 -0
index 81ca9d62eae3..30a07e97626a 100644
@@ -923,6 +923,23 @@ static void lt9611c_hdmi_audio_shutdown(struct drm_bridge *bridge,
 	drm_atomic_helper_connector_hdmi_clear_audio_infoframe(connector);
 }
 
+static void lt9611c_bridge_hpd_enable(struct drm_bridge *bridge)
+{
+	struct lt9611c *lt9611c = bridge_to_lt9611c(bridge);
+	u8 cmd[5] = {0x52, 0x48, 0x31, 0x3a, 0x00};
+	u8 data[5];
+	int ret;
+
+	mutex_lock(&lt9611c->ocm_lock);
+	ret = lt9611c_read_write_flow(lt9611c, cmd, ARRAY_SIZE(cmd),
+				      data, ARRAY_SIZE(data));
+	if (!ret)
+		lt9611c->hdmi_connected = (data[4] == 0x02);
+	mutex_unlock(&lt9611c->ocm_lock);
+
+	schedule_work(&lt9611c->work);
+}
+
 static int lt9611c_hdmi_audio_startup(struct drm_bridge *bridge,
 				      struct drm_connector *connector)
 {
@@ -939,6 +956,7 @@ static const struct drm_bridge_funcs lt9611c_bridge_funcs = {
 	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
 	.atomic_reset = drm_atomic_helper_bridge_reset,
+	.hpd_enable = lt9611c_bridge_hpd_enable,
 
 	.hdmi_tmds_char_rate_valid = lt9611c_hdmi_tmds_char_rate_valid,
 	.hdmi_write_avi_infoframe = lt9611c_hdmi_write_avi_infoframe,
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/5 drm/bridge: lt9611c: fix DT parsing and bridge refcount

In reply to [email protected]

From: Mohit Dsor <[email protected]>

Ensure DT nodes are properly released on error and acquire a reference to next_bridge

---
 drivers/gpu/drm/bridge/lontium-lt9611c.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/lontium-lt9611c.c +10 -1
index 30a07e97626a..4c8a3829a4be 100644
@@ -974,6 +974,8 @@ static const struct drm_bridge_funcs lt9611c_bridge_funcs = {
 static int lt9611c_parse_dt(struct device *dev,
 			    struct lt9611c *lt9611c)
 {
+	int ret;
+
 	lt9611c->dsi0_node = of_graph_get_remote_node(dev->of_node, 0, -1);
 	if (!lt9611c->dsi0_node)
 		return dev_err_probe(dev, -ENODEV, "failed to get remote node for primary dsi\n");
@@ -984,7 +986,14 @@ static int lt9611c_parse_dt(struct device *dev,
 				 &lt9611c->selected_port))
 		lt9611c->selected_port = 0;
 
-	return drm_of_find_panel_or_bridge(dev->of_node, 2, -1, NULL, &lt9611c->bridge.next_bridge);
+	ret = drm_of_find_panel_or_bridge(dev->of_node, 2, -1, NULL, &lt9611c->bridge.next_bridge);
+	if (ret) {
+		of_node_put(lt9611c->dsi1_node);
+		of_node_put(lt9611c->dsi0_node);
+		return ret;
+	}
+	drm_bridge_get(lt9611c->bridge.next_bridge);
+	return 0;
 }
 
 static int lt9611c_gpio_init(struct lt9611c *lt9611c)
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/5 drm/bridge: lt9611c: fix chip type initialization

In reply to [email protected]

From: Mohit Dsor <[email protected]>

Remove redundant assignment of chip_type from I2C match as it is derived from DT data when available.

---
 drivers/gpu/drm/bridge/lontium-lt9611c.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/bridge/lontium-lt9611c.c +0 -1
index 4c8a3829a4be..d35a246e2d01 100644
@@ -1105,7 +1105,6 @@ static int lt9611c_probe(struct i2c_client *client)
 
 	lt9611c->dev = dev;
 	lt9611c->client = client;
-	lt9611c->chip_type = id->driver_data;
 
 	if (dev->of_node) {
 		lt9611c->chip_type = (uintptr_t)of_device_get_match_data(dev);
Signature · 1 line
2.34.1
#5 lore raw

PATCH 5/5 drm/bridge: lt9611c: clean up probe error and remove paths

In reply to [email protected]

From: Mohit Dsor <[email protected]>

Remove redundant cleanup of IRQ and bridge resources.

---
 drivers/gpu/drm/bridge/lontium-lt9611c.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611c.c +0 -3
index d35a246e2d01..30828bb9b3b8 100644
@@ -1234,9 +1234,7 @@ static int lt9611c_probe(struct i2c_client *client)
 	return 0;
 
 err_remove_bridge:
-	free_irq(client->irq, lt9611c);
 	cancel_work_sync(&lt9611c->work);
-	drm_bridge_remove(&lt9611c->bridge);
 
 err_disable_regulators:
 	regulator_bulk_disable(ARRAY_SIZE(lt9611c->supplies), lt9611c->supplies);
@@ -1252,7 +1250,6 @@ static void lt9611c_remove(struct i2c_client *client)
 {
 	struct lt9611c *lt9611c = i2c_get_clientdata(client);
 
-	free_irq(client->irq, lt9611c);
 	cancel_work_sync(&lt9611c->work);
 	regulator_bulk_disable(ARRAY_SIZE(lt9611c->supplies), lt9611c->supplies);
 	of_node_put(lt9611c->dsi1_node);
Signature · 1 line
2.34.1