2 * Hardware monitoring driver for LTC2978 and compatible chips.
4 * Copyright (c) 2011 Ericsson AB.
5 * Copyright (c) 2013, 2014, 2015 Guenter Roeck
6 * Copyright (c) 2015 Linear Technology
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include <linux/delay.h>
20 #include <linux/jiffies.h>
21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include <linux/init.h>
24 #include <linux/err.h>
25 #include <linux/slab.h>
26 #include <linux/i2c.h>
27 #include <linux/regulator/driver.h>
30 enum chips
{ ltc2974
, ltc2975
, ltc2977
, ltc2978
, ltc2980
, ltc3880
, ltc3882
,
31 ltc3883
, ltc3886
, ltc3887
, ltm2987
, ltm4675
, ltm4676
};
33 /* Common for all chips */
34 #define LTC2978_MFR_VOUT_PEAK 0xdd
35 #define LTC2978_MFR_VIN_PEAK 0xde
36 #define LTC2978_MFR_TEMPERATURE_PEAK 0xdf
37 #define LTC2978_MFR_SPECIAL_ID 0xe7 /* Undocumented on LTC3882 */
38 #define LTC2978_MFR_COMMON 0xef
40 /* LTC2974, LTC2975, LCT2977, LTC2980, LTC2978, and LTM2987 */
41 #define LTC2978_MFR_VOUT_MIN 0xfb
42 #define LTC2978_MFR_VIN_MIN 0xfc
43 #define LTC2978_MFR_TEMPERATURE_MIN 0xfd
45 /* LTC2974, LTC2975 */
46 #define LTC2974_MFR_IOUT_PEAK 0xd7
47 #define LTC2974_MFR_IOUT_MIN 0xd8
49 /* LTC3880, LTC3882, LTC3883, LTC3887, LTM4675, and LTM4676 */
50 #define LTC3880_MFR_IOUT_PEAK 0xd7
51 #define LTC3880_MFR_CLEAR_PEAKS 0xe3
52 #define LTC3880_MFR_TEMPERATURE2_PEAK 0xf4
54 /* LTC3883 and LTC3886 only */
55 #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 LTC2974_ID 0x0210
66 #define LTC2975_ID 0x0220
67 #define LTC2977_ID 0x0130
68 #define LTC2978_ID_REV1 0x0110 /* Early revision */
69 #define LTC2978_ID_REV2 0x0120
70 #define LTC2980_ID_A 0x8030 /* A/B for two die IDs */
71 #define LTC2980_ID_B 0x8040
72 #define LTC3880_ID 0x4020
73 #define LTC3882_ID 0x4200
74 #define LTC3882_ID_D1 0x4240 /* Dash 1 */
75 #define LTC3883_ID 0x4300
76 #define LTC3886_ID 0x4600
77 #define LTC3887_ID 0x4700
78 #define LTM2987_ID_A 0x8010 /* A/B for two die IDs */
79 #define LTM2987_ID_B 0x8020
80 #define LTM4675_ID 0x47a0
81 #define LTM4676_ID_REV1 0x4400
82 #define LTM4676_ID_REV2 0x4480
83 #define LTM4676A_ID 0x47e0
85 #define LTC2974_NUM_PAGES 4
86 #define LTC2978_NUM_PAGES 8
87 #define LTC3880_NUM_PAGES 2
88 #define LTC3883_NUM_PAGES 1
90 #define LTC_POLL_TIMEOUT 100 /* in milli-seconds */
92 #define LTC_NOT_BUSY BIT(5)
93 #define LTC_NOT_PENDING BIT(4)
96 * LTC2978 clears peak data whenever the CLEAR_FAULTS command is executed, which
97 * happens pretty much each time chip data is updated. Raw peak data therefore
98 * does not provide much value. To be able to provide useful peak data, keep an
99 * internal cache of measured peak data, which is only cleared if an explicit
100 * "clear peak" command is executed for the sensor in question.
103 struct ltc2978_data
{
105 u16 vin_min
, vin_max
;
106 u16 temp_min
[LTC2974_NUM_PAGES
], temp_max
[LTC2974_NUM_PAGES
];
107 u16 vout_min
[LTC2978_NUM_PAGES
], vout_max
[LTC2978_NUM_PAGES
];
108 u16 iout_min
[LTC2974_NUM_PAGES
], iout_max
[LTC2974_NUM_PAGES
];
109 u16 iin_min
, iin_max
;
110 u16 pin_min
, pin_max
;
112 struct pmbus_driver_info info
;
115 #define to_ltc2978_data(x) container_of(x, struct ltc2978_data, info)
117 #define FEAT_CLEAR_PEAKS BIT(0)
118 #define FEAT_NEEDS_POLLING BIT(1)
120 #define has_clear_peaks(d) ((d)->features & FEAT_CLEAR_PEAKS)
121 #define needs_polling(d) ((d)->features & FEAT_NEEDS_POLLING)
123 static int ltc_wait_ready(struct i2c_client
*client
)
125 unsigned long timeout
= jiffies
+ msecs_to_jiffies(LTC_POLL_TIMEOUT
);
126 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
127 struct ltc2978_data
*data
= to_ltc2978_data(info
);
131 if (!needs_polling(data
))
135 * LTC3883 does not support LTC_NOT_PENDING, even though
136 * the datasheet claims that it does.
139 if (data
->id
!= ltc3883
)
140 mask
|= LTC_NOT_PENDING
;
143 status
= pmbus_read_byte_data(client
, 0, LTC2978_MFR_COMMON
);
144 if (status
== -EBADMSG
|| status
== -ENXIO
) {
145 /* PEC error or NACK: chip may be busy, try again */
146 usleep_range(50, 100);
152 if ((status
& mask
) == mask
)
155 usleep_range(50, 100);
156 } while (time_before(jiffies
, timeout
));
161 static int ltc_read_word_data(struct i2c_client
*client
, int page
, int reg
)
165 ret
= ltc_wait_ready(client
);
169 return pmbus_read_word_data(client
, page
, reg
);
172 static int ltc_read_byte_data(struct i2c_client
*client
, int page
, int reg
)
176 ret
= ltc_wait_ready(client
);
180 return pmbus_read_byte_data(client
, page
, reg
);
183 static int ltc_write_byte(struct i2c_client
*client
, int page
, u8 byte
)
187 ret
= ltc_wait_ready(client
);
191 return pmbus_write_byte(client
, page
, byte
);
194 static inline int lin11_to_val(int data
)
196 s16 e
= ((s16
)data
) >> 11;
197 s32 m
= (((s16
)(data
<< 5)) >> 5);
200 * mantissa is 10 bit + sign, exponent adds up to 15 bit.
201 * Add 6 bit to exponent for maximum accuracy (10 + 15 + 6 = 31).
204 return (e
< 0 ? m
>> -e
: m
<< e
);
207 static int ltc_get_max(struct ltc2978_data
*data
, struct i2c_client
*client
,
208 int page
, int reg
, u16
*pmax
)
212 ret
= ltc_read_word_data(client
, page
, reg
);
214 if (lin11_to_val(ret
) > lin11_to_val(*pmax
))
221 static int ltc_get_min(struct ltc2978_data
*data
, struct i2c_client
*client
,
222 int page
, int reg
, u16
*pmin
)
226 ret
= ltc_read_word_data(client
, page
, reg
);
228 if (lin11_to_val(ret
) < lin11_to_val(*pmin
))
235 static int ltc2978_read_word_data_common(struct i2c_client
*client
, int page
,
238 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
239 struct ltc2978_data
*data
= to_ltc2978_data(info
);
243 case PMBUS_VIRT_READ_VIN_MAX
:
244 ret
= ltc_get_max(data
, client
, page
, LTC2978_MFR_VIN_PEAK
,
247 case PMBUS_VIRT_READ_VOUT_MAX
:
248 ret
= ltc_read_word_data(client
, page
, LTC2978_MFR_VOUT_PEAK
);
251 * VOUT is 16 bit unsigned with fixed exponent,
252 * so we can compare it directly
254 if (ret
> data
->vout_max
[page
])
255 data
->vout_max
[page
] = ret
;
256 ret
= data
->vout_max
[page
];
259 case PMBUS_VIRT_READ_TEMP_MAX
:
260 ret
= ltc_get_max(data
, client
, page
,
261 LTC2978_MFR_TEMPERATURE_PEAK
,
262 &data
->temp_max
[page
]);
264 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
265 case PMBUS_VIRT_RESET_VIN_HISTORY
:
266 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
270 ret
= ltc_wait_ready(client
);
279 static int ltc2978_read_word_data(struct i2c_client
*client
, int page
, int reg
)
281 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
282 struct ltc2978_data
*data
= to_ltc2978_data(info
);
286 case PMBUS_VIRT_READ_VIN_MIN
:
287 ret
= ltc_get_min(data
, client
, page
, LTC2978_MFR_VIN_MIN
,
290 case PMBUS_VIRT_READ_VOUT_MIN
:
291 ret
= ltc_read_word_data(client
, page
, LTC2978_MFR_VOUT_MIN
);
294 * VOUT_MIN is known to not be supported on some lots
295 * of LTC2978 revision 1, and will return the maximum
296 * possible voltage if read. If VOUT_MAX is valid and
297 * lower than the reading of VOUT_MIN, use it instead.
299 if (data
->vout_max
[page
] && ret
> data
->vout_max
[page
])
300 ret
= data
->vout_max
[page
];
301 if (ret
< data
->vout_min
[page
])
302 data
->vout_min
[page
] = ret
;
303 ret
= data
->vout_min
[page
];
306 case PMBUS_VIRT_READ_TEMP_MIN
:
307 ret
= ltc_get_min(data
, client
, page
,
308 LTC2978_MFR_TEMPERATURE_MIN
,
309 &data
->temp_min
[page
]);
311 case PMBUS_VIRT_READ_IOUT_MAX
:
312 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
313 case PMBUS_VIRT_READ_TEMP2_MAX
:
314 case PMBUS_VIRT_RESET_TEMP2_HISTORY
:
318 ret
= ltc2978_read_word_data_common(client
, page
, reg
);
324 static int ltc2974_read_word_data(struct i2c_client
*client
, int page
, int reg
)
326 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
327 struct ltc2978_data
*data
= to_ltc2978_data(info
);
331 case PMBUS_VIRT_READ_IOUT_MAX
:
332 ret
= ltc_get_max(data
, client
, page
, LTC2974_MFR_IOUT_PEAK
,
333 &data
->iout_max
[page
]);
335 case PMBUS_VIRT_READ_IOUT_MIN
:
336 ret
= ltc_get_min(data
, client
, page
, LTC2974_MFR_IOUT_MIN
,
337 &data
->iout_min
[page
]);
339 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
343 ret
= ltc2978_read_word_data(client
, page
, reg
);
349 static int ltc2975_read_word_data(struct i2c_client
*client
, int page
, int reg
)
351 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
352 struct ltc2978_data
*data
= to_ltc2978_data(info
);
356 case PMBUS_VIRT_READ_IIN_MAX
:
357 ret
= ltc_get_max(data
, client
, page
, LTC2975_MFR_IIN_PEAK
,
360 case PMBUS_VIRT_READ_IIN_MIN
:
361 ret
= ltc_get_min(data
, client
, page
, LTC2975_MFR_IIN_MIN
,
364 case PMBUS_VIRT_READ_PIN_MAX
:
365 ret
= ltc_get_max(data
, client
, page
, LTC2975_MFR_PIN_PEAK
,
368 case PMBUS_VIRT_READ_PIN_MIN
:
369 ret
= ltc_get_min(data
, client
, page
, LTC2975_MFR_PIN_MIN
,
372 case PMBUS_VIRT_RESET_IIN_HISTORY
:
373 case PMBUS_VIRT_RESET_PIN_HISTORY
:
377 ret
= ltc2978_read_word_data(client
, page
, reg
);
383 static int ltc3880_read_word_data(struct i2c_client
*client
, int page
, int reg
)
385 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
386 struct ltc2978_data
*data
= to_ltc2978_data(info
);
390 case PMBUS_VIRT_READ_IOUT_MAX
:
391 ret
= ltc_get_max(data
, client
, page
, LTC3880_MFR_IOUT_PEAK
,
392 &data
->iout_max
[page
]);
394 case PMBUS_VIRT_READ_TEMP2_MAX
:
395 ret
= ltc_get_max(data
, client
, page
,
396 LTC3880_MFR_TEMPERATURE2_PEAK
,
399 case PMBUS_VIRT_READ_VIN_MIN
:
400 case PMBUS_VIRT_READ_VOUT_MIN
:
401 case PMBUS_VIRT_READ_TEMP_MIN
:
404 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
405 case PMBUS_VIRT_RESET_TEMP2_HISTORY
:
409 ret
= ltc2978_read_word_data_common(client
, page
, reg
);
415 static int ltc3883_read_word_data(struct i2c_client
*client
, int page
, int reg
)
417 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
418 struct ltc2978_data
*data
= to_ltc2978_data(info
);
422 case PMBUS_VIRT_READ_IIN_MAX
:
423 ret
= ltc_get_max(data
, client
, page
, LTC3883_MFR_IIN_PEAK
,
426 case PMBUS_VIRT_RESET_IIN_HISTORY
:
430 ret
= ltc3880_read_word_data(client
, page
, reg
);
436 static int ltc2978_clear_peaks(struct ltc2978_data
*data
,
437 struct i2c_client
*client
, int page
)
441 if (has_clear_peaks(data
))
442 ret
= ltc_write_byte(client
, 0, LTC3880_MFR_CLEAR_PEAKS
);
444 ret
= ltc_write_byte(client
, page
, PMBUS_CLEAR_FAULTS
);
449 static int ltc2978_write_word_data(struct i2c_client
*client
, int page
,
452 const struct pmbus_driver_info
*info
= pmbus_get_driver_info(client
);
453 struct ltc2978_data
*data
= to_ltc2978_data(info
);
457 case PMBUS_VIRT_RESET_IIN_HISTORY
:
458 data
->iin_max
= 0x7c00;
459 data
->iin_min
= 0x7bff;
460 ret
= ltc2978_clear_peaks(data
, client
, 0);
462 case PMBUS_VIRT_RESET_PIN_HISTORY
:
463 data
->pin_max
= 0x7c00;
464 data
->pin_min
= 0x7bff;
465 ret
= ltc2978_clear_peaks(data
, client
, 0);
467 case PMBUS_VIRT_RESET_IOUT_HISTORY
:
468 data
->iout_max
[page
] = 0x7c00;
469 data
->iout_min
[page
] = 0xfbff;
470 ret
= ltc2978_clear_peaks(data
, client
, page
);
472 case PMBUS_VIRT_RESET_TEMP2_HISTORY
:
473 data
->temp2_max
= 0x7c00;
474 ret
= ltc2978_clear_peaks(data
, client
, page
);
476 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
477 data
->vout_min
[page
] = 0xffff;
478 data
->vout_max
[page
] = 0;
479 ret
= ltc2978_clear_peaks(data
, client
, page
);
481 case PMBUS_VIRT_RESET_VIN_HISTORY
:
482 data
->vin_min
= 0x7bff;
483 data
->vin_max
= 0x7c00;
484 ret
= ltc2978_clear_peaks(data
, client
, page
);
486 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
487 data
->temp_min
[page
] = 0x7bff;
488 data
->temp_max
[page
] = 0x7c00;
489 ret
= ltc2978_clear_peaks(data
, client
, page
);
492 ret
= ltc_wait_ready(client
);
501 static const struct i2c_device_id ltc2978_id
[] = {
502 {"ltc2974", ltc2974
},
503 {"ltc2975", ltc2975
},
504 {"ltc2977", ltc2977
},
505 {"ltc2978", ltc2978
},
506 {"ltc2980", ltc2980
},
507 {"ltc3880", ltc3880
},
508 {"ltc3882", ltc3882
},
509 {"ltc3883", ltc3883
},
510 {"ltc3886", ltc3886
},
511 {"ltc3887", ltc3887
},
512 {"ltm2987", ltm2987
},
513 {"ltm4675", ltm4675
},
514 {"ltm4676", ltm4676
},
517 MODULE_DEVICE_TABLE(i2c
, ltc2978_id
);
519 #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
520 static const struct regulator_desc ltc2978_reg_desc
[] = {
521 PMBUS_REGULATOR("vout", 0),
522 PMBUS_REGULATOR("vout", 1),
523 PMBUS_REGULATOR("vout", 2),
524 PMBUS_REGULATOR("vout", 3),
525 PMBUS_REGULATOR("vout", 4),
526 PMBUS_REGULATOR("vout", 5),
527 PMBUS_REGULATOR("vout", 6),
528 PMBUS_REGULATOR("vout", 7),
530 #endif /* CONFIG_SENSORS_LTC2978_REGULATOR */
532 static int ltc2978_get_id(struct i2c_client
*client
)
536 chip_id
= i2c_smbus_read_word_data(client
, LTC2978_MFR_SPECIAL_ID
);
538 const struct i2c_device_id
*id
;
539 u8 buf
[I2C_SMBUS_BLOCK_MAX
];
542 if (!i2c_check_functionality(client
->adapter
,
543 I2C_FUNC_SMBUS_READ_BLOCK_DATA
))
546 ret
= i2c_smbus_read_block_data(client
, PMBUS_MFR_ID
, buf
);
549 if (ret
< 3 || strncmp(buf
, "LTC", 3))
552 ret
= i2c_smbus_read_block_data(client
, PMBUS_MFR_MODEL
, buf
);
555 for (id
= <c2978_id
[0]; strlen(id
->name
); id
++) {
556 if (!strncasecmp(id
->name
, buf
, strlen(id
->name
)))
557 return (int)id
->driver_data
;
562 chip_id
&= LTC2978_ID_MASK
;
564 if (chip_id
== LTC2974_ID
)
566 else if (chip_id
== LTC2975_ID
)
568 else if (chip_id
== LTC2977_ID
)
570 else if (chip_id
== LTC2978_ID_REV1
|| chip_id
== LTC2978_ID_REV2
)
572 else if (chip_id
== LTC2980_ID_A
|| chip_id
== LTC2980_ID_B
)
574 else if (chip_id
== LTC3880_ID
)
576 else if (chip_id
== LTC3882_ID
|| chip_id
== LTC3882_ID_D1
)
578 else if (chip_id
== LTC3883_ID
)
580 else if (chip_id
== LTC3886_ID
)
582 else if (chip_id
== LTC3887_ID
)
584 else if (chip_id
== LTM2987_ID_A
|| chip_id
== LTM2987_ID_B
)
586 else if (chip_id
== LTM4675_ID
)
588 else if (chip_id
== LTM4676_ID_REV1
|| chip_id
== LTM4676_ID_REV2
||
589 chip_id
== LTM4676A_ID
)
592 dev_err(&client
->dev
, "Unsupported chip ID 0x%x\n", chip_id
);
596 static int ltc2978_probe(struct i2c_client
*client
,
597 const struct i2c_device_id
*id
)
600 struct ltc2978_data
*data
;
601 struct pmbus_driver_info
*info
;
603 if (!i2c_check_functionality(client
->adapter
,
604 I2C_FUNC_SMBUS_READ_WORD_DATA
))
607 data
= devm_kzalloc(&client
->dev
, sizeof(struct ltc2978_data
),
612 chip_id
= ltc2978_get_id(client
);
617 if (data
->id
!= id
->driver_data
)
618 dev_warn(&client
->dev
,
619 "Device mismatch: Configured %s, detected %s\n",
621 ltc2978_id
[data
->id
].name
);
624 info
->write_word_data
= ltc2978_write_word_data
;
625 info
->write_byte
= ltc_write_byte
;
626 info
->read_word_data
= ltc_read_word_data
;
627 info
->read_byte_data
= ltc_read_byte_data
;
629 data
->vin_min
= 0x7bff;
630 data
->vin_max
= 0x7c00;
631 for (i
= 0; i
< ARRAY_SIZE(data
->vout_min
); i
++)
632 data
->vout_min
[i
] = 0xffff;
633 for (i
= 0; i
< ARRAY_SIZE(data
->iout_min
); i
++)
634 data
->iout_min
[i
] = 0xfbff;
635 for (i
= 0; i
< ARRAY_SIZE(data
->iout_max
); i
++)
636 data
->iout_max
[i
] = 0x7c00;
637 for (i
= 0; i
< ARRAY_SIZE(data
->temp_min
); i
++)
638 data
->temp_min
[i
] = 0x7bff;
639 for (i
= 0; i
< ARRAY_SIZE(data
->temp_max
); i
++)
640 data
->temp_max
[i
] = 0x7c00;
641 data
->temp2_max
= 0x7c00;
645 info
->read_word_data
= ltc2974_read_word_data
;
646 info
->pages
= LTC2974_NUM_PAGES
;
647 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
649 for (i
= 0; i
< info
->pages
; i
++) {
650 info
->func
[i
] |= PMBUS_HAVE_VOUT
651 | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_POUT
652 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
653 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
;
657 info
->read_word_data
= ltc2975_read_word_data
;
658 info
->pages
= LTC2974_NUM_PAGES
;
659 info
->func
[0] = PMBUS_HAVE_IIN
| PMBUS_HAVE_PIN
660 | PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
662 for (i
= 0; i
< info
->pages
; i
++) {
663 info
->func
[i
] |= PMBUS_HAVE_VOUT
664 | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_POUT
665 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
666 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
;
673 info
->read_word_data
= ltc2978_read_word_data
;
674 info
->pages
= LTC2978_NUM_PAGES
;
675 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
676 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
677 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
678 for (i
= 1; i
< LTC2978_NUM_PAGES
; i
++) {
679 info
->func
[i
] = PMBUS_HAVE_VOUT
680 | PMBUS_HAVE_STATUS_VOUT
;
687 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
688 info
->read_word_data
= ltc3880_read_word_data
;
689 info
->pages
= LTC3880_NUM_PAGES
;
690 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_IIN
691 | PMBUS_HAVE_STATUS_INPUT
692 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
693 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
694 | PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
695 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
696 info
->func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
697 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
699 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
702 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
703 info
->read_word_data
= ltc3880_read_word_data
;
704 info
->pages
= LTC3880_NUM_PAGES
;
705 info
->func
[0] = PMBUS_HAVE_VIN
706 | PMBUS_HAVE_STATUS_INPUT
707 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
708 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
709 | PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
710 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
711 info
->func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
712 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
714 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
717 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
718 info
->read_word_data
= ltc3883_read_word_data
;
719 info
->pages
= LTC3883_NUM_PAGES
;
720 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_IIN
721 | PMBUS_HAVE_STATUS_INPUT
722 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
723 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
724 | PMBUS_HAVE_PIN
| PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
725 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
728 data
->features
|= FEAT_CLEAR_PEAKS
| FEAT_NEEDS_POLLING
;
729 info
->read_word_data
= ltc3883_read_word_data
;
730 info
->pages
= LTC3880_NUM_PAGES
;
731 info
->func
[0] = PMBUS_HAVE_VIN
| PMBUS_HAVE_IIN
732 | PMBUS_HAVE_STATUS_INPUT
733 | PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
734 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
735 | PMBUS_HAVE_PIN
| PMBUS_HAVE_POUT
| PMBUS_HAVE_TEMP
736 | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_STATUS_TEMP
;
737 info
->func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
738 | PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
740 | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
;
746 #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
747 info
->num_regulators
= info
->pages
;
748 info
->reg_desc
= ltc2978_reg_desc
;
749 if (info
->num_regulators
> ARRAY_SIZE(ltc2978_reg_desc
)) {
750 dev_err(&client
->dev
, "num_regulators too large!");
751 info
->num_regulators
= ARRAY_SIZE(ltc2978_reg_desc
);
755 return pmbus_do_probe(client
, id
, info
);
759 static const struct of_device_id ltc2978_of_match
[] = {
760 { .compatible
= "lltc,ltc2974" },
761 { .compatible
= "lltc,ltc2975" },
762 { .compatible
= "lltc,ltc2977" },
763 { .compatible
= "lltc,ltc2978" },
764 { .compatible
= "lltc,ltc2980" },
765 { .compatible
= "lltc,ltc3880" },
766 { .compatible
= "lltc,ltc3882" },
767 { .compatible
= "lltc,ltc3883" },
768 { .compatible
= "lltc,ltc3886" },
769 { .compatible
= "lltc,ltc3887" },
770 { .compatible
= "lltc,ltm2987" },
771 { .compatible
= "lltc,ltm4675" },
772 { .compatible
= "lltc,ltm4676" },
775 MODULE_DEVICE_TABLE(of
, ltc2978_of_match
);
778 static struct i2c_driver ltc2978_driver
= {
781 .of_match_table
= of_match_ptr(ltc2978_of_match
),
783 .probe
= ltc2978_probe
,
784 .remove
= pmbus_do_remove
,
785 .id_table
= ltc2978_id
,
788 module_i2c_driver(ltc2978_driver
);
790 MODULE_AUTHOR("Guenter Roeck");
791 MODULE_DESCRIPTION("PMBus driver for LTC2978 and comppatible chips");
792 MODULE_LICENSE("GPL");