aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/hwmon/max3444029
-rw-r--r--drivers/hwmon/pmbus/Kconfig4
-rw-r--r--drivers/hwmon/pmbus/max34440.c112
3 files changed, 138 insertions, 7 deletions
diff --git a/Documentation/hwmon/max34440 b/Documentation/hwmon/max34440
index 36b335c461dc..bbdf9bf5d8f5 100644
--- a/Documentation/hwmon/max34440
+++ b/Documentation/hwmon/max34440
@@ -11,6 +11,11 @@ Supported chips:
11 Prefixes: 'max34441' 11 Prefixes: 'max34441'
12 Addresses scanned: - 12 Addresses scanned: -
13 Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX34441.pdf 13 Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX34441.pdf
14 * Maxim MAX34446
15 PMBus Power-Supply Data Logger
16 Prefixes: 'max34446'
17 Addresses scanned: -
18 Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX34446.pdf
14 19
15Author: Guenter Roeck <guenter.roeck@ericsson.com> 20Author: Guenter Roeck <guenter.roeck@ericsson.com>
16 21
@@ -19,8 +24,8 @@ Description
19----------- 24-----------
20 25
21This driver supports hardware montoring for Maxim MAX34440 PMBus 6-Channel 26This driver supports hardware montoring for Maxim MAX34440 PMBus 6-Channel
22Power-Supply Manager and MAX34441 PMBus 5-Channel Power-Supply Manager 27Power-Supply Manager, MAX34441 PMBus 5-Channel Power-Supply Manager
23and Intelligent Fan Controller. 28and Intelligent Fan Controller, and MAX34446 PMBus Power-Supply Data Logger.
24 29
25The driver is a client driver to the core PMBus driver. Please see 30The driver is a client driver to the core PMBus driver. Please see
26Documentation/hwmon/pmbus for details on PMBus client drivers. 31Documentation/hwmon/pmbus for details on PMBus client drivers.
@@ -33,6 +38,13 @@ This driver does not auto-detect devices. You will have to instantiate the
33devices explicitly. Please see Documentation/i2c/instantiating-devices for 38devices explicitly. Please see Documentation/i2c/instantiating-devices for
34details. 39details.
35 40
41For MAX34446, the value of the currX_crit attribute determines if current or
42voltage measurement is enabled for a given channel. Voltage measurement is
43enabled if currX_crit is set to 0; current measurement is enabled if the
44attribute is set to a positive value. Power measurement is only enabled if
45channel 1 (3) is configured for voltage measurement, and channel 2 (4) is
46configured for current measurement.
47
36 48
37Platform data support 49Platform data support
38--------------------- 50---------------------
@@ -60,16 +72,27 @@ in[1-6]_lowest Historical minimum voltage.
60in[1-6]_highest Historical maximum voltage. 72in[1-6]_highest Historical maximum voltage.
61in[1-6]_reset_history Write any value to reset history. 73in[1-6]_reset_history Write any value to reset history.
62 74
75 MAX34446 only supports in[1-4].
76
63curr[1-6]_label "iout[1-6]". 77curr[1-6]_label "iout[1-6]".
64curr[1-6]_input Measured current. From READ_IOUT register. 78curr[1-6]_input Measured current. From READ_IOUT register.
65curr[1-6]_max Maximum current. From IOUT_OC_WARN_LIMIT register. 79curr[1-6]_max Maximum current. From IOUT_OC_WARN_LIMIT register.
66curr[1-6]_crit Critical maximum current. From IOUT_OC_FAULT_LIMIT register. 80curr[1-6]_crit Critical maximum current. From IOUT_OC_FAULT_LIMIT register.
67curr[1-6]_max_alarm Current high alarm. From IOUT_OC_WARNING status. 81curr[1-6]_max_alarm Current high alarm. From IOUT_OC_WARNING status.
68curr[1-6]_crit_alarm Current critical high alarm. From IOUT_OC_FAULT status. 82curr[1-6]_crit_alarm Current critical high alarm. From IOUT_OC_FAULT status.
83curr[1-4]_average Historical average current (MAX34446 only).
69curr[1-6]_highest Historical maximum current. 84curr[1-6]_highest Historical maximum current.
70curr[1-6]_reset_history Write any value to reset history. 85curr[1-6]_reset_history Write any value to reset history.
71 86
72 in6 and curr6 attributes only exist for MAX34440. 87 in6 and curr6 attributes only exist for MAX34440.
88 MAX34446 only supports curr[1-4].
89
90power[1,3]_label "pout[1,3]"
91power[1,3]_input Measured power.
92power[1,3]_average Historical average power.
93power[1,3]_highest Historical maximum power.
94
95 Power attributes only exist for MAX34446.
73 96
74temp[1-8]_input Measured temperatures. From READ_TEMPERATURE_1 register. 97temp[1-8]_input Measured temperatures. From READ_TEMPERATURE_1 register.
75 temp1 is the chip's internal temperature. temp2..temp5 98 temp1 is the chip's internal temperature. temp2..temp5
@@ -80,7 +103,9 @@ temp[1-8]_max Maximum temperature. From OT_WARN_LIMIT register.
80temp[1-8]_crit Critical high temperature. From OT_FAULT_LIMIT register. 103temp[1-8]_crit Critical high temperature. From OT_FAULT_LIMIT register.
81temp[1-8]_max_alarm Temperature high alarm. 104temp[1-8]_max_alarm Temperature high alarm.
82temp[1-8]_crit_alarm Temperature critical high alarm. 105temp[1-8]_crit_alarm Temperature critical high alarm.
106temp[1-8]_average Historical average temperature (MAX34446 only).
83temp[1-8]_highest Historical maximum temperature. 107temp[1-8]_highest Historical maximum temperature.
84temp[1-8]_reset_history Write any value to reset history. 108temp[1-8]_reset_history Write any value to reset history.
85 109
86 temp7 and temp8 attributes only exist for MAX34440. 110 temp7 and temp8 attributes only exist for MAX34440.
111 MAX34446 only supports temp[1-3].
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index d1aa2dbd5b75..1f0d0110b6b8 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -68,11 +68,11 @@ config SENSORS_MAX16064
68 be called max16064. 68 be called max16064.
69 69
70config SENSORS_MAX34440 70config SENSORS_MAX34440
71 tristate "Maxim MAX34440/MAX34441" 71 tristate "Maxim MAX34440 and compatibles"
72 default n 72 default n
73 help 73 help
74 If you say yes here you get hardware monitoring support for Maxim 74 If you say yes here you get hardware monitoring support for Maxim
75 MAX34440 and MAX34441. 75 MAX34440, MAX34441, and MAX34446.
76 76
77 This driver can also be built as a module. If so, the module will 77 This driver can also be built as a module. If so, the module will
78 be called max34440. 78 be called max34440.
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index 95ee9e195cb6..2ada7b021fbe 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -25,21 +25,35 @@
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include "pmbus.h" 26#include "pmbus.h"
27 27
28enum chips { max34440, max34441 }; 28enum chips { max34440, max34441, max34446 };
29 29
30#define MAX34440_MFR_VOUT_PEAK 0xd4 30#define MAX34440_MFR_VOUT_PEAK 0xd4
31#define MAX34440_MFR_IOUT_PEAK 0xd5 31#define MAX34440_MFR_IOUT_PEAK 0xd5
32#define MAX34440_MFR_TEMPERATURE_PEAK 0xd6 32#define MAX34440_MFR_TEMPERATURE_PEAK 0xd6
33#define MAX34440_MFR_VOUT_MIN 0xd7 33#define MAX34440_MFR_VOUT_MIN 0xd7
34 34
35#define MAX34446_MFR_POUT_PEAK 0xe0
36#define MAX34446_MFR_POUT_AVG 0xe1
37#define MAX34446_MFR_IOUT_AVG 0xe2
38#define MAX34446_MFR_TEMPERATURE_AVG 0xe3
39
35#define MAX34440_STATUS_OC_WARN (1 << 0) 40#define MAX34440_STATUS_OC_WARN (1 << 0)
36#define MAX34440_STATUS_OC_FAULT (1 << 1) 41#define MAX34440_STATUS_OC_FAULT (1 << 1)
37#define MAX34440_STATUS_OT_FAULT (1 << 5) 42#define MAX34440_STATUS_OT_FAULT (1 << 5)
38#define MAX34440_STATUS_OT_WARN (1 << 6) 43#define MAX34440_STATUS_OT_WARN (1 << 6)
39 44
45struct max34440_data {
46 int id;
47 struct pmbus_driver_info info;
48};
49
50#define to_max34440_data(x) container_of(x, struct max34440_data, info)
51
40static int max34440_read_word_data(struct i2c_client *client, int page, int reg) 52static int max34440_read_word_data(struct i2c_client *client, int page, int reg)
41{ 53{
42 int ret; 54 int ret;
55 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
56 const struct max34440_data *data = to_max34440_data(info);
43 57
44 switch (reg) { 58 switch (reg) {
45 case PMBUS_VIRT_READ_VOUT_MIN: 59 case PMBUS_VIRT_READ_VOUT_MIN:
@@ -50,14 +64,43 @@ static int max34440_read_word_data(struct i2c_client *client, int page, int reg)
50 ret = pmbus_read_word_data(client, page, 64 ret = pmbus_read_word_data(client, page,
51 MAX34440_MFR_VOUT_PEAK); 65 MAX34440_MFR_VOUT_PEAK);
52 break; 66 break;
67 case PMBUS_VIRT_READ_IOUT_AVG:
68 if (data->id != max34446)
69 return -ENXIO;
70 ret = pmbus_read_word_data(client, page,
71 MAX34446_MFR_IOUT_AVG);
72 break;
53 case PMBUS_VIRT_READ_IOUT_MAX: 73 case PMBUS_VIRT_READ_IOUT_MAX:
54 ret = pmbus_read_word_data(client, page, 74 ret = pmbus_read_word_data(client, page,
55 MAX34440_MFR_IOUT_PEAK); 75 MAX34440_MFR_IOUT_PEAK);
56 break; 76 break;
77 case PMBUS_VIRT_READ_POUT_AVG:
78 if (data->id != max34446)
79 return -ENXIO;
80 ret = pmbus_read_word_data(client, page,
81 MAX34446_MFR_POUT_AVG);
82 break;
83 case PMBUS_VIRT_READ_POUT_MAX:
84 if (data->id != max34446)
85 return -ENXIO;
86 ret = pmbus_read_word_data(client, page,
87 MAX34446_MFR_POUT_PEAK);
88 break;
89 case PMBUS_VIRT_READ_TEMP_AVG:
90 if (data->id != max34446)
91 return -ENXIO;
92 ret = pmbus_read_word_data(client, page,
93 MAX34446_MFR_TEMPERATURE_AVG);
94 break;
57 case PMBUS_VIRT_READ_TEMP_MAX: 95 case PMBUS_VIRT_READ_TEMP_MAX:
58 ret = pmbus_read_word_data(client, page, 96 ret = pmbus_read_word_data(client, page,
59 MAX34440_MFR_TEMPERATURE_PEAK); 97 MAX34440_MFR_TEMPERATURE_PEAK);
60 break; 98 break;
99 case PMBUS_VIRT_RESET_POUT_HISTORY:
100 if (data->id != max34446)
101 return -ENXIO;
102 ret = 0;
103 break;
61 case PMBUS_VIRT_RESET_VOUT_HISTORY: 104 case PMBUS_VIRT_RESET_VOUT_HISTORY:
62 case PMBUS_VIRT_RESET_IOUT_HISTORY: 105 case PMBUS_VIRT_RESET_IOUT_HISTORY:
63 case PMBUS_VIRT_RESET_TEMP_HISTORY: 106 case PMBUS_VIRT_RESET_TEMP_HISTORY:
@@ -73,9 +116,19 @@ static int max34440_read_word_data(struct i2c_client *client, int page, int reg)
73static int max34440_write_word_data(struct i2c_client *client, int page, 116static int max34440_write_word_data(struct i2c_client *client, int page,
74 int reg, u16 word) 117 int reg, u16 word)
75{ 118{
119 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
120 const struct max34440_data *data = to_max34440_data(info);
76 int ret; 121 int ret;
77 122
78 switch (reg) { 123 switch (reg) {
124 case PMBUS_VIRT_RESET_POUT_HISTORY:
125 ret = pmbus_write_word_data(client, page,
126 MAX34446_MFR_POUT_PEAK, 0);
127 if (ret)
128 break;
129 ret = pmbus_write_word_data(client, page,
130 MAX34446_MFR_POUT_AVG, 0);
131 break;
79 case PMBUS_VIRT_RESET_VOUT_HISTORY: 132 case PMBUS_VIRT_RESET_VOUT_HISTORY:
80 ret = pmbus_write_word_data(client, page, 133 ret = pmbus_write_word_data(client, page,
81 MAX34440_MFR_VOUT_MIN, 0x7fff); 134 MAX34440_MFR_VOUT_MIN, 0x7fff);
@@ -87,11 +140,18 @@ static int max34440_write_word_data(struct i2c_client *client, int page,
87 case PMBUS_VIRT_RESET_IOUT_HISTORY: 140 case PMBUS_VIRT_RESET_IOUT_HISTORY:
88 ret = pmbus_write_word_data(client, page, 141 ret = pmbus_write_word_data(client, page,
89 MAX34440_MFR_IOUT_PEAK, 0); 142 MAX34440_MFR_IOUT_PEAK, 0);
143 if (!ret && data->id == max34446)
144 ret = pmbus_write_word_data(client, page,
145 MAX34446_MFR_IOUT_AVG, 0);
146
90 break; 147 break;
91 case PMBUS_VIRT_RESET_TEMP_HISTORY: 148 case PMBUS_VIRT_RESET_TEMP_HISTORY:
92 ret = pmbus_write_word_data(client, page, 149 ret = pmbus_write_word_data(client, page,
93 MAX34440_MFR_TEMPERATURE_PEAK, 150 MAX34440_MFR_TEMPERATURE_PEAK,
94 0x8000); 151 0x8000);
152 if (!ret && data->id == max34446)
153 ret = pmbus_write_word_data(client, page,
154 MAX34446_MFR_TEMPERATURE_AVG, 0);
95 break; 155 break;
96 default: 156 default:
97 ret = -ENODATA; 157 ret = -ENODATA;
@@ -225,20 +285,66 @@ static struct pmbus_driver_info max34440_info[] = {
225 .read_word_data = max34440_read_word_data, 285 .read_word_data = max34440_read_word_data,
226 .write_word_data = max34440_write_word_data, 286 .write_word_data = max34440_write_word_data,
227 }, 287 },
288 [max34446] = {
289 .pages = 7,
290 .format[PSC_VOLTAGE_IN] = direct,
291 .format[PSC_VOLTAGE_OUT] = direct,
292 .format[PSC_TEMPERATURE] = direct,
293 .format[PSC_CURRENT_OUT] = direct,
294 .format[PSC_POWER] = direct,
295 .m[PSC_VOLTAGE_IN] = 1,
296 .b[PSC_VOLTAGE_IN] = 0,
297 .R[PSC_VOLTAGE_IN] = 3,
298 .m[PSC_VOLTAGE_OUT] = 1,
299 .b[PSC_VOLTAGE_OUT] = 0,
300 .R[PSC_VOLTAGE_OUT] = 3,
301 .m[PSC_CURRENT_OUT] = 1,
302 .b[PSC_CURRENT_OUT] = 0,
303 .R[PSC_CURRENT_OUT] = 3,
304 .m[PSC_POWER] = 1,
305 .b[PSC_POWER] = 0,
306 .R[PSC_POWER] = 3,
307 .m[PSC_TEMPERATURE] = 1,
308 .b[PSC_TEMPERATURE] = 0,
309 .R[PSC_TEMPERATURE] = 2,
310 .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
311 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
312 .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
313 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
314 .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
315 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
316 .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
317 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
318 .func[4] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
319 .func[5] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
320 .func[6] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
321 .read_byte_data = max34440_read_byte_data,
322 .read_word_data = max34440_read_word_data,
323 .write_word_data = max34440_write_word_data,
324 },
228}; 325};
229 326
230static int max34440_probe(struct i2c_client *client, 327static int max34440_probe(struct i2c_client *client,
231 const struct i2c_device_id *id) 328 const struct i2c_device_id *id)
232{ 329{
233 return pmbus_do_probe(client, id, &max34440_info[id->driver_data]); 330 struct max34440_data *data;
331
332 data = devm_kzalloc(&client->dev, sizeof(struct max34440_data),
333 GFP_KERNEL);
334 if (!data)
335 return -ENOMEM;
336 data->id = id->driver_data;
337 data->info = max34440_info[id->driver_data];
338
339 return pmbus_do_probe(client, id, &data->info);
234} 340}
235 341
236static const struct i2c_device_id max34440_id[] = { 342static const struct i2c_device_id max34440_id[] = {
237 {"max34440", max34440}, 343 {"max34440", max34440},
238 {"max34441", max34441}, 344 {"max34441", max34441},
345 {"max34446", max34446},
239 {} 346 {}
240}; 347};
241
242MODULE_DEVICE_TABLE(i2c, max34440_id); 348MODULE_DEVICE_TABLE(i2c, max34440_id);
243 349
244/* This is the driver that will be inserted */ 350/* This is the driver that will be inserted */