1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Hardware monitoring driver for LTC2978 and compatible chips.
5 * Copyright (c) 2011 Ericsson AB.
6 * Copyright (c) 2013, 2014, 2015 Guenter Roeck
7 * Copyright (c) 2015 Linear Technology
8 * Copyright (c) 2018 Analog Devices Inc.
11 #include <linux/delay.h>
12 #include <linux/jiffies.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/err.h>
17 #include <linux/slab.h>
18 #include <linux/i2c.h>
19 #include <linux/regulator/driver.h>
22 enum chips
{ ltc2974
, ltc2975
, ltc2977
, ltc2978
, ltc2980
, ltc3880
, ltc3882
,
23 ltc3883
, ltc3886
, ltc3887
, ltm2987
, ltm4675
, ltm4676
, ltm4686
};
25 /* Common for all chips */
26 #define LTC2978_MFR_VOUT_PEAK 0xdd
27 #define LTC2978_MFR_VIN_PEAK 0xde
28 #define LTC2978_MFR_TEMPERATURE_PEAK 0xdf
29 #define LTC2978_MFR_SPECIAL_ID 0xe7 /* Undocumented on LTC3882 */
30 #define LTC2978_MFR_COMMON 0xef
32 /* LTC2974, LTC2975, LCT2977, LTC2980, LTC2978, and LTM2987 */
33 #define LTC2978_MFR_VOUT_MIN 0xfb
34 #define LTC2978_MFR_VIN_MIN 0xfc
35 #define LTC2978_MFR_TEMPERATURE_MIN 0xfd
37 /* LTC2974, LTC2975 */
38 #define LTC2974_MFR_IOUT_PEAK 0xd7
39 #define LTC2974_MFR_IOUT_MIN 0xd8
41 /* LTC3880, LTC3882, LTC3883, LTC3887, LTM4675, and LTM4676 */
42 #define LTC3880_MFR_IOUT_PEAK 0xd7
43 #define LTC3880_MFR_CLEAR_PEAKS 0xe3
44 #define LTC3880_MFR_TEMPERATURE2_PEAK 0xf4
46 /* LTC3883 and LTC3886 only */
47 #define LTC3883_MFR_IIN_PEAK 0xe1
50 #define LTC2975_MFR_IIN_PEAK 0xc4
51 #define LTC2975_MFR_IIN_MIN 0xc5
52 #define LTC2975_MFR_PIN_PEAK 0xc6
53 #define LTC2975_MFR_PIN_MIN 0xc7
55 #define LTC2978_ID_MASK 0xfff0
57 #define LTC2974_ID 0x0210
58 #define LTC2975_ID 0x0220
59 #define LTC2977_ID 0x0130
60 #define LTC2978_ID_REV1 0x0110 /* Early revision */
61 #define LTC2978_ID_REV2 0x0120
62 #define LTC2980_ID_A 0x8030 /* A/B for two die IDs */
63 #define LTC2980_ID_B 0x8040
64 #define LTC3880_ID 0x4020
65 #define LTC3882_ID 0x4200
66 #define LTC3882_ID_D1 0x4240 /* Dash 1 */
67 #define LTC3883_ID 0x4300
68 #define LTC3886_ID 0x4600
69 #define LTC3887_ID 0x4700
70 #define LTM2987_ID_A 0x8010 /* A/B for two die IDs */
71 #define LTM2987_ID_B 0x8020
72 #define LTM4675_ID 0x47a0
73 #define LTM4676_ID_REV1 0x4400
74 #define LTM4676_ID_REV2 0x4480
75 #define LTM4676A_ID 0x47e0
76 #define LTM4686_ID 0x4770
78 #define LTC2974_NUM_PAGES 4
79 #define LTC2978_NUM_PAGES 8
80 #define LTC3880_NUM_PAGES 2
81 #define LTC3883_NUM_PAGES 1
83 #define LTC_POLL_TIMEOUT 100 /* in milli-seconds */
85 #define LTC_NOT_BUSY BIT(5)
86 #define LTC_NOT_PENDING BIT(4)
89 * LTC2978 clears peak data whenever the CLEAR_FAULTS command is executed, which
90 * happens pretty much each time chip data is updated. Raw peak data therefore
91 * does not provide much value. To be able to provide useful peak data, keep an
92 * internal cache of measured peak data, which is only cleared if an explicit
93 * "clear peak" command is executed for the sensor in question.
99 u16 temp_min
[LTC2974_NUM_PAGES
], temp_max
[LTC2974_NUM_PAGES
];
100 u16 vout_min
[LTC2978_NUM_PAGES
], vout_max
[LTC2978_NUM_PAGES
];
101 u16 iout_min
[LTC2974_NUM_PAGES
], iout_max
[LTC2974_NUM_PAGES
];
102 u16 iin_min
, iin_max
;
103 u16 pin_min
, pin_max
;
105 struct pmbus_driver_info info
;
108 #define to_ltc2978_data(x) container_of(x, struct ltc2978_data, info)
110 #define FEAT_CLEAR_PEAKS BIT(0)
111 #define FEAT_NEEDS_POLLING BIT(1)
113 #define has_clear_peaks(d) ((d)->features & FEAT_CLEAR_PEAKS)
114 #define needs_polling(d) ((d)->features & FEAT_NEEDS_POLLING)
116 static int ltc_wait_ready(struct i2c_client
*client
)
118 unsigned long timeout
= jiffies
+ msecs_to_jiffies(LTC_POLL_TIMEOUT
);
119 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
120 struct ltc2978_data
*data
= to_ltc2978_data(info
);
124 if (!needs_polling(data
))
128 * LTC3883 does not support LTC_NOT_PENDING, even though
129 * the datasheet claims that it does.
132 if (data
->id
!= ltc3883
)
133 mask
|= LTC_NOT_PENDING
;
136 status
= pmbus_read_byte_data(client
, 0, LTC2978_MFR_COMMON
);
137 if (status
== -EBADMSG
|| status
== -ENXIO
) {
138 /* PEC error or NACK: chip may be busy, try again */
139 usleep_range(50, 100);
145 if ((status
& mask
) == mask
)
148 usleep_range(50, 100);
149 } while (time_before(jiffies
, timeout
));
154 static int ltc_read_word_data(struct i2c_client
*client
, int page
, int reg
)
158 ret
= ltc_wait_ready(client
);
162 return pmbus_read_word_data(client
, page
, reg
);
165 static int ltc_read_byte_data(struct i2c_client
*client
, int page
, int reg
)
169 ret
= ltc_wait_ready(client
);
173 return pmbus_read_byte_data(client
, page
, reg
);
176 static int ltc_write_byte(struct i2c_client
*client
, int page
, u8 byte
)
180 ret
= ltc_wait_ready(client
);
184 return pmbus_write_byte(client
, page
, byte
);
187 static inline int lin11_to_val(int data
)
189 s16 e
= ((s16
)data
) >> 11;
190 s32 m
= (((s16
)(data
<< 5)) >> 5);
193 * mantissa is 10 bit + sign, exponent adds up to 15 bit.
194 * Add 6 bit to exponent for maximum accuracy (10 + 15 + 6 = 31).
197 return (e
< 0 ? m
>> -e
: m
<< e
);
200 static int ltc_get_max(struct ltc2978_data
*data
, struct i2c_client
*client
,
201 int page
, int reg
, u16
*pmax
)
205 ret
= ltc_read_word_data(client
, page
, reg
);
207 if (lin11_to_val(ret
) > lin11_to_val(*pmax
))
214 static int ltc_get_min(struct ltc2978_data
*data
, struct i2c_client
*client
,
215 int page
, int reg
, u16
*pmin
)
219 ret
= ltc_read_word_data(client
, page
, reg
);
221 if (lin11_to_val(ret
) < lin11_to_val(*pmin
))
228 static int ltc2978_read_word_data_common(struct i2c_client
*client
, int page
,
231 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
232 struct ltc2978_data
*data
= to_ltc2978_data(info
);
236 case PMBUS_VIRT_READ_VIN_MAX
:
237 ret
= ltc_get_max(data
, client
, page
, LTC2978_MFR_VIN_PEAK
,
240 case PMBUS_VIRT_READ_VOUT_MAX
:
241 ret
= ltc_read_word_data(client
, page
, LTC2978_MFR_VOUT_PEAK
);
244 * VOUT is 16 bit unsigned with fixed exponent,
245 * so we can compare it directly
247 if (ret
> data
->vout_max
[page
])
248 data
->vout_max
[page
] = ret
;
249 ret
= data
->vout_max
[page
];
252 case PMBUS_VIRT_READ_TEMP_MAX
:
253 ret
= ltc_get_max(data
, client
, page
,
254 LTC2978_MFR_TEMPERATURE_PEAK
,
255 &data
->temp_max
[page
]);
257 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
258 case PMBUS_VIRT_RESET_VIN_HISTORY
:
259 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
263 ret
= ltc_wait_ready(client
);
272 static int ltc2978_read_word_data(struct i2c_client
*client
, int page
, int reg
)
274 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
275 struct ltc2978_data
*data
= to_ltc2978_data(info
);
279 case PMBUS_VIRT_READ_VIN_MIN
:
280 ret
= ltc_get_min(data
, client
, page
, LTC2978_MFR_VIN_MIN
,
283 case PMBUS_VIRT_READ_VOUT_MIN
:
284 ret
= ltc_read_word_data(client
, page
, LTC2978_MFR_VOUT_MIN
);
287 * VOUT_MIN is known to not be supported on some lots
288 * of LTC2978 revision 1, and will return the maximum
289 * possible voltage if read. If VOUT_MAX is valid and
290 * lower than the reading of VOUT_MIN, use it instead.
292 if (data
->vout_max
[page
] && ret
> data
->vout_max
[page
])
293 ret
= data
->vout_max
[page
];
294 if (ret
< data
->vout_min
[page
])
295 data
->vout_min
[page
] = ret
;
296 ret
= data
->vout_min
[page
];
299 case PMBUS_VIRT_READ_TEMP_MIN
:
300 ret
= ltc_get_min(data
, client
, page
,
301 LTC2978_MFR_TEMPERATURE_MIN
,
302 &data
->temp_min
[page
]);
304 case PMBUS_VIRT_READ_IOUT_MAX
:
305 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
306 case PMBUS_VIRT_READ_TEMP2_MAX
:
307 case PMBUS_VIRT_RESET_TEMP2_HISTORY
:
311 ret
= ltc2978_read_word_data_common(client
, page
, reg
);
317 static int ltc2974_read_word_data(struct i2c_client
*client
, int page
, int reg
)
319 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
320 struct ltc2978_data
*data
= to_ltc2978_data(info
);
324 case PMBUS_VIRT_READ_IOUT_MAX
:
325 ret
= ltc_get_max(data
, client
, page
, LTC2974_MFR_IOUT_PEAK
,
326 &data
->iout_max
[page
]);
328 case PMBUS_VIRT_READ_IOUT_MIN
:
329 ret
= ltc_get_min(data
, client
, page
, LTC2974_MFR_IOUT_MIN
,
330 &data
->iout_min
[page
]);
332 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
336 ret
= ltc2978_read_word_data(client
, page
, reg
);
342 static int ltc2975_read_word_data(struct i2c_client
*client
, int page
, int reg
)
344 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
345 struct ltc2978_data
*data
= to_ltc2978_data(info
);
349 case PMBUS_VIRT_READ_IIN_MAX
:
350 ret
= ltc_get_max(data
, client
, page
, LTC2975_MFR_IIN_PEAK
,
353 case PMBUS_VIRT_READ_IIN_MIN
:
354 ret
= ltc_get_min(data
, client
, page
, LTC2975_MFR_IIN_MIN
,
357 case PMBUS_VIRT_READ_PIN_MAX
:
358 ret
= ltc_get_max(data
, client
, page
, LTC2975_MFR_PIN_PEAK
,
361 case PMBUS_VIRT_READ_PIN_MIN
:
362 ret
= ltc_get_min(data
, client
, page
, LTC2975_MFR_PIN_MIN
,
365 case PMBUS_VIRT_RESET_IIN_HISTORY
:
366 case PMBUS_VIRT_RESET_PIN_HISTORY
:
370 ret
= ltc2978_read_word_data(client
, page
, reg
);
376 static int ltc3880_read_word_data(struct i2c_client
*client
, int page
, int reg
)
378 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
379 struct ltc2978_data
*data
= to_ltc2978_data(info
);
383 case PMBUS_VIRT_READ_IOUT_MAX
:
384 ret
= ltc_get_max(data
, client
, page
, LTC3880_MFR_IOUT_PEAK
,
385 &data
->iout_max
[page
]);
387 case PMBUS_VIRT_READ_TEMP2_MAX
:
388 ret
= ltc_get_max(data
, client
, page
,
389 LTC3880_MFR_TEMPERATURE2_PEAK
,
392 case PMBUS_VIRT_READ_VIN_MIN
:
393 case PMBUS_VIRT_READ_VOUT_MIN
:
394 case PMBUS_VIRT_READ_TEMP_MIN
:
397 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
398 case PMBUS_VIRT_RESET_TEMP2_HISTORY
:
402 ret
= ltc2978_read_word_data_common(client
, page
, reg
);
408 static int ltc3883_read_word_data(struct i2c_client
*client
, int page
, int reg
)
410 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
411 struct ltc2978_data
*data
= to_ltc2978_data(info
);
415 case PMBUS_VIRT_READ_IIN_MAX
:
416 ret
= ltc_get_max(data
, client
, page
, LTC3883_MFR_IIN_PEAK
,
419 case PMBUS_VIRT_RESET_IIN_HISTORY
:
423 ret
= ltc3880_read_word_data(client
, page
, reg
);
429 static int ltc2978_clear_peaks(struct ltc2978_data
*data
,
430 struct i2c_client
*client
, int page
)
434 if (has_clear_peaks(data
))
435 ret
= ltc_write_byte(client
, 0, LTC3880_MFR_CLEAR_PEAKS
);
437 ret
= ltc_write_byte(client
, page
, PMBUS_CLEAR_FAULTS
);
442 static int ltc2978_write_word_data(struct i2c_client
*client
, int page
,
445 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
446 struct ltc2978_data
*data
= to_ltc2978_data(info
);
450 case PMBUS_VIRT_RESET_IIN_HISTORY
:
451 data
->iin_max
= 0x7c00;
452 data
->iin_min
= 0x7bff;
453 ret
= ltc2978_clear_peaks(data
, client
, 0);
455 case PMBUS_VIRT_RESET_PIN_HISTORY
:
456 data
->pin_max
= 0x7c00;
457 data
->pin_min
= 0x7bff;
458 ret
= ltc2978_clear_peaks(data
, client
, 0);
460 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
461 data
->iout_max
[page
] = 0x7c00;
462 data
->iout_min
[page
] = 0xfbff;
463 ret
= ltc2978_clear_peaks(data
, client
, page
);
465 case PMBUS_VIRT_RESET_TEMP2_HISTORY
:
466 data
->temp2_max
= 0x7c00;
467 ret
= ltc2978_clear_peaks(data
, client
, page
);
469 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
470 data
->vout_min
[page
] = 0xffff;
471 data
->vout_max
[page
] = 0;
472 ret
= ltc2978_clear_peaks(data
, client
, page
);
474 case PMBUS_VIRT_RESET_VIN_HISTORY
:
475 data
->vin_min
= 0x7bff;
476 data
->vin_max
= 0x7c00;
477 ret
= ltc2978_clear_peaks(data
, client
, page
);
479 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
480 data
->temp_min
[page
] = 0x7bff;
481 data
->temp_max
[page
] = 0x7c00;
482 ret
= ltc2978_clear_peaks(data
, client
, page
);
485 ret
= ltc_wait_ready(client
);
494 static const struct i2c_device_id ltc2978_id
[] = {
495 {"ltc2974", ltc2974
},
496 {"ltc2975", ltc2975
},
497 {"ltc2977", ltc2977
},
498 {"ltc2978", ltc2978
},
499 {"ltc2980", ltc2980
},
500 {"ltc3880", ltc3880
},
501 {"ltc3882", ltc3882
},
502 {"ltc3883", ltc3883
},
503 {"ltc3886", ltc3886
},
504 {"ltc3887", ltc3887
},
505 {"ltm2987", ltm2987
},
506 {"ltm4675", ltm4675
},
507 {"ltm4676", ltm4676
},
508 {"ltm4686", ltm4686
},
511 MODULE_DEVICE_TABLE(i2c
, ltc2978_id
);
513 #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
514 static const struct regulator_desc ltc2978_reg_desc
[] = {
515 PMBUS_REGULATOR("vout", 0),
516 PMBUS_REGULATOR("vout", 1),
517 PMBUS_REGULATOR("vout", 2),
518 PMBUS_REGULATOR("vout", 3),
519 PMBUS_REGULATOR("vout", 4),
520 PMBUS_REGULATOR("vout", 5),
521 PMBUS_REGULATOR("vout", 6),
522 PMBUS_REGULATOR("vout", 7),
524 #endif /* CONFIG_SENSORS_LTC2978_REGULATOR */
526 static int ltc2978_get_id(struct i2c_client
*client
)
530 chip_id
= i2c_smbus_read_word_data(client
, LTC2978_MFR_SPECIAL_ID
);
532 const struct i2c_device_id
*id
;
533 u8 buf
[I2C_SMBUS_BLOCK_MAX
];
536 if (!i2c_check_functionality(client
->adapter
,
537 I2C_FUNC_SMBUS_READ_BLOCK_DATA
))
540 ret
= i2c_smbus_read_block_data(client
, PMBUS_MFR_ID
, buf
);
543 if (ret
< 3 || strncmp(buf
, "LTC", 3))
546 ret
= i2c_smbus_read_block_data(client
, PMBUS_MFR_MODEL
, buf
);
549 for (id
= <c2978_id
[0]; strlen(id
->name
); id
++) {
550 if (!strncasecmp(id
->name
, buf
, strlen(id
->name
)))
551 return (int)id
->driver_data
;
556 chip_id
&= LTC2978_ID_MASK
;
558 if (chip_id
== LTC2974_ID
)
560 else if (chip_id
== LTC2975_ID
)
562 else if (chip_id
== LTC2977_ID
)
564 else if (chip_id
== LTC2978_ID_REV1
|| chip_id
== LTC2978_ID_REV2
)
566 else if (chip_id
== LTC2980_ID_A
|| chip_id
== LTC2980_ID_B
)
568 else if (chip_id
== LTC3880_ID
)
570 else if (chip_id
== LTC3882_ID
|| chip_id
== LTC3882_ID_D1
)
572 else if (chip_id
== LTC3883_ID
)
574 else if (chip_id
== LTC3886_ID
)
576 else if (chip_id
== LTC3887_ID
)
578 else if (chip_id
== LTM2987_ID_A
|| chip_id
== LTM2987_ID_B
)
580 else if (chip_id
== LTM4675_ID
)
582 else if (chip_id
== LTM4676_ID_REV1
|| chip_id
== LTM4676_ID_REV2
||
583 chip_id
== LTM4676A_ID
)
585 else if (chip_id
== LTM4686_ID
)
588 dev_err(&client
->dev
, "Unsupported chip ID 0x%x\n", chip_id
);
592 static int ltc2978_probe(struct i2c_client
*client
,
593 const struct i2c_device_id
*id
)
596 struct ltc2978_data
*data
;
597 struct pmbus_driver_info
*info
;
599 if (!i2c_check_functionality(client
->adapter
,
600 I2C_FUNC_SMBUS_READ_WORD_DATA
))
603 data
= devm_kzalloc(&client
->dev
, sizeof(struct ltc2978_data
),
608 chip_id
= ltc2978_get_id(client
);
613 if (data
->id
!= id
->driver_data
)
614 dev_warn(&client
->dev
,
615 "Device mismatch: Configured %s, detected %s\n",
617 ltc2978_id
[data
->id
].name
);
620 info
->write_word_data
= ltc2978_write_word_data
;
621 info
->write_byte
= ltc_write_byte
;
622 info
->read_word_data
= ltc_read_word_data
;
623 info
->read_byte_data
= ltc_read_byte_data
;
625 data
->vin_min
= 0x7bff;
626 data
->vin_max
= 0x7c00;
627 for (i
= 0; i
< ARRAY_SIZE(data
->vout_min
); i
++)
628 data
->vout_min
[i
] = 0xffff;
629 for (i
= 0; i
< ARRAY_SIZE(data
->iout_min
); i
++)
630 data
->iout_min
[i
] = 0xfbff;
631 for (i
= 0; i
< ARRAY_SIZE(data
->iout_max
); i
++)
632 data
->iout_max
[i
] = 0x7c00;
633 for (i
= 0; i
< ARRAY_SIZE(data
->temp_min
); i
++)
634 data
->temp_min
[i
] = 0x7bff;
635 for (i
= 0; i
< ARRAY_SIZE(data
->temp_max
); i
++)
636 data
->temp_max
[i
] = 0x7c00;
637 data
->temp2_max
= 0x7c00;
641 info
->read_word_data
= ltc2974_read_word_data
;
642 info
->pages
= LTC2974_NUM_PAGES
;
643 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
645 for (i
= 0; i
< info
->pages
; i
++) {
646 info
->func
[i
] |= PMBUS_HAVE_VOUT
647 | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_POUT
648 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
649 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
;
653 info
->read_word_data
= ltc2975_read_word_data
;
654 info
->pages
= LTC2974_NUM_PAGES
;
655 info
->func
[0] = PMBUS_HAVE_IIN
| PMBUS_HAVE_PIN
656 | PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
658 for (i
= 0; i
< info
->pages
; i
++) {
659 info
->func
[i
] |= PMBUS_HAVE_VOUT
660 | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_POUT
661 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
662 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
;
669 info
->read_word_data
= ltc2978_read_word_data
;
670 info
->pages
= LTC2978_NUM_PAGES
;
671 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
672 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
673 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
674 for (i
= 1; i
< LTC2978_NUM_PAGES
; i
++) {
675 info
->func
[i
] = PMBUS_HAVE_VOUT
676 | PMBUS_HAVE_STATUS_VOUT
;
684 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
685 info
->read_word_data
= ltc3880_read_word_data
;
686 info
->pages
= LTC3880_NUM_PAGES
;
687 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_IIN
688 | PMBUS_HAVE_STATUS_INPUT
689 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
690 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
691 | PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
692 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
693 info
->func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
694 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
696 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
699 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
700 info
->read_word_data
= ltc3880_read_word_data
;
701 info
->pages
= LTC3880_NUM_PAGES
;
702 info
->func
[0] = PMBUS_HAVE_VIN
703 | PMBUS_HAVE_STATUS_INPUT
704 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
705 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
706 | PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
707 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
708 info
->func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
709 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
711 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
714 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
715 info
->read_word_data
= ltc3883_read_word_data
;
716 info
->pages
= LTC3883_NUM_PAGES
;
717 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_IIN
718 | PMBUS_HAVE_STATUS_INPUT
719 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
720 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
721 | PMBUS_HAVE_PIN
| PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
722 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
725 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
726 info
->read_word_data
= ltc3883_read_word_data
;
727 info
->pages
= LTC3880_NUM_PAGES
;
728 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_IIN
729 | PMBUS_HAVE_STATUS_INPUT
730 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
731 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
732 | PMBUS_HAVE_PIN
| PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
733 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
734 info
->func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
735 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
737 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
743 #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
744 info
->num_regulators
= info
->pages
;
745 info
->reg_desc
= ltc2978_reg_desc
;
746 if (info
->num_regulators
> ARRAY_SIZE(ltc2978_reg_desc
)) {
747 dev_err(&client
->dev
, "num_regulators too large!");
748 info
->num_regulators
= ARRAY_SIZE(ltc2978_reg_desc
);
752 return pmbus_do_probe(client
, id
, info
);
756 static const struct of_device_id ltc2978_of_match
[] = {
757 { .compatible
= "lltc,ltc2974" },
758 { .compatible
= "lltc,ltc2975" },
759 { .compatible
= "lltc,ltc2977" },
760 { .compatible
= "lltc,ltc2978" },
761 { .compatible
= "lltc,ltc2980" },
762 { .compatible
= "lltc,ltc3880" },
763 { .compatible
= "lltc,ltc3882" },
764 { .compatible
= "lltc,ltc3883" },
765 { .compatible
= "lltc,ltc3886" },
766 { .compatible
= "lltc,ltc3887" },
767 { .compatible
= "lltc,ltm2987" },
768 { .compatible
= "lltc,ltm4675" },
769 { .compatible
= "lltc,ltm4676" },
770 { .compatible
= "lltc,ltm4686" },
773 MODULE_DEVICE_TABLE(of
, ltc2978_of_match
);
776 static struct i2c_driver ltc2978_driver
= {
779 .of_match_table
= of_match_ptr(ltc2978_of_match
),
781 .probe
= ltc2978_probe
,
782 .remove
= pmbus_do_remove
,
783 .id_table
= ltc2978_id
,
786 module_i2c_driver(ltc2978_driver
);
788 MODULE_AUTHOR("Guenter Roeck");
789 MODULE_DESCRIPTION("PMBus driver for LTC2978 and compatible chips");
790 MODULE_LICENSE("GPL");