diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-07-09 16:11:44 -0400 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-07-28 20:09:53 -0400 |
commit | 70e94b276c21638a0a37908f6696a6b122944dea (patch) | |
tree | 9d017d968a85b4d5313c4f5117bcae042f73555e /drivers/hwmon/pmbus | |
parent | 8ebed854506301f4f67e75c73cae967d4a45ab4d (diff) |
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>
Diffstat (limited to 'drivers/hwmon/pmbus')
-rw-r--r-- | drivers/hwmon/pmbus/max8688.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/max8688.c b/drivers/hwmon/pmbus/max8688.c index ddc8a64c2ba5..c3e72f1a3cfb 100644 --- a/drivers/hwmon/pmbus/max8688.c +++ b/drivers/hwmon/pmbus/max8688.c | |||
@@ -25,6 +25,9 @@ | |||
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include "pmbus.h" | 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 | #define MAX8688_MFG_STATUS 0xd8 | 31 | #define MAX8688_MFG_STATUS 0xd8 |
29 | 32 | ||
30 | #define MAX8688_STATUS_OC_FAULT (1 << 4) | 33 | #define MAX8688_STATUS_OC_FAULT (1 << 4) |
@@ -37,6 +40,62 @@ | |||
37 | #define MAX8688_STATUS_OT_FAULT (1 << 13) | 40 | #define MAX8688_STATUS_OT_FAULT (1 << 13) |
38 | #define MAX8688_STATUS_OT_WARNING (1 << 14) | 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 | static int max8688_read_byte_data(struct i2c_client *client, int page, int reg) | 99 | static int max8688_read_byte_data(struct i2c_client *client, int page, int reg) |
41 | { | 100 | { |
42 | int ret = 0; | 101 | int ret = 0; |
@@ -111,6 +170,8 @@ static struct pmbus_driver_info max8688_info = { | |||
111 | | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT | 170 | | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
112 | | PMBUS_HAVE_STATUS_TEMP, | 171 | | PMBUS_HAVE_STATUS_TEMP, |
113 | .read_byte_data = max8688_read_byte_data, | 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 | static int max8688_probe(struct i2c_client *client, | 177 | static int max8688_probe(struct i2c_client *client, |