From 9e1e5e68ccc160b5f76d9a0110720e818c266fe0 Mon Sep 17 00:00:00 2001 From: LuluTHSu Date: Fri, 10 Dec 2021 11:41:08 +0800 Subject: [PATCH] Modify Mowgli's PSU patch Modify the PEC enable condition so that mowgli's PSU (Artesyn) doesn't enable PEC. Signed-off-by: LuluTHSu --- .../0001-Fix-psu-signal-and-vout-issue.patch | 78 +++++++++++++------ 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/meta-ibm/meta-witherspoon/recipes-kernel/linux/linux-aspeed/0001-Fix-psu-signal-and-vout-issue.patch b/meta-ibm/meta-witherspoon/recipes-kernel/linux/linux-aspeed/0001-Fix-psu-signal-and-vout-issue.patch index ba4ce0f32d..fc1eebcc09 100644 --- a/meta-ibm/meta-witherspoon/recipes-kernel/linux/linux-aspeed/0001-Fix-psu-signal-and-vout-issue.patch +++ b/meta-ibm/meta-witherspoon/recipes-kernel/linux/linux-aspeed/0001-Fix-psu-signal-and-vout-issue.patch @@ -1,15 +1,22 @@ -From 5e8a59a82fa905acdaf641d777d1ae264d511fe0 Mon Sep 17 00:00:00 2001 -From: AndyYFWang -Date: Thu, 26 Nov 2020 17:05:40 +0800 +From c1adcc5600e6d12d402b9b01350609ddea9d2c28 Mon Sep 17 00:00:00 2001 +From: LuluTHSu +Date: Fri, 10 Dec 2021 11:05:00 +0800 Subject: [PATCH] Fix psu signal and vout issue +Due to mowgli's psu(Artesyn) doesn't support PMBus PEC checking, +thermal reading and linear-16-conversion- formula, need to remove +them by updating driver patch for fixing psu reading error. + +Signed-off-by: Andy YF Wang +Signed-off-by: LuluTHSu --- - drivers/hwmon/pmbus/ibm-cffps.c | 3 +-- - drivers/hwmon/pmbus/pmbus_core.c | 12 +++++++----- - 2 files changed, 8 insertions(+), 7 deletions(-) + drivers/hwmon/pmbus/ibm-cffps.c | 5 ++--- + drivers/hwmon/pmbus/pmbus_core.c | 10 ++++++---- + include/linux/pmbus.h | 9 +++++++++ + 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c -index 7cf4cc5..844531e 100644 +index 7cf4cc5..e199f24 100644 --- a/drivers/hwmon/pmbus/ibm-cffps.c +++ b/drivers/hwmon/pmbus/ibm-cffps.c @@ -444,8 +444,7 @@ static struct pmbus_driver_info ibm_cffps_info[] = { @@ -22,36 +29,63 @@ index 7cf4cc5..844531e 100644 PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_FAN12, +@@ -469,7 +468,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, diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c -index f7fc388..e9646c8 100644 +index f7fc388..418e070 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c -@@ -636,8 +636,10 @@ static long pmbus_reg2data_linear(struct pmbus_data *data, +@@ -635,7 +635,7 @@ static long pmbus_reg2data_linear(struct pmbus_data *data, + s32 mantissa; long val; - if (sensor->class == PSC_VOLTAGE_OUT) { /* LINEAR16 */ -- exponent = data->exponent[sensor->page]; -- mantissa = (u16) sensor->data; -+ //exponent = data->exponent[sensor->page]; -+ //mantissa = (u16) sensor->data; -+ exponent = ((s16)sensor->data) >> 11; -+ mantissa = ((s16)((sensor->data & 0x7ff) << 5)) >> 5; +- if (sensor->class == PSC_VOLTAGE_OUT) { /* LINEAR16 */ ++ if (sensor->class == PSC_VOLTAGE_OUT && !(data->flags & PMBUS_NO_CAPABILITY)) { /* LINEAR16 */ + exponent = data->exponent[sensor->page]; + mantissa = (u16) sensor->data; } else { /* LINEAR11 */ - exponent = ((s16)sensor->data) >> 11; - mantissa = ((s16)((sensor->data & 0x7ff) << 5)) >> 5; -@@ -2156,9 +2158,9 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, +@@ -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; -+ //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); +diff --git a/include/linux/pmbus.h b/include/linux/pmbus.h +index 08468fc..74e1be0 100644 +--- a/include/linux/pmbus.h ++++ b/include/linux/pmbus.h +@@ -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