[PATCH] hwmon: (pmbus): Introduce page_change_delay

William A. Kennington III posted 1 patch 23 hours ago
There is a newer version of this series
drivers/hwmon/pmbus/pmbus.h      |  1 +
drivers/hwmon/pmbus/pmbus_core.c | 59 ++++++++++++++++++++++----------
2 files changed, 41 insertions(+), 19 deletions(-)
[PATCH] hwmon: (pmbus): Introduce page_change_delay
Posted by William A. Kennington III 23 hours ago
We have some buggy pmbus devices that require a delay after performing a
page change operation before trying to issue more commands to the
device.

This allows for a configurable delay after page changes, but not
affecting other read or write operations.

Signed-off-by: William A. Kennington III <william@wkennington.com>
---
 drivers/hwmon/pmbus/pmbus.h      |  1 +
 drivers/hwmon/pmbus/pmbus_core.c | 59 ++++++++++++++++++++++----------
 2 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index ddb19c9726d6..742dafc44390 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -482,6 +482,7 @@ struct pmbus_driver_info {
 	 */
 	int access_delay;		/* in microseconds */
 	int write_delay;		/* in microseconds */
+	int page_change_delay;		/* in microseconds */
 };
 
 /* Regulator ops */
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 787683e83db6..cfb724a8718b 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -116,6 +116,7 @@ struct pmbus_data {
 	int vout_high[PMBUS_PAGES];	/* voltage high margin */
 	ktime_t write_time;		/* Last SMBUS write timestamp */
 	ktime_t access_time;		/* Last SMBUS access timestamp */
+	ktime_t page_change_time;	/* Last SMBUS page change timestamp */
 };
 
 struct pmbus_debugfs_entry {
@@ -178,24 +179,44 @@ static void pmbus_wait(struct i2c_client *client)
 
 		if (delta < info->access_delay)
 			fsleep(info->access_delay - delta);
-	} else if (info->write_delay) {
+	}
+	if (info->write_delay) {
 		delta = ktime_us_delta(ktime_get(), data->write_time);
 
 		if (delta < info->write_delay)
 			fsleep(info->write_delay - delta);
 	}
+	if (info->page_change_delay) {
+		delta = ktime_us_delta(ktime_get(), data->page_change_time);
+
+		if (delta < info->page_change_delay)
+			fsleep(info->page_change_delay - delta);
+	}
 }
 
-/* Sets the last accessed timestamp for pmbus_wait */
-static void pmbus_update_ts(struct i2c_client *client, bool write_op)
+#define PMBUS_OP_READ_BIT 1
+#define PMBUS_OP_WRITE_BIT 2
+#define PMBUS_OP_PAGE_CHANGE_BIT 4
+
+#define PMBUS_OP_READ PMBUS_OP_READ_BIT
+#define PMBUS_OP_WRITE PMBUS_OP_WRITE_BIT
+#define PMBUS_OP_PAGE_CHANGE (PMBUS_OP_PAGE_CHANGE_BIT | PMBUS_OP_WRITE)
+
+/* Sets the last operation timestamp for pmbus_wait */
+static void pmbus_update_ts(struct i2c_client *client, int op)
 {
 	struct pmbus_data *data = i2c_get_clientdata(client);
 	const struct pmbus_driver_info *info = data->info;
+	ktime_t now = ktime_get();
 
 	if (info->access_delay) {
-		data->access_time = ktime_get();
-	} else if (info->write_delay && write_op) {
-		data->write_time = ktime_get();
+		data->access_time = now;
+	}
+	if (info->write_delay && (op & PMBUS_OP_WRITE_BIT)) {
+		data->write_time = now;
+	}
+	if (info->page_change_delay && (op & PMBUS_OP_PAGE_CHANGE_BIT)) {
+		data->write_time = now;
 	}
 }
 
@@ -211,13 +232,13 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
 	    data->info->pages > 1 && page != data->currpage) {
 		pmbus_wait(client);
 		rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
-		pmbus_update_ts(client, true);
+		pmbus_update_ts(client, PMBUS_OP_PAGE_CHANGE);
 		if (rv < 0)
 			return rv;
 
 		pmbus_wait(client);
 		rv = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
-		pmbus_update_ts(client, false);
+		pmbus_update_ts(client, PMBUS_OP_READ);
 		if (rv < 0)
 			return rv;
 
@@ -231,7 +252,7 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
 		pmbus_wait(client);
 		rv = i2c_smbus_write_byte_data(client, PMBUS_PHASE,
 					       phase);
-		pmbus_update_ts(client, true);
+		pmbus_update_ts(client, PMBUS_OP_WRITE);
 		if (rv)
 			return rv;
 	}
