Commit 00a98b7f authored by Adam Wujek's avatar Adam Wujek

sw/patches/linux: in hartmann_psu ignore the content of CAPABILITY register

Hartmann PSU returns the wrong value of CAPABILITY (0x1f) register.
It returns 0xff, which include the support for PEC, which is not true
at least for some registers like 0x9A-0x9E.
Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent eb190b08
From e5befc024cb4515d815662ed8746712cc5366bfc Mon Sep 17 00:00:00 2001
From: Eddie James <eajames@linux.ibm.com>
Date: Tue, 22 Dec 2020 09:26:39 -0600
Subject: [PATCH] hwmon: (pmbus) Add a PMBUS_NO_CAPABILITY platform data flag
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>
Link: https://lore.kernel.org/r/20201222152640.27749-2-eajames@linux.ibm.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
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;
+ }
pmbus_clear_faults(client);
diff --git a/include/linux/pmbus.h b/include/linux/pmbus.h
index ee3c2aba2a8e..a747057a095f 100644
--- a/include/linux/pmbus.h
+++ b/include/linux/pmbus.h
@@ -38,6 +38,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.17.1
From 5f7e74288c8ea8dedefeb3d443168f95d1ea252e Mon Sep 17 00:00:00 2001
From: Adam Wujek <dev_public@wujek.eu>
Date: Wed, 20 Apr 2022 00:48:05 +0200
Subject: [PATCH] hwmon: (hartmann_psu) ignore the content of CAPABILITY
register
Hartmann PSU returns the wrong value of CAPABILITY (0x1f) register.
It returns 0xff, which include the support for PEC, which is not true
at least for some registers like 0x9A-0x9E.
Signed-off-by: Adam Wujek <dev_public@wujek.eu>
---
drivers/hwmon/pmbus/hartmann_psu.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/hwmon/pmbus/hartmann_psu.c b/drivers/hwmon/pmbus/hartmann_psu.c
index 0515ef47af5d..439d63afa342 100644
--- a/drivers/hwmon/pmbus/hartmann_psu.c
+++ b/drivers/hwmon/pmbus/hartmann_psu.c
@@ -20,6 +20,7 @@
#include <linux/init.h>
#include <linux/err.h>
#include <linux/i2c.h>
+#include <linux/pmbus.h>
#include "pmbus.h"
#define LINEAR11_MANTISSA_MASK 0x7FF
@@ -118,9 +119,14 @@ static struct pmbus_driver_info hartmann_psu_info = {
.format[PSC_VOLTAGE_OUT] = linear,
};
+static struct pmbus_platform_data hartmann_psu_pdata = {
+ .flags = PMBUS_NO_CAPABILITY,
+};
+
static int hartmann_psu_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ client->dev.platform_data = &hartmann_psu_pdata;
return pmbus_do_probe(client, id, &hartmann_psu_info);
}
--
2.17.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment