Skip to contentSkip to conversation

hwmon: (pmbus) Add a NO_PEC flag to probe chips with faulty CAPABILITY

PATCH In review Eddie James 2 participants 6 messages Dec 21, 2020 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

cover hwmon: (pmbus) Add a NO_PEC flag to probe chips with faulty CAPABILITY

Some PMBus chips don't respond with valid data when reading the CAPABILITY register. For instance the register may report that the chip supports PEC when in reality it does not. For such chips, PEC must not be enabled while probing the chip, so this series adds a flag that allows device drivers to force PEC off. The second patch enables this flag for the IBM CFFPS driver, which supports power supplies that report invalid in the CAPABILITY register and must therefore force PEC off.

Eddie James (2):
hwmon: (pmbus) Add a NO_PEC flag to probe chips with faulty CAPABILITY
hwmon: (pmbus/ibm-cffps) Set the PMBUS_NO_PEC flag

 drivers/hwmon/pmbus/ibm-cffps.c  |  2 +-
 drivers/hwmon/pmbus/pmbus_core.c |  8 +++++---
 include/linux/pmbus.h            | 10 ++++++++++
 3 files changed, 16 insertions(+), 4 deletions(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/2 hwmon: (pmbus) Add a NO_PEC flag to probe chips with faulty CAPABILITY

Some PMBus chips don't respond with valid data when reading the CAPABILITY register. For instance the register may report that the chip supports PEC when in reality it does not. For such chips, PEC must not be enabled while probing the chip, so add a flag so that device drivers can force PEC off.

---
 drivers/hwmon/pmbus/pmbus_core.c |  8 +++++---
 include/linux/pmbus.h            | 10 ++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +5 -3
index 192442b3b7a2..3de1657dde35 100644
@@ -2204,9 +2204,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_PEC)) {
+		ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
+		if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK))
+			client->flags |= I2C_CLIENT_PEC;
+	}
 
 	/*
 	 * Check if the chip is write protected. If it is, we can not clear
include/linux/pmbus.h +10 -0
index 1ea5bae708a1..9bdc8a581b03 100644
@@ -34,6 +34,16 @@
  */
 #define PMBUS_WRITE_PROTECTED	BIT(1)
 
+/*
+ * PMBUS_NO_PEC
+ *
+ * Some PMBus chips don't respond with valid data when reading the CAPABILITY
+ * register. In this case, the register may report that the chip supports PEC
+ * with bit 7 (PB_CAPABILITY_ERROR_CHECK) when in reality it's not supported.
+ * For such chips, PEC must not be enabled before probing the chip.
+ */
+#define PMBUS_NO_PEC			BIT(2)
+
 struct pmbus_platform_data {
 	u32 flags;		/* Device specific flags */
 
Signature · 1 line
2.27.0
maintainer
#2 lore raw
Quoted 6 lines · Eddie James

Some PMBus chips don't respond with valid data when reading the CAPABILITY register. For instance the register may report that the chip supports PEC when in reality it does not. For such chips, PEC must not be enabled while probing the chip, so add a flag so that device drivers can force PEC off.

I think the flag should indicate that the capability register shall not be read/used. That the capability register is currently only used to check for PEC is secondary. We might,for example, start using it to check for alert support or to check the numeric format.

Thanks,
Guenter

Quoted 47 lines
---
 drivers/hwmon/pmbus/pmbus_core.c |  8 +++++---
 include/linux/pmbus.h            | 10 ++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +5 -3
index 192442b3b7a2..3de1657dde35 100644
@@ -2204,9 +2204,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_PEC)) {
+		ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
+		if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK))
+			client->flags |= I2C_CLIENT_PEC;
+	}
 
 	/*
 	 * Check if the chip is write protected. If it is, we can not clear
include/linux/pmbus.h +10 -0
index 1ea5bae708a1..9bdc8a581b03 100644
@@ -34,6 +34,16 @@
  */
 #define PMBUS_WRITE_PROTECTED	BIT(1)
 
+/*
+ * PMBUS_NO_PEC
+ *
+ * Some PMBus chips don't respond with valid data when reading the CAPABILITY
+ * register. In this case, the register may report that the chip supports PEC
+ * with bit 7 (PB_CAPABILITY_ERROR_CHECK) when in reality it's not supported.
+ * For such chips, PEC must not be enabled before probing the chip.
+ */
+#define PMBUS_NO_PEC			BIT(2)
+
 struct pmbus_platform_data {
 	u32 flags;		/* Device specific flags */
 
#3 lore raw
Quoted 8 lines · Guenter Roeck
Quoted 6 lines · Eddie James

Some PMBus chips don't respond with valid data when reading the CAPABILITY register. For instance the register may report that the chip supports PEC when in reality it does not. For such chips, PEC must not be enabled while probing the chip, so add a flag so that device drivers can force PEC off.

Quoted 5 lines

I think the flag should indicate that the capability register shall not be read/used. That the capability register is currently only used to check for PEC is secondary. We might,for example, start using it to check for alert support or to check the numeric format.

OK, that makes sense. I'll rename the flag in v2, how does PMBUS_NO_CAPABILITY sound?

Thanks for the quick reply,
Eddie

Quoted 59 lines

Thanks,
Guenter

Quoted 55 lines
---
 drivers/hwmon/pmbus/pmbus_core.c |  8 +++++---
 include/linux/pmbus.h            | 10 ++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +5 -3
index 192442b3b7a2..3de1657dde35 100644
@@ -2204,9 +2204,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_PEC)) {
+		ret = i2c_smbus_read_byte_data(client,
 PMBUS_CAPABILITY);
+		if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK))
+			client->flags |= I2C_CLIENT_PEC;
+	}
 
