Skip to contentSkip to conversation

usb: typec: mux: tusb1046: add HPD_IN override support

PATCH In review Ajit Singh 4 participants 7 messages Nov 4 – Nov 19

Subsystems (4)
lore
Share & tools
lore

Ajit Singh

author
#0 lore raw

cover usb: typec: mux: tusb1046: add HPD_IN override support

For boards where HPD_IN is not asserted by hardware, the TUSB1046 allows software to force it high over I2C using the HPDIN_OVERRIDE bit in the General register (0x0A).

Add the optional ti,hpd-in-override property and driver support to force HPD_IN high when DisplayPort mode is selected, and clear the override when switching to USB or Safe mode.

Ajit Singh (2):
dt-bindings: usb: ti,tusb1046: document HPD_IN override
usb: typec: mux: tusb1046: support HPD_IN override

 .../devicetree/bindings/usb/ti,tusb1046.yaml       |  9 +++++++++
 drivers/usb/typec/mux/tusb1046.c                   | 14 ++++++++++++++
 2 files changed, 23 insertions(+)
Signature · 1 line
2.50.1 (Apple Git-155)
author
#1 lore raw

PATCH 1/2 dt-bindings: usb: ti,tusb1046: document HPD_IN override

For boards where HPD_IN is not asserted by hardware, the TUSB1046 can force it high over I2C using the HPDIN_OVERRIDE bit in the General register (0x0A).

Document the optional ti,hpd-in-override property to force HPD_IN high when DisplayPort mode is selected.

---
 Documentation/devicetree/bindings/usb/ti,tusb1046.yaml | 9 +++++++++
 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/usb/ti,tusb1046.yaml +9 -0
index e1501ea6b50b..58e9fde3ca71 100644
@@ -20,6 +20,14 @@ properties:
   reg:
     maxItems: 1
 
+  ti,hpd-in-override:
+    type: boolean
+    description: |
+      Force the HPD_IN signal high through the HPDIN_OVERRIDE bit in the
+      General register while DisplayPort Alt Mode is active. This is useful
+      on boards where HPD_IN is not driven by the downstream DisplayPort
+      sink.
+
 required:
   - compatible
   - reg
@@ -39,6 +47,7 @@ examples:
 
             mode-switch;
             orientation-switch;