@@ -251,7 +272,7 @@ int pmbus_write_byte(struct i2c_client *client, int page, u8 value)
 
 	pmbus_wait(client);
 	rv = i2c_smbus_write_byte(client, value);
-	pmbus_update_ts(client, true);
+	pmbus_update_ts(client, PMBUS_OP_WRITE);
 
 	return rv;
 }
@@ -286,7 +307,7 @@ int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
 
 	pmbus_wait(client);
 	rv = i2c_smbus_write_word_data(client, reg, word);
-	pmbus_update_ts(client, true);
+	pmbus_update_ts(client, PMBUS_OP_WRITE);
 
 	return rv;
 }
@@ -408,7 +429,7 @@ int pmbus_read_word_data(struct i2c_client *client, int page, int phase, u8 reg)
 
 	pmbus_wait(client);
 	rv = i2c_smbus_read_word_data(client, reg);
-	pmbus_update_ts(client, false);
+	pmbus_update_ts(client, PMBUS_OP_READ);
 
 	return rv;
 }
@@ -471,7 +492,7 @@ int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg)
 
 	pmbus_wait(client);
 	rv = i2c_smbus_read_byte_data(client, reg);
-	pmbus_update_ts(client, false);
+	pmbus_update_ts(client, PMBUS_OP_READ);
 
 	return rv;
 }
@@ -487,7 +508,7 @@ int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, u8 value)
 
 	pmbus_wait(client);
 	rv = i2c_smbus_write_byte_data(client, reg, value);
-	pmbus_update_ts(client, true);
+	pmbus_update_ts(client, PMBUS_OP_WRITE);
 
 	return rv;
 }
@@ -523,7 +544,7 @@ static int pmbus_read_block_data(struct i2c_client *client, int page, u8 reg,
 
 	pmbus_wait(client);
 	rv = i2c_smbus_read_block_data(client, reg, data_buf);
-	pmbus_update_ts(client, false);
+	pmbus_update_ts(client, PMBUS_OP_READ);
 
 	return rv;
 }
@@ -2530,7 +2551,7 @@ static int pmbus_read_coefficients(struct i2c_client *client,
 	rv = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
 			    I2C_SMBUS_WRITE, PMBUS_COEFFICIENTS,
 			    I2C_SMBUS_BLOCK_PROC_CALL, &data);
-	pmbus_update_ts(client, true);
+	pmbus_update_ts(client, PMBUS_OP_READ | PMBUS_OP_WRITE);
 
 	if (rv < 0)
 		return rv;
@@ -2734,7 +2755,7 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
 	if (!(data->flags & PMBUS_NO_CAPABILITY)) {
 		pmbus_wait(client);
 		ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
-		pmbus_update_ts(client, false);
+		pmbus_update_ts(client, PMBUS_OP_READ);
 
 		if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK)) {
 			if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_PEC))
@@ -2750,13 +2771,13 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
 	data->read_status = pmbus_read_status_word;
 	pmbus_wait(client);
 	ret = i2c_smbus_read_word_data(client, PMBUS_STATUS_WORD);
-	pmbus_update_ts(client, false);
+	pmbus_update_ts(client, PMBUS_OP_READ);
 
 	if (ret < 0 || ret == 0xffff) {
 		data->read_status = pmbus_read_status_byte;
 		pmbus_wait(client);
 		ret = i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE);
