Skip to contentSkip to conversation

hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag

PATCH In review Lulu Su 2 participants 4 messages Jan 17, 2022 – Jan 27, 2022 Hardware monitoring

lore
Share & tools
lore

Lulu Su

author
#0 lore raw

PATCH 1/1 hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag

From: Eddie James <[email protected]>

Some PMBus chips don't respond with valid data when reading the CAPABILITY register. Add a flag that device drivers can set so that the PMBus core driver doesn't use CAPABILITY to determine it's behavior.

(cherry picked from commit e5befc024cb4515d815662ed8746712cc5366bfc)
---
 drivers/hwmon/pmbus/pmbus_core.c | 8 +++++---
 include/linux/pmbus.h            | 9 +++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +5 -3
index f7fc388..0f381558 100644
@@ -2156,9 +2156,11 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
 	}
 
 	/* Enable PEC if the controller supports it */
-	ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
-	if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK))
-		client->flags |= I2C_CLIENT_PEC;
+	if (!(data->flags & PMBUS_NO_CAPABILITY)) {
+		ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
+		if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK))
+			client->flags |= I2C_CLIENT_PEC;
+	}
 
 	if (data->info->pages)
 		pmbus_clear_faults(client);
include/linux/pmbus.h +9 -0
index 08468fc..74e1be0 100644
@@ -25,6 +25,15 @@
  */
 #define PMBUS_SKIP_STATUS_CHECK	(1 << 0)
 
+/*
+ * PMBUS_NO_CAPABILITY
+ *
+ * Some PMBus chips don't respond with valid data when reading the CAPABILITY
+ * register. For such chips, this flag should be set so that the PMBus core
+ * driver doesn't use CAPABILITY to determine it's behavior.
+ */
+#define PMBUS_NO_CAPABILITY			BIT(2)
+
 struct pmbus_platform_data {
 	u32 flags;		/* Device specific flags */
 
Signature · 8 lines
2.7.4


---------------------------------------------------------------------------------------------------------------------------------------------------------------
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. 
Any unauthorized review, use, copying or distribution of this email or the content of this email is strictly prohibited.
If you are not the intended recipient, you may reply to the sender and should delete this e-mail immediately.
---------------------------------------------------------------------------------------------------------------------------------------------------------------
#1 lore raw

Hello,

I note that you're targeting v5.4 for this patch. I don't know anyone working on maintaining this kernel tree in the openbmc project.

I suggest you move your platform to the latest LTS, v5.15. This patch is already present in that tree.

Quoted 66 lines · Lulu Su

From: Eddie James <[email protected]>

Some PMBus chips don't respond with valid data when reading the CAPABILITY register. Add a flag that device drivers can set so that the PMBus core driver doesn't use CAPABILITY to determine it's behavior.

(cherry picked from commit e5befc024cb4515d815662ed8746712cc5366bfc)
---
 drivers/hwmon/pmbus/pmbus_core.c | 8 +++++---
 include/linux/pmbus.h            | 9 +++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +5 -3
index f7fc388..0f381558 100644
@@ -2156,9 +2156,11 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
        }
 
        /* Enable PEC if the controller supports it */
-       ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
-       if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK))
-               client->flags |= I2C_CLIENT_PEC;
+       if (!(data->flags & PMBUS_NO_CAPABILITY)) {
+               ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
+               if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK))
+                       client->flags |= I2C_CLIENT_PEC;
+       }
 
        if (data->info->pages)
                pmbus_clear_faults(client);
include/linux/pmbus.h +9 -1
index 08468fc..74e1be0 100644
@@ -25,6 +25,15 @@
  */
 #define PMBUS_SKIP_STATUS_CHECK        (1 << 0)
 
+/*
+ * PMBUS_NO_CAPABILITY
+ *
+ * Some PMBus chips don't respond with valid data when reading the CAPABILITY
+ * register. For such chips, this flag should be set so that the PMBus core
+ * driver doesn't use CAPABILITY to determine it's behavior.
+ */
+#define PMBUS_NO_CAPABILITY                    BIT(2)
+
 struct pmbus_platform_data {
        u32 flags;              /* Device specific flags */
 
--

2.7.4

---------------------------------------------------------------------------------------------------------------------------------------------------------------
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or distribution of this email or the content of this email is strictly prohibited. If you are not the intended recipient, you may reply to the sender and should delete this e-mail immediately.
---------------------------------------------------------------------------------------------------------------------------------------------------------------

#2 lore raw

Hello,

Thanks for the suggestion, but this branch has been used for our platform for a while.

Andrew Jeffery suggested that we backport this commit.
(https://github.com/ibm-openbmc/openbmc/pull/204#:~:text=There%27s%20proper%20support%20for%20avoiding%20the%20CAPABILITY%20register%20upstream.%20Please%20backport%20https%3A//git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/hwmon/pmbus/pmbus_core.c%3Fh%3Dv5.16%2Drc4%26id%3De5befc024cb45%20and%20implement%20the%20patch%20in%20terms%20of%20that.)

Could you agree to backport this commit? Thanks.

Quoted 5 lines

Hello,

I note that you're targeting v5.4 for this patch. I don't know anyone working on maintaining this kernel tree in the openbmc project.

I suggest you move your platform to the latest LTS, v5.15. This patch is already present in that tree.

---------------------------------------------------------------------------------------------------------------------------------------------------------------
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or distribution of this email or the content of this email is strictly prohibited. If you are not the intended recipient, you may reply to the sender and should delete this e-mail immediately.
---------------------------------------------------------------------------------------------------------------------------------------------------------------

#3 lore raw
Quoted 4 lines · On Mon, 17 Jan 2022 at 07:08, <[email protected]> wrote:

Hello,

Thanks for the suggestion, but this branch has been used for our platform for a while.

Are you merging and testing stable updates into this branch?

If so, it would be good if you could contribute your changes to the community maintained repository.

If not, then I suggest you look into this.

Quoted 5 lines

Andrew Jeffery suggested that we backport this commit.
(https://github.com/ibm-openbmc/openbmc/pull/204#:~:text=There%27s%20proper%20support%20for%20avoiding%20the%20CAPABILITY%20register%20upstream.%20Please%20backport%20https%3A//git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/hwmon/pmbus/pmbus_core.c%3Fh%3Dv5.16%2Drc4%26id%3De5befc024cb45%20and%20implement%20the%20patch%20in%20terms%20of%20that.)

Could you agree to backport this commit? Thanks.

I have backported this commit and pushed it to dev-5.4.

Be warned that no one is maintaining this old branch, so if you are shipping firmware based off it, I would recommend finding someone to step forward to help maintain it.

Cheers,

Joel

Quoted 13 lines
Quoted 6 lines

Hello,

I note that you're targeting v5.4 for this patch. I don't know anyone working on maintaining this kernel tree in the openbmc project.

I suggest you move your platform to the latest LTS, v5.15. This patch is already present in that tree.

---------------------------------------------------------------------------------------------------------------------------------------------------------------
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or distribution of this email or the content of this email is strictly prohibited. If you are not the intended recipient, you may reply to the sender and should delete this e-mail immediately.
---------------------------------------------------------------------------------------------------------------------------------------------------------------