linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] hwmon: (pmbus) Add the PMBUS_NO_CAPABILITY flag
@ 2020-12-22 15:26 Eddie James
  2020-12-22 15:26 ` [PATCH v2 1/2] hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag Eddie James
  2020-12-22 15:26 ` [PATCH v2 2/2] hwmon: (pmbus/ibm-cffps) Set the PMBUS_NO_CAPABILITY flag Eddie James
  0 siblings, 2 replies; 5+ messages in thread
From: Eddie James @ 2020-12-22 15:26 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux-kernel, jdelvare, linux, eajames, bjwyman

Some PMBus chips, like some power supplies supported by the cffps driver,
don't respond with valid data when reading the CAPABILITY register. Add a
platform data flag that device drivers can set to tell the PMBus core
driver that it shouldn't use the CAPABILITY register. The second patch
sets this flag for the cffps driver.

Changes since v1:
 - Rename the flag to PMBUS_NO_CAPABILITY and adjust the associated
   comment accordingly.

Eddie James (2):
  hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag
  hwmon: (pmbus/ibm-cffps) Set the PMBUS_NO_CAPABILITY flag

 drivers/hwmon/pmbus/ibm-cffps.c  | 2 +-
 drivers/hwmon/pmbus/pmbus_core.c | 8 +++++---
 include/linux/pmbus.h            | 9 +++++++++
 3 files changed, 15 insertions(+), 4 deletions(-)

-- 
2.27.0


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

* [PATCH v2 1/2] hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag
  2020-12-22 15:26 [PATCH v2 0/2] hwmon: (pmbus) Add the PMBUS_NO_CAPABILITY flag Eddie James
@ 2020-12-22 15:26 ` Eddie James
  2020-12-23 15:40   ` Guenter Roeck
  2020-12-22 15:26 ` [PATCH v2 2/2] hwmon: (pmbus/ibm-cffps) Set the PMBUS_NO_CAPABILITY flag Eddie James
  1 sibling, 1 reply; 5+ messages in thread
From: Eddie James @ 2020-12-22 15:26 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux-kernel, jdelvare, linux, eajames, bjwyman

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.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/hwmon/pmbus/pmbus_core.c | 8 +++++---
 include/linux/pmbus.h            | 9 +++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 192442b3b7a2..906c9fec9cce 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -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_CAPABILITY)) {
+		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
diff --git a/include/linux/pmbus.h b/include/linux/pmbus.h
index 1ea5bae708a1..12cbbf305969 100644
--- a/include/linux/pmbus.h
+++ b/include/linux/pmbus.h
@@ -34,6 +34,15 @@
  */
 #define PMBUS_WRITE_PROTECTED	BIT(1)
 
+/*
+ * 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.27.0


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

* [PATCH v2 2/2] hwmon: (pmbus/ibm-cffps) Set the PMBUS_NO_CAPABILITY flag
  2020-12-22 15:26 [PATCH v2 0/2] hwmon: (pmbus) Add the PMBUS_NO_CAPABILITY flag Eddie James
  2020-12-22 15:26 ` [PATCH v2 1/2] hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag Eddie James
@ 2020-12-22 15:26 ` Eddie James
  2020-12-23 15:40   ` Guenter Roeck
  1 sibling, 1 reply; 5+ messages in thread
From: Eddie James @ 2020-12-22 15:26 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux-kernel, jdelvare, linux, eajames, bjwyman

Several power supplies supported by the IBM CFFPS driver don't
report valid data in the CAPABILITY register. This results in PEC
being enabled when it's not supported by the device, and since
the automatic version detection might fail, disable use of the
CAPABILITY register across the board for this driver.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/hwmon/pmbus/ibm-cffps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
index d6bbbb223871..ffde5aaa5036 100644
--- a/drivers/hwmon/pmbus/ibm-cffps.c
+++ b/drivers/hwmon/pmbus/ibm-cffps.c
@@ -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_CAPABILITY,
 };
 
 static int ibm_cffps_probe(struct i2c_client *client)
-- 
2.27.0


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

* Re: [PATCH v2 1/2] hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag
  2020-12-22 15:26 ` [PATCH v2 1/2] hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag Eddie James
@ 2020-12-23 15:40   ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2020-12-23 15:40 UTC (permalink / raw)
  To: Eddie James; +Cc: linux-hwmon, linux-kernel, jdelvare, bjwyman

On Tue, Dec 22, 2020 at 09:26:39AM -0600, Eddie James wrote:
> 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.
> 
> Signed-off-by: Eddie James <eajames@linux.ibm.com>

Applied.

Thanks,
Guenter

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

* Re: [PATCH v2 2/2] hwmon: (pmbus/ibm-cffps) Set the PMBUS_NO_CAPABILITY flag
  2020-12-22 15:26 ` [PATCH v2 2/2] hwmon: (pmbus/ibm-cffps) Set the PMBUS_NO_CAPABILITY flag Eddie James
@ 2020-12-23 15:40   ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2020-12-23 15:40 UTC (permalink / raw)
  To: Eddie James; +Cc: linux-hwmon, linux-kernel, jdelvare, bjwyman

On Tue, Dec 22, 2020 at 09:26:40AM -0600, Eddie James wrote:
> Several power supplies supported by the IBM CFFPS driver don't
> report valid data in the CAPABILITY register. This results in PEC
> being enabled when it's not supported by the device, and since
> the automatic version detection might fail, disable use of the
> CAPABILITY register across the board for this driver.
> 
> Signed-off-by: Eddie James <eajames@linux.ibm.com>

Applied.

Thanks,
Guenter

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

end of thread, other threads:[~2020-12-23 15:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 15:26 [PATCH v2 0/2] hwmon: (pmbus) Add the PMBUS_NO_CAPABILITY flag Eddie James
2020-12-22 15:26 ` [PATCH v2 1/2] hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag Eddie James
2020-12-23 15:40   ` Guenter Roeck
2020-12-22 15:26 ` [PATCH v2 2/2] hwmon: (pmbus/ibm-cffps) Set the PMBUS_NO_CAPABILITY flag Eddie James
2020-12-23 15:40   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).