-		pmbus_update_ts(client, false);
+		pmbus_update_ts(client, PMBUS_OP_READ);
 
 		if (ret < 0 || ret == 0xff) {
 			dev_err(dev, "PMBus status register not found\n");
-- 
2.49.0.472.ge94155a9ec-goog
Re: [PATCH] hwmon: (pmbus): Introduce page_change_delay
Posted by Guenter Roeck 20 hours ago
On 4/2/25 12:34, William A. Kennington III wrote:
> We have some buggy pmbus devices that require a delay after performing a
> page change operation before trying to issue more commands to the
> device.
> 
> This allows for a configurable delay after page changes, but not
> affecting other read or write operations.
> 
> Signed-off-by: William A. Kennington III <william@wkennington.com>
> ---
>   drivers/hwmon/pmbus/pmbus.h      |  1 +
>   drivers/hwmon/pmbus/pmbus_core.c | 59 ++++++++++++++++++++++----------
>   2 files changed, 41 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
> index ddb19c9726d6..742dafc44390 100644
> --- a/drivers/hwmon/pmbus/pmbus.h
> +++ b/drivers/hwmon/pmbus/pmbus.h
> @@ -482,6 +482,7 @@ struct pmbus_driver_info {
>   	 */
>   	int access_delay;		/* in microseconds */
>   	int write_delay;		/* in microseconds */
> +	int page_change_delay;		/* in microseconds */
>   };
>   
>   /* Regulator ops */
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index 787683e83db6..cfb724a8718b 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -116,6 +116,7 @@ struct pmbus_data {
>   	int vout_high[PMBUS_PAGES];	/* voltage high margin */
>   	ktime_t write_time;		/* Last SMBUS write timestamp */
>   	ktime_t access_time;		/* Last SMBUS access timestamp */
> +	ktime_t page_change_time;	/* Last SMBUS page change timestamp */
>   };
>   
>   struct pmbus_debugfs_entry {
> @@ -178,24 +179,44 @@ static void pmbus_wait(struct i2c_client *client)
>   
>   		if (delta < info->access_delay)
>   			fsleep(info->access_delay - delta);
> -	} else if (info->write_delay) {
> +	}
> +	if (info->write_delay) {
>   		delta = ktime_us_delta(ktime_get(), data->write_time);
>   
>   		if (delta < info->write_delay)
>   			fsleep(info->write_delay - delta);
>   	}
> +	if (info->page_change_delay) {
> +		delta = ktime_us_delta(ktime_get(), data->page_change_time);
> +

page_change_time isn't actually set. I suggest to just use data->write_time.
Also see below.

> +		if (delta < info->page_change_delay)
> +			fsleep(info->page_change_delay - delta);
> +	}
>   }
>   
> -/* Sets the last accessed timestamp for pmbus_wait */
> -static void pmbus_update_ts(struct i2c_client *client, bool write_op)
> +#define PMBUS_OP_READ_BIT 1
> +#define PMBUS_OP_WRITE_BIT 2
> +#define PMBUS_OP_PAGE_CHANGE_BIT 4

#define<space>NAME<tab>BIT(...)

> +
> +#define PMBUS_OP_READ PMBUS_OP_READ_BIT
> +#define PMBUS_OP_WRITE PMBUS_OP_WRITE_BIT
> +#define PMBUS_OP_PAGE_CHANGE (PMBUS_OP_PAGE_CHANGE_BIT | PMBUS_OP_WRITE)

That is way too complicated. Just make it

#define PMBUS_OP_READ		BIT(0)
#define PMBUS_OP_WRITE		BIT(1)
#define PMBUS_OP_PAGE_CHANGE	BIT(2)

A page change implies a write, so it is not necessary to combine the bits.

