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.
[dni_dps460] Add attributes to retrieve PMBus status command codes (s…
…onic-net#197) Add attributes to retrieve PMBus status command codes (Port of sonic-net#194 from 201811 branch) Signed-off-by: Arun Saravanan Balachandran <Arun_Saravanan_Balac@dell.com>
- Loading branch information
1 parent
2fcd4e3
commit 65fccd7
Showing
2 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
183 changes: 183 additions & 0 deletions
183
patch/driver-hwmon-pmbus-dni_dps460-add-status-attributes.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,183 @@ | ||
From 0a3a6f30eb6ea96a1642a3ad75d2de87a1448fb3 Mon Sep 17 00:00:00 2001 | ||
From: Arun Saravanan Balachandran <Arun_Saravanan_Balac@dell.com> | ||
Date: Thu, 11 Feb 2021 09:15:41 +0000 | ||
Subject: [PATCH] Add attributes to retrieve PMBus status command codes | ||
|
||
Signed-off-by: Arun Saravanan Balachandran <Arun_Saravanan_Balac@dell.com> | ||
--- | ||
drivers/hwmon/pmbus/dni_dps460.c | 152 +++++++++++++++++++++++++++++++++++++++ | ||
1 file changed, 152 insertions(+) | ||
|
||
diff --git a/drivers/hwmon/pmbus/dni_dps460.c b/drivers/hwmon/pmbus/dni_dps460.c | ||
index d314c1f..313165a 100644 | ||
--- a/drivers/hwmon/pmbus/dni_dps460.c | ||
+++ b/drivers/hwmon/pmbus/dni_dps460.c | ||
@@ -166,13 +166,165 @@ static ssize_t set_pec(struct device *dev, struct device_attribute *dummy, | ||
return count; | ||
} | ||
|
||
+static ssize_t show_capability(struct device *dev, struct device_attribute *devattr, | ||
+ char *buf) { | ||
+ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct pmbus_data *data = i2c_get_clientdata(client); | ||
+ int val; | ||
+ | ||
+ mutex_lock(&data->update_lock); | ||
+ val = pmbus_read_byte_data(client, 0, PMBUS_CAPABILITY); | ||
+ pmbus_clear_faults(client); | ||
+ mutex_unlock(&data->update_lock); | ||
+ if (val < 0) { | ||
+ return val; | ||
+ } | ||
+ return sprintf(buf, "0x%x\n", val); | ||
+} | ||
+ | ||
+static ssize_t show_status_word(struct device *dev, struct device_attribute *devattr, | ||
+ char *buf) { | ||
+ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct pmbus_data *data = i2c_get_clientdata(client); | ||
+ int val; | ||
+ | ||
+ mutex_lock(&data->update_lock); | ||
+ val = pmbus_read_word_data(client, 0, PMBUS_STATUS_WORD); | ||
+ pmbus_clear_faults(client); | ||
+ mutex_unlock(&data->update_lock); | ||
+ if (val < 0) { | ||
+ return val; | ||
+ } | ||
+ return sprintf(buf, "0x%x\n", val); | ||
+} | ||
+ | ||
+static ssize_t show_status_vout(struct device *dev, struct device_attribute *devattr, | ||
+ char *buf) { | ||
+ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct pmbus_data *data = i2c_get_clientdata(client); | ||
+ int val; | ||
+ | ||
+ mutex_lock(&data->update_lock); | ||
+ val = pmbus_read_byte_data(client, 0, PMBUS_STATUS_VOUT); | ||
+ pmbus_clear_faults(client); | ||
+ mutex_unlock(&data->update_lock); | ||
+ if (val < 0) { | ||
+ return val; | ||
+ } | ||
+ return sprintf(buf, "0x%x\n", val); | ||
+} | ||
+ | ||
+static ssize_t show_status_iout(struct device *dev, struct device_attribute *devattr, | ||
+ char *buf) { | ||
+ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct pmbus_data *data = i2c_get_clientdata(client); | ||
+ int val; | ||
+ | ||
+ mutex_lock(&data->update_lock); | ||
+ val = pmbus_read_byte_data(client, 0, PMBUS_STATUS_IOUT); | ||
+ pmbus_clear_faults(client); | ||
+ mutex_unlock(&data->update_lock); | ||
+ if (val < 0) { | ||
+ return val; | ||
+ } | ||
+ return sprintf(buf, "0x%x\n", val); | ||
+} | ||
+ | ||
+static ssize_t show_status_input(struct device *dev, struct device_attribute *devattr, | ||
+ char *buf) { | ||
+ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct pmbus_data *data = i2c_get_clientdata(client); | ||
+ int val; | ||
+ | ||
+ mutex_lock(&data->update_lock); | ||
+ val = pmbus_read_byte_data(client, 0, PMBUS_STATUS_INPUT); | ||
+ pmbus_clear_faults(client); | ||
+ mutex_unlock(&data->update_lock); | ||
+ if (val < 0) { | ||
+ return val; | ||
+ } | ||
+ return sprintf(buf, "0x%x\n", val); | ||
+} | ||
+ | ||
+static ssize_t show_status_temp(struct device *dev, struct device_attribute *devattr, | ||
+ char *buf) { | ||
+ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct pmbus_data *data = i2c_get_clientdata(client); | ||
+ int val; | ||
+ | ||
+ mutex_lock(&data->update_lock); | ||
+ val = pmbus_read_byte_data(client, 0, PMBUS_STATUS_TEMPERATURE); | ||
+ pmbus_clear_faults(client); | ||
+ mutex_unlock(&data->update_lock); | ||
+ if (val < 0) { | ||
+ return val; | ||
+ } | ||
+ return sprintf(buf, "0x%x\n", val); | ||
+} | ||
+ | ||
+static ssize_t show_status_cml(struct device *dev, struct device_attribute *devattr, | ||
+ char *buf) { | ||
+ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct pmbus_data *data = i2c_get_clientdata(client); | ||
+ int val; | ||
+ | ||
+ mutex_lock(&data->update_lock); | ||
+ val = pmbus_read_byte_data(client, 0, PMBUS_STATUS_CML); | ||
+ pmbus_clear_faults(client); | ||
+ mutex_unlock(&data->update_lock); | ||
+ if (val < 0) { | ||
+ return val; | ||
+ } | ||
+ return sprintf(buf, "0x%x\n", val); | ||
+} | ||
+ | ||
+static ssize_t show_status_fans(struct device *dev, struct device_attribute *devattr, | ||
+ char *buf) { | ||
+ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct pmbus_data *data = i2c_get_clientdata(client); | ||
+ int val; | ||
+ | ||
+ mutex_lock(&data->update_lock); | ||
+ val = pmbus_read_byte_data(client, 0, PMBUS_STATUS_FAN_12); | ||
+ pmbus_clear_faults(client); | ||
+ mutex_unlock(&data->update_lock); | ||
+ if (val < 0) { | ||
+ return val; | ||
+ } | ||
+ return sprintf(buf, "0x%x\n", val); | ||
+} | ||
+ | ||
static SENSOR_DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec, 0); | ||
static SENSOR_DEVICE_ATTR(fan1_target, S_IWUSR | S_IRUGO, get_target, | ||
set_target, 0); | ||
+static SENSOR_DEVICE_ATTR(capability, S_IRUGO, show_capability, NULL, 0); | ||
+static SENSOR_DEVICE_ATTR(status_word, S_IRUGO, show_status_word, NULL, 0); | ||
+static SENSOR_DEVICE_ATTR(status_vout, S_IRUGO, show_status_vout, NULL, 0); | ||
+static SENSOR_DEVICE_ATTR(status_iout, S_IRUGO, show_status_iout, NULL, 0); | ||
+static SENSOR_DEVICE_ATTR(status_input, S_IRUGO, show_status_input, NULL, 0); | ||
+static SENSOR_DEVICE_ATTR(status_temp, S_IRUGO, show_status_temp, NULL, 0); | ||
+static SENSOR_DEVICE_ATTR(status_cml, S_IRUGO, show_status_cml, NULL, 0); | ||
+static SENSOR_DEVICE_ATTR(status_fans_12, S_IRUGO, show_status_fans, NULL, 0); | ||
|
||
static struct attribute *dni_dps460_attrs[] = { | ||
&sensor_dev_attr_fan1_target.dev_attr.attr, | ||
&sensor_dev_attr_pec.dev_attr.attr, | ||
+ &sensor_dev_attr_capability.dev_attr.attr, | ||
+ &sensor_dev_attr_status_word.dev_attr.attr, | ||
+ &sensor_dev_attr_status_vout.dev_attr.attr, | ||
+ &sensor_dev_attr_status_iout.dev_attr.attr, | ||
+ &sensor_dev_attr_status_input.dev_attr.attr, | ||
+ &sensor_dev_attr_status_temp.dev_attr.attr, | ||
+ &sensor_dev_attr_status_cml.dev_attr.attr, | ||
+ &sensor_dev_attr_status_fans_12.dev_attr.attr, | ||
NULL | ||
}; | ||
static struct attribute_group dni_dps460_attr_grp = { | ||
-- | ||
2.7.4 | ||
|
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