Skip to contentSkip to conversation

usb: typec: tipd: improve probe diagnostics and POWER_STATUS handling

PATCH Superseded Radhey Shyam Pandey 2 participants 6 messages May 19 – Jun 1

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover usb: typec: tipd: improve probe diagnostics and POWER_STATUS handling

This series tightens TI TIPD (TPS6598x family) bring-up ergonomics and cleans up register bit definitions:

- Log vendor ID read failures with I2C return code and register value so boards with wiring or address mistakes are easier to debug at probe time.

- Treat operation without an interrupt line as a normal polling setup and log at debug instead of warning.

- Name TPS_REG_POWER_STATUS connection/source-sink bit masks and use them consistently with TPS_FIELD_GET (no behavior change).

Changes for v2:
- Extend commit description in 1/3 patch.
- Move to _dbg() for missing IRQ message in 2/3 patch.
- Add Heikki Krogerus Reviewed-by tag in 3/3 patch.

Link to v1:
https://lore.kernel.org/all/[email protected]

Radhey Shyam Pandey (3):
usb: typec: tipd: add error message for vendor ID read failure
usb: typec: tipd: demote missing IRQ message to debug
usb: typec: tipd: name TPS_REG_POWER_STATUS field masks

 drivers/usb/typec/tipd/core.c     |  9 ++++++---
 drivers/usb/typec/tipd/tps6598x.h | 10 +++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)

base-commit: 1a2ab0feaa23147e347b4d4cb79cb3fc392118eb

Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/3 usb: typec: tipd: add error message for vendor ID read failure

Log an error when the vendor ID read fails or returns zero, including the I2C error code and register value, and initialize the vendor ID variable to avoid logging an uninitialized value on read failure.

---
Changes for v2:
- Extend commit description to justify vid initialization.

---
 drivers/usb/typec/tipd/core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/typec/tipd/core.c +5 -2
index 43faec794b95..b282366b5326 100644
@@ -1744,7 +1744,7 @@ static int tps6598x_probe(struct i2c_client *client)
 	struct tps6598x *tps;
 	struct fwnode_handle *fwnode;
 	u32 status;
-	u32 vid;
+	u32 vid = 0;
 	int ret;
 
 	data = i2c_get_match_data(client);
