blob: f01f4887fb2e6b92d416d17a8ea75233bdd1ca91 [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Guenter Roeckc3ff9a62011-09-02 09:58:37 -07002/*
Guenter Roeck649ca822015-06-08 09:56:20 -07003 * Hardware monitoring driver for LTC2978 and compatible chips.
Guenter Roeckc3ff9a62011-09-02 09:58:37 -07004 *
5 * Copyright (c) 2011 Ericsson AB.
Guenter Roeck649ca822015-06-08 09:56:20 -07006 * Copyright (c) 2013, 2014, 2015 Guenter Roeck
Michael Jonese04d1ce2015-08-17 17:45:32 -07007 * Copyright (c) 2015 Linear Technology
Michael Hennerich4e15d052018-08-14 14:18:28 +02008 * Copyright (c) 2018 Analog Devices Inc.
Guenter Roeckc3ff9a62011-09-02 09:58:37 -07009 */
10
Michael Jonese04d1ce2015-08-17 17:45:32 -070011#include <linux/delay.h>
12#include <linux/jiffies.h>
Guenter Roeckc3ff9a62011-09-02 09:58:37 -070013#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>
Alan Tull77aa3582014-10-15 13:55:10 -050019#include <linux/regulator/driver.h>
Guenter Roeckc3ff9a62011-09-02 09:58:37 -070020#include "pmbus.h"
21
Guenter Roeck52aae6a2015-08-17 06:38:01 -070022enum chips { ltc2974, ltc2975, ltc2977, ltc2978, ltc2980, ltc3880, ltc3882,
Michael Hennerich4e15d052018-08-14 14:18:28 +020023 ltc3883, ltc3886, ltc3887, ltm2987, ltm4675, ltm4676, ltm4686 };
Guenter Roeckc3ff9a62011-09-02 09:58:37 -070024
Guenter Roeckfd9175d2013-01-27 09:24:28 -080025/* Common for all chips */
Guenter Roeckc3ff9a62011-09-02 09:58:37 -070026#define LTC2978_MFR_VOUT_PEAK 0xdd
27#define LTC2978_MFR_VIN_PEAK 0xde
28#define LTC2978_MFR_TEMPERATURE_PEAK 0xdf
Guenter Roeckacb092c2015-08-17 06:27:56 -070029#define LTC2978_MFR_SPECIAL_ID 0xe7 /* Undocumented on LTC3882 */
Michael Jonese04d1ce2015-08-17 17:45:32 -070030#define LTC2978_MFR_COMMON 0xef
Guenter Roeckc3ff9a62011-09-02 09:58:37 -070031
Guenter Roeck52aae6a2015-08-17 06:38:01 -070032/* LTC2974, LTC2975, LCT2977, LTC2980, LTC2978, and LTM2987 */
Guenter Roeckc3ff9a62011-09-02 09:58:37 -070033#define LTC2978_MFR_VOUT_MIN 0xfb
34#define LTC2978_MFR_VIN_MIN 0xfc
35#define LTC2978_MFR_TEMPERATURE_MIN 0xfd
36
Guenter Roeck649ca822015-06-08 09:56:20 -070037/* LTC2974, LTC2975 */
Guenter Roeckfd9175d2013-01-27 09:24:28 -080038#define LTC2974_MFR_IOUT_PEAK 0xd7
39#define LTC2974_MFR_IOUT_MIN 0xd8
40
Guenter Roeckccf2dc52015-08-17 20:08:09 -070041/* LTC3880, LTC3882, LTC3883, LTC3887, LTM4675, and LTM4676 */
Guenter Roeckddfb41c2011-09-11 20:31:09 -070042#define LTC3880_MFR_IOUT_PEAK 0xd7
43#define LTC3880_MFR_CLEAR_PEAKS 0xe3
44#define LTC3880_MFR_TEMPERATURE2_PEAK 0xf4
45
Guenter Roeck228b6872015-08-17 07:21:43 -070046/* LTC3883 and LTC3886 only */
Guenter Roeckfd9175d2013-01-27 09:24:28 -080047#define LTC3883_MFR_IIN_PEAK 0xe1
48
Guenter Roeck649ca822015-06-08 09:56:20 -070049/* LTC2975 only */
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
54
Guenter Roeck00c83372015-08-17 06:21:01 -070055#define LTC2978_ID_MASK 0xfff0
56
57#define LTC2974_ID 0x0210
58#define LTC2975_ID 0x0220
Guenter Roeckc24c407e2013-09-23 10:56:48 -070059#define LTC2977_ID 0x0130
Guenter Roeckacb092c2015-08-17 06:27:56 -070060#define LTC2978_ID_REV1 0x0110 /* Early revision */
61#define LTC2978_ID_REV2 0x0120
Guenter Roeck52aae6a2015-08-17 06:38:01 -070062#define LTC2980_ID_A 0x8030 /* A/B for two die IDs */
63#define LTC2980_ID_B 0x8040
Guenter Roeck00c83372015-08-17 06:21:01 -070064#define LTC3880_ID 0x4020
Guenter Roeckacb092c2015-08-17 06:27:56 -070065#define LTC3882_ID 0x4200
66#define LTC3882_ID_D1 0x4240 /* Dash 1 */
Guenter Roeckfd9175d2013-01-27 09:24:28 -080067#define LTC3883_ID 0x4300
Guenter Roeck228b6872015-08-17 07:21:43 -070068#define LTC3886_ID 0x4600
Guenter Roeck15398562015-08-07 09:06:37 -070069#define LTC3887_ID 0x4700
Guenter Roeck52aae6a2015-08-17 06:38:01 -070070#define LTM2987_ID_A 0x8010 /* A/B for two die IDs */
71#define LTM2987_ID_B 0x8020
Guenter Roeckccf2dc52015-08-17 20:08:09 -070072#define LTM4675_ID 0x47a0
Guenter Roeck00c83372015-08-17 06:21:01 -070073#define LTM4676_ID_REV1 0x4400
74#define LTM4676_ID_REV2 0x4480
Guenter Roeck15398562015-08-07 09:06:37 -070075#define LTM4676A_ID 0x47e0
Michael Hennerich4e15d052018-08-14 14:18:28 +020076#define LTM4686_ID 0x4770
Guenter Roeckc3ff9a62011-09-02 09:58:37 -070077
Guenter Roeckfd9175d2013-01-27 09:24:28 -080078#define LTC2974_NUM_PAGES 4
Guenter Roeck3d0d2832013-02-28 08:14:45 -080079#define LTC2978_NUM_PAGES 8
80#define LTC3880_NUM_PAGES 2
Guenter Roeckfd9175d2013-01-27 09:24:28 -080081#define LTC3883_NUM_PAGES 1
Guenter Roeck3d0d2832013-02-28 08:14:45 -080082
Michael Jonese04d1ce2015-08-17 17:45:32 -070083#define LTC_POLL_TIMEOUT 100 /* in milli-seconds */
84
85#define LTC_NOT_BUSY BIT(5)
86#define LTC_NOT_PENDING BIT(4)
87
Guenter Roeckc3ff9a62011-09-02 09:58:37 -070088/*
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.
94 */
Guenter Roeck3d0d2832013-02-28 08:14:45 -080095
Guenter Roeckc3ff9a62011-09-02 09:58:37 -070096struct ltc2978_data {
97 enum chips id;
Guenter Roeck3d0d2832013-02-28 08:14:45 -080098 u16 vin_min, vin_max;
Guenter Roeckfd9175d2013-01-27 09:24:28 -080099 u16 temp_min[LTC2974_NUM_PAGES], temp_max[LTC2974_NUM_PAGES];
Guenter Roeck3d0d2832013-02-28 08:14:45 -0800100 u16 vout_min[LTC2978_NUM_PAGES], vout_max[LTC2978_NUM_PAGES];
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800101 u16 iout_min[LTC2974_NUM_PAGES], iout_max[LTC2974_NUM_PAGES];
Guenter Roeck649ca822015-06-08 09:56:20 -0700102 u16 iin_min, iin_max;
103 u16 pin_min, pin_max;
Guenter Roeck3d0d2832013-02-28 08:14:45 -0800104 u16 temp2_max;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700105 struct pmbus_driver_info info;
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700106 u32 features;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700107};
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700108#define to_ltc2978_data(x) container_of(x, struct ltc2978_data, info)
109
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700110#define FEAT_CLEAR_PEAKS BIT(0)
Michael Jonese04d1ce2015-08-17 17:45:32 -0700111#define FEAT_NEEDS_POLLING BIT(1)
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700112
113#define has_clear_peaks(d) ((d)->features & FEAT_CLEAR_PEAKS)
Michael Jonese04d1ce2015-08-17 17:45:32 -0700114#define needs_polling(d) ((d)->features & FEAT_NEEDS_POLLING)
115
116static int ltc_wait_ready(struct i2c_client *client)
117{
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);
121 int status;
122 u8 mask;
123
124 if (!needs_polling(data))
125 return 0;
126
127 /*
128 * LTC3883 does not support LTC_NOT_PENDING, even though
129 * the datasheet claims that it does.
130 */
131 mask = LTC_NOT_BUSY;
132 if (data->id != ltc3883)
133 mask |= LTC_NOT_PENDING;
134
135 do {
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);
140 continue;
141 }
142 if (status < 0)
143 return status;
144
145 if ((status & mask) == mask)
146 return 0;
147
148 usleep_range(50, 100);
149 } while (time_before(jiffies, timeout));
150
151 return -ETIMEDOUT;
152}
153
154static int ltc_read_word_data(struct i2c_client *client, int page, int reg)
155{
156 int ret;
157
158 ret = ltc_wait_ready(client);
159 if (ret < 0)
160 return ret;
161
162 return pmbus_read_word_data(client, page, reg);
163}
164
165static int ltc_read_byte_data(struct i2c_client *client, int page, int reg)
166{
167 int ret;
168
169 ret = ltc_wait_ready(client);
170 if (ret < 0)
171 return ret;
172
173 return pmbus_read_byte_data(client, page, reg);
174}
175
176static int ltc_write_byte(struct i2c_client *client, int page, u8 byte)
177{
178 int ret;
179
180 ret = ltc_wait_ready(client);
181 if (ret < 0)
182 return ret;
183
184 return pmbus_write_byte(client, page, byte);
185}
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700186
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700187static inline int lin11_to_val(int data)
188{
189 s16 e = ((s16)data) >> 11;
190 s32 m = (((s16)(data << 5)) >> 5);
191
192 /*
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).
195 */
196 e += 6;
197 return (e < 0 ? m >> -e : m << e);
198}
199
Guenter Roeckee847a22015-08-15 17:17:53 -0700200static int ltc_get_max(struct ltc2978_data *data, struct i2c_client *client,
201 int page, int reg, u16 *pmax)
202{
203 int ret;
204
Michael Jonese04d1ce2015-08-17 17:45:32 -0700205 ret = ltc_read_word_data(client, page, reg);
Guenter Roeckee847a22015-08-15 17:17:53 -0700206 if (ret >= 0) {
207 if (lin11_to_val(ret) > lin11_to_val(*pmax))
208 *pmax = ret;
209 ret = *pmax;
210 }
211 return ret;
212}
213
214static int ltc_get_min(struct ltc2978_data *data, struct i2c_client *client,
215 int page, int reg, u16 *pmin)
216{
217 int ret;
218
Michael Jonese04d1ce2015-08-17 17:45:32 -0700219 ret = ltc_read_word_data(client, page, reg);
Guenter Roeckee847a22015-08-15 17:17:53 -0700220 if (ret >= 0) {
221 if (lin11_to_val(ret) < lin11_to_val(*pmin))
222 *pmin = ret;
223 ret = *pmin;
224 }
225 return ret;
226}
227
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700228static int ltc2978_read_word_data_common(struct i2c_client *client, int page,
229 int reg)
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700230{
231 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
232 struct ltc2978_data *data = to_ltc2978_data(info);
233 int ret;
234
235 switch (reg) {
236 case PMBUS_VIRT_READ_VIN_MAX:
Guenter Roeckee847a22015-08-15 17:17:53 -0700237 ret = ltc_get_max(data, client, page, LTC2978_MFR_VIN_PEAK,
238 &data->vin_max);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700239 break;
240 case PMBUS_VIRT_READ_VOUT_MAX:
Michael Jonese04d1ce2015-08-17 17:45:32 -0700241 ret = ltc_read_word_data(client, page, LTC2978_MFR_VOUT_PEAK);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700242 if (ret >= 0) {
243 /*
244 * VOUT is 16 bit unsigned with fixed exponent,
245 * so we can compare it directly
246 */
247 if (ret > data->vout_max[page])
248 data->vout_max[page] = ret;
249 ret = data->vout_max[page];
250 }
251 break;
252 case PMBUS_VIRT_READ_TEMP_MAX:
Guenter Roeckee847a22015-08-15 17:17:53 -0700253 ret = ltc_get_max(data, client, page,
254 LTC2978_MFR_TEMPERATURE_PEAK,
255 &data->temp_max[page]);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700256 break;
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700257 case PMBUS_VIRT_RESET_VOUT_HISTORY:
258 case PMBUS_VIRT_RESET_VIN_HISTORY:
259 case PMBUS_VIRT_RESET_TEMP_HISTORY:
260 ret = 0;
261 break;
262 default:
Michael Jonese04d1ce2015-08-17 17:45:32 -0700263 ret = ltc_wait_ready(client);
264 if (ret < 0)
265 return ret;
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700266 ret = -ENODATA;
267 break;
268 }
269 return ret;
270}
271
272static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg)
273{
274 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
275 struct ltc2978_data *data = to_ltc2978_data(info);
276 int ret;
277
278 switch (reg) {
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700279 case PMBUS_VIRT_READ_VIN_MIN:
Guenter Roeckee847a22015-08-15 17:17:53 -0700280 ret = ltc_get_min(data, client, page, LTC2978_MFR_VIN_MIN,
281 &data->vin_min);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700282 break;
283 case PMBUS_VIRT_READ_VOUT_MIN:
Michael Jonese04d1ce2015-08-17 17:45:32 -0700284 ret = ltc_read_word_data(client, page, LTC2978_MFR_VOUT_MIN);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700285 if (ret >= 0) {
286 /*
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.
291 */
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];
297 }
298 break;
299 case PMBUS_VIRT_READ_TEMP_MIN:
Guenter Roeckee847a22015-08-15 17:17:53 -0700300 ret = ltc_get_min(data, client, page,
301 LTC2978_MFR_TEMPERATURE_MIN,
302 &data->temp_min[page]);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700303 break;
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700304 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:
308 ret = -ENXIO;
309 break;
310 default:
311 ret = ltc2978_read_word_data_common(client, page, reg);
312 break;
313 }
314 return ret;
315}
316
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800317static int ltc2974_read_word_data(struct i2c_client *client, int page, int reg)
318{
319 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
320 struct ltc2978_data *data = to_ltc2978_data(info);
321 int ret;
322
323 switch (reg) {
324 case PMBUS_VIRT_READ_IOUT_MAX:
Guenter Roeckee847a22015-08-15 17:17:53 -0700325 ret = ltc_get_max(data, client, page, LTC2974_MFR_IOUT_PEAK,
326 &data->iout_max[page]);
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800327 break;
328 case PMBUS_VIRT_READ_IOUT_MIN:
Guenter Roeckee847a22015-08-15 17:17:53 -0700329 ret = ltc_get_min(data, client, page, LTC2974_MFR_IOUT_MIN,
330 &data->iout_min[page]);
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800331 break;
332 case PMBUS_VIRT_RESET_IOUT_HISTORY:
333 ret = 0;
334 break;
335 default:
336 ret = ltc2978_read_word_data(client, page, reg);
337 break;
338 }
339 return ret;
340}
341
Guenter Roeck649ca822015-06-08 09:56:20 -0700342static int ltc2975_read_word_data(struct i2c_client *client, int page, int reg)
343{
344 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
345 struct ltc2978_data *data = to_ltc2978_data(info);
346 int ret;
347
348 switch (reg) {
349 case PMBUS_VIRT_READ_IIN_MAX:
Guenter Roeckee847a22015-08-15 17:17:53 -0700350 ret = ltc_get_max(data, client, page, LTC2975_MFR_IIN_PEAK,
351 &data->iin_max);
Guenter Roeck649ca822015-06-08 09:56:20 -0700352 break;
353 case PMBUS_VIRT_READ_IIN_MIN:
Guenter Roeckee847a22015-08-15 17:17:53 -0700354 ret = ltc_get_min(data, client, page, LTC2975_MFR_IIN_MIN,
355 &data->iin_min);
Guenter Roeck649ca822015-06-08 09:56:20 -0700356 break;
357 case PMBUS_VIRT_READ_PIN_MAX:
Guenter Roeckee847a22015-08-15 17:17:53 -0700358 ret = ltc_get_max(data, client, page, LTC2975_MFR_PIN_PEAK,
359 &data->pin_max);
Guenter Roeck649ca822015-06-08 09:56:20 -0700360 break;
361 case PMBUS_VIRT_READ_PIN_MIN:
Guenter Roeckee847a22015-08-15 17:17:53 -0700362 ret = ltc_get_min(data, client, page, LTC2975_MFR_PIN_MIN,
363 &data->pin_min);
Guenter Roeck649ca822015-06-08 09:56:20 -0700364 break;
365 case PMBUS_VIRT_RESET_IIN_HISTORY:
366 case PMBUS_VIRT_RESET_PIN_HISTORY:
367 ret = 0;
368 break;
369 default:
370 ret = ltc2978_read_word_data(client, page, reg);
371 break;
372 }
373 return ret;
374}
375
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700376static int ltc3880_read_word_data(struct i2c_client *client, int page, int reg)
377{
378 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
379 struct ltc2978_data *data = to_ltc2978_data(info);
380 int ret;
381
382 switch (reg) {
383 case PMBUS_VIRT_READ_IOUT_MAX:
Guenter Roeckee847a22015-08-15 17:17:53 -0700384 ret = ltc_get_max(data, client, page, LTC3880_MFR_IOUT_PEAK,
385 &data->iout_max[page]);
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700386 break;
387 case PMBUS_VIRT_READ_TEMP2_MAX:
Guenter Roeckee847a22015-08-15 17:17:53 -0700388 ret = ltc_get_max(data, client, page,
389 LTC3880_MFR_TEMPERATURE2_PEAK,
390 &data->temp2_max);
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700391 break;
392 case PMBUS_VIRT_READ_VIN_MIN:
393 case PMBUS_VIRT_READ_VOUT_MIN:
394 case PMBUS_VIRT_READ_TEMP_MIN:
395 ret = -ENXIO;
396 break;
397 case PMBUS_VIRT_RESET_IOUT_HISTORY:
398 case PMBUS_VIRT_RESET_TEMP2_HISTORY:
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700399 ret = 0;
400 break;
401 default:
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700402 ret = ltc2978_read_word_data_common(client, page, reg);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700403 break;
404 }
405 return ret;
406}
407
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800408static int ltc3883_read_word_data(struct i2c_client *client, int page, int reg)
409{
410 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
411 struct ltc2978_data *data = to_ltc2978_data(info);
412 int ret;
413
414 switch (reg) {
415 case PMBUS_VIRT_READ_IIN_MAX:
Guenter Roeckee847a22015-08-15 17:17:53 -0700416 ret = ltc_get_max(data, client, page, LTC3883_MFR_IIN_PEAK,
417 &data->iin_max);
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800418 break;
419 case PMBUS_VIRT_RESET_IIN_HISTORY:
420 ret = 0;
421 break;
422 default:
423 ret = ltc3880_read_word_data(client, page, reg);
424 break;
425 }
426 return ret;
427}
428
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700429static int ltc2978_clear_peaks(struct ltc2978_data *data,
430 struct i2c_client *client, int page)
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700431{
432 int ret;
433
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700434 if (has_clear_peaks(data))
Michael Jonese04d1ce2015-08-17 17:45:32 -0700435 ret = ltc_write_byte(client, 0, LTC3880_MFR_CLEAR_PEAKS);
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800436 else
Michael Jonese04d1ce2015-08-17 17:45:32 -0700437 ret = ltc_write_byte(client, page, PMBUS_CLEAR_FAULTS);
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700438
439 return ret;
440}
441
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700442static int ltc2978_write_word_data(struct i2c_client *client, int page,
443 int reg, u16 word)
444{
445 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
446 struct ltc2978_data *data = to_ltc2978_data(info);
447 int ret;
448
449 switch (reg) {
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800450 case PMBUS_VIRT_RESET_IIN_HISTORY:
451 data->iin_max = 0x7c00;
Guenter Roeck649ca822015-06-08 09:56:20 -0700452 data->iin_min = 0x7bff;
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700453 ret = ltc2978_clear_peaks(data, client, 0);
Guenter Roeck649ca822015-06-08 09:56:20 -0700454 break;
455 case PMBUS_VIRT_RESET_PIN_HISTORY:
456 data->pin_max = 0x7c00;
457 data->pin_min = 0x7bff;
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700458 ret = ltc2978_clear_peaks(data, client, 0);
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800459 break;
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700460 case PMBUS_VIRT_RESET_IOUT_HISTORY:
Guenter Roeckdbd712c2013-02-21 09:33:25 -0800461 data->iout_max[page] = 0x7c00;
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800462 data->iout_min[page] = 0xfbff;
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700463 ret = ltc2978_clear_peaks(data, client, page);
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700464 break;
465 case PMBUS_VIRT_RESET_TEMP2_HISTORY:
Guenter Roeckdbd712c2013-02-21 09:33:25 -0800466 data->temp2_max = 0x7c00;
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700467 ret = ltc2978_clear_peaks(data, client, page);
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700468 break;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700469 case PMBUS_VIRT_RESET_VOUT_HISTORY:
470 data->vout_min[page] = 0xffff;
471 data->vout_max[page] = 0;
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700472 ret = ltc2978_clear_peaks(data, client, page);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700473 break;
474 case PMBUS_VIRT_RESET_VIN_HISTORY:
475 data->vin_min = 0x7bff;
Guenter Roeckdbd712c2013-02-21 09:33:25 -0800476 data->vin_max = 0x7c00;
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700477 ret = ltc2978_clear_peaks(data, client, page);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700478 break;
479 case PMBUS_VIRT_RESET_TEMP_HISTORY:
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800480 data->temp_min[page] = 0x7bff;
Guenter Roeck8c958c72013-02-21 10:27:54 -0800481 data->temp_max[page] = 0x7c00;
Guenter Roeck8582bcc2015-08-15 17:02:09 -0700482 ret = ltc2978_clear_peaks(data, client, page);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700483 break;
484 default:
Michael Jonese04d1ce2015-08-17 17:45:32 -0700485 ret = ltc_wait_ready(client);
486 if (ret < 0)
487 return ret;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700488 ret = -ENODATA;
489 break;
490 }
491 return ret;
492}
493
494static const struct i2c_device_id ltc2978_id[] = {
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800495 {"ltc2974", ltc2974},
Guenter Roeck649ca822015-06-08 09:56:20 -0700496 {"ltc2975", ltc2975},
Guenter Roeckc24c407e2013-09-23 10:56:48 -0700497 {"ltc2977", ltc2977},
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700498 {"ltc2978", ltc2978},
Guenter Roeck52aae6a2015-08-17 06:38:01 -0700499 {"ltc2980", ltc2980},
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700500 {"ltc3880", ltc3880},
Guenter Roeckbf893862015-06-08 10:29:45 -0700501 {"ltc3882", ltc3882},
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800502 {"ltc3883", ltc3883},
Guenter Roeck228b6872015-08-17 07:21:43 -0700503 {"ltc3886", ltc3886},
Guenter Roeck15398562015-08-07 09:06:37 -0700504 {"ltc3887", ltc3887},
Guenter Roeck52aae6a2015-08-17 06:38:01 -0700505 {"ltm2987", ltm2987},
Guenter Roeckccf2dc52015-08-17 20:08:09 -0700506 {"ltm4675", ltm4675},
Guenter Roeckf76992b2014-03-05 21:23:01 -0800507 {"ltm4676", ltm4676},
Michael Hennerich4e15d052018-08-14 14:18:28 +0200508 {"ltm4686", ltm4686},
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700509 {}
510};
511MODULE_DEVICE_TABLE(i2c, ltc2978_id);
512
Alan Tull77aa3582014-10-15 13:55:10 -0500513#if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
514static 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),
523};
524#endif /* CONFIG_SENSORS_LTC2978_REGULATOR */
525
Guenter Roeck836954d2015-06-08 10:14:00 -0700526static int ltc2978_get_id(struct i2c_client *client)
527{
528 int chip_id;
529
530 chip_id = i2c_smbus_read_word_data(client, LTC2978_MFR_SPECIAL_ID);
Guenter Roeckbf893862015-06-08 10:29:45 -0700531 if (chip_id < 0) {
532 const struct i2c_device_id *id;
533 u8 buf[I2C_SMBUS_BLOCK_MAX];
534 int ret;
535
536 if (!i2c_check_functionality(client->adapter,
537 I2C_FUNC_SMBUS_READ_BLOCK_DATA))
538 return -ENODEV;
539
540 ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
541 if (ret < 0)
542 return ret;
543 if (ret < 3 || strncmp(buf, "LTC", 3))
544 return -ENODEV;
545
546 ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
547 if (ret < 0)
548 return ret;
549 for (id = &ltc2978_id[0]; strlen(id->name); id++) {
550 if (!strncasecmp(id->name, buf, strlen(id->name)))
551 return (int)id->driver_data;
552 }
553 return -ENODEV;
554 }
Guenter Roeck836954d2015-06-08 10:14:00 -0700555
Guenter Roeck00c83372015-08-17 06:21:01 -0700556 chip_id &= LTC2978_ID_MASK;
557
558 if (chip_id == LTC2974_ID)
Guenter Roeck836954d2015-06-08 10:14:00 -0700559 return ltc2974;
Guenter Roeck649ca822015-06-08 09:56:20 -0700560 else if (chip_id == LTC2975_ID)
561 return ltc2975;
Guenter Roeck836954d2015-06-08 10:14:00 -0700562 else if (chip_id == LTC2977_ID)
563 return ltc2977;
Guenter Roeckacb092c2015-08-17 06:27:56 -0700564 else if (chip_id == LTC2978_ID_REV1 || chip_id == LTC2978_ID_REV2)
Guenter Roeck836954d2015-06-08 10:14:00 -0700565 return ltc2978;
Guenter Roeck52aae6a2015-08-17 06:38:01 -0700566 else if (chip_id == LTC2980_ID_A || chip_id == LTC2980_ID_B)
567 return ltc2980;
Guenter Roeck00c83372015-08-17 06:21:01 -0700568 else if (chip_id == LTC3880_ID)
Guenter Roeck836954d2015-06-08 10:14:00 -0700569 return ltc3880;
Guenter Roeckacb092c2015-08-17 06:27:56 -0700570 else if (chip_id == LTC3882_ID || chip_id == LTC3882_ID_D1)
571 return ltc3882;
Guenter Roeck00c83372015-08-17 06:21:01 -0700572 else if (chip_id == LTC3883_ID)
Guenter Roeck836954d2015-06-08 10:14:00 -0700573 return ltc3883;
Guenter Roeck228b6872015-08-17 07:21:43 -0700574 else if (chip_id == LTC3886_ID)
575 return ltc3886;
Guenter Roeck00c83372015-08-17 06:21:01 -0700576 else if (chip_id == LTC3887_ID)
Guenter Roeck15398562015-08-07 09:06:37 -0700577 return ltc3887;
Guenter Roeck52aae6a2015-08-17 06:38:01 -0700578 else if (chip_id == LTM2987_ID_A || chip_id == LTM2987_ID_B)
579 return ltm2987;
Guenter Roeckccf2dc52015-08-17 20:08:09 -0700580 else if (chip_id == LTM4675_ID)
581 return ltm4675;
Guenter Roeck00c83372015-08-17 06:21:01 -0700582 else if (chip_id == LTM4676_ID_REV1 || chip_id == LTM4676_ID_REV2 ||
583 chip_id == LTM4676A_ID)
Guenter Roeck836954d2015-06-08 10:14:00 -0700584 return ltm4676;
Michael Hennerich4e15d052018-08-14 14:18:28 +0200585 else if (chip_id == LTM4686_ID)
586 return ltm4686;
Guenter Roeck836954d2015-06-08 10:14:00 -0700587
588 dev_err(&client->dev, "Unsupported chip ID 0x%x\n", chip_id);
589 return -ENODEV;
590}
591
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700592static int ltc2978_probe(struct i2c_client *client,
593 const struct i2c_device_id *id)
594{
Guenter Roeck836954d2015-06-08 10:14:00 -0700595 int i, chip_id;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700596 struct ltc2978_data *data;
597 struct pmbus_driver_info *info;
598
599 if (!i2c_check_functionality(client->adapter,
600 I2C_FUNC_SMBUS_READ_WORD_DATA))
601 return -ENODEV;
602
Guenter Roeck8b313ca2012-02-22 08:56:43 -0800603 data = devm_kzalloc(&client->dev, sizeof(struct ltc2978_data),
604 GFP_KERNEL);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700605 if (!data)
606 return -ENOMEM;
607
Guenter Roeck836954d2015-06-08 10:14:00 -0700608 chip_id = ltc2978_get_id(client);
Guenter Roeck8b313ca2012-02-22 08:56:43 -0800609 if (chip_id < 0)
610 return chip_id;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700611
Guenter Roeck836954d2015-06-08 10:14:00 -0700612 data->id = chip_id;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700613 if (data->id != id->driver_data)
614 dev_warn(&client->dev,
615 "Device mismatch: Configured %s, detected %s\n",
616 id->name,
617 ltc2978_id[data->id].name);
618
619 info = &data->info;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700620 info->write_word_data = ltc2978_write_word_data;
Michael Jonese04d1ce2015-08-17 17:45:32 -0700621 info->write_byte = ltc_write_byte;
622 info->read_word_data = ltc_read_word_data;
623 info->read_byte_data = ltc_read_byte_data;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700624
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700625 data->vin_min = 0x7bff;
Guenter Roeckdbd712c2013-02-21 09:33:25 -0800626 data->vin_max = 0x7c00;
Guenter Roeck3d0d2832013-02-28 08:14:45 -0800627 for (i = 0; i < ARRAY_SIZE(data->vout_min); i++)
628 data->vout_min[i] = 0xffff;
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800629 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;
Guenter Roeck8c958c72013-02-21 10:27:54 -0800635 for (i = 0; i < ARRAY_SIZE(data->temp_max); i++)
636 data->temp_max[i] = 0x7c00;
Guenter Roeckdbd712c2013-02-21 09:33:25 -0800637 data->temp2_max = 0x7c00;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700638
Guenter Roeckf366fcc2013-02-21 10:49:40 -0800639 switch (data->id) {
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800640 case ltc2974:
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
644 | PMBUS_HAVE_TEMP2;
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;
650 }
651 break;
Guenter Roeck649ca822015-06-08 09:56:20 -0700652 case ltc2975:
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
657 | PMBUS_HAVE_TEMP2;
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;
663 }
664 break;
Guenter Roeckc24c407e2013-09-23 10:56:48 -0700665 case ltc2977:
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700666 case ltc2978:
Guenter Roeck52aae6a2015-08-17 06:38:01 -0700667 case ltc2980:
668 case ltm2987:
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700669 info->read_word_data = ltc2978_read_word_data;
Guenter Roeck3d0d2832013-02-28 08:14:45 -0800670 info->pages = LTC2978_NUM_PAGES;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700671 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;
Guenter Roeck3d0d2832013-02-28 08:14:45 -0800674 for (i = 1; i < LTC2978_NUM_PAGES; i++) {
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700675 info->func[i] = PMBUS_HAVE_VOUT
676 | PMBUS_HAVE_STATUS_VOUT;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700677 }
678 break;
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700679 case ltc3880:
Guenter Roeck15398562015-08-07 09:06:37 -0700680 case ltc3887:
Guenter Roeckccf2dc52015-08-17 20:08:09 -0700681 case ltm4675:
Guenter Roeckf76992b2014-03-05 21:23:01 -0800682 case ltm4676:
Michael Hennerich4e15d052018-08-14 14:18:28 +0200683 case ltm4686:
Michael Jonese04d1ce2015-08-17 17:45:32 -0700684 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING;
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700685 info->read_word_data = ltc3880_read_word_data;
Guenter Roeck3d0d2832013-02-28 08:14:45 -0800686 info->pages = LTC3880_NUM_PAGES;
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700687 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
695 | PMBUS_HAVE_POUT
696 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800697 break;
Guenter Roeckbf893862015-06-08 10:29:45 -0700698 case ltc3882:
Michael Jonese04d1ce2015-08-17 17:45:32 -0700699 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING;
Guenter Roeckbf893862015-06-08 10:29:45 -0700700 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
710 | PMBUS_HAVE_POUT
711 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
712 break;
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800713 case ltc3883:
Michael Jonese04d1ce2015-08-17 17:45:32 -0700714 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING;
Guenter Roeckfd9175d2013-01-27 09:24:28 -0800715 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;
Guenter Roeckddfb41c2011-09-11 20:31:09 -0700723 break;
Guenter Roeck228b6872015-08-17 07:21:43 -0700724 case ltc3886:
Michael Jonese04d1ce2015-08-17 17:45:32 -0700725 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING;
Guenter Roeck228b6872015-08-17 07:21:43 -0700726 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
736 | PMBUS_HAVE_POUT
737 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
738 break;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700739 default:
Guenter Roeck8b313ca2012-02-22 08:56:43 -0800740 return -ENODEV;
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700741 }
Alan Tull77aa3582014-10-15 13:55:10 -0500742
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);
749 }
750#endif
751
Guenter Roeck8b313ca2012-02-22 08:56:43 -0800752 return pmbus_do_probe(client, id, info);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700753}
754
Alan Tull77aa3582014-10-15 13:55:10 -0500755#ifdef CONFIG_OF
756static const struct of_device_id ltc2978_of_match[] = {
757 { .compatible = "lltc,ltc2974" },
Guenter Roeck649ca822015-06-08 09:56:20 -0700758 { .compatible = "lltc,ltc2975" },
Alan Tull77aa3582014-10-15 13:55:10 -0500759 { .compatible = "lltc,ltc2977" },
760 { .compatible = "lltc,ltc2978" },
Guenter Roeck52aae6a2015-08-17 06:38:01 -0700761 { .compatible = "lltc,ltc2980" },
Alan Tull77aa3582014-10-15 13:55:10 -0500762 { .compatible = "lltc,ltc3880" },
Guenter Roeckbf893862015-06-08 10:29:45 -0700763 { .compatible = "lltc,ltc3882" },
Alan Tull77aa3582014-10-15 13:55:10 -0500764 { .compatible = "lltc,ltc3883" },
Guenter Roeck228b6872015-08-17 07:21:43 -0700765 { .compatible = "lltc,ltc3886" },
Guenter Roeck15398562015-08-07 09:06:37 -0700766 { .compatible = "lltc,ltc3887" },
Guenter Roeck52aae6a2015-08-17 06:38:01 -0700767 { .compatible = "lltc,ltm2987" },
Guenter Roeckccf2dc52015-08-17 20:08:09 -0700768 { .compatible = "lltc,ltm4675" },
Alan Tull77aa3582014-10-15 13:55:10 -0500769 { .compatible = "lltc,ltm4676" },
Michael Hennerich4e15d052018-08-14 14:18:28 +0200770 { .compatible = "lltc,ltm4686" },
Alan Tull77aa3582014-10-15 13:55:10 -0500771 { }
772};
773MODULE_DEVICE_TABLE(of, ltc2978_of_match);
774#endif
775
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700776static struct i2c_driver ltc2978_driver = {
777 .driver = {
778 .name = "ltc2978",
Alan Tull77aa3582014-10-15 13:55:10 -0500779 .of_match_table = of_match_ptr(ltc2978_of_match),
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700780 },
781 .probe = ltc2978_probe,
Guenter Roeckdd285ad2012-02-22 08:56:44 -0800782 .remove = pmbus_do_remove,
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700783 .id_table = ltc2978_id,
784};
785
Axel Linf0967ee2012-01-20 15:38:18 +0800786module_i2c_driver(ltc2978_driver);
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700787
788MODULE_AUTHOR("Guenter Roeck");
Colin Ian King89688e82018-11-26 16:28:32 +0000789MODULE_DESCRIPTION("PMBus driver for LTC2978 and compatible chips");
Guenter Roeckc3ff9a62011-09-02 09:58:37 -0700790MODULE_LICENSE("GPL");