> +
> +/* Sets the last operation timestamp for pmbus_wait */
> +static void pmbus_update_ts(struct i2c_client *client, int op)
>   {
>   	struct pmbus_data *data = i2c_get_clientdata(client);
>   	const struct pmbus_driver_info *info = data->info;
> +	ktime_t now = ktime_get();
>   
>   	if (info->access_delay) {
> -		data->access_time = ktime_get();
> -	} else if (info->write_delay && write_op) {
> -		data->write_time = ktime_get();
> +		data->access_time = now;
> +	}
> +	if (info->write_delay && (op & PMBUS_OP_WRITE_BIT)) {
> +		data->write_time = now;
> +	}
> +	if (info->page_change_delay && (op & PMBUS_OP_PAGE_CHANGE_BIT)) {
> +		data->write_time = now;
>   	}

Seems to me that we should only need write_time and not
page_change_time since both will always be set together.

I also think this can be simplified if ktime_get() is always called anyway.

	ktime_t now = ktime_get();

	data->access_time = now;
	if (op & (PMBUS_OP_WRITE | PMBUS_OP_PAGE_CHANGE))
		data->write_time = now;

It doesn't matter if the values are set unnecessarily if there is no delay
because they won't be used in that case.

>   }
>   
> @@ -211,13 +232,13 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
>   	    data->info->pages > 1 && page != data->currpage) {
>   		pmbus_wait(client);
>   		rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
> -		pmbus_update_ts(client, true);
> +		pmbus_update_ts(client, PMBUS_OP_PAGE_CHANGE);
>   		if (rv < 0)
>   			return rv;
>   
>   		pmbus_wait(client);
>   		rv = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
> -		pmbus_update_ts(client, false);
> +		pmbus_update_ts(client, PMBUS_OP_READ);
>   		if (rv < 0)
>   			return rv;
>   
> @@ -231,7 +252,7 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
>   		pmbus_wait(client);
>   		rv = i2c_smbus_write_byte_data(client, PMBUS_PHASE,
>   					       phase);
> -		pmbus_update_ts(client, true);
> +		pmbus_update_ts(client, PMBUS_OP_WRITE);
>   		if (rv)
>   			return rv;
>   	}
> @@ -251,7 +272,7 @@ int pmbus_write_byte(struct i2c_client *client, int page, u8 value)
>   
>   	pmbus_wait(client);
>   	rv = i2c_smbus_write_byte(client, value);
> -	pmbus_update_ts(client, true);
> +	pmbus_update_ts(client, PMBUS_OP_WRITE);
>   
>   	return rv;
>   }
> @@ -286,7 +307,7 @@ int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
>   
>   	pmbus_wait(client);
>   	rv = i2c_smbus_write_word_data(client, reg, word);
> -	pmbus_update_ts(client, true);
> +	pmbus_update_ts(client, PMBUS_OP_WRITE);
>   
>   	return rv;
>   }
> @@ -408,7 +429,7 @@ int pmbus_read_word_data(struct i2c_client *client, int page, int phase, u8 reg)
>   
>   	pmbus_wait(client);
>   	rv = i2c_smbus_read_word_data(client, reg);
> -	pmbus_update_ts(client, false);
> +	pmbus_update_ts(client, PMBUS_OP_READ);
>   
>   	return rv;
>   }
> @@ -471,7 +492,7 @@ int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg)
>   
>   	pmbus_wait(client);
>   	rv = i2c_smbus_read_byte_data(client, reg);
> -	pmbus_update_ts(client, false);
> +	pmbus_update_ts(client, PMBUS_OP_READ);
>   
>   	return rv;
>   }
> @@ -487,7 +508,7 @@ int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, u8 value)
>   
>   	pmbus_wait(client);
>   	rv = i2c_smbus_write_byte_data(client, reg, value);
> -	pmbus_update_ts(client, true);
> +	pmbus_update_ts(client, PMBUS_OP_WRITE);
>   
>   	return rv;
>   }
> @@ -523,7 +544,7 @@ static int pmbus_read_block_data(struct i2c_client *client, int page, u8 reg,
>   
>   	pmbus_wait(client);
>   	rv = i2c_smbus_read_block_data(client, reg, data_buf);
> -	pmbus_update_ts(client, false);
> +	pmbus_update_ts(client, PMBUS_OP_READ);
>   
>   	return rv;
>   }
> @@ -2530,7 +2551,7 @@ static int pmbus_read_coefficients(struct i2c_client *client,
>   	rv = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
>   			    I2C_SMBUS_WRITE, PMBUS_COEFFICIENTS,
>   			    I2C_SMBUS_BLOCK_PROC_CALL, &data);
> -	pmbus_update_ts(client, true);
> +	pmbus_update_ts(client, PMBUS_OP_READ | PMBUS_OP_WRITE);

I don't immediately follow the reason for adding PMBUS_OP_READ.

>   
>   	if (rv < 0)
>   		return rv;
> @@ -2734,7 +2755,7 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
>   	if (!(data->flags & PMBUS_NO_CAPABILITY)) {
>   		pmbus_wait(client);
>   		ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
> -		pmbus_update_ts(client, false);
> +		pmbus_update_ts(client, PMBUS_OP_READ);
>   
>   		if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK)) {
>   			if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_PEC))
> @@ -2750,13 +2771,13 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
>   	data->read_status = pmbus_read_status_word;
>   	pmbus_wait(client);
>   	ret = i2c_smbus_read_word_data(client, PMBUS_STATUS_WORD);
> -	pmbus_update_ts(client, false);
> +	pmbus_update_ts(client, PMBUS_OP_READ);
>   
>   	if (ret < 0 || ret == 0xffff) {
>   		data->read_status = pmbus_read_status_byte;
>   		pmbus_wait(client);
>   		ret = i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE);
> -		pmbus_update_ts(client, false);
> +		pmbus_update_ts(client, PMBUS_OP_READ);
>   
>   		if (ret < 0 || ret == 0xff) {
>   			dev_err(dev, "PMBus status register not found\n");
[PATCH v2] hwmon: (pmbus): Introduce page_change_delay
Posted by William A. Kennington III 22 hours ago
We have some buggy pmbus devices that require a delay after performing a
page change operation before trying to issue more commands to the
device.

This allows for a configurable delay after page changes, but not
affecting other read or write operations.

Signed-off-by: William A. Kennington III <william@wkennington.com>
---
V1 -> V2: Simplify how the backoff time is stored and computed

 drivers/hwmon/pmbus/pmbus.h      |  1 +
 drivers/hwmon/pmbus/pmbus_core.c | 69 ++++++++++++++++----------------
 2 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index ddb19c9726d6..742dafc44390 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -482,6 +482,7 @@ struct pmbus_driver_info {
 	 */
 	int access_delay;		/* in microseconds */
 	int write_delay;		/* in microseconds */
+	int page_change_delay;		/* in microseconds */
 };
 
 /* Regulator ops */
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 787683e83db6..46d80d3743d9 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -114,8 +114,8 @@ struct pmbus_data {
 
 	int vout_low[PMBUS_PAGES];	/* voltage low margin */
 	int vout_high[PMBUS_PAGES];	/* voltage high margin */
-	ktime_t write_time;		/* Last SMBUS write timestamp */
-	ktime_t access_time;		/* Last SMBUS access timestamp */
+
+	ktime_t next_access_backoff;	/* Wait until at least this time */
 };
 
 struct pmbus_debugfs_entry {
@@ -170,33 +170,34 @@ EXPORT_SYMBOL_NS_GPL(pmbus_set_update, "PMBUS");
 static void pmbus_wait(struct i2c_client *client)
 {
 	struct pmbus_data *data = i2c_get_clientdata(client);
-	const struct pmbus_driver_info *info = data->info;
-	s64 delta;
+	s64 delay = ktime_us_delta(data->next_access_backoff, ktime_get());
 
-	if (info->access_delay) {
-		delta = ktime_us_delta(ktime_get(), data->access_time);
+	if (delay > 0)
+		fsleep(delay);
+}
 
-		if (delta < info->access_delay)
-			fsleep(info->access_delay - delta);
-	} else if (info->write_delay) {
-		delta = ktime_us_delta(ktime_get(), data->write_time);
+#define PMBUS_OP_READ_BIT 1
+#define PMBUS_OP_WRITE_BIT 2
+#define PMBUS_OP_PAGE_CHANGE_BIT 4
 
-		if (delta < info->write_delay)
-			fsleep(info->write_delay - delta);
-	}
-}
+#define PMBUS_OP_READ PMBUS_OP_READ_BIT
+#define PMBUS_OP_WRITE PMBUS_OP_WRITE_BIT
+#define PMBUS_OP_PAGE_CHANGE (PMBUS_OP_PAGE_CHANGE_BIT | PMBUS_OP_WRITE)
 
-/* Sets the last accessed timestamp for pmbus_wait */
-static void pmbus_update_ts(struct i2c_client *client, bool write_op)
+/* Sets the last operation timestamp for pmbus_wait */
+static void pmbus_update_ts(struct i2c_client *client, int op)
 {
 	struct pmbus_data *data = i2c_get_clientdata(client);
 	const struct pmbus_driver_info *info = data->info;
+	int delay = info->access_delay;
 
-	if (info->access_delay) {
-		data->access_time = ktime_get();
-	} else if (info->write_delay && write_op) {
-		data->write_time = ktime_get();
-	}
+	if (op & PMBUS_OP_WRITE_BIT)
+		delay = max(delay, info->write_delay);
+	if (op & PMBUS_OP_PAGE_CHANGE_BIT)
+		delay = max(delay, info->page_change_delay);
+
+	if (delay > 0)
+		data->next_access_backoff = ktime_add_us(ktime_get(), delay);
 }
 
 int pmbus_set_page(struct i2c_client *client, int page, int phase)
@@ -211,13 +212,13 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
 	    data->info->pages > 1 && page != data->currpage) {
 		pmbus_wait(client);
 		rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
-		pmbus_update_ts(client, true);
+		pmbus_update_ts(client, PMBUS_OP_PAGE_CHANGE);
 		if (rv < 0)
 			return rv;
 
 		pmbus_wait(client);
 		rv = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
-		pmbus_update_ts(client, false);
+		pmbus_update_ts(client, PMBUS_OP_READ);
 		if (rv < 0)
 			return rv;
 
@@ -231,7 +232,7 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
 		pmbus_wait(client);
 		rv = i2c_smbus_write_byte_data(client, PMBUS_PHASE,
 					       phase);
-		pmbus_update_ts(client, true);
+		pmbus_update_ts(client, PMBUS_OP_WRITE);
 		if (rv)
 			return rv;
 	}
