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
7 * Copyright (c) 2018 Analog Devices Inc.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 #include <linux/delay.h>
21 #include <linux/jiffies.h>
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/init.h>
25 #include <linux/err.h>
26 #include <linux/slab.h>
27 #include <linux/i2c.h>
28 #include <linux/regulator/driver.h>
31 enum chips { ltc2974, ltc2975, ltc2977, ltc2978, ltc2980, ltc3880, ltc3882,
32 ltc3883, ltc3886, ltc3887, ltm2987, ltm4675, ltm4676, ltm4686 };
34 /* Common for all chips */
35 #define LTC2978_MFR_VOUT_PEAK 0xdd
36 #define LTC2978_MFR_VIN_PEAK 0xde
37 #define LTC2978_MFR_TEMPERATURE_PEAK 0xdf
38 #define LTC2978_MFR_SPECIAL_ID 0xe7 /* Undocumented on LTC3882 */
39 #define LTC2978_MFR_COMMON 0xef
41 /* LTC2974, LTC2975, LCT2977, LTC2980, LTC2978, and LTM2987 */
42 #define LTC2978_MFR_VOUT_MIN 0xfb
43 #define LTC2978_MFR_VIN_MIN 0xfc
44 #define LTC2978_MFR_TEMPERATURE_MIN 0xfd
46 /* LTC2974, LTC2975 */
47 #define LTC2974_MFR_IOUT_PEAK 0xd7
48 #define LTC2974_MFR_IOUT_MIN 0xd8
50 /* LTC3880, LTC3882, LTC3883, LTC3887, LTM4675, and LTM4676 */
51 #define LTC3880_MFR_IOUT_PEAK 0xd7
52 #define LTC3880_MFR_CLEAR_PEAKS 0xe3
53 #define LTC3880_MFR_TEMPERATURE2_PEAK 0xf4
55 /* LTC3883 and LTC3886 only */
56 #define LTC3883_MFR_IIN_PEAK 0xe1
59 #define LTC2975_MFR_IIN_PEAK 0xc4
60 #define LTC2975_MFR_IIN_MIN 0xc5
61 #define LTC2975_MFR_PIN_PEAK 0xc6
62 #define LTC2975_MFR_PIN_MIN 0xc7
64 #define LTC2978_ID_MASK 0xfff0
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 LTC2980_ID_A 0x8030 /* A/B for two die IDs */
72 #define LTC2980_ID_B 0x8040
73 #define LTC3880_ID 0x4020
74 #define LTC3882_ID 0x4200
75 #define LTC3882_ID_D1 0x4240 /* Dash 1 */
76 #define LTC3883_ID 0x4300
77 #define LTC3886_ID 0x4600
78 #define LTC3887_ID 0x4700
79 #define LTM2987_ID_A 0x8010 /* A/B for two die IDs */
80 #define LTM2987_ID_B 0x8020
81 #define LTM4675_ID 0x47a0
82 #define LTM4676_ID_REV1 0x4400
83 #define LTM4676_ID_REV2 0x4480
84 #define LTM4676A_ID 0x47e0
85 #define LTM4686_ID 0x4770
87 #define LTC2974_NUM_PAGES 4
88 #define LTC2978_NUM_PAGES 8
89 #define LTC3880_NUM_PAGES 2
90 #define LTC3883_NUM_PAGES 1
92 #define LTC_POLL_TIMEOUT 100 /* in milli-seconds */
94 #define LTC_NOT_BUSY BIT(5)
95 #define LTC_NOT_PENDING BIT(4)
98 * LTC2978 clears peak data whenever the CLEAR_FAULTS command is executed, which
99 * happens pretty much each time chip data is updated. Raw peak data therefore
100 * does not provide much value. To be able to provide useful peak data, keep an
101 * internal cache of measured peak data, which is only cleared if an explicit
102 * "clear peak" command is executed for the sensor in question.
105 struct ltc2978_data {
107 u16 vin_min, vin_max;
108 u16 temp_min[LTC2974_NUM_PAGES], temp_max[LTC2974_NUM_PAGES];
109 u16 vout_min[LTC2978_NUM_PAGES], vout_max[LTC2978_NUM_PAGES];
110 u16 iout_min[LTC2974_NUM_PAGES], iout_max[LTC2974_NUM_PAGES];
111 u16 iin_min, iin_max;
112 u16 pin_min, pin_max;
114 struct pmbus_driver_info info;
117 #define to_ltc2978_data(x) container_of(x, struct ltc2978_data, info)
119 #define FEAT_CLEAR_PEAKS BIT(0)
120 #define FEAT_NEEDS_POLLING BIT(1)
122 #define has_clear_peaks(d) ((d)->features & FEAT_CLEAR_PEAKS)
123 #define needs_polling(d) ((d)->features & FEAT_NEEDS_POLLING)
125 static int ltc_wait_ready(struct i2c_client *client)
127 unsigned long timeout = jiffies + msecs_to_jiffies(LTC_POLL_TIMEOUT);
128 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
129 struct ltc2978_data *data = to_ltc2978_data(info);
133 if (!needs_polling(data))
137 * LTC3883 does not support LTC_NOT_PENDING, even though
138 * the datasheet claims that it does.
141 if (data->id != ltc3883)
142 mask |= LTC_NOT_PENDING;
145 status = pmbus_read_byte_data(client, 0, LTC2978_MFR_COMMON);
146 if (status == -EBADMSG || status == -ENXIO) {
147 /* PEC error or NACK: chip may be busy, try again */
148 usleep_range(50, 100);
154 if ((status & mask) == mask)
157 usleep_range(50, 100);
158 } while (time_before(jiffies, timeout));
163 static int ltc_read_word_data(struct i2c_client *client, int page, int reg)
167 ret = ltc_wait_ready(client);
171 return pmbus_read_word_data(client, page, reg);
174 static int ltc_read_byte_data(struct i2c_client *client, int page, int reg)
178 ret = ltc_wait_ready(client);
182 return pmbus_read_byte_data(client, page, reg);
185 static int ltc_write_byte(struct i2c_client *client, int page, u8 byte)
189 ret = ltc_wait_ready(client);
193 return pmbus_write_byte(client, page, byte);
196 static inline int lin11_to_val(int data)
198 s16 e = ((s16)data) >> 11;
199 s32 m = (((s16)(data << 5)) >> 5);
202 * mantissa is 10 bit + sign, exponent adds up to 15 bit.
203 * Add 6 bit to exponent for maximum accuracy (10 + 15 + 6 = 31).
206 return (e < 0 ? m >> -e : m << e);
209 static int ltc_get_max(struct ltc2978_data *data, struct i2c_client *client,
210 int page, int reg, u16 *pmax)
214 ret = ltc_read_word_data(client, page, reg);
216 if (lin11_to_val(ret) > lin11_to_val(*pmax))
223 static int ltc_get_min(struct ltc2978_data *data, struct i2c_client *client,
224 int page, int reg, u16 *pmin)
228 ret = ltc_read_word_data(client, page, reg);
230 if (lin11_to_val(ret) < lin11_to_val(*pmin))
237 static int ltc2978_read_word_data_common(struct i2c_client *client, int page,
240 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
241 struct ltc2978_data *data = to_ltc2978_data(info);
245 case PMBUS_VIRT_READ_VIN_MAX:
246 ret = ltc_get_max(data, client, page, LTC2978_MFR_VIN_PEAK,
249 case PMBUS_VIRT_READ_VOUT_MAX:
250 ret = ltc_read_word_data(client, page, LTC2978_MFR_VOUT_PEAK);
253 * VOUT is 16 bit unsigned with fixed exponent,
254 * so we can compare it directly
256 if (ret > data->vout_max[page])
257 data->vout_max[page] = ret;
258 ret = data->vout_max[page];
261 case PMBUS_VIRT_READ_TEMP_MAX:
262 ret = ltc_get_max(data, client, page,
263 LTC2978_MFR_TEMPERATURE_PEAK,
264 &data->temp_max[page]);
266 case PMBUS_VIRT_RESET_VOUT_HISTORY:
267 case PMBUS_VIRT_RESET_VIN_HISTORY:
268 case PMBUS_VIRT_RESET_TEMP_HISTORY:
272 ret = ltc_wait_ready(client);
281 static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg)
283 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
284 struct ltc2978_data *data = to_ltc2978_data(info);
288 case PMBUS_VIRT_READ_VIN_MIN:
289 ret = ltc_get_min(data, client, page, LTC2978_MFR_VIN_MIN,
292 case PMBUS_VIRT_READ_VOUT_MIN:
293 ret = ltc_read_word_data(client, page, LTC2978_MFR_VOUT_MIN);
296 * VOUT_MIN is known to not be supported on some lots
297 * of LTC2978 revision 1, and will return the maximum
298 * possible voltage if read. If VOUT_MAX is valid and
299 * lower than the reading of VOUT_MIN, use it instead.
301 if (data->vout_max[page] && ret > data->vout_max[page])
302 ret = data->vout_max[page];
303 if (ret < data->vout_min[page])
304 data->vout_min[page] = ret;
305 ret = data->vout_min[page];
308 case PMBUS_VIRT_READ_TEMP_MIN:
309 ret = ltc_get_min(data, client, page,
310 LTC2978_MFR_TEMPERATURE_MIN,
311 &data->temp_min[page]);
313 case PMBUS_VIRT_READ_IOUT_MAX:
314 case PMBUS_VIRT_RESET_IOUT_HISTORY:
315 case PMBUS_VIRT_READ_TEMP2_MAX:
316 case PMBUS_VIRT_RESET_TEMP2_HISTORY:
320 ret = ltc2978_read_word_data_common(client, page, reg);
326 static int ltc2974_read_word_data(struct i2c_client *client, int page, int reg)
328 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
329 struct ltc2978_data *data = to_ltc2978_data(info);
333 case PMBUS_VIRT_READ_IOUT_MAX:
334 ret = ltc_get_max(data, client, page, LTC2974_MFR_IOUT_PEAK,
335 &data->iout_max[page]);
337 case PMBUS_VIRT_READ_IOUT_MIN:
338 ret = ltc_get_min(data, client, page, LTC2974_MFR_IOUT_MIN,
339 &data->iout_min[page]);
341 case PMBUS_VIRT_RESET_IOUT_HISTORY:
345 ret = ltc2978_read_word_data(client, page, reg);
351 static int ltc2975_read_word_data(struct i2c_client *client, int page, int reg)
353 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
354 struct ltc2978_data *data = to_ltc2978_data(info);
358 case PMBUS_VIRT_READ_IIN_MAX:
359 ret = ltc_get_max(data, client, page, LTC2975_MFR_IIN_PEAK,
362 case PMBUS_VIRT_READ_IIN_MIN:
363 ret = ltc_get_min(data, client, page, LTC2975_MFR_IIN_MIN,
366 case PMBUS_VIRT_READ_PIN_MAX:
367 ret = ltc_get_max(data, client, page, LTC2975_MFR_PIN_PEAK,
370 case PMBUS_VIRT_READ_PIN_MIN:
371 ret = ltc_get_min(data, client, page, LTC2975_MFR_PIN_MIN,
374 case PMBUS_VIRT_RESET_IIN_HISTORY:
375 case PMBUS_VIRT_RESET_PIN_HISTORY:
379 ret = ltc2978_read_word_data(client, page, reg);
385 static int ltc3880_read_word_data(struct i2c_client *client, int page, int reg)
387 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
388 struct ltc2978_data *data = to_ltc2978_data(info);
392 case PMBUS_VIRT_READ_IOUT_MAX:
393 ret = ltc_get_max(data, client, page, LTC3880_MFR_IOUT_PEAK,
394 &data->iout_max[page]);
396 case PMBUS_VIRT_READ_TEMP2_MAX:
397 ret = ltc_get_max(data, client, page,
398 LTC3880_MFR_TEMPERATURE2_PEAK,
401 case PMBUS_VIRT_READ_VIN_MIN:
402 case PMBUS_VIRT_READ_VOUT_MIN:
403 case PMBUS_VIRT_READ_TEMP_MIN:
406 case PMBUS_VIRT_RESET_IOUT_HISTORY:
407 case PMBUS_VIRT_RESET_TEMP2_HISTORY:
411 ret = ltc2978_read_word_data_common(client, page, reg);
417 static int ltc3883_read_word_data(struct i2c_client *client, int page, int reg)
419 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
420 struct ltc2978_data *data = to_ltc2978_data(info);
424 case PMBUS_VIRT_READ_IIN_MAX:
425 ret = ltc_get_max(data, client, page, LTC3883_MFR_IIN_PEAK,
428 case PMBUS_VIRT_RESET_IIN_HISTORY:
432 ret = ltc3880_read_word_data(client, page, reg);
438 static int ltc2978_clear_peaks(struct ltc2978_data *data,
439 struct i2c_client *client, int page)
443 if (has_clear_peaks(data))
444 ret = ltc_write_byte(client, 0, LTC3880_MFR_CLEAR_PEAKS);
446 ret = ltc_write_byte(client, page, PMBUS_CLEAR_FAULTS);
451 static int ltc2978_write_word_data(struct i2c_client *client, int page,
454 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
455 struct ltc2978_data *data = to_ltc2978_data(info);
459 case PMBUS_VIRT_RESET_IIN_HISTORY:
460 data->iin_max = 0x7c00;
461 data->iin_min = 0x7bff;
462 ret = ltc2978_clear_peaks(data, client, 0);
464 case PMBUS_VIRT_RESET_PIN_HISTORY:
465 data->pin_max = 0x7c00;
466 data->pin_min = 0x7bff;
467 ret = ltc2978_clear_peaks(data, client, 0);
469 case PMBUS_VIRT_RESET_IOUT_HISTORY:
470 data->iout_max[page] = 0x7c00;
471 data->iout_min[page] = 0xfbff;
472 ret = ltc2978_clear_peaks(data, client, page);
474 case PMBUS_VIRT_RESET_TEMP2_HISTORY:
475 data->temp2_max = 0x7c00;
476 ret = ltc2978_clear_peaks(data, client, page);
478 case PMBUS_VIRT_RESET_VOUT_HISTORY:
479 data->vout_min[page] = 0xffff;
480 data->vout_max[page] = 0;
481 ret = ltc2978_clear_peaks(data, client, page);
483 case PMBUS_VIRT_RESET_VIN_HISTORY:
484 data->vin_min = 0x7bff;
485 data->vin_max = 0x7c00;
486 ret = ltc2978_clear_peaks(data, client, page);
488 case PMBUS_VIRT_RESET_TEMP_HISTORY:
489 data->temp_min[page] = 0x7bff;
490 data->temp_max[page] = 0x7c00;
491 ret = ltc2978_clear_peaks(data, client, page);
494 ret = ltc_wait_ready(client);
503 static const struct i2c_device_id ltc2978_id[] = {
504 {"ltc2974", ltc2974},
505 {"ltc2975", ltc2975},
506 {"ltc2977", ltc2977},
507 {"ltc2978", ltc2978},
508 {"ltc2980", ltc2980},
509 {"ltc3880", ltc3880},
510 {"ltc3882", ltc3882},
511 {"ltc3883", ltc3883},
512 {"ltc3886", ltc3886},
513 {"ltc3887", ltc3887},
514 {"ltm2987", ltm2987},
515 {"ltm4675", ltm4675},
516 {"ltm4676", ltm4676},
517 {"ltm4686", ltm4686},
520 MODULE_DEVICE_TABLE(i2c, ltc2978_id);
522 #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
523 static const struct regulator_desc ltc2978_reg_desc[] = {
524 PMBUS_REGULATOR("vout", 0),
525 PMBUS_REGULATOR("vout", 1),
526 PMBUS_REGULATOR("vout", 2),
527 PMBUS_REGULATOR("vout", 3),
528 PMBUS_REGULATOR("vout", 4),
529 PMBUS_REGULATOR("vout", 5),
530 PMBUS_REGULATOR("vout", 6),
531 PMBUS_REGULATOR("vout", 7),
533 #endif /* CONFIG_SENSORS_LTC2978_REGULATOR */
535 static int ltc2978_get_id(struct i2c_client *client)
539 chip_id = i2c_smbus_read_word_data(client, LTC2978_MFR_SPECIAL_ID);
541 const struct i2c_device_id *id;
542 u8 buf[I2C_SMBUS_BLOCK_MAX];
545 if (!i2c_check_functionality(client->adapter,
546 I2C_FUNC_SMBUS_READ_BLOCK_DATA))
549 ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
552 if (ret < 3 || strncmp(buf, "LTC", 3))
555 ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
558 for (id = <c2978_id[0]; strlen(id->name); id++) {
559 if (!strncasecmp(id->name, buf, strlen(id->name)))
560 return (int)id->driver_data;
565 chip_id &= LTC2978_ID_MASK;
567 if (chip_id == LTC2974_ID)
569 else if (chip_id == LTC2975_ID)
571 else if (chip_id == LTC2977_ID)
573 else if (chip_id == LTC2978_ID_REV1 || chip_id == LTC2978_ID_REV2)
575 else if (chip_id == LTC2980_ID_A || chip_id == LTC2980_ID_B)
577 else if (chip_id == LTC3880_ID)
579 else if (chip_id == LTC3882_ID || chip_id == LTC3882_ID_D1)
581 else if (chip_id == LTC3883_ID)
583 else if (chip_id == LTC3886_ID)
585 else if (chip_id == LTC3887_ID)
587 else if (chip_id == LTM2987_ID_A || chip_id == LTM2987_ID_B)
589 else if (chip_id == LTM4675_ID)
591 else if (chip_id == LTM4676_ID_REV1 || chip_id == LTM4676_ID_REV2 ||
592 chip_id == LTM4676A_ID)
594 else if (chip_id == LTM4686_ID)
597 dev_err(&client->dev, "Unsupported chip ID 0x%x\n", chip_id);
601 static int ltc2978_probe(struct i2c_client *client,
602 const struct i2c_device_id *id)
605 struct ltc2978_data *data;
606 struct pmbus_driver_info *info;
608 if (!i2c_check_functionality(client->adapter,
609 I2C_FUNC_SMBUS_READ_WORD_DATA))
612 data = devm_kzalloc(&client->dev, sizeof(struct ltc2978_data),
617 chip_id = ltc2978_get_id(client);
622 if (data->id != id->driver_data)
623 dev_warn(&client->dev,
624 "Device mismatch: Configured %s, detected %s\n",
626 ltc2978_id[data->id].name);
629 info->write_word_data = ltc2978_write_word_data;
630 info->write_byte = ltc_write_byte;
631 info->read_word_data = ltc_read_word_data;
632 info->read_byte_data = ltc_read_byte_data;
634 data->vin_min = 0x7bff;
635 data->vin_max = 0x7c00;
636 for (i = 0; i < ARRAY_SIZE(data->vout_min); i++)
637 data->vout_min[i] = 0xffff;
638 for (i = 0; i < ARRAY_SIZE(data->iout_min); i++)
639 data->iout_min[i] = 0xfbff;
640 for (i = 0; i < ARRAY_SIZE(data->iout_max); i++)
641 data->iout_max[i] = 0x7c00;
642 for (i = 0; i < ARRAY_SIZE(data->temp_min); i++)
643 data->temp_min[i] = 0x7bff;
644 for (i = 0; i < ARRAY_SIZE(data->temp_max); i++)
645 data->temp_max[i] = 0x7c00;
646 data->temp2_max = 0x7c00;
650 info->read_word_data = ltc2974_read_word_data;
651 info->pages = LTC2974_NUM_PAGES;
652 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
654 for (i = 0; i < info->pages; i++) {
655 info->func[i] |= PMBUS_HAVE_VOUT
656 | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_POUT
657 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
658 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT;
662 info->read_word_data = ltc2975_read_word_data;
663 info->pages = LTC2974_NUM_PAGES;
664 info->func[0] = PMBUS_HAVE_IIN | PMBUS_HAVE_PIN
665 | PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
667 for (i = 0; i < info->pages; i++) {
668 info->func[i] |= PMBUS_HAVE_VOUT
669 | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_POUT
670 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
671 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT;
678 info->read_word_data = ltc2978_read_word_data;
679 info->pages = LTC2978_NUM_PAGES;
680 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
681 | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
682 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
683 for (i = 1; i < LTC2978_NUM_PAGES; i++) {
684 info->func[i] = PMBUS_HAVE_VOUT
685 | PMBUS_HAVE_STATUS_VOUT;
693 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING;
694 info->read_word_data = ltc3880_read_word_data;
695 info->pages = LTC3880_NUM_PAGES;
696 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN
697 | PMBUS_HAVE_STATUS_INPUT
698 | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
699 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
700 | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP
701 | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP;
702 info->func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
703 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
705 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
708 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING;
709 info->read_word_data = ltc3880_read_word_data;
710 info->pages = LTC3880_NUM_PAGES;
711 info->func[0] = PMBUS_HAVE_VIN
712 | PMBUS_HAVE_STATUS_INPUT
713 | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
714 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
715 | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP
716 | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP;
717 info->func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
718 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
720 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
723 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING;
724 info->read_word_data = ltc3883_read_word_data;
725 info->pages = LTC3883_NUM_PAGES;
726 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN
727 | PMBUS_HAVE_STATUS_INPUT
728 | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
729 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
730 | PMBUS_HAVE_PIN | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP
731 | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP;
734 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING;
735 info->read_word_data = ltc3883_read_word_data;
736 info->pages = LTC3880_NUM_PAGES;
737 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN
738 | PMBUS_HAVE_STATUS_INPUT
739 | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
740 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
741 | PMBUS_HAVE_PIN | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP
742 | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP;
743 info->func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
744 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
746 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
752 #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
753 info->num_regulators = info->pages;
754 info->reg_desc = ltc2978_reg_desc;
755 if (info->num_regulators > ARRAY_SIZE(ltc2978_reg_desc)) {
756 dev_err(&client->dev, "num_regulators too large!");
757 info->num_regulators = ARRAY_SIZE(ltc2978_reg_desc);
761 return pmbus_do_probe(client, id, info);
765 static const struct of_device_id ltc2978_of_match[] = {
766 { .compatible = "lltc,ltc2974" },
767 { .compatible = "lltc,ltc2975" },
768 { .compatible = "lltc,ltc2977" },
769 { .compatible = "lltc,ltc2978" },
770 { .compatible = "lltc,ltc2980" },
771 { .compatible = "lltc,ltc3880" },
772 { .compatible = "lltc,ltc3882" },
773 { .compatible = "lltc,ltc3883" },
774 { .compatible = "lltc,ltc3886" },
775 { .compatible = "lltc,ltc3887" },
776 { .compatible = "lltc,ltm2987" },
777 { .compatible = "lltc,ltm4675" },
778 { .compatible = "lltc,ltm4676" },
779 { .compatible = "lltc,ltm4686" },
782 MODULE_DEVICE_TABLE(of, ltc2978_of_match);
785 static struct i2c_driver ltc2978_driver = {
788 .of_match_table = of_match_ptr(ltc2978_of_match),
790 .probe = ltc2978_probe,
791 .remove = pmbus_do_remove,
792 .id_table = ltc2978_id,
795 module_i2c_driver(ltc2978_driver);
797 MODULE_AUTHOR("Guenter Roeck");
798 MODULE_DESCRIPTION("PMBus driver for LTC2978 and comppatible chips");
799 MODULE_LICENSE("GPL");