Linux USB
 help / color / mirror / Atom feed
* [PATCH v2 0/3] usb: typec: tipd: improve probe diagnostics and POWER_STATUS handling
@ 2026-05-19 18:19 Radhey Shyam Pandey
  2026-05-19 18:19 ` [PATCH v2 1/3] usb: typec: tipd: add error message for vendor ID read failure Radhey Shyam Pandey
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Radhey Shyam Pandey @ 2026-05-19 18:19 UTC (permalink / raw)
  To: heikki.krogerus, gregkh; +Cc: linux-usb, linux-kernel, git, Radhey Shyam Pandey

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/20260513182850.165349-1-radhey.shyam.pandey@amd.com

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] usb: typec: tipd: add error message for vendor ID read failure
  2026-05-19 18:19 [PATCH v2 0/3] usb: typec: tipd: improve probe diagnostics and POWER_STATUS handling Radhey Shyam Pandey
@ 2026-05-19 18:19 ` Radhey Shyam Pandey
  2026-06-01 13:38   ` Heikki Krogerus
  2026-05-19 18:19 ` [PATCH v2 2/3] usb: typec: tipd: demote missing IRQ message to debug Radhey Shyam Pandey
  2026-05-19 18:19 ` [PATCH v2 3/3] usb: typec: tipd: name TPS_REG_POWER_STATUS field masks Radhey Shyam Pandey
  2 siblings, 1 reply; 6+ messages in thread
From: Radhey Shyam Pandey @ 2026-05-19 18:19 UTC (permalink / raw)
  To: heikki.krogerus, gregkh; +Cc: linux-usb, linux-kernel, git, 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.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
---
Changes for v2:
- Extend commit description to justify vid initialization.
---
 drivers/usb/typec/tipd/core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 43faec794b95..b282366b5326 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -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;
+		}
 	}
 
 	/*
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] usb: typec: tipd: demote missing IRQ message to debug
  2026-05-19 18:19 [PATCH v2 0/3] usb: typec: tipd: improve probe diagnostics and POWER_STATUS handling Radhey Shyam Pandey
  2026-05-19 18:19 ` [PATCH v2 1/3] usb: typec: tipd: add error message for vendor ID read failure Radhey Shyam Pandey
@ 2026-05-19 18:19 ` Radhey Shyam Pandey
  2026-06-01 13:39   ` Heikki Krogerus
  2026-05-19 18:19 ` [PATCH v2 3/3] usb: typec: tipd: name TPS_REG_POWER_STATUS field masks Radhey Shyam Pandey
  2 siblings, 1 reply; 6+ messages in thread
From: Radhey Shyam Pandey @ 2026-05-19 18:19 UTC (permalink / raw)
  To: heikki.krogerus, gregkh; +Cc: linux-usb, linux-kernel, git, 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.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
---
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(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index b282366b5326..58cf486c3d68 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -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));
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] usb: typec: tipd: name TPS_REG_POWER_STATUS field masks
  2026-05-19 18:19 [PATCH v2 0/3] usb: typec: tipd: improve probe diagnostics and POWER_STATUS handling Radhey Shyam Pandey
  2026-05-19 18:19 ` [PATCH v2 1/3] usb: typec: tipd: add error message for vendor ID read failure Radhey Shyam Pandey
  2026-05-19 18:19 ` [PATCH v2 2/3] usb: typec: tipd: demote missing IRQ message to debug Radhey Shyam Pandey
@ 2026-05-19 18:19 ` Radhey Shyam Pandey
  2 siblings, 0 replies; 6+ messages in thread
From: Radhey Shyam Pandey @ 2026-05-19 18:19 UTC (permalink / raw)
  To: heikki.krogerus, gregkh; +Cc: linux-usb, linux-kernel, git, 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.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
---
Changes for v2:
- Add Heikki Krogerus Reviewed-by tag.
---
 drivers/usb/typec/tipd/tps6598x.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h
index 03edbb77bbd6..d4140f4da5bb 100644
--- a/drivers/usb/typec/tipd/tps6598x.h
+++ b/drivers/usb/typec/tipd/tps6598x.h
@@ -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)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/3] usb: typec: tipd: add error message for vendor ID read failure
  2026-05-19 18:19 ` [PATCH v2 1/3] usb: typec: tipd: add error message for vendor ID read failure Radhey Shyam Pandey
@ 2026-06-01 13:38   ` Heikki Krogerus
  0 siblings, 0 replies; 6+ messages in thread
From: Heikki Krogerus @ 2026-06-01 13:38 UTC (permalink / raw)
  To: Radhey Shyam Pandey; +Cc: gregkh, linux-usb, linux-kernel, git

On Tue, May 19, 2026 at 11:49:54PM +0530, Radhey Shyam Pandey wrote:
> 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.
> 
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> Changes for v2:
> - Extend commit description to justify vid initialization.
> ---
>  drivers/usb/typec/tipd/core.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 43faec794b95..b282366b5326 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -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;
> +		}
>  	}
>  
>  	/*
> -- 
> 2.43.0

-- 
heikki

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/3] usb: typec: tipd: demote missing IRQ message to debug
  2026-05-19 18:19 ` [PATCH v2 2/3] usb: typec: tipd: demote missing IRQ message to debug Radhey Shyam Pandey
@ 2026-06-01 13:39   ` Heikki Krogerus
  0 siblings, 0 replies; 6+ messages in thread
From: Heikki Krogerus @ 2026-06-01 13:39 UTC (permalink / raw)
  To: Radhey Shyam Pandey; +Cc: gregkh, linux-usb, linux-kernel, git

On Tue, May 19, 2026 at 11:49:55PM +0530, Radhey Shyam Pandey wrote:
> Operating without an interrupt line and using the driver's polling path
> is valid. So move the log level to debug instead of warning.
> 
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> 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(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index b282366b5326..58cf486c3d68 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -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));
> -- 
> 2.43.0

-- 
heikki

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-06-01 13:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19 18:19 [PATCH v2 0/3] usb: typec: tipd: improve probe diagnostics and POWER_STATUS handling Radhey Shyam Pandey
2026-05-19 18:19 ` [PATCH v2 1/3] usb: typec: tipd: add error message for vendor ID read failure Radhey Shyam Pandey
2026-06-01 13:38   ` Heikki Krogerus
2026-05-19 18:19 ` [PATCH v2 2/3] usb: typec: tipd: demote missing IRQ message to debug Radhey Shyam Pandey
2026-06-01 13:39   ` Heikki Krogerus
2026-05-19 18:19 ` [PATCH v2 3/3] usb: typec: tipd: name TPS_REG_POWER_STATUS field masks Radhey Shyam Pandey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox