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>
24 ltc2972
, ltc2974
, ltc2975
, ltc2977
, ltc2978
, ltc2979
, ltc2980
,
26 ltc3880
, ltc3882
, ltc3883
, ltc3884
, ltc3886
, ltc3887
, ltc3889
, ltc7880
,
28 ltm2987
, ltm4664
, ltm4675
, ltm4676
, ltm4677
, ltm4678
, ltm4680
, ltm4686
,
32 /* Common for all chips */
33 #define LTC2978_MFR_VOUT_PEAK 0xdd
34 #define LTC2978_MFR_VIN_PEAK 0xde
35 #define LTC2978_MFR_TEMPERATURE_PEAK 0xdf
36 #define LTC2978_MFR_SPECIAL_ID 0xe7 /* Undocumented on LTC3882 */
37 #define LTC2978_MFR_COMMON 0xef
39 /* LTC2974, LTC2975, LCT2977, LTC2980, LTC2978, and LTM2987 */
40 #define LTC2978_MFR_VOUT_MIN 0xfb
41 #define LTC2978_MFR_VIN_MIN 0xfc
42 #define LTC2978_MFR_TEMPERATURE_MIN 0xfd
44 /* LTC2974, LTC2975 */
45 #define LTC2974_MFR_IOUT_PEAK 0xd7
46 #define LTC2974_MFR_IOUT_MIN 0xd8
48 /* LTC3880, LTC3882, LTC3883, LTC3887, LTM4675, and LTM4676 */
49 #define LTC3880_MFR_IOUT_PEAK 0xd7
50 #define LTC3880_MFR_CLEAR_PEAKS 0xe3
51 #define LTC3880_MFR_TEMPERATURE2_PEAK 0xf4
53 /* LTC3883, LTC3884, LTC3886, LTC3889 and LTC7880 only */
54 #define LTC3883_MFR_IIN_PEAK 0xe1
58 #define LTC2975_MFR_IIN_PEAK 0xc4
59 #define LTC2975_MFR_IIN_MIN 0xc5
60 #define LTC2975_MFR_PIN_PEAK 0xc6
61 #define LTC2975_MFR_PIN_MIN 0xc7
63 #define LTC2978_ID_MASK 0xfff0
65 #define LTC2972_ID 0x0310
66 #define LTC2974_ID 0x0210
67 #define LTC2975_ID 0x0220
68 #define LTC2977_ID 0x0130
69 #define LTC2978_ID_REV1 0x0110 /* Early revision */
70 #define LTC2978_ID_REV2 0x0120
71 #define LTC2979_ID_A 0x8060
72 #define LTC2979_ID_B 0x8070
73 #define LTC2980_ID_A 0x8030 /* A/B for two die IDs */
74 #define LTC2980_ID_B 0x8040
75 #define LTC3880_ID 0x4020
76 #define LTC3882_ID 0x4200
77 #define LTC3882_ID_D1 0x4240 /* Dash 1 */
78 #define LTC3883_ID 0x4300
79 #define LTC3884_ID 0x4C00
80 #define LTC3886_ID 0x4600
81 #define LTC3887_ID 0x4700
82 #define LTM2987_ID_A 0x8010 /* A/B for two die IDs */
83 #define LTM2987_ID_B 0x8020
84 #define LTC3889_ID 0x4900
85 #define LTC7880_ID 0x49E0
86 #define LTM4664_ID 0x4120
87 #define LTM4675_ID 0x47a0
88 #define LTM4676_ID_REV1 0x4400
89 #define LTM4676_ID_REV2 0x4480
90 #define LTM4676A_ID 0x47e0
91 #define LTM4677_ID_REV1 0x47B0
92 #define LTM4677_ID_REV2 0x47D0
93 #define LTM4678_ID_REV1 0x4100
94 #define LTM4678_ID_REV2 0x4110
95 #define LTM4680_ID 0x4140
96 #define LTM4686_ID 0x4770
97 #define LTM4700_ID 0x4130
99 #define LTC2972_NUM_PAGES 2
100 #define LTC2974_NUM_PAGES 4
101 #define LTC2978_NUM_PAGES 8
102 #define LTC3880_NUM_PAGES 2
103 #define LTC3883_NUM_PAGES 1
105 #define LTC_POLL_TIMEOUT 100 /* in milli-seconds */
107 #define LTC_NOT_BUSY BIT(6)
108 #define LTC_NOT_PENDING BIT(5)
111 * LTC2978 clears peak data whenever the CLEAR_FAULTS command is executed, which
112 * happens pretty much each time chip data is updated. Raw peak data therefore
113 * does not provide much value. To be able to provide useful peak data, keep an
114 * internal cache of measured peak data, which is only cleared if an explicit
115 * "clear peak" command is executed for the sensor in question.
118 struct ltc2978_data
{
120 u16 vin_min
, vin_max
;
121 u16 temp_min
[LTC2974_NUM_PAGES
], temp_max
[LTC2974_NUM_PAGES
];
122 u16 vout_min
[LTC2978_NUM_PAGES
], vout_max
[LTC2978_NUM_PAGES
];
123 u16 iout_min
[LTC2974_NUM_PAGES
], iout_max
[LTC2974_NUM_PAGES
];
124 u16 iin_min
, iin_max
;
125 u16 pin_min
, pin_max
;
127 struct pmbus_driver_info info
;
130 #define to_ltc2978_data(x) container_of(x, struct ltc2978_data, info)
132 #define FEAT_CLEAR_PEAKS BIT(0)
133 #define FEAT_NEEDS_POLLING BIT(1)
135 #define has_clear_peaks(d) ((d)->features & FEAT_CLEAR_PEAKS)
136 #define needs_polling(d) ((d)->features & FEAT_NEEDS_POLLING)
138 static int ltc_wait_ready(struct i2c_client
*client
)
140 unsigned long timeout
= jiffies
+ msecs_to_jiffies(LTC_POLL_TIMEOUT
);
141 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
142 struct ltc2978_data
*data
= to_ltc2978_data(info
);
146 if (!needs_polling(data
))
150 * LTC3883 does not support LTC_NOT_PENDING, even though
151 * the datasheet claims that it does.
154 if (data
->id
!= ltc3883
)
155 mask
|= LTC_NOT_PENDING
;
158 status
= pmbus_read_byte_data(client
, 0, LTC2978_MFR_COMMON
);
159 if (status
== -EBADMSG
|| status
== -ENXIO
) {
160 /* PEC error or NACK: chip may be busy, try again */
161 usleep_range(50, 100);
167 if ((status
& mask
) == mask
)
170 usleep_range(50, 100);
171 } while (time_before(jiffies
, timeout
));
176 static int ltc_read_word_data(struct i2c_client
*client
, int page
, int phase
,
181 ret
= ltc_wait_ready(client
);
185 return pmbus_read_word_data(client
, page
, 0xff, reg
);
188 static int ltc_read_byte_data(struct i2c_client
*client
, int page
, int reg
)
192 ret
= ltc_wait_ready(client
);
196 return pmbus_read_byte_data(client
, page
, reg
);
199 static int ltc_write_byte(struct i2c_client
*client
, int page
, u8 byte
)
203 ret
= ltc_wait_ready(client
);
207 return pmbus_write_byte(client
, page
, byte
);
210 static inline int lin11_to_val(int data
)
212 s16 e
= ((s16
)data
) >> 11;
213 s32 m
= (((s16
)(data
<< 5)) >> 5);
216 * mantissa is 10 bit + sign, exponent adds up to 15 bit.
217 * Add 6 bit to exponent for maximum accuracy (10 + 15 + 6 = 31).
220 return (e
< 0 ? m
>> -e
: m
<< e
);
223 static int ltc_get_max(struct ltc2978_data
*data
, struct i2c_client
*client
,
224 int page
, int reg
, u16
*pmax
)
228 ret
= ltc_read_word_data(client
, page
, 0xff, reg
);
230 if (lin11_to_val(ret
) > lin11_to_val(*pmax
))
237 static int ltc_get_min(struct ltc2978_data
*data
, struct i2c_client
*client
,
238 int page
, int reg
, u16
*pmin
)
242 ret
= ltc_read_word_data(client
, page
, 0xff, reg
);
244 if (lin11_to_val(ret
) < lin11_to_val(*pmin
))
251 static int ltc2978_read_word_data_common(struct i2c_client
*client
, int page
,
254 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
255 struct ltc2978_data
*data
= to_ltc2978_data(info
);
259 case PMBUS_VIRT_READ_VIN_MAX
:
260 ret
= ltc_get_max(data
, client
, page
, LTC2978_MFR_VIN_PEAK
,
263 case PMBUS_VIRT_READ_VOUT_MAX
:
264 ret
= ltc_read_word_data(client
, page
, 0xff,
265 LTC2978_MFR_VOUT_PEAK
);
268 * VOUT is 16 bit unsigned with fixed exponent,
269 * so we can compare it directly
271 if (ret
> data
->vout_max
[page
])
272 data
->vout_max
[page
] = ret
;
273 ret
= data
->vout_max
[page
];
276 case PMBUS_VIRT_READ_TEMP_MAX
:
277 ret
= ltc_get_max(data
, client
, page
,
278 LTC2978_MFR_TEMPERATURE_PEAK
,
279 &data
->temp_max
[page
]);
281 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
282 case PMBUS_VIRT_RESET_VIN_HISTORY
:
283 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
287 ret
= ltc_wait_ready(client
);
296 static int ltc2978_read_word_data(struct i2c_client
*client
, int page
,
299 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
300 struct ltc2978_data
*data
= to_ltc2978_data(info
);
304 case PMBUS_VIRT_READ_VIN_MIN
:
305 ret
= ltc_get_min(data
, client
, page
, LTC2978_MFR_VIN_MIN
,
308 case PMBUS_VIRT_READ_VOUT_MIN
:
309 ret
= ltc_read_word_data(client
, page
, phase
,
310 LTC2978_MFR_VOUT_MIN
);
313 * VOUT_MIN is known to not be supported on some lots
314 * of LTC2978 revision 1, and will return the maximum
315 * possible voltage if read. If VOUT_MAX is valid and
316 * lower than the reading of VOUT_MIN, use it instead.
318 if (data
->vout_max
[page
] && ret
> data
->vout_max
[page
])
319 ret
= data
->vout_max
[page
];
320 if (ret
< data
->vout_min
[page
])
321 data
->vout_min
[page
] = ret
;
322 ret
= data
->vout_min
[page
];
325 case PMBUS_VIRT_READ_TEMP_MIN
:
326 ret
= ltc_get_min(data
, client
, page
,
327 LTC2978_MFR_TEMPERATURE_MIN
,
328 &data
->temp_min
[page
]);
330 case PMBUS_VIRT_READ_IOUT_MAX
:
331 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
332 case PMBUS_VIRT_READ_TEMP2_MAX
:
333 case PMBUS_VIRT_RESET_TEMP2_HISTORY
:
337 ret
= ltc2978_read_word_data_common(client
, page
, reg
);
343 static int ltc2974_read_word_data(struct i2c_client
*client
, int page
,
346 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
347 struct ltc2978_data
*data
= to_ltc2978_data(info
);
351 case PMBUS_VIRT_READ_IOUT_MAX
:
352 ret
= ltc_get_max(data
, client
, page
, LTC2974_MFR_IOUT_PEAK
,
353 &data
->iout_max
[page
]);
355 case PMBUS_VIRT_READ_IOUT_MIN
:
356 ret
= ltc_get_min(data
, client
, page
, LTC2974_MFR_IOUT_MIN
,
357 &data
->iout_min
[page
]);
359 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
363 ret
= ltc2978_read_word_data(client
, page
, phase
, reg
);
369 static int ltc2975_read_word_data(struct i2c_client
*client
, int page
,
372 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
373 struct ltc2978_data
*data
= to_ltc2978_data(info
);
377 case PMBUS_VIRT_READ_IIN_MAX
:
378 ret
= ltc_get_max(data
, client
, page
, LTC2975_MFR_IIN_PEAK
,
381 case PMBUS_VIRT_READ_IIN_MIN
:
382 ret
= ltc_get_min(data
, client
, page
, LTC2975_MFR_IIN_MIN
,
385 case PMBUS_VIRT_READ_PIN_MAX
:
386 ret
= ltc_get_max(data
, client
, page
, LTC2975_MFR_PIN_PEAK
,
389 case PMBUS_VIRT_READ_PIN_MIN
:
390 ret
= ltc_get_min(data
, client
, page
, LTC2975_MFR_PIN_MIN
,
393 case PMBUS_VIRT_RESET_IIN_HISTORY
:
394 case PMBUS_VIRT_RESET_PIN_HISTORY
:
398 ret
= ltc2978_read_word_data(client
, page
, phase
, reg
);
404 static int ltc3880_read_word_data(struct i2c_client
*client
, int page
,
407 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
408 struct ltc2978_data
*data
= to_ltc2978_data(info
);
412 case PMBUS_VIRT_READ_IOUT_MAX
:
413 ret
= ltc_get_max(data
, client
, page
, LTC3880_MFR_IOUT_PEAK
,
414 &data
->iout_max
[page
]);
416 case PMBUS_VIRT_READ_TEMP2_MAX
:
417 ret
= ltc_get_max(data
, client
, page
,
418 LTC3880_MFR_TEMPERATURE2_PEAK
,
421 case PMBUS_VIRT_READ_VIN_MIN
:
422 case PMBUS_VIRT_READ_VOUT_MIN
:
423 case PMBUS_VIRT_READ_TEMP_MIN
:
426 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
427 case PMBUS_VIRT_RESET_TEMP2_HISTORY
:
431 ret
= ltc2978_read_word_data_common(client
, page
, reg
);
437 static int ltc3883_read_word_data(struct i2c_client
*client
, int page
,
440 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
441 struct ltc2978_data
*data
= to_ltc2978_data(info
);
445 case PMBUS_VIRT_READ_IIN_MAX
:
446 ret
= ltc_get_max(data
, client
, page
, LTC3883_MFR_IIN_PEAK
,
449 case PMBUS_VIRT_RESET_IIN_HISTORY
:
453 ret
= ltc3880_read_word_data(client
, page
, phase
, reg
);
459 static int ltc2978_clear_peaks(struct ltc2978_data
*data
,
460 struct i2c_client
*client
, int page
)
464 if (has_clear_peaks(data
))
465 ret
= ltc_write_byte(client
, 0, LTC3880_MFR_CLEAR_PEAKS
);
467 ret
= ltc_write_byte(client
, page
, PMBUS_CLEAR_FAULTS
);
472 static int ltc2978_write_word_data(struct i2c_client
*client
, int page
,
475 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
476 struct ltc2978_data
*data
= to_ltc2978_data(info
);
480 case PMBUS_VIRT_RESET_IIN_HISTORY
:
481 data
->iin_max
= 0x7c00;
482 data
->iin_min
= 0x7bff;
483 ret
= ltc2978_clear_peaks(data
, client
, 0);
485 case PMBUS_VIRT_RESET_PIN_HISTORY
:
486 data
->pin_max
= 0x7c00;
487 data
->pin_min
= 0x7bff;
488 ret
= ltc2978_clear_peaks(data
, client
, 0);
490 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
491 data
->iout_max
[page
] = 0x7c00;
492 data
->iout_min
[page
] = 0xfbff;
493 ret
= ltc2978_clear_peaks(data
, client
, page
);
495 case PMBUS_VIRT_RESET_TEMP2_HISTORY
:
496 data
->temp2_max
= 0x7c00;
497 ret
= ltc2978_clear_peaks(data
, client
, page
);
499 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
500 data
->vout_min
[page
] = 0xffff;
501 data
->vout_max
[page
] = 0;
502 ret
= ltc2978_clear_peaks(data
, client
, page
);
504 case PMBUS_VIRT_RESET_VIN_HISTORY
:
505 data
->vin_min
= 0x7bff;
506 data
->vin_max
= 0x7c00;
507 ret
= ltc2978_clear_peaks(data
, client
, page
);
509 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
510 data
->temp_min
[page
] = 0x7bff;
511 data
->temp_max
[page
] = 0x7c00;
512 ret
= ltc2978_clear_peaks(data
, client
, page
);
515 ret
= ltc_wait_ready(client
);
524 static const struct i2c_device_id ltc2978_id
[] = {
525 {"ltc2972", ltc2972
},
526 {"ltc2974", ltc2974
},
527 {"ltc2975", ltc2975
},
528 {"ltc2977", ltc2977
},
529 {"ltc2978", ltc2978
},
530 {"ltc2979", ltc2979
},
531 {"ltc2980", ltc2980
},
532 {"ltc3880", ltc3880
},
533 {"ltc3882", ltc3882
},
534 {"ltc3883", ltc3883
},
535 {"ltc3884", ltc3884
},
536 {"ltc3886", ltc3886
},
537 {"ltc3887", ltc3887
},
538 {"ltc3889", ltc3889
},
539 {"ltc7880", ltc7880
},
540 {"ltm2987", ltm2987
},
541 {"ltm4664", ltm4664
},
542 {"ltm4675", ltm4675
},
543 {"ltm4676", ltm4676
},
544 {"ltm4677", ltm4677
},
545 {"ltm4678", ltm4678
},
546 {"ltm4680", ltm4680
},
547 {"ltm4686", ltm4686
},
548 {"ltm4700", ltm4700
},
551 MODULE_DEVICE_TABLE(i2c
, ltc2978_id
);
553 #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
554 static const struct regulator_desc ltc2978_reg_desc
[] = {
555 PMBUS_REGULATOR("vout", 0),
556 PMBUS_REGULATOR("vout", 1),
557 PMBUS_REGULATOR("vout", 2),
558 PMBUS_REGULATOR("vout", 3),
559 PMBUS_REGULATOR("vout", 4),
560 PMBUS_REGULATOR("vout", 5),
561 PMBUS_REGULATOR("vout", 6),
562 PMBUS_REGULATOR("vout", 7),
564 #endif /* CONFIG_SENSORS_LTC2978_REGULATOR */
566 static int ltc2978_get_id(struct i2c_client
*client
)
570 chip_id
= i2c_smbus_read_word_data(client
, LTC2978_MFR_SPECIAL_ID
);
572 const struct i2c_device_id
*id
;
573 u8 buf
[I2C_SMBUS_BLOCK_MAX
];
576 if (!i2c_check_functionality(client
->adapter
,
577 I2C_FUNC_SMBUS_READ_BLOCK_DATA
))
580 ret
= i2c_smbus_read_block_data(client
, PMBUS_MFR_ID
, buf
);
583 if (ret
< 3 || strncmp(buf
, "LTC", 3))
586 ret
= i2c_smbus_read_block_data(client
, PMBUS_MFR_MODEL
, buf
);
589 for (id
= <c2978_id
[0]; strlen(id
->name
); id
++) {
590 if (!strncasecmp(id
->name
, buf
, strlen(id
->name
)))
591 return (int)id
->driver_data
;
596 chip_id
&= LTC2978_ID_MASK
;
598 if (chip_id
== LTC2972_ID
)
600 else if (chip_id
== LTC2974_ID
)
602 else if (chip_id
== LTC2975_ID
)
604 else if (chip_id
== LTC2977_ID
)
606 else if (chip_id
== LTC2978_ID_REV1
|| chip_id
== LTC2978_ID_REV2
)
608 else if (chip_id
== LTC2979_ID_A
|| chip_id
== LTC2979_ID_B
)
610 else if (chip_id
== LTC2980_ID_A
|| chip_id
== LTC2980_ID_B
)
612 else if (chip_id
== LTC3880_ID
)
614 else if (chip_id
== LTC3882_ID
|| chip_id
== LTC3882_ID_D1
)
616 else if (chip_id
== LTC3883_ID
)
618 else if (chip_id
== LTC3884_ID
)
620 else if (chip_id
== LTC3886_ID
)
622 else if (chip_id
== LTC3887_ID
)
624 else if (chip_id
== LTC3889_ID
)
626 else if (chip_id
== LTC7880_ID
)
628 else if (chip_id
== LTM2987_ID_A
|| chip_id
== LTM2987_ID_B
)
630 else if (chip_id
== LTM4664_ID
)
632 else if (chip_id
== LTM4675_ID
)
634 else if (chip_id
== LTM4676_ID_REV1
|| chip_id
== LTM4676_ID_REV2
||
635 chip_id
== LTM4676A_ID
)
637 else if (chip_id
== LTM4677_ID_REV1
|| chip_id
== LTM4677_ID_REV2
)
639 else if (chip_id
== LTM4678_ID_REV1
|| chip_id
== LTM4678_ID_REV2
)
641 else if (chip_id
== LTM4680_ID
)
643 else if (chip_id
== LTM4686_ID
)
645 else if (chip_id
== LTM4700_ID
)
648 dev_err(&client
->dev
, "Unsupported chip ID 0x%x\n", chip_id
);
652 static int ltc2978_probe(struct i2c_client
*client
)
655 struct ltc2978_data
*data
;
656 struct pmbus_driver_info
*info
;
657 const struct i2c_device_id
*id
;
659 if (!i2c_check_functionality(client
->adapter
,
660 I2C_FUNC_SMBUS_READ_WORD_DATA
))
663 data
= devm_kzalloc(&client
->dev
, sizeof(struct ltc2978_data
),
668 chip_id
= ltc2978_get_id(client
);
673 id
= i2c_match_id(ltc2978_id
, client
);
674 if (data
->id
!= id
->driver_data
)
675 dev_warn(&client
->dev
,
676 "Device mismatch: Configured %s (%d), detected %d\n",
678 (int) id
->driver_data
,
682 info
->write_word_data
= ltc2978_write_word_data
;
683 info
->write_byte
= ltc_write_byte
;
684 info
->read_word_data
= ltc_read_word_data
;
685 info
->read_byte_data
= ltc_read_byte_data
;
687 data
->vin_min
= 0x7bff;
688 data
->vin_max
= 0x7c00;
689 for (i
= 0; i
< ARRAY_SIZE(data
->vout_min
); i
++)
690 data
->vout_min
[i
] = 0xffff;
691 for (i
= 0; i
< ARRAY_SIZE(data
->iout_min
); i
++)
692 data
->iout_min
[i
] = 0xfbff;
693 for (i
= 0; i
< ARRAY_SIZE(data
->iout_max
); i
++)
694 data
->iout_max
[i
] = 0x7c00;
695 for (i
= 0; i
< ARRAY_SIZE(data
->temp_min
); i
++)
696 data
->temp_min
[i
] = 0x7bff;
697 for (i
= 0; i
< ARRAY_SIZE(data
->temp_max
); i
++)
698 data
->temp_max
[i
] = 0x7c00;
699 data
->temp2_max
= 0x7c00;
703 info
->read_word_data
= ltc2975_read_word_data
;
704 info
->pages
= LTC2972_NUM_PAGES
;
705 info
->func
[0] = PMBUS_HAVE_IIN
| PMBUS_HAVE_PIN
706 | PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
708 for (i
= 0; i
< info
->pages
; i
++) {
709 info
->func
[i
] |= PMBUS_HAVE_VOUT
710 | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_POUT
711 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
712 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
;
716 info
->read_word_data
= ltc2974_read_word_data
;
717 info
->pages
= LTC2974_NUM_PAGES
;
718 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
720 for (i
= 0; i
< info
->pages
; i
++) {
721 info
->func
[i
] |= PMBUS_HAVE_VOUT
722 | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_POUT
723 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
724 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
;
728 info
->read_word_data
= ltc2975_read_word_data
;
729 info
->pages
= LTC2974_NUM_PAGES
;
730 info
->func
[0] = PMBUS_HAVE_IIN
| PMBUS_HAVE_PIN
731 | PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
733 for (i
= 0; i
< info
->pages
; i
++) {
734 info
->func
[i
] |= PMBUS_HAVE_VOUT
735 | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_POUT
736 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
737 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
;
746 info
->read_word_data
= ltc2978_read_word_data
;
747 info
->pages
= LTC2978_NUM_PAGES
;
748 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
749 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
750 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
751 for (i
= 1; i
< LTC2978_NUM_PAGES
; i
++) {
752 info
->func
[i
] = PMBUS_HAVE_VOUT
753 | PMBUS_HAVE_STATUS_VOUT
;
762 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
763 info
->read_word_data
= ltc3880_read_word_data
;
764 info
->pages
= LTC3880_NUM_PAGES
;
765 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_IIN
766 | PMBUS_HAVE_STATUS_INPUT
767 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
768 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
769 | PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
770 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
771 info
->func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
772 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
774 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
777 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
778 info
->read_word_data
= ltc3880_read_word_data
;
779 info
->pages
= LTC3880_NUM_PAGES
;
780 info
->func
[0] = PMBUS_HAVE_VIN
781 | PMBUS_HAVE_STATUS_INPUT
782 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
783 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
784 | PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
785 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
786 info
->func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
787 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
789 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
792 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
793 info
->read_word_data
= ltc3883_read_word_data
;
794 info
->pages
= LTC3883_NUM_PAGES
;
795 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_IIN
796 | PMBUS_HAVE_STATUS_INPUT
797 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
798 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
799 | PMBUS_HAVE_PIN
| PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
800 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
810 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
811 info
->read_word_data
= ltc3883_read_word_data
;
812 info
->pages
= LTC3880_NUM_PAGES
;
813 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_IIN
814 | PMBUS_HAVE_STATUS_INPUT
815 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
816 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
817 | PMBUS_HAVE_PIN
| PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
818 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
819 info
->func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
820 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
822 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
828 #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
829 info
->num_regulators
= info
->pages
;
830 info
->reg_desc
= ltc2978_reg_desc
;
831 if (info
->num_regulators
> ARRAY_SIZE(ltc2978_reg_desc
)) {
832 dev_err(&client
->dev
, "num_regulators too large!");
833 info
->num_regulators
= ARRAY_SIZE(ltc2978_reg_desc
);
837 return pmbus_do_probe(client
, info
);
842 static const struct of_device_id ltc2978_of_match
[] = {
843 { .compatible
= "lltc,ltc2972" },
844 { .compatible
= "lltc,ltc2974" },
845 { .compatible
= "lltc,ltc2975" },
846 { .compatible
= "lltc,ltc2977" },
847 { .compatible
= "lltc,ltc2978" },
848 { .compatible
= "lltc,ltc2979" },
849 { .compatible
= "lltc,ltc2980" },
850 { .compatible
= "lltc,ltc3880" },
851 { .compatible
= "lltc,ltc3882" },
852 { .compatible
= "lltc,ltc3883" },
853 { .compatible
= "lltc,ltc3884" },
854 { .compatible
= "lltc,ltc3886" },
855 { .compatible
= "lltc,ltc3887" },
856 { .compatible
= "lltc,ltc3889" },
857 { .compatible
= "lltc,ltc7880" },
858 { .compatible
= "lltc,ltm2987" },
859 { .compatible
= "lltc,ltm4664" },
860 { .compatible
= "lltc,ltm4675" },
861 { .compatible
= "lltc,ltm4676" },
862 { .compatible
= "lltc,ltm4677" },
863 { .compatible
= "lltc,ltm4678" },
864 { .compatible
= "lltc,ltm4680" },
865 { .compatible
= "lltc,ltm4686" },
866 { .compatible
= "lltc,ltm4700" },
869 MODULE_DEVICE_TABLE(of
, ltc2978_of_match
);
872 static struct i2c_driver ltc2978_driver
= {
875 .of_match_table
= of_match_ptr(ltc2978_of_match
),
877 .probe_new
= ltc2978_probe
,
878 .id_table
= ltc2978_id
,
881 module_i2c_driver(ltc2978_driver
);
883 MODULE_AUTHOR("Guenter Roeck");
884 MODULE_DESCRIPTION("PMBus driver for LTC2978 and compatible chips");
885 MODULE_LICENSE("GPL");