forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mellanox] Add new patches come along with hw-mgmt V.7.0000.3020 (son…
…ic-net#129) Add new patches which required by new hw-mgmt package V.7.0000.3020 Including: - support for VID protocol detection per page bases - Increase i2c-mlxcpld transaction pooling - mlxreg-hotplug: Use capability register for attribute creation - Add support for attributes composed from few registers - Add config for sensor xdpe122 and modify mlx_wdt to m
- Loading branch information
Showing
6 changed files
with
840 additions
and
0 deletions.
There are no files selected for viewing
386 changes: 386 additions & 0 deletions
386
patch/0060-hwmon-pmbus-core-Add-support-for-vid-mode-detecti.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,386 @@ | ||
From 482c5a7b46fd39c2df42c47f96a817c2d50b9c75 Mon Sep 17 00:00:00 2001 | ||
From: Vadim Pasternak <[email protected]> | ||
Date: Tue, 3 Mar 2020 14:33:59 +0200 | ||
Subject: [hwmon v1] hwmon: (pmbus/core) Add support for vid mode detection per | ||
page bases | ||
|
||
Add support for VID protocol detection per page bases, instead of | ||
detecting it based on PMBU_VOUT readout from page 0. | ||
The reason that some devices allows to configure different VID modes | ||
per page within the same device. | ||
|
||
Extend "vrm_version" with the type for Intel IMVP9 and AMD 6.25mV VID | ||
modes. | ||
Add calculation for those types. | ||
|
||
Add support for devices XDPE12254, XDPE12284. | ||
All these device support two pages. | ||
The below lists of VOUT_MODE command readout with their related VID | ||
protocols, Digital to Analog Converter steps, supported by these | ||
devices: | ||
VR12.0 mode, 5-mV DAC - 0x01; | ||
VR12.5 mode, 10-mV DAC - 0x02; | ||
IMVP9 mode, 5-mV DAC - 0x03; | ||
AMD mode 6.25mV - 0x10. | ||
|
||
Signed-off-by: Vadim Pasternak <[email protected]> | ||
--- | ||
drivers/hwmon/pmbus/Kconfig | 9 +++ | ||
drivers/hwmon/pmbus/Makefile | 1 + | ||
drivers/hwmon/pmbus/max20751.c | 2 +- | ||
drivers/hwmon/pmbus/pmbus.c | 5 +- | ||
drivers/hwmon/pmbus/pmbus.h | 4 +- | ||
drivers/hwmon/pmbus/pmbus_core.c | 10 ++- | ||
drivers/hwmon/pmbus/tps53679.c | 44 +++++----- | ||
drivers/hwmon/pmbus/xdpe12284.c | 171 +++++++++++++++++++++++++++++++++++++++ | ||
8 files changed, 219 insertions(+), 27 deletions(-) | ||
create mode 100644 drivers/hwmon/pmbus/xdpe12284.c | ||
|
||
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig | ||
index 61938ea22208..79fd67e0c940 100644 | ||
--- a/drivers/hwmon/pmbus/Kconfig | ||
+++ b/drivers/hwmon/pmbus/Kconfig | ||
@@ -156,6 +156,15 @@ config SENSORS_UCD9200 | ||
This driver can also be built as a module. If so, the module will | ||
be called ucd9200. | ||
|
||
+config SENSORS_XDPE122 | ||
+ tristate "Infineon XDPE122 family" | ||
+ help | ||
+ If you say yes here you get hardware monitoring support for Infineon | ||
+ XDPE12254, XDPE12284, device. | ||
+ | ||
+ This driver can also be built as a module. If so, the module will | ||
+ be called xdpe12284. | ||
+ | ||
config SENSORS_ZL6100 | ||
tristate "Intersil ZL6100 and compatibles" | ||
default n | ||
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile | ||
index b912fec9876d..e0fe17121afb 100644 | ||
--- a/drivers/hwmon/pmbus/Makefile | ||
+++ b/drivers/hwmon/pmbus/Makefile | ||
@@ -16,4 +16,5 @@ obj-$(CONFIG_SENSORS_TPS40422) += tps40422.o | ||
obj-$(CONFIG_SENSORS_TPS53679) += tps53679.o | ||
obj-$(CONFIG_SENSORS_UCD9000) += ucd9000.o | ||
obj-$(CONFIG_SENSORS_UCD9200) += ucd9200.o | ||
+obj-$(CONFIG_SENSORS_XDPE122) += xdpe12284.o | ||
obj-$(CONFIG_SENSORS_ZL6100) += zl6100.o | ||
diff --git a/drivers/hwmon/pmbus/max20751.c b/drivers/hwmon/pmbus/max20751.c | ||
index ab74aeae8cf2..394c662c811b 100644 | ||
--- a/drivers/hwmon/pmbus/max20751.c | ||
+++ b/drivers/hwmon/pmbus/max20751.c | ||
@@ -25,7 +25,7 @@ static struct pmbus_driver_info max20751_info = { | ||
.pages = 1, | ||
.format[PSC_VOLTAGE_IN] = linear, | ||
.format[PSC_VOLTAGE_OUT] = vid, | ||
- .vrm_version = vr12, | ||
+ .vrm_version[0] = vr12, | ||
.format[PSC_TEMPERATURE] = linear, | ||
.format[PSC_CURRENT_OUT] = linear, | ||
.format[PSC_POWER] = linear, | ||
diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c | ||
index 44ca8a94873d..ad360a88a53a 100644 | ||
--- a/drivers/hwmon/pmbus/pmbus.c | ||
+++ b/drivers/hwmon/pmbus/pmbus.c | ||
@@ -121,7 +121,7 @@ static int pmbus_identify(struct i2c_client *client, | ||
} | ||
|
||
if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) { | ||
- int vout_mode; | ||
+ int vout_mode, i; | ||
|
||
vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); | ||
if (vout_mode >= 0 && vout_mode != 0xff) { | ||
@@ -130,7 +130,8 @@ static int pmbus_identify(struct i2c_client *client, | ||
break; | ||
case 1: | ||
info->format[PSC_VOLTAGE_OUT] = vid; | ||
- info->vrm_version = vr11; | ||
+ for (i = 0; i < info->pages; i++) | ||
+ info->vrm_version[i] = vr11; | ||
break; | ||
case 2: | ||
info->format[PSC_VOLTAGE_OUT] = direct; | ||
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h | ||
index 4efa2bd4f6d8..881156491581 100644 | ||
--- a/drivers/hwmon/pmbus/pmbus.h | ||
+++ b/drivers/hwmon/pmbus/pmbus.h | ||
@@ -341,12 +341,12 @@ enum pmbus_sensor_classes { | ||
#define PMBUS_HAVE_STATUS_VMON BIT(19) | ||
|
||
enum pmbus_data_format { linear = 0, direct, vid }; | ||
-enum vrm_version { vr11 = 0, vr12, vr13 }; | ||
+enum vrm_version { vr11 = 0, vr12, vr13, imvp9, amd625mv }; | ||
|
||
struct pmbus_driver_info { | ||
int pages; /* Total number of pages */ | ||
enum pmbus_data_format format[PSC_NUM_CLASSES]; | ||
- enum vrm_version vrm_version; | ||
+ enum vrm_version vrm_version[PMBUS_PAGES]; /* vrm version per page */ | ||
/* | ||
* Support one set of coefficients for each sensor type | ||
* Used for chips providing data in direct mode. | ||
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c | ||
index 682b01624908..764a28105831 100644 | ||
--- a/drivers/hwmon/pmbus/pmbus_core.c | ||
+++ b/drivers/hwmon/pmbus/pmbus_core.c | ||
@@ -522,7 +522,7 @@ static long pmbus_reg2data_vid(struct pmbus_data *data, | ||
long val = sensor->data; | ||
long rv = 0; | ||
|
||
- switch (data->info->vrm_version) { | ||
+ switch (data->info->vrm_version[sensor->page]) { | ||
case vr11: | ||
if (val >= 0x02 && val <= 0xb2) | ||
rv = DIV_ROUND_CLOSEST(160000 - (val - 2) * 625, 100); | ||
@@ -535,6 +535,14 @@ static long pmbus_reg2data_vid(struct pmbus_data *data, | ||
if (val >= 0x01) | ||
rv = 500 + (val - 1) * 10; | ||
break; | ||
+ case imvp9: | ||
+ if (val >= 0x01) | ||
+ rv = 200 + (val - 1) * 10; | ||
+ break; | ||
+ case amd625mv: | ||
+ if (val >= 0x0 && val <= 0xd8) | ||
+ rv = DIV_ROUND_CLOSEST(155000 - val * 625, 100); | ||
+ break; | ||
} | ||
return rv; | ||
} | ||
diff --git a/drivers/hwmon/pmbus/tps53679.c b/drivers/hwmon/pmbus/tps53679.c | ||
index 45eacc504e2f..28d3de029b91 100644 | ||
--- a/drivers/hwmon/pmbus/tps53679.c | ||
+++ b/drivers/hwmon/pmbus/tps53679.c | ||
@@ -33,27 +33,29 @@ static int tps53679_identify(struct i2c_client *client, | ||
struct pmbus_driver_info *info) | ||
{ | ||
u8 vout_params; | ||
- int ret; | ||
- | ||
- /* Read the register with VOUT scaling value.*/ | ||
- ret = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); | ||
- if (ret < 0) | ||
- return ret; | ||
- | ||
- vout_params = ret & GENMASK(4, 0); | ||
- | ||
- switch (vout_params) { | ||
- case TPS53679_PROT_VR13_10MV: | ||
- case TPS53679_PROT_VR12_5_10MV: | ||
- info->vrm_version = vr13; | ||
- break; | ||
- case TPS53679_PROT_VR13_5MV: | ||
- case TPS53679_PROT_VR12_5MV: | ||
- case TPS53679_PROT_IMVP8_5MV: | ||
- info->vrm_version = vr12; | ||
- break; | ||
- default: | ||
- return -EINVAL; | ||
+ int i, ret; | ||
+ | ||
+ for (i = 0; i < TPS53679_PAGE_NUM; i++) { | ||
+ /* Read the register with VOUT scaling value.*/ | ||
+ ret = pmbus_read_byte_data(client, i, PMBUS_VOUT_MODE); | ||
+ if (ret < 0) | ||
+ return ret; | ||
+ | ||
+ vout_params = ret & GENMASK(4, 0); | ||
+ | ||
+ switch (vout_params) { | ||
+ case TPS53679_PROT_VR13_10MV: | ||
+ case TPS53679_PROT_VR12_5_10MV: | ||
+ info->vrm_version[i] = vr13; | ||
+ break; | ||
+ case TPS53679_PROT_VR13_5MV: | ||
+ case TPS53679_PROT_VR12_5MV: | ||
+ case TPS53679_PROT_IMVP8_5MV: | ||
+ info->vrm_version[i] = vr12; | ||
+ break; | ||
+ default: | ||
+ return -EINVAL; | ||
+ } | ||
} | ||
|
||
return 0; | ||
diff --git a/drivers/hwmon/pmbus/xdpe12284.c b/drivers/hwmon/pmbus/xdpe12284.c | ||
new file mode 100644 | ||
index 000000000000..660556b89e9f | ||
--- /dev/null | ||
+++ b/drivers/hwmon/pmbus/xdpe12284.c | ||
@@ -0,0 +1,171 @@ | ||
+// SPDX-License-Identifier: GPL-2.0-or-later | ||
+/* | ||
+ * Hardware monitoring driver for Infineon Multi-phase Digital VR Controllers | ||
+ * | ||
+ * Copyright (c) 2020 Mellanox Technologies. All rights reserved. | ||
+ */ | ||
+ | ||
+#include <linux/err.h> | ||
+#include <linux/i2c.h> | ||
+#include <linux/init.h> | ||
+#include <linux/kernel.h> | ||
+#include <linux/module.h> | ||
+#include "pmbus.h" | ||
+ | ||
+#define XDPE122_PROT_VR12_5MV 0x01 /* VR12.0 mode, 5-mV DAC */ | ||
+#define XDPE122_PROT_VR12_5_10MV 0x02 /* VR12.5 mode, 10-mV DAC */ | ||
+#define XDPE122_PROT_IMVP9_10MV 0x03 /* IMVP9 mode, 10-mV DAC */ | ||
+#define XDPE122_AMD_625MV 0x10 /* AMD mode 6.25mV */ | ||
+#define XDPE122_PAGE_NUM 2 | ||
+ | ||
+static int xdpe122_read_word_data(struct i2c_client *client, int page, int reg) | ||
+{ | ||
+ const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | ||
+ long val; | ||
+ s16 exponent; | ||
+ s32 mantissa; | ||
+ int ret; | ||
+ | ||
+ switch (reg) { | ||
+ case PMBUS_VOUT_OV_FAULT_LIMIT: | ||
+ case PMBUS_VOUT_UV_FAULT_LIMIT: | ||
+ ret = pmbus_read_word_data(client, page, reg); | ||
+ if (ret < 0) | ||
+ return ret; | ||
+ | ||
+ /* Convert register value to LINEAR11 data. */ | ||
+ exponent = ((s16)ret) >> 11; | ||
+ mantissa = ((s16)((ret & GENMASK(10, 0)) << 5)) >> 5; | ||
+ val = mantissa * 1000L; | ||
+ if (exponent >= 0) | ||
+ val <<= exponent; | ||
+ else | ||
+ val >>= -exponent; | ||
+ | ||
+ /* Convert data to VID register. */ | ||
+ switch (info->vrm_version[page]) { | ||
+ case vr13: | ||
+ if (val >= 500) | ||
+ return 1 + DIV_ROUND_CLOSEST(val - 500, 10); | ||
+ return 0; | ||
+ case vr12: | ||
+ if (val >= 250) | ||
+ return 1 + DIV_ROUND_CLOSEST(val - 250, 5); | ||
+ return 0; | ||
+ case imvp9: | ||
+ if (val >= 200) | ||
+ return 1 + DIV_ROUND_CLOSEST(val - 200, 10); | ||
+ return 0; | ||
+ case amd625mv: | ||
+ if (val >= 200 && val <= 1550) | ||
+ return DIV_ROUND_CLOSEST((1550 - val) * 100, | ||
+ 625); | ||
+ return 0; | ||
+ default: | ||
+ return -EINVAL; | ||
+ } | ||
+ default: | ||
+ return -ENODATA; | ||
+ } | ||
+ | ||
+ return 0; | ||
+} | ||
+ | ||
+static int xdpe122_identify(struct i2c_client *client, | ||
+ struct pmbus_driver_info *info) | ||
+{ | ||
+ u8 vout_params; | ||
+ int i, ret; | ||
+ | ||
+ for (i = 0; i < XDPE122_PAGE_NUM; i++) { | ||
+ /* Read the register with VOUT scaling value.*/ | ||
+ ret = pmbus_read_byte_data(client, i, PMBUS_VOUT_MODE); | ||
+ if (ret < 0) | ||
+ return ret; | ||
+ | ||
+ vout_params = ret & GENMASK(4, 0); | ||
+ | ||
+ switch (vout_params) { | ||
+ case XDPE122_PROT_VR12_5_10MV: | ||
+ info->vrm_version[i] = vr13; | ||
+ break; | ||
+ case XDPE122_PROT_VR12_5MV: | ||
+ info->vrm_version[i] = vr12; | ||
+ break; | ||
+ case XDPE122_PROT_IMVP9_10MV: | ||
+ info->vrm_version[i] = imvp9; | ||
+ break; | ||
+ case XDPE122_AMD_625MV: | ||
+ info->vrm_version[i] = amd625mv; | ||
+ break; | ||
+ default: | ||
+ return -EINVAL; | ||
+ } | ||
+ } | ||
+ | ||
+ return 0; | ||
+} | ||
+ | ||
+static struct pmbus_driver_info xdpe122_info = { | ||
+ .pages = XDPE122_PAGE_NUM, | ||
+ .format[PSC_VOLTAGE_IN] = linear, | ||
+ .format[PSC_VOLTAGE_OUT] = vid, | ||
+ .format[PSC_TEMPERATURE] = linear, | ||
+ .format[PSC_CURRENT_IN] = linear, | ||
+ .format[PSC_CURRENT_OUT] = linear, | ||
+ .format[PSC_POWER] = linear, | ||
+ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | | ||
+ PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | | ||
+ PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | | ||
+ PMBUS_HAVE_POUT | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT, | ||
+ .func[1] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | | ||
+ PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | | ||
+ PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | | ||
+ PMBUS_HAVE_POUT | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT, | ||
+ .identify = xdpe122_identify, | ||
+ .read_word_data = xdpe122_read_word_data, | ||
+}; | ||
+ | ||
+static int xdpe122_probe(struct i2c_client *client, | ||
+ const struct i2c_device_id *id) | ||
+{ | ||
+ struct pmbus_driver_info *info; | ||
+ | ||
+ info = devm_kmemdup(&client->dev, &xdpe122_info, sizeof(*info), | ||
+ GFP_KERNEL); | ||
+ if (!info) | ||
+ return -ENOMEM; | ||
+ | ||
+ return pmbus_do_probe(client, id, info); | ||
+} | ||
+ | ||
+static const struct i2c_device_id xdpe122_id[] = { | ||
+ {"xdpe12254", 0}, | ||
+ {"xdpe12284", 0}, | ||
+ {} | ||
+}; | ||
+ | ||
+MODULE_DEVICE_TABLE(i2c, xdpe122_id); | ||
+ | ||
+static const struct of_device_id __maybe_unused xdpe122_of_match[] = { | ||
+ {.compatible = "infineon,xdpe12254"}, | ||
+ {.compatible = "infineon,xdpe12284"}, | ||
+ {} | ||
+}; | ||
+MODULE_DEVICE_TABLE(of, xdpe122_of_match); | ||
+ | ||
+static struct i2c_driver xdpe122_driver = { | ||
+ .driver = { | ||
+ .name = "xdpe12284", | ||
+ .of_match_table = of_match_ptr(xdpe122_of_match), | ||
+ }, | ||
+ .probe = xdpe122_probe, | ||
+ .remove = pmbus_do_remove, | ||
+ .id_table = xdpe122_id, | ||
+}; | ||
+ | ||
+module_i2c_driver(xdpe122_driver); | ||
+ | ||
+MODULE_AUTHOR("Vadim Pasternak <[email protected]>"); | ||
+MODULE_DESCRIPTION("PMBus driver for Infineon XDPE122 family"); | ||
+MODULE_LICENSE("GPL"); | ||
-- | ||
2.11.0 | ||
|
Oops, something went wrong.