+            ti,hpd-in-override;
 
             port {
                 endpoint {
Signature · 1 line
2.50.1 (Apple Git-155)
author
#4 lore raw

PATCH 2/2 usb: typec: mux: tusb1046: support HPD_IN override

In reply to Ajit Singh

For boards where HPD_IN is not asserted by hardware, software can force it high over I2C using the HPDIN_OVERRIDE bit in the General register (0x0A).

Add support for the optional ti,hpd-in-override property to force HPD_IN high when DisplayPort mode is selected. Clear the override when switching to USB or Safe mode, and preserve the existing bit value when the property is absent.

---
 drivers/usb/typec/mux/tusb1046.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/usb/typec/mux/tusb1046.c +14 -0
index 34ef81f75693..c21b1f8b9786 100644
@@ -21,6 +21,7 @@
 /* General register bits */
 #define TUSB1046_GENERAL_FLIPSEL BIT(2)
 #define TUSB1046_GENERAL_CTLSEL  GENMASK(1, 0)
+#define TUSB1046_GENERAL_HPDIN_OVERRIDE BIT(3)
 
 /* Mux modes */
 #define TUSB1046_CTLSEL_DISABLED          0x0
@@ -32,6 +33,7 @@ struct tusb1046_priv {
 	struct i2c_client *client;
 	struct typec_switch_dev *sw;
 	struct typec_mux_dev *mux;
+	bool hpdin_override;
 
 	/* Lock General register during accesses */
 	struct mutex general_reg_lock;
@@ -44,6 +46,7 @@ static int tusb1046_mux_set(struct typec_mux_dev *mux,
 	struct i2c_client *client = priv->client;
 	struct device *dev = &client->dev;
 	int mode, val, ret = 0;
+	bool dp_active = false;
 
 	if (state->mode >= TYPEC_STATE_MODAL &&
 	    state->alt->svid != USB_TYPEC_DP_SID)
@@ -67,9 +70,11 @@ static int tusb1046_mux_set(struct typec_mux_dev *mux,
 	case TYPEC_DP_STATE_C:
 	case TYPEC_DP_STATE_E:
 		mode = TUSB1046_CTLSEL_4LANE_DP;
+		dp_active = true;
 		break;
 	case TYPEC_DP_STATE_D:
 		mode = TUSB1046_CTLSEL_USB3_AND_2LANE_DP;
+		dp_active = true;
 		break;
 	case TYPEC_STATE_SAFE:
 	default:
@@ -80,6 +85,13 @@ static int tusb1046_mux_set(struct typec_mux_dev *mux,
 	val &= ~TUSB1046_GENERAL_CTLSEL;
 	val |= mode;
 
+	if (priv->hpdin_override) {
+		if (dp_active)
+			val |= TUSB1046_GENERAL_HPDIN_OVERRIDE;
+		else
+			val &= ~TUSB1046_GENERAL_HPDIN_OVERRIDE;
+	}
+
 	ret = i2c_smbus_write_byte_data(client, TUSB1046_REG_GENERAL, val);
 
 out_unlock:
@@ -131,6 +143,8 @@ static int tusb1046_i2c_probe(struct i2c_client *client)
 		return -ENOMEM;
 
 	priv->client = client;
+	priv->hpdin_override =
+		device_property_read_bool(dev, "ti,hpd-in-override");
 
 	mutex_init(&priv->general_reg_lock);
 
Signature · 1 line
2.50.1 (Apple Git-155)
#5 lore raw

Re: [PATCH v1 2/2] usb: typec: mux: tusb1046: support HPD_IN override

Sashiko has reviewed this patch and found no issues.
Quoted 10 lines

For boards where HPD_IN is not asserted by hardware, software can force it high over I2C using the HPDIN_OVERRIDE bit in the General register (0x0A).

Add support for the optional ti,hpd-in-override property to force HPD_IN high when DisplayPort mode is selected. Clear the override when switching to USB or Safe mode, and preserve the existing bit value when the property is absent.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#2 lore raw

Re: [PATCH v1 1/2] dt-bindings: usb: ti,tusb1046: document HPD_IN override

In reply to Ajit Singh
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

For boards where HPD_IN is not asserted by hardware, the TUSB1046 can force it high over I2C using the HPDIN_OVERRIDE bit in the General register (0x0A).

Document the optional ti,hpd-in-override property to force HPD_IN high when DisplayPort mode is selected.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Acked-by on v1 2/2
#6 lore raw

Re: [PATCH v1 2/2] usb: typec: mux: tusb1046: support HPD_IN override

In reply to Ajit Singh
Quoted 10 lines · Ajit Singh

For boards where HPD_IN is not asserted by hardware, software can force it high over I2C using the HPDIN_OVERRIDE bit in the General register (0x0A).

Add support for the optional ti,hpd-in-override property to force HPD_IN high when DisplayPort mode is selected. Clear the override when switching to USB or Safe mode, and preserve the existing bit value when the property is absent.

Quoted 70 lines
---
 drivers/usb/typec/mux/tusb1046.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/usb/typec/mux/tusb1046.c +14 -0
index 34ef81f75693..c21b1f8b9786 100644
@@ -21,6 +21,7 @@
 /* General register bits */
 #define TUSB1046_GENERAL_FLIPSEL BIT(2)
 #define TUSB1046_GENERAL_CTLSEL  GENMASK(1, 0)
+#define TUSB1046_GENERAL_HPDIN_OVERRIDE BIT(3)
 
 /* Mux modes */
 #define TUSB1046_CTLSEL_DISABLED          0x0
@@ -32,6 +33,7 @@ struct tusb1046_priv {
 	struct i2c_client *client;
 	struct typec_switch_dev *sw;
 	struct typec_mux_dev *mux;
+	bool hpdin_override;
 
 	/* Lock General register during accesses */
 	struct mutex general_reg_lock;
@@ -44,6 +46,7 @@ static int tusb1046_mux_set(struct typec_mux_dev *mux,
 	struct i2c_client *client = priv->client;
 	struct device *dev = &client->dev;
 	int mode, val, ret = 0;
+	bool dp_active = false;
 
 	if (state->mode >= TYPEC_STATE_MODAL &&
 	    state->alt->svid != USB_TYPEC_DP_SID)
@@ -67,9 +70,11 @@ static int tusb1046_mux_set(struct typec_mux_dev *mux,
 	case TYPEC_DP_STATE_C:
 	case TYPEC_DP_STATE_E:
 		mode = TUSB1046_CTLSEL_4LANE_DP;
+		dp_active = true;
 		break;
 	case TYPEC_DP_STATE_D:
 		mode = TUSB1046_CTLSEL_USB3_AND_2LANE_DP;
+		dp_active = true;
 		break;
 	case TYPEC_STATE_SAFE:
 	default:
@@ -80,6 +85,13 @@ static int tusb1046_mux_set(struct typec_mux_dev *mux,
 	val &= ~TUSB1046_GENERAL_CTLSEL;
 	val |= mode;
 
+	if (priv->hpdin_override) {
+		if (dp_active)
+			val |= TUSB1046_GENERAL_HPDIN_OVERRIDE;
+		else
+			val &= ~TUSB1046_GENERAL_HPDIN_OVERRIDE;
+	}
+
 	ret = i2c_smbus_write_byte_data(client, TUSB1046_REG_GENERAL, val);
 
 out_unlock:
@@ -131,6 +143,8 @@ static int tusb1046_i2c_probe(struct i2c_client *client)
 		return -ENOMEM;
 
 	priv->client = client;
+	priv->hpdin_override =
+		device_property_read_bool(dev, "ti,hpd-in-override");
 
 	mutex_init(&priv->general_reg_lock);
 
Signature · 1 line
2.50.1 (Apple Git-155)
Signature · 1 line
heikki
maintainer
#3 lore raw

Re: [PATCH v1 1/2] dt-bindings: usb: ti,tusb1046: document HPD_IN override

In reply to Ajit Singh
Quoted 17 lines · Ajit Singh

For boards where HPD_IN is not asserted by hardware, the TUSB1046 can force it high over I2C using the HPDIN_OVERRIDE bit in the General register (0x0A).

Document the optional ti,hpd-in-override property to force HPD_IN high when DisplayPort mode is selected.

---
 Documentation/devicetree/bindings/usb/ti,tusb1046.yaml | 9 +++++++++
 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/usb/ti,tusb1046.yaml +0 -0
index e1501ea6b50b..58e9fde3ca71 100644

Documentation/devicetree/bindings/usb/ti,tusb1046.yaml properties: · line 29

Quoted 10 lines
Documentation/devicetree/bindings/usb/ti,tusb1046.yaml +7 -0
@@ -20,6 +20,14 @@ properties:
   reg:
     maxItems: 1
 
+  ti,hpd-in-override:
+    type: boolean
+    description: |
+      Force the HPD_IN signal high through the HPDIN_OVERRIDE bit in the
+      General register while DisplayPort Alt Mode is active. This is useful
+      on boards where HPD_IN is not driven by the downstream DisplayPort
+      sink.

The existing no-hpd property doesn't work here?

Rob