Commit 70e94b276c21638a0a37908f6696a6b122944dea
1 parent
8ebed85450
Exists in
master
and in
6 other branches
hwmon: (max8688) Add support for peak attributes
Add support for voltage, current, and temperature peak (historic maximum) attributes. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Showing 2 changed files with 67 additions and 0 deletions Side-by-side Diff
Documentation/hwmon/max8688
... | ... | @@ -50,6 +50,8 @@ |
50 | 50 | in1_max_alarm Voltage high alarm. From VOLTAGE_OV_WARNING status. |
51 | 51 | in1_lcrit_alarm Voltage critical low alarm. From VOLTAGE_UV_FAULT status. |
52 | 52 | in1_crit_alarm Voltage critical high alarm. From VOLTAGE_OV_FAULT status. |
53 | +in1_highest Historical maximum voltage. | |
54 | +in1_reset_history Write any value to reset history. | |
53 | 55 | |
54 | 56 | curr1_label "iout1" |
55 | 57 | curr1_input Measured current. From READ_IOUT register. |
... | ... | @@ -57,6 +59,8 @@ |
57 | 59 | curr1_crit Critical maximum current. From IOUT_OC_FAULT_LIMIT register. |
58 | 60 | curr1_max_alarm Current high alarm. From IOUT_OC_WARN_LIMIT register. |
59 | 61 | curr1_crit_alarm Current critical high alarm. From IOUT_OC_FAULT status. |
62 | +curr1_highest Historical maximum current. | |
63 | +curr1_reset_history Write any value to reset history. | |
60 | 64 | |
61 | 65 | temp1_input Measured temperature. From READ_TEMPERATURE_1 register. |
62 | 66 | temp1_max Maximum temperature. From OT_WARN_LIMIT register. |
... | ... | @@ -67,4 +71,6 @@ |
67 | 71 | temp1_crit_alarm Chip temperature critical high alarm. Set by comparing |
68 | 72 | READ_TEMPERATURE_1 with OT_FAULT_LIMIT if TEMP_OT_FAULT |
69 | 73 | status is set. |
74 | +temp1_highest Historical maximum temperature. | |
75 | +temp1_reset_history Write any value to reset history. |
drivers/hwmon/pmbus/max8688.c
... | ... | @@ -25,6 +25,9 @@ |
25 | 25 | #include <linux/i2c.h> |
26 | 26 | #include "pmbus.h" |
27 | 27 | |
28 | +#define MAX8688_MFR_VOUT_PEAK 0xd4 | |
29 | +#define MAX8688_MFR_IOUT_PEAK 0xd5 | |
30 | +#define MAX8688_MFR_TEMPERATURE_PEAK 0xd6 | |
28 | 31 | #define MAX8688_MFG_STATUS 0xd8 |
29 | 32 | |
30 | 33 | #define MAX8688_STATUS_OC_FAULT (1 << 4) |
... | ... | @@ -37,6 +40,62 @@ |
37 | 40 | #define MAX8688_STATUS_OT_FAULT (1 << 13) |
38 | 41 | #define MAX8688_STATUS_OT_WARNING (1 << 14) |
39 | 42 | |
43 | +static int max8688_read_word_data(struct i2c_client *client, int page, int reg) | |
44 | +{ | |
45 | + int ret; | |
46 | + | |
47 | + if (page) | |
48 | + return -EINVAL; | |
49 | + | |
50 | + switch (reg) { | |
51 | + case PMBUS_VIRT_READ_VOUT_MAX: | |
52 | + ret = pmbus_read_word_data(client, 0, MAX8688_MFR_VOUT_PEAK); | |
53 | + break; | |
54 | + case PMBUS_VIRT_READ_IOUT_MAX: | |
55 | + ret = pmbus_read_word_data(client, 0, MAX8688_MFR_IOUT_PEAK); | |
56 | + break; | |
57 | + case PMBUS_VIRT_READ_TEMP_MAX: | |
58 | + ret = pmbus_read_word_data(client, 0, | |
59 | + MAX8688_MFR_TEMPERATURE_PEAK); | |
60 | + break; | |
61 | + case PMBUS_VIRT_RESET_VOUT_HISTORY: | |
62 | + case PMBUS_VIRT_RESET_IOUT_HISTORY: | |
63 | + case PMBUS_VIRT_RESET_TEMP_HISTORY: | |
64 | + ret = 0; | |
65 | + break; | |
66 | + default: | |
67 | + ret = -ENODATA; | |
68 | + break; | |
69 | + } | |
70 | + return ret; | |
71 | +} | |
72 | + | |
73 | +static int max8688_write_word_data(struct i2c_client *client, int page, int reg, | |
74 | + u16 word) | |
75 | +{ | |
76 | + int ret; | |
77 | + | |
78 | + switch (reg) { | |
79 | + case PMBUS_VIRT_RESET_VOUT_HISTORY: | |
80 | + ret = pmbus_write_word_data(client, 0, MAX8688_MFR_VOUT_PEAK, | |
81 | + 0); | |
82 | + break; | |
83 | + case PMBUS_VIRT_RESET_IOUT_HISTORY: | |
84 | + ret = pmbus_write_word_data(client, 0, MAX8688_MFR_IOUT_PEAK, | |
85 | + 0); | |
86 | + break; | |
87 | + case PMBUS_VIRT_RESET_TEMP_HISTORY: | |
88 | + ret = pmbus_write_word_data(client, 0, | |
89 | + MAX8688_MFR_TEMPERATURE_PEAK, | |
90 | + 0xffff); | |
91 | + break; | |
92 | + default: | |
93 | + ret = -ENODATA; | |
94 | + break; | |
95 | + } | |
96 | + return ret; | |
97 | +} | |
98 | + | |
40 | 99 | static int max8688_read_byte_data(struct i2c_client *client, int page, int reg) |
41 | 100 | { |
42 | 101 | int ret = 0; |
... | ... | @@ -111,6 +170,8 @@ |
111 | 170 | | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
112 | 171 | | PMBUS_HAVE_STATUS_TEMP, |
113 | 172 | .read_byte_data = max8688_read_byte_data, |
173 | + .read_word_data = max8688_read_word_data, | |
174 | + .write_word_data = max8688_write_word_data, | |
114 | 175 | }; |
115 | 176 | |
116 | 177 | static int max8688_probe(struct i2c_client *client, |