@@ -1772,8 +1772,11 @@ static int tps6598x_probe(struct i2c_client *client)
 
 	if (!device_is_compatible(tps->dev, "ti,tps25750")) {
 		ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
-		if (ret < 0 || !vid)
+		if (ret < 0 || !vid) {
+			dev_err(tps->dev, "failed to read vendor ID: %d, vid: %#x\n",
+				ret, vid);
 			return -ENODEV;
+		}
 	}
 
 	/*
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] usb: typec: tipd: add error message for vendor ID read failure

Quoted 5 lines · Radhey Shyam Pandey

Log an error when the vendor ID read fails or returns zero, including the I2C error code and register value, and initialize the vendor ID variable to avoid logging an uninitialized value on read failure.

Quoted 35 lines

---
Changes for v2:
- Extend commit description to justify vid initialization.

---
 drivers/usb/typec/tipd/core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/typec/tipd/core.c +5 -2
index 43faec794b95..b282366b5326 100644
@@ -1744,7 +1744,7 @@ static int tps6598x_probe(struct i2c_client *client)
 	struct tps6598x *tps;
 	struct fwnode_handle *fwnode;
 	u32 status;
-	u32 vid;
+	u32 vid = 0;
 	int ret;
 
 	data = i2c_get_match_data(client);
@@ -1772,8 +1772,11 @@ static int tps6598x_probe(struct i2c_client *client)
 
 	if (!device_is_compatible(tps->dev, "ti,tps25750")) {
 		ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
-		if (ret < 0 || !vid)
+		if (ret < 0 || !vid) {
+			dev_err(tps->dev, "failed to read vendor ID: %d, vid: %#x\n",
+				ret, vid);
 			return -ENODEV;
+		}
 	}
 
 	/*
Signature · 1 line
2.43.0
Signature · 1 line
heikki
#3 lore raw

PATCH v2 2/3 usb: typec: tipd: demote missing IRQ message to debug

In reply to Radhey Shyam Pandey

Operating without an interrupt line and using the driver's polling path is valid. So move the log level to debug instead of warning.

---
Changes for v2:
- Suggested by Heikki Krogerus - make it dev_dbg.

---
 drivers/usb/typec/tipd/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tipd/core.c +1 -1
index b282366b5326..58cf486c3d68 100644
@@ -1853,7 +1853,7 @@ static int tps6598x_probe(struct i2c_client *client)
 						IRQF_SHARED | IRQF_ONESHOT,
 						dev_name(&client->dev), tps);
 	} else {
-		dev_warn(tps->dev, "Unable to find the interrupt, switching to polling\n");
+		dev_dbg(tps->dev, "no IRQ specified, using polling mode\n");
 		INIT_DELAYED_WORK(&tps->wq_poll, tps6598x_poll_work);
 		queue_delayed_work(system_power_efficient_wq, &tps->wq_poll,
 				   msecs_to_jiffies(POLL_INTERVAL));
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 2/3
#4 lore raw

Re: [PATCH v2 2/3] usb: typec: tipd: demote missing IRQ message to debug

Quoted 4 lines · Radhey Shyam Pandey

Operating without an interrupt line and using the driver's polling path is valid. So move the log level to debug instead of warning.

Quoted 22 lines

---
Changes for v2:
- Suggested by Heikki Krogerus - make it dev_dbg.

---
 drivers/usb/typec/tipd/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tipd/core.c +1 -1
index b282366b5326..58cf486c3d68 100644
@@ -1853,7 +1853,7 @@ static int tps6598x_probe(struct i2c_client *client)
 						IRQF_SHARED | IRQF_ONESHOT,
 						dev_name(&client->dev), tps);
 	} else {
-		dev_warn(tps->dev, "Unable to find the interrupt, switching to polling\n");
+		dev_dbg(tps->dev, "no IRQ specified, using polling mode\n");
 		INIT_DELAYED_WORK(&tps->wq_poll, tps6598x_poll_work);
 		queue_delayed_work(system_power_efficient_wq, &tps->wq_poll,
 				   msecs_to_jiffies(POLL_INTERVAL));
Signature · 1 line
2.43.0
Signature · 1 line
heikki
#5 lore raw

PATCH v2 3/3 usb: typec: tipd: name TPS_REG_POWER_STATUS field masks

In reply to Radhey Shyam Pandey

Define named masks for Power Status fields (connection and source/sink) and reuse them consistently for both field extraction and value construction. This avoids raw bit usage, keeps the definitions aligned. No functional change.

---
Changes for v2:
- Add Heikki Krogerus Reviewed-by tag.

---
 drivers/usb/typec/tipd/tps6598x.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/usb/typec/tipd/tps6598x.h +7 -3
index 03edbb77bbd6..d4140f4da5bb 100644
@@ -142,9 +142,13 @@
 #define TPS_SYSTEM_POWER_STATE_S4	0x04
 #define TPS_SYSTEM_POWER_STATE_S5	0x05
 
-/* TPS_REG_POWER_STATUS bits */
-#define TPS_POWER_STATUS_CONNECTION(x)  TPS_FIELD_GET(BIT(0), (x))
-#define TPS_POWER_STATUS_SOURCESINK(x)	TPS_FIELD_GET(BIT(1), (x))
+/* TPS_REG_POWER_STATUS bits (masks shared by TPS_FIELD_GET accessors and FIELD_PREP) */
+#define TPS_POWER_STATUS_CONNECTION_MASK	BIT(0)
+#define TPS_POWER_STATUS_SOURCESINK_MASK	BIT(1)
+#define TPS_POWER_STATUS_CONNECTION(x) \
+	TPS_FIELD_GET(TPS_POWER_STATUS_CONNECTION_MASK, (x))
+#define TPS_POWER_STATUS_SOURCESINK(x) \
+	TPS_FIELD_GET(TPS_POWER_STATUS_SOURCESINK_MASK, (x))
 #define TPS_POWER_STATUS_BC12_DET(x)	TPS_FIELD_GET(BIT(2), (x))
 
 #define TPS_POWER_STATUS_TYPEC_CURRENT_MASK GENMASK(3, 2)
Signature · 1 line
2.43.0