1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Hardware monitoring driver for Maxim MAX34440/MAX34441
5 * Copyright (c) 2011 Ericsson AB.
6 * Copyright (c) 2012 Guenter Roeck
9 #include <linux/bitops.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/err.h>
14 #include <linux/i2c.h>
17 enum chips
{ max34440
, max34441
, max34446
, max34451
, max34460
, max34461
};
19 #define MAX34440_MFR_VOUT_PEAK 0xd4
20 #define MAX34440_MFR_IOUT_PEAK 0xd5
21 #define MAX34440_MFR_TEMPERATURE_PEAK 0xd6
22 #define MAX34440_MFR_VOUT_MIN 0xd7
24 #define MAX34446_MFR_POUT_PEAK 0xe0
25 #define MAX34446_MFR_POUT_AVG 0xe1
26 #define MAX34446_MFR_IOUT_AVG 0xe2
27 #define MAX34446_MFR_TEMPERATURE_AVG 0xe3
29 #define MAX34440_STATUS_OC_WARN BIT(0)
30 #define MAX34440_STATUS_OC_FAULT BIT(1)
31 #define MAX34440_STATUS_OT_FAULT BIT(5)
32 #define MAX34440_STATUS_OT_WARN BIT(6)
34 #define MAX34451_MFR_CHANNEL_CONFIG 0xe4
35 #define MAX34451_MFR_CHANNEL_CONFIG_SEL_MASK 0x3f
37 struct max34440_data
{
39 struct pmbus_driver_info info
;
42 #define to_max34440_data(x) container_of(x, struct max34440_data, info)
44 static int max34440_read_word_data(struct i2c_client
*client
, int page
, int reg
)
47 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
48 const struct max34440_data
*data
= to_max34440_data(info
);
51 case PMBUS_VIRT_READ_VOUT_MIN
:
52 ret
= pmbus_read_word_data(client
, page
,
53 MAX34440_MFR_VOUT_MIN
);
55 case PMBUS_VIRT_READ_VOUT_MAX
:
56 ret
= pmbus_read_word_data(client
, page
,
57 MAX34440_MFR_VOUT_PEAK
);
59 case PMBUS_VIRT_READ_IOUT_AVG
:
60 if (data
->id
!= max34446
&& data
->id
!= max34451
)
62 ret
= pmbus_read_word_data(client
, page
,
63 MAX34446_MFR_IOUT_AVG
);
65 case PMBUS_VIRT_READ_IOUT_MAX
:
66 ret
= pmbus_read_word_data(client
, page
,
67 MAX34440_MFR_IOUT_PEAK
);
69 case PMBUS_VIRT_READ_POUT_AVG
:
70 if (data
->id
!= max34446
)
72 ret
= pmbus_read_word_data(client
, page
,
73 MAX34446_MFR_POUT_AVG
);
75 case PMBUS_VIRT_READ_POUT_MAX
:
76 if (data
->id
!= max34446
)
78 ret
= pmbus_read_word_data(client
, page
,
79 MAX34446_MFR_POUT_PEAK
);
81 case PMBUS_VIRT_READ_TEMP_AVG
:
82 if (data
->id
!= max34446
&& data
->id
!= max34460
&&
85 ret
= pmbus_read_word_data(client
, page
,
86 MAX34446_MFR_TEMPERATURE_AVG
);
88 case PMBUS_VIRT_READ_TEMP_MAX
:
89 ret
= pmbus_read_word_data(client
, page
,
90 MAX34440_MFR_TEMPERATURE_PEAK
);
92 case PMBUS_VIRT_RESET_POUT_HISTORY
:
93 if (data
->id
!= max34446
)
97 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
98 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
99 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
109 static int max34440_write_word_data(struct i2c_client
*client
, int page
,
112 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
113 const struct max34440_data
*data
= to_max34440_data(info
);
117 case PMBUS_VIRT_RESET_POUT_HISTORY
:
118 ret
= pmbus_write_word_data(client
, page
,
119 MAX34446_MFR_POUT_PEAK
, 0);
122 ret
= pmbus_write_word_data(client
, page
,
123 MAX34446_MFR_POUT_AVG
, 0);
125 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
126 ret
= pmbus_write_word_data(client
, page
,
127 MAX34440_MFR_VOUT_MIN
, 0x7fff);
130 ret
= pmbus_write_word_data(client
, page
,
131 MAX34440_MFR_VOUT_PEAK
, 0);
133 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
134 ret
= pmbus_write_word_data(client
, page
,
135 MAX34440_MFR_IOUT_PEAK
, 0);
136 if (!ret
&& (data
->id
== max34446
|| data
->id
== max34451
))
137 ret
= pmbus_write_word_data(client
, page
,
138 MAX34446_MFR_IOUT_AVG
, 0);
141 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
142 ret
= pmbus_write_word_data(client
, page
,
143 MAX34440_MFR_TEMPERATURE_PEAK
,
145 if (!ret
&& data
->id
== max34446
)
146 ret
= pmbus_write_word_data(client
, page
,
147 MAX34446_MFR_TEMPERATURE_AVG
, 0);
156 static int max34440_read_byte_data(struct i2c_client
*client
, int page
, int reg
)
162 ret
= pmbus_set_page(client
, page
);
168 case PMBUS_STATUS_IOUT
:
169 mfg_status
= pmbus_read_word_data(client
, 0,
170 PMBUS_STATUS_MFR_SPECIFIC
);
173 if (mfg_status
& MAX34440_STATUS_OC_WARN
)
174 ret
|= PB_IOUT_OC_WARNING
;
175 if (mfg_status
& MAX34440_STATUS_OC_FAULT
)
176 ret
|= PB_IOUT_OC_FAULT
;
178 case PMBUS_STATUS_TEMPERATURE
:
179 mfg_status
= pmbus_read_word_data(client
, 0,
180 PMBUS_STATUS_MFR_SPECIFIC
);
183 if (mfg_status
& MAX34440_STATUS_OT_WARN
)
184 ret
|= PB_TEMP_OT_WARNING
;
185 if (mfg_status
& MAX34440_STATUS_OT_FAULT
)
186 ret
|= PB_TEMP_OT_FAULT
;
195 static int max34451_set_supported_funcs(struct i2c_client
*client
,
196 struct max34440_data
*data
)
199 * Each of the channel 0-15 can be configured to monitor the following
200 * functions based on MFR_CHANNEL_CONFIG[5:0]
201 * 0x10: Sequencing + voltage monitoring (only valid for PAGES 0–11)
202 * 0x20: Voltage monitoring (no sequencing)
203 * 0x21: Voltage read only
204 * 0x22: Current monitoring
205 * 0x23: Current read only
206 * 0x30: General-purpose input active low
207 * 0x34: General-purpose input active high
213 for (page
= 0; page
< 16; page
++) {
214 rv
= i2c_smbus_write_byte_data(client
, PMBUS_PAGE
, page
);
218 rv
= i2c_smbus_read_word_data(client
,
219 MAX34451_MFR_CHANNEL_CONFIG
);
223 switch (rv
& MAX34451_MFR_CHANNEL_CONFIG_SEL_MASK
) {
226 data
->info
.func
[page
] = PMBUS_HAVE_VOUT
|
227 PMBUS_HAVE_STATUS_VOUT
;
230 data
->info
.func
[page
] = PMBUS_HAVE_VOUT
;
233 data
->info
.func
[page
] = PMBUS_HAVE_IOUT
|
234 PMBUS_HAVE_STATUS_IOUT
;
237 data
->info
.func
[page
] = PMBUS_HAVE_IOUT
;
247 static struct pmbus_driver_info max34440_info
[] = {
250 .format
[PSC_VOLTAGE_IN
] = direct
,
251 .format
[PSC_VOLTAGE_OUT
] = direct
,
252 .format
[PSC_TEMPERATURE
] = direct
,
253 .format
[PSC_CURRENT_OUT
] = direct
,
254 .m
[PSC_VOLTAGE_IN
] = 1,
255 .b
[PSC_VOLTAGE_IN
] = 0,
256 .R
[PSC_VOLTAGE_IN
] = 3, /* R = 0 in datasheet reflects mV */
257 .m
[PSC_VOLTAGE_OUT
] = 1,
258 .b
[PSC_VOLTAGE_OUT
] = 0,
259 .R
[PSC_VOLTAGE_OUT
] = 3, /* R = 0 in datasheet reflects mV */
260 .m
[PSC_CURRENT_OUT
] = 1,
261 .b
[PSC_CURRENT_OUT
] = 0,
262 .R
[PSC_CURRENT_OUT
] = 3, /* R = 0 in datasheet reflects mA */
263 .m
[PSC_TEMPERATURE
] = 1,
264 .b
[PSC_TEMPERATURE
] = 0,
265 .R
[PSC_TEMPERATURE
] = 2,
266 .func
[0] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
267 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
268 .func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
269 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
270 .func
[2] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
271 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
272 .func
[3] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
273 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
274 .func
[4] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
275 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
276 .func
[5] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
277 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
278 .func
[6] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
279 .func
[7] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
280 .func
[8] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
281 .func
[9] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
282 .func
[10] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
283 .func
[11] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
284 .func
[12] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
285 .func
[13] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
286 .read_byte_data
= max34440_read_byte_data
,
287 .read_word_data
= max34440_read_word_data
,
288 .write_word_data
= max34440_write_word_data
,
292 .format
[PSC_VOLTAGE_IN
] = direct
,
293 .format
[PSC_VOLTAGE_OUT
] = direct
,
294 .format
[PSC_TEMPERATURE
] = direct
,
295 .format
[PSC_CURRENT_OUT
] = direct
,
296 .format
[PSC_FAN
] = direct
,
297 .m
[PSC_VOLTAGE_IN
] = 1,
298 .b
[PSC_VOLTAGE_IN
] = 0,
299 .R
[PSC_VOLTAGE_IN
] = 3,
300 .m
[PSC_VOLTAGE_OUT
] = 1,
301 .b
[PSC_VOLTAGE_OUT
] = 0,
302 .R
[PSC_VOLTAGE_OUT
] = 3,
303 .m
[PSC_CURRENT_OUT
] = 1,
304 .b
[PSC_CURRENT_OUT
] = 0,
305 .R
[PSC_CURRENT_OUT
] = 3,
306 .m
[PSC_TEMPERATURE
] = 1,
307 .b
[PSC_TEMPERATURE
] = 0,
308 .R
[PSC_TEMPERATURE
] = 2,
312 .func
[0] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
313 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
314 .func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
315 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
316 .func
[2] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
317 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
318 .func
[3] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
319 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
320 .func
[4] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
321 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
322 .func
[5] = PMBUS_HAVE_FAN12
| PMBUS_HAVE_STATUS_FAN12
,
323 .func
[6] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
324 .func
[7] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
325 .func
[8] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
326 .func
[9] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
327 .func
[10] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
328 .func
[11] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
329 .read_byte_data
= max34440_read_byte_data
,
330 .read_word_data
= max34440_read_word_data
,
331 .write_word_data
= max34440_write_word_data
,
335 .format
[PSC_VOLTAGE_IN
] = direct
,
336 .format
[PSC_VOLTAGE_OUT
] = direct
,
337 .format
[PSC_TEMPERATURE
] = direct
,
338 .format
[PSC_CURRENT_OUT
] = direct
,
339 .format
[PSC_POWER
] = direct
,
340 .m
[PSC_VOLTAGE_IN
] = 1,
341 .b
[PSC_VOLTAGE_IN
] = 0,
342 .R
[PSC_VOLTAGE_IN
] = 3,
343 .m
[PSC_VOLTAGE_OUT
] = 1,
344 .b
[PSC_VOLTAGE_OUT
] = 0,
345 .R
[PSC_VOLTAGE_OUT
] = 3,
346 .m
[PSC_CURRENT_OUT
] = 1,
347 .b
[PSC_CURRENT_OUT
] = 0,
348 .R
[PSC_CURRENT_OUT
] = 3,
352 .m
[PSC_TEMPERATURE
] = 1,
353 .b
[PSC_TEMPERATURE
] = 0,
354 .R
[PSC_TEMPERATURE
] = 2,
355 .func
[0] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
356 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
| PMBUS_HAVE_POUT
,
357 .func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
358 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
359 .func
[2] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
360 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
| PMBUS_HAVE_POUT
,
361 .func
[3] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
362 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
,
363 .func
[4] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
364 .func
[5] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
365 .func
[6] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
366 .read_byte_data
= max34440_read_byte_data
,
367 .read_word_data
= max34440_read_word_data
,
368 .write_word_data
= max34440_write_word_data
,
372 .format
[PSC_VOLTAGE_OUT
] = direct
,
373 .format
[PSC_TEMPERATURE
] = direct
,
374 .format
[PSC_CURRENT_OUT
] = direct
,
375 .m
[PSC_VOLTAGE_OUT
] = 1,
376 .b
[PSC_VOLTAGE_OUT
] = 0,
377 .R
[PSC_VOLTAGE_OUT
] = 3,
378 .m
[PSC_CURRENT_OUT
] = 1,
379 .b
[PSC_CURRENT_OUT
] = 0,
380 .R
[PSC_CURRENT_OUT
] = 2,
381 .m
[PSC_TEMPERATURE
] = 1,
382 .b
[PSC_TEMPERATURE
] = 0,
383 .R
[PSC_TEMPERATURE
] = 2,
384 /* func 0-15 is set dynamically before probing */
385 .func
[16] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
386 .func
[17] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
387 .func
[18] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
388 .func
[19] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
389 .func
[20] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
390 .read_byte_data
= max34440_read_byte_data
,
391 .read_word_data
= max34440_read_word_data
,
392 .write_word_data
= max34440_write_word_data
,
396 .format
[PSC_VOLTAGE_OUT
] = direct
,
397 .format
[PSC_TEMPERATURE
] = direct
,
398 .m
[PSC_VOLTAGE_OUT
] = 1,
399 .b
[PSC_VOLTAGE_OUT
] = 0,
400 .R
[PSC_VOLTAGE_OUT
] = 3,
401 .m
[PSC_TEMPERATURE
] = 1,
402 .b
[PSC_TEMPERATURE
] = 0,
403 .R
[PSC_TEMPERATURE
] = 2,
404 .func
[0] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
405 .func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
406 .func
[2] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
407 .func
[3] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
408 .func
[4] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
409 .func
[5] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
410 .func
[6] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
411 .func
[7] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
412 .func
[8] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
413 .func
[9] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
414 .func
[10] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
415 .func
[11] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
416 .func
[13] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
417 .func
[14] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
418 .func
[15] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
419 .func
[16] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
420 .func
[17] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
421 .read_byte_data
= max34440_read_byte_data
,
422 .read_word_data
= max34440_read_word_data
,
423 .write_word_data
= max34440_write_word_data
,
427 .format
[PSC_VOLTAGE_OUT
] = direct
,
428 .format
[PSC_TEMPERATURE
] = direct
,
429 .m
[PSC_VOLTAGE_OUT
] = 1,
430 .b
[PSC_VOLTAGE_OUT
] = 0,
431 .R
[PSC_VOLTAGE_OUT
] = 3,
432 .m
[PSC_TEMPERATURE
] = 1,
433 .b
[PSC_TEMPERATURE
] = 0,
434 .R
[PSC_TEMPERATURE
] = 2,
435 .func
[0] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
436 .func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
437 .func
[2] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
438 .func
[3] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
439 .func
[4] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
440 .func
[5] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
441 .func
[6] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
442 .func
[7] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
443 .func
[8] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
444 .func
[9] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
445 .func
[10] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
446 .func
[11] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
447 .func
[12] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
448 .func
[13] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
449 .func
[14] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
450 .func
[15] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
451 /* page 16 is reserved */
452 .func
[17] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
453 .func
[18] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
454 .func
[19] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
455 .func
[20] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
456 .func
[21] = PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
457 .read_byte_data
= max34440_read_byte_data
,
458 .read_word_data
= max34440_read_word_data
,
459 .write_word_data
= max34440_write_word_data
,
463 static int max34440_probe(struct i2c_client
*client
,
464 const struct i2c_device_id
*id
)
466 struct max34440_data
*data
;
469 data
= devm_kzalloc(&client
->dev
, sizeof(struct max34440_data
),
473 data
->id
= id
->driver_data
;
474 data
->info
= max34440_info
[id
->driver_data
];
476 if (data
->id
== max34451
) {
477 rv
= max34451_set_supported_funcs(client
, data
);
482 return pmbus_do_probe(client
, id
, &data
->info
);
485 static const struct i2c_device_id max34440_id
[] = {
486 {"max34440", max34440
},
487 {"max34441", max34441
},
488 {"max34446", max34446
},
489 {"max34451", max34451
},
490 {"max34460", max34460
},
491 {"max34461", max34461
},
494 MODULE_DEVICE_TABLE(i2c
, max34440_id
);
496 /* This is the driver that will be inserted */
497 static struct i2c_driver max34440_driver
= {
501 .probe
= max34440_probe
,
502 .remove
= pmbus_do_remove
,
503 .id_table
= max34440_id
,
506 module_i2c_driver(max34440_driver
);
508 MODULE_AUTHOR("Guenter Roeck");
509 MODULE_DESCRIPTION("PMBus driver for Maxim MAX34440/MAX34441");
510 MODULE_LICENSE("GPL");