diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-07-09 14:17:33 -0400 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-07-28 20:09:52 -0400 |
commit | c576e30cd0c9814b3b45772d46924d796f538dee (patch) | |
tree | b4dee480e3f90896f993ac2ec1abf38bc907d795 | |
parent | 6f183d33a02e686608f708ef713b6423db39bcba (diff) |
hwmon: (adm1275) Add support for peak attributes
Add support for voltage and current peak (historic maximum) attributes.
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
-rw-r--r-- | Documentation/hwmon/adm1275 | 8 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/adm1275.c | 60 |
2 files changed, 66 insertions, 2 deletions
diff --git a/Documentation/hwmon/adm1275 b/Documentation/hwmon/adm1275 index 6a3a6476cf2..097b3ccc4be 100644 --- a/Documentation/hwmon/adm1275 +++ b/Documentation/hwmon/adm1275 | |||
@@ -43,8 +43,8 @@ Documentation/hwmon/pmbus for details. | |||
43 | Sysfs entries | 43 | Sysfs entries |
44 | ------------- | 44 | ------------- |
45 | 45 | ||
46 | The following attributes are supported. Limits are read-write; all other | 46 | The following attributes are supported. Limits are read-write, history reset |
47 | attributes are read-only. | 47 | attributes are write-only, all other attributes are read-only. |
48 | 48 | ||
49 | in1_label "vin1" or "vout1" depending on chip variant and | 49 | in1_label "vin1" or "vout1" depending on chip variant and |
50 | configuration. | 50 | configuration. |
@@ -53,8 +53,12 @@ in1_min Minumum Voltage. From VOUT_UV_WARN_LIMIT register. | |||
53 | in1_max Maximum voltage. From VOUT_OV_WARN_LIMIT register. | 53 | in1_max Maximum voltage. From VOUT_OV_WARN_LIMIT register. |
54 | in1_min_alarm Voltage low alarm. From VOLTAGE_UV_WARNING status. | 54 | in1_min_alarm Voltage low alarm. From VOLTAGE_UV_WARNING status. |
55 | in1_max_alarm Voltage high alarm. From VOLTAGE_OV_WARNING status. | 55 | in1_max_alarm Voltage high alarm. From VOLTAGE_OV_WARNING status. |
56 | in1_highest Historical maximum voltage. | ||
57 | in1_reset_history Write any value to reset history. | ||
56 | 58 | ||
57 | curr1_label "iout1" | 59 | curr1_label "iout1" |
58 | curr1_input Measured current. From READ_IOUT register. | 60 | curr1_input Measured current. From READ_IOUT register. |
59 | curr1_max Maximum current. From IOUT_OC_WARN_LIMIT register. | 61 | curr1_max Maximum current. From IOUT_OC_WARN_LIMIT register. |
60 | curr1_max_alarm Current high alarm. From IOUT_OC_WARN_LIMIT register. | 62 | curr1_max_alarm Current high alarm. From IOUT_OC_WARN_LIMIT register. |
63 | curr1_highest Historical maximum current. | ||
64 | curr1_reset_history Write any value to reset history. | ||
diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c index 71770ffbdaf..c936e278230 100644 --- a/drivers/hwmon/pmbus/adm1275.c +++ b/drivers/hwmon/pmbus/adm1275.c | |||
@@ -23,11 +23,68 @@ | |||
23 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
24 | #include "pmbus.h" | 24 | #include "pmbus.h" |
25 | 25 | ||
26 | #define ADM1275_PEAK_IOUT 0xd0 | ||
27 | #define ADM1275_PEAK_VIN 0xd1 | ||
28 | #define ADM1275_PEAK_VOUT 0xd2 | ||
26 | #define ADM1275_PMON_CONFIG 0xd4 | 29 | #define ADM1275_PMON_CONFIG 0xd4 |
27 | 30 | ||
28 | #define ADM1275_VIN_VOUT_SELECT (1 << 6) | 31 | #define ADM1275_VIN_VOUT_SELECT (1 << 6) |
29 | #define ADM1275_VRANGE (1 << 5) | 32 | #define ADM1275_VRANGE (1 << 5) |
30 | 33 | ||
34 | static int adm1275_read_word_data(struct i2c_client *client, int page, int reg) | ||
35 | { | ||
36 | int ret; | ||
37 | |||
38 | if (page) | ||
39 | return -EINVAL; | ||
40 | |||
41 | switch (reg) { | ||
42 | case PMBUS_VIRT_READ_IOUT_MAX: | ||
43 | ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_IOUT); | ||
44 | break; | ||
45 | case PMBUS_VIRT_READ_VOUT_MAX: | ||
46 | ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_VOUT); | ||
47 | break; | ||
48 | case PMBUS_VIRT_READ_VIN_MAX: | ||
49 | ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_VIN); | ||
50 | break; | ||
51 | case PMBUS_VIRT_RESET_IOUT_HISTORY: | ||
52 | case PMBUS_VIRT_RESET_VOUT_HISTORY: | ||
53 | case PMBUS_VIRT_RESET_VIN_HISTORY: | ||
54 | ret = 0; | ||
55 | break; | ||
56 | default: | ||
57 | ret = -ENODATA; | ||
58 | break; | ||
59 | } | ||
60 | return ret; | ||
61 | } | ||
62 | |||
63 | static int adm1275_write_word_data(struct i2c_client *client, int page, int reg, | ||
64 | u16 word) | ||
65 | { | ||
66 | int ret; | ||
67 | |||
68 | if (page) | ||
69 | return -EINVAL; | ||
70 | |||
71 | switch (reg) { | ||
72 | case PMBUS_VIRT_RESET_IOUT_HISTORY: | ||
73 | ret = pmbus_write_word_data(client, 0, ADM1275_PEAK_IOUT, 0); | ||
74 | break; | ||
75 | case PMBUS_VIRT_RESET_VOUT_HISTORY: | ||
76 | ret = pmbus_write_word_data(client, 0, ADM1275_PEAK_VOUT, 0); | ||
77 | break; | ||
78 | case PMBUS_VIRT_RESET_VIN_HISTORY: | ||
79 | ret = pmbus_write_word_data(client, 0, ADM1275_PEAK_VIN, 0); | ||
80 | break; | ||
81 | default: | ||
82 | ret = -ENODATA; | ||
83 | break; | ||
84 | } | ||
85 | return ret; | ||
86 | } | ||
87 | |||
31 | static int adm1275_probe(struct i2c_client *client, | 88 | static int adm1275_probe(struct i2c_client *client, |
32 | const struct i2c_device_id *id) | 89 | const struct i2c_device_id *id) |
33 | { | 90 | { |
@@ -58,6 +115,9 @@ static int adm1275_probe(struct i2c_client *client, | |||
58 | info->R[PSC_CURRENT_OUT] = -1; | 115 | info->R[PSC_CURRENT_OUT] = -1; |
59 | info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT; | 116 | info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT; |
60 | 117 | ||
118 | info->read_word_data = adm1275_read_word_data; | ||
119 | info->write_word_data = adm1275_write_word_data; | ||
120 | |||
61 | if (config & ADM1275_VRANGE) { | 121 | if (config & ADM1275_VRANGE) { |
62 | info->m[PSC_VOLTAGE_IN] = 19199; | 122 | info->m[PSC_VOLTAGE_IN] = 19199; |
63 | info->b[PSC_VOLTAGE_IN] = 0; | 123 | info->b[PSC_VOLTAGE_IN] = 0; |