drivers/hwmon/pmbus/pmbus_core.c +0 -0
 	/*
 	 * Check if the chip is write protected. If it is, we can not

clear

include/linux/pmbus.h +4 -0
index 1ea5bae708a1..9bdc8a581b03 100644
@@ -34,6 +34,16 @@
  */
 #define PMBUS_WRITE_PROTECTED	BIT(1)
 
+/*
+ * PMBUS_NO_PEC
+ *
+ * Some PMBus chips don't respond with valid data when reading the

CAPABILITY
+ * register. In this case, the register may report that the chip supports PEC
+ * with bit 7 (PB_CAPABILITY_ERROR_CHECK) when in reality it's not supported.
+ * For such chips, PEC must not be enabled before probing the chip.
+ */

include/linux/pmbus.h +2 -0
+#define PMBUS_NO_PEC			BIT(2)
+
 struct pmbus_platform_data {
 	u32 flags;		/* Device specific flags */
maintainer
#4 lore raw
Quoted 9 lines · Eddie James
Quoted 8 lines · Guenter Roeck
Quoted 6 lines · Eddie James

Some PMBus chips don't respond with valid data when reading the CAPABILITY register. For instance the register may report that the chip supports PEC when in reality it does not. For such chips, PEC must not be enabled while probing the chip, so add a flag so that device drivers can force PEC off.

Quoted 9 lines
Quoted 5 lines

I think the flag should indicate that the capability register shall not be read/used. That the capability register is currently only used to check for PEC is secondary. We might,for example, start using it to check for alert support or to check the numeric format.

OK, that makes sense. I'll rename the flag in v2, how does PMBUS_NO_CAPABILITY sound?

sgtm

Thanks,
Guenter

Quoted 63 lines

Thanks for the quick reply,
Eddie

Quoted 59 lines

Thanks,
Guenter

Quoted 55 lines
---
 drivers/hwmon/pmbus/pmbus_core.c |  8 +++++---
 include/linux/pmbus.h            | 10 ++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +5 -3
index 192442b3b7a2..3de1657dde35 100644
@@ -2204,9 +2204,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_PEC)) {
+		ret = i2c_smbus_read_byte_data(client,
 PMBUS_CAPABILITY);
+		if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK))
+			client->flags |= I2C_CLIENT_PEC;
+	}
 
drivers/hwmon/pmbus/pmbus_core.c +0 -0
 	/*
 	 * Check if the chip is write protected. If it is, we can not

clear

include/linux/pmbus.h +4 -0
index 1ea5bae708a1..9bdc8a581b03 100644
@@ -34,6 +34,16 @@
  */
 #define PMBUS_WRITE_PROTECTED	BIT(1)
 
+/*
+ * PMBUS_NO_PEC
+ *
+ * Some PMBus chips don't respond with valid data when reading the

CAPABILITY
+ * register. In this case, the register may report that the chip supports PEC
+ * with bit 7 (PB_CAPABILITY_ERROR_CHECK) when in reality it's not supported.
+ * For such chips, PEC must not be enabled before probing the chip.
+ */

include/linux/pmbus.h +2 -0
+#define PMBUS_NO_PEC			BIT(2)
+
 struct pmbus_platform_data {
 	u32 flags;		/* Device specific flags */
#5 lore raw

PATCH 2/2 hwmon: (pmbus/ibm-cffps) Set the PMBUS_NO_PEC flag

In reply to Eddie James

Several power supplies supported by the IBM CFFPS driver don't report valid data in the CAPABILITY register, or support PEC only for certain PMBus registers. Since the automatic version detection of the driver might fail on some supplies with PEC enabled, just disable PEC entirely for this driver.

---
 drivers/hwmon/pmbus/ibm-cffps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/ibm-cffps.c +1 -1
index d6bbbb223871..f8e3ae989e99 100644
@@ -472,7 +472,7 @@ static struct pmbus_driver_info ibm_cffps_info[] = {
 };
 
 static struct pmbus_platform_data ibm_cffps_pdata = {
-	.flags = PMBUS_SKIP_STATUS_CHECK,
+	.flags = PMBUS_SKIP_STATUS_CHECK | PMBUS_NO_PEC,
 };
 
 static int ibm_cffps_probe(struct i2c_client *client)
Signature · 1 line
2.27.0