@@ -251,7 +252,7 @@ int pmbus_write_byte(struct i2c_client *client, int page, u8 value)
 
 	pmbus_wait(client);
 	rv = i2c_smbus_write_byte(client, value);
-	pmbus_update_ts(client, true);
+	pmbus_update_ts(client, PMBUS_OP_WRITE);
 
 	return rv;
 }
@@ -286,7 +287,7 @@ int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
 
 	pmbus_wait(client);
 	rv = i2c_smbus_write_word_data(client, reg, word);
-	pmbus_update_ts(client, true);
+	pmbus_update_ts(client, PMBUS_OP_WRITE);
 
 	return rv;
 }
@@ -408,7 +409,7 @@ int pmbus_read_word_data(struct i2c_client *client, int page, int phase, u8 reg)
 
 	pmbus_wait(client);
 	rv = i2c_smbus_read_word_data(client, reg);
-	pmbus_update_ts(client, false);
+	pmbus_update_ts(client, PMBUS_OP_READ);
 
 	return rv;
 }
@@ -471,7 +472,7 @@ int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg)
 
 	pmbus_wait(client);
 	rv = i2c_smbus_read_byte_data(client, reg);
-	pmbus_update_ts(client, false);
+	pmbus_update_ts(client, PMBUS_OP_READ);
 
 	return rv;
 }
@@ -487,7 +488,7 @@ int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, u8 value)
 
 	pmbus_wait(client);
 	rv = i2c_smbus_write_byte_data(client, reg, value);
-	pmbus_update_ts(client, true);
+	pmbus_update_ts(client, PMBUS_OP_WRITE);
 
 	return rv;
 }
@@ -523,7 +524,7 @@ static int pmbus_read_block_data(struct i2c_client *client, int page, u8 reg,
 
 	pmbus_wait(client);
 	rv = i2c_smbus_read_block_data(client, reg, data_buf);
-	pmbus_update_ts(client, false);
+	pmbus_update_ts(client, PMBUS_OP_READ);
 
 	return rv;
 }
@@ -2530,7 +2531,7 @@ static int pmbus_read_coefficients(struct i2c_client *client,
 	rv = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
 			    I2C_SMBUS_WRITE, PMBUS_COEFFICIENTS,
 			    I2C_SMBUS_BLOCK_PROC_CALL, &data);
-	pmbus_update_ts(client, true);
+	pmbus_update_ts(client, PMBUS_OP_READ | PMBUS_OP_WRITE);
 
 	if (rv < 0)
 		return rv;
@@ -2734,7 +2735,7 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
 	if (!(data->flags & PMBUS_NO_CAPABILITY)) {
 		pmbus_wait(client);
 		ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
-		pmbus_update_ts(client, false);
+		pmbus_update_ts(client, PMBUS_OP_READ);
 
 		if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK)) {
 			if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_PEC))
@@ -2750,13 +2751,13 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
 	data->read_status = pmbus_read_status_word;
 	pmbus_wait(client);
 	ret = i2c_smbus_read_word_data(client, PMBUS_STATUS_WORD);
-	pmbus_update_ts(client, false);
+	pmbus_update_ts(client, PMBUS_OP_READ);
 
 	if (ret < 0 || ret == 0xffff) {
 		data->read_status = pmbus_read_status_byte;
 		pmbus_wait(client);
 		ret = i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE);
-		pmbus_update_ts(client, false);
+		pmbus_update_ts(client, PMBUS_OP_READ);
 
 		if (ret < 0 || ret == 0xff) {
 			dev_err(dev, "PMBus status register not found\n");
-- 
2.49.0.472.ge94155a9ec-goog