Commit | Line | Data |
---|---|---|
c3ff9a67 | 1 | /* |
fd9175d2 | 2 | * Hardware monitoring driver for LTC2974, LTC2978, LTC3880, and LTC3883 |
c3ff9a67 GR |
3 | * |
4 | * Copyright (c) 2011 Ericsson AB. | |
fd9175d2 | 5 | * Copyright (c) 2013 Guenter Roeck |
c3ff9a67 GR |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | */ | |
21 | ||
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 "pmbus.h" | |
29 | ||
fd9175d2 | 30 | enum chips { ltc2974, ltc2978, ltc3880, ltc3883 }; |
c3ff9a67 | 31 | |
fd9175d2 | 32 | /* Common for all chips */ |
c3ff9a67 GR |
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 | |
37 | ||
fd9175d2 | 38 | /* LTC2974 and LTC2978 */ |
c3ff9a67 GR |
39 | #define LTC2978_MFR_VOUT_MIN 0xfb |
40 | #define LTC2978_MFR_VIN_MIN 0xfc | |
41 | #define LTC2978_MFR_TEMPERATURE_MIN 0xfd | |
42 | ||
fd9175d2 GR |
43 | /* LTC2974 only */ |
44 | #define LTC2974_MFR_IOUT_PEAK 0xd7 | |
45 | #define LTC2974_MFR_IOUT_MIN 0xd8 | |
46 | ||
47 | /* LTC3880 and LTC3883 */ | |
ddfb41ca GR |
48 | #define LTC3880_MFR_IOUT_PEAK 0xd7 |
49 | #define LTC3880_MFR_CLEAR_PEAKS 0xe3 | |
50 | #define LTC3880_MFR_TEMPERATURE2_PEAK 0xf4 | |
51 | ||
fd9175d2 GR |
52 | /* LTC3883 only */ |
53 | #define LTC3883_MFR_IIN_PEAK 0xe1 | |
54 | ||
55 | #define LTC2974_ID 0x0212 | |
c3ff9a67 GR |
56 | #define LTC2978_ID_REV1 0x0121 |
57 | #define LTC2978_ID_REV2 0x0122 | |
ddfb41ca GR |
58 | #define LTC3880_ID 0x4000 |
59 | #define LTC3880_ID_MASK 0xff00 | |
fd9175d2 GR |
60 | #define LTC3883_ID 0x4300 |
61 | #define LTC3883_ID_MASK 0xff00 | |
c3ff9a67 | 62 | |
fd9175d2 | 63 | #define LTC2974_NUM_PAGES 4 |
3d0d2839 GR |
64 | #define LTC2978_NUM_PAGES 8 |
65 | #define LTC3880_NUM_PAGES 2 | |
fd9175d2 | 66 | #define LTC3883_NUM_PAGES 1 |
3d0d2839 | 67 | |
c3ff9a67 GR |
68 | /* |
69 | * LTC2978 clears peak data whenever the CLEAR_FAULTS command is executed, which | |
70 | * happens pretty much each time chip data is updated. Raw peak data therefore | |
71 | * does not provide much value. To be able to provide useful peak data, keep an | |
72 | * internal cache of measured peak data, which is only cleared if an explicit | |
73 | * "clear peak" command is executed for the sensor in question. | |
74 | */ | |
3d0d2839 | 75 | |
c3ff9a67 GR |
76 | struct ltc2978_data { |
77 | enum chips id; | |
3d0d2839 | 78 | u16 vin_min, vin_max; |
fd9175d2 | 79 | u16 temp_min[LTC2974_NUM_PAGES], temp_max[LTC2974_NUM_PAGES]; |
3d0d2839 | 80 | u16 vout_min[LTC2978_NUM_PAGES], vout_max[LTC2978_NUM_PAGES]; |
fd9175d2 GR |
81 | u16 iout_min[LTC2974_NUM_PAGES], iout_max[LTC2974_NUM_PAGES]; |
82 | u16 iin_max; | |
3d0d2839 | 83 | u16 temp2_max; |
c3ff9a67 GR |
84 | struct pmbus_driver_info info; |
85 | }; | |
86 | ||
87 | #define to_ltc2978_data(x) container_of(x, struct ltc2978_data, info) | |
88 | ||
89 | static inline int lin11_to_val(int data) | |
90 | { | |
91 | s16 e = ((s16)data) >> 11; | |
92 | s32 m = (((s16)(data << 5)) >> 5); | |
93 | ||
94 | /* | |
95 | * mantissa is 10 bit + sign, exponent adds up to 15 bit. | |
96 | * Add 6 bit to exponent for maximum accuracy (10 + 15 + 6 = 31). | |
97 | */ | |
98 | e += 6; | |
99 | return (e < 0 ? m >> -e : m << e); | |
100 | } | |
101 | ||
ddfb41ca GR |
102 | static int ltc2978_read_word_data_common(struct i2c_client *client, int page, |
103 | int reg) | |
c3ff9a67 GR |
104 | { |
105 | const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | |
106 | struct ltc2978_data *data = to_ltc2978_data(info); | |
107 | int ret; | |
108 | ||
109 | switch (reg) { | |
110 | case PMBUS_VIRT_READ_VIN_MAX: | |
111 | ret = pmbus_read_word_data(client, page, LTC2978_MFR_VIN_PEAK); | |
112 | if (ret >= 0) { | |
113 | if (lin11_to_val(ret) > lin11_to_val(data->vin_max)) | |
114 | data->vin_max = ret; | |
115 | ret = data->vin_max; | |
116 | } | |
117 | break; | |
118 | case PMBUS_VIRT_READ_VOUT_MAX: | |
119 | ret = pmbus_read_word_data(client, page, LTC2978_MFR_VOUT_PEAK); | |
120 | if (ret >= 0) { | |
121 | /* | |
122 | * VOUT is 16 bit unsigned with fixed exponent, | |
123 | * so we can compare it directly | |
124 | */ | |
125 | if (ret > data->vout_max[page]) | |
126 | data->vout_max[page] = ret; | |
127 | ret = data->vout_max[page]; | |
128 | } | |
129 | break; | |
130 | case PMBUS_VIRT_READ_TEMP_MAX: | |
131 | ret = pmbus_read_word_data(client, page, | |
132 | LTC2978_MFR_TEMPERATURE_PEAK); | |
133 | if (ret >= 0) { | |
8c958c70 GR |
134 | if (lin11_to_val(ret) |
135 | > lin11_to_val(data->temp_max[page])) | |
136 | data->temp_max[page] = ret; | |
137 | ret = data->temp_max[page]; | |
c3ff9a67 GR |
138 | } |
139 | break; | |
ddfb41ca GR |
140 | case PMBUS_VIRT_RESET_VOUT_HISTORY: |
141 | case PMBUS_VIRT_RESET_VIN_HISTORY: | |
142 | case PMBUS_VIRT_RESET_TEMP_HISTORY: | |
143 | ret = 0; | |
144 | break; | |
145 | default: | |
146 | ret = -ENODATA; | |
147 | break; | |
148 | } | |
149 | return ret; | |
150 | } | |
151 | ||
152 | static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg) | |
153 | { | |
154 | const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | |
155 | struct ltc2978_data *data = to_ltc2978_data(info); | |
156 | int ret; | |
157 | ||
158 | switch (reg) { | |
c3ff9a67 GR |
159 | case PMBUS_VIRT_READ_VIN_MIN: |
160 | ret = pmbus_read_word_data(client, page, LTC2978_MFR_VIN_MIN); | |
161 | if (ret >= 0) { | |
162 | if (lin11_to_val(ret) < lin11_to_val(data->vin_min)) | |
163 | data->vin_min = ret; | |
164 | ret = data->vin_min; | |
165 | } | |
166 | break; | |
167 | case PMBUS_VIRT_READ_VOUT_MIN: | |
168 | ret = pmbus_read_word_data(client, page, LTC2978_MFR_VOUT_MIN); | |
169 | if (ret >= 0) { | |
170 | /* | |
171 | * VOUT_MIN is known to not be supported on some lots | |
172 | * of LTC2978 revision 1, and will return the maximum | |
173 | * possible voltage if read. If VOUT_MAX is valid and | |
174 | * lower than the reading of VOUT_MIN, use it instead. | |
175 | */ | |
176 | if (data->vout_max[page] && ret > data->vout_max[page]) | |
177 | ret = data->vout_max[page]; | |
178 | if (ret < data->vout_min[page]) | |
179 | data->vout_min[page] = ret; | |
180 | ret = data->vout_min[page]; | |
181 | } | |
182 | break; | |
183 | case PMBUS_VIRT_READ_TEMP_MIN: | |
184 | ret = pmbus_read_word_data(client, page, | |
185 | LTC2978_MFR_TEMPERATURE_MIN); | |
186 | if (ret >= 0) { | |
187 | if (lin11_to_val(ret) | |
fd9175d2 GR |
188 | < lin11_to_val(data->temp_min[page])) |
189 | data->temp_min[page] = ret; | |
190 | ret = data->temp_min[page]; | |
c3ff9a67 GR |
191 | } |
192 | break; | |
ddfb41ca GR |
193 | case PMBUS_VIRT_READ_IOUT_MAX: |
194 | case PMBUS_VIRT_RESET_IOUT_HISTORY: | |
195 | case PMBUS_VIRT_READ_TEMP2_MAX: | |
196 | case PMBUS_VIRT_RESET_TEMP2_HISTORY: | |
197 | ret = -ENXIO; | |
198 | break; | |
199 | default: | |
200 | ret = ltc2978_read_word_data_common(client, page, reg); | |
201 | break; | |
202 | } | |
203 | return ret; | |
204 | } | |
205 | ||
fd9175d2 GR |
206 | static int ltc2974_read_word_data(struct i2c_client *client, int page, int reg) |
207 | { | |
208 | const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | |
209 | struct ltc2978_data *data = to_ltc2978_data(info); | |
210 | int ret; | |
211 | ||
212 | switch (reg) { | |
213 | case PMBUS_VIRT_READ_IOUT_MAX: | |
214 | ret = pmbus_read_word_data(client, page, LTC2974_MFR_IOUT_PEAK); | |
215 | if (ret >= 0) { | |
216 | if (lin11_to_val(ret) | |
217 | > lin11_to_val(data->iout_max[page])) | |
218 | data->iout_max[page] = ret; | |
219 | ret = data->iout_max[page]; | |
220 | } | |
221 | break; | |
222 | case PMBUS_VIRT_READ_IOUT_MIN: | |
223 | ret = pmbus_read_word_data(client, page, LTC2974_MFR_IOUT_MIN); | |
224 | if (ret >= 0) { | |
225 | if (lin11_to_val(ret) | |
226 | < lin11_to_val(data->iout_min[page])) | |
227 | data->iout_min[page] = ret; | |
228 | ret = data->iout_min[page]; | |
229 | } | |
230 | break; | |
231 | case PMBUS_VIRT_RESET_IOUT_HISTORY: | |
232 | ret = 0; | |
233 | break; | |
234 | default: | |
235 | ret = ltc2978_read_word_data(client, page, reg); | |
236 | break; | |
237 | } | |
238 | return ret; | |
239 | } | |
240 | ||
ddfb41ca GR |
241 | static int ltc3880_read_word_data(struct i2c_client *client, int page, int reg) |
242 | { | |
243 | const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | |
244 | struct ltc2978_data *data = to_ltc2978_data(info); | |
245 | int ret; | |
246 | ||
247 | switch (reg) { | |
248 | case PMBUS_VIRT_READ_IOUT_MAX: | |
249 | ret = pmbus_read_word_data(client, page, LTC3880_MFR_IOUT_PEAK); | |
250 | if (ret >= 0) { | |
251 | if (lin11_to_val(ret) | |
252 | > lin11_to_val(data->iout_max[page])) | |
253 | data->iout_max[page] = ret; | |
254 | ret = data->iout_max[page]; | |
255 | } | |
256 | break; | |
257 | case PMBUS_VIRT_READ_TEMP2_MAX: | |
258 | ret = pmbus_read_word_data(client, page, | |
259 | LTC3880_MFR_TEMPERATURE2_PEAK); | |
260 | if (ret >= 0) { | |
dbd712c2 GR |
261 | if (lin11_to_val(ret) > lin11_to_val(data->temp2_max)) |
262 | data->temp2_max = ret; | |
263 | ret = data->temp2_max; | |
ddfb41ca GR |
264 | } |
265 | break; | |
266 | case PMBUS_VIRT_READ_VIN_MIN: | |
267 | case PMBUS_VIRT_READ_VOUT_MIN: | |
268 | case PMBUS_VIRT_READ_TEMP_MIN: | |
269 | ret = -ENXIO; | |
270 | break; | |
271 | case PMBUS_VIRT_RESET_IOUT_HISTORY: | |
272 | case PMBUS_VIRT_RESET_TEMP2_HISTORY: | |
c3ff9a67 GR |
273 | ret = 0; |
274 | break; | |
275 | default: | |
ddfb41ca | 276 | ret = ltc2978_read_word_data_common(client, page, reg); |
c3ff9a67 GR |
277 | break; |
278 | } | |
279 | return ret; | |
280 | } | |
281 | ||
fd9175d2 GR |
282 | static int ltc3883_read_word_data(struct i2c_client *client, int page, int reg) |
283 | { | |
284 | const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | |
285 | struct ltc2978_data *data = to_ltc2978_data(info); | |
286 | int ret; | |
287 | ||
288 | switch (reg) { | |
289 | case PMBUS_VIRT_READ_IIN_MAX: | |
290 | ret = pmbus_read_word_data(client, page, LTC3883_MFR_IIN_PEAK); | |
291 | if (ret >= 0) { | |
292 | if (lin11_to_val(ret) | |
293 | > lin11_to_val(data->iin_max)) | |
294 | data->iin_max = ret; | |
295 | ret = data->iin_max; | |
296 | } | |
297 | break; | |
298 | case PMBUS_VIRT_RESET_IIN_HISTORY: | |
299 | ret = 0; | |
300 | break; | |
301 | default: | |
302 | ret = ltc3880_read_word_data(client, page, reg); | |
303 | break; | |
304 | } | |
305 | return ret; | |
306 | } | |
307 | ||
ddfb41ca GR |
308 | static int ltc2978_clear_peaks(struct i2c_client *client, int page, |
309 | enum chips id) | |
310 | { | |
311 | int ret; | |
312 | ||
fd9175d2 | 313 | if (id == ltc3880 || id == ltc3883) |
ddfb41ca | 314 | ret = pmbus_write_byte(client, 0, LTC3880_MFR_CLEAR_PEAKS); |
fd9175d2 GR |
315 | else |
316 | ret = pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS); | |
ddfb41ca GR |
317 | |
318 | return ret; | |
319 | } | |
320 | ||
c3ff9a67 GR |
321 | static int ltc2978_write_word_data(struct i2c_client *client, int page, |
322 | int reg, u16 word) | |
323 | { | |
324 | const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | |
325 | struct ltc2978_data *data = to_ltc2978_data(info); | |
326 | int ret; | |
327 | ||
328 | switch (reg) { | |
fd9175d2 GR |
329 | case PMBUS_VIRT_RESET_IIN_HISTORY: |
330 | data->iin_max = 0x7c00; | |
331 | ret = ltc2978_clear_peaks(client, page, data->id); | |
332 | break; | |
ddfb41ca | 333 | case PMBUS_VIRT_RESET_IOUT_HISTORY: |
dbd712c2 | 334 | data->iout_max[page] = 0x7c00; |
fd9175d2 | 335 | data->iout_min[page] = 0xfbff; |
ddfb41ca GR |
336 | ret = ltc2978_clear_peaks(client, page, data->id); |
337 | break; | |
338 | case PMBUS_VIRT_RESET_TEMP2_HISTORY: | |
dbd712c2 | 339 | data->temp2_max = 0x7c00; |
ddfb41ca GR |
340 | ret = ltc2978_clear_peaks(client, page, data->id); |
341 | break; | |
c3ff9a67 GR |
342 | case PMBUS_VIRT_RESET_VOUT_HISTORY: |
343 | data->vout_min[page] = 0xffff; | |
344 | data->vout_max[page] = 0; | |
ddfb41ca | 345 | ret = ltc2978_clear_peaks(client, page, data->id); |
c3ff9a67 GR |
346 | break; |
347 | case PMBUS_VIRT_RESET_VIN_HISTORY: | |
348 | data->vin_min = 0x7bff; | |
dbd712c2 | 349 | data->vin_max = 0x7c00; |
ddfb41ca | 350 | ret = ltc2978_clear_peaks(client, page, data->id); |
c3ff9a67 GR |
351 | break; |
352 | case PMBUS_VIRT_RESET_TEMP_HISTORY: | |
fd9175d2 | 353 | data->temp_min[page] = 0x7bff; |
8c958c70 | 354 | data->temp_max[page] = 0x7c00; |
ddfb41ca | 355 | ret = ltc2978_clear_peaks(client, page, data->id); |
c3ff9a67 GR |
356 | break; |
357 | default: | |
358 | ret = -ENODATA; | |
359 | break; | |
360 | } | |
361 | return ret; | |
362 | } | |
363 | ||
364 | static const struct i2c_device_id ltc2978_id[] = { | |
fd9175d2 | 365 | {"ltc2974", ltc2974}, |
c3ff9a67 | 366 | {"ltc2978", ltc2978}, |
ddfb41ca | 367 | {"ltc3880", ltc3880}, |
fd9175d2 | 368 | {"ltc3883", ltc3883}, |
c3ff9a67 GR |
369 | {} |
370 | }; | |
371 | MODULE_DEVICE_TABLE(i2c, ltc2978_id); | |
372 | ||
373 | static int ltc2978_probe(struct i2c_client *client, | |
374 | const struct i2c_device_id *id) | |
375 | { | |
8b313ca7 | 376 | int chip_id, i; |
c3ff9a67 GR |
377 | struct ltc2978_data *data; |
378 | struct pmbus_driver_info *info; | |
379 | ||
380 | if (!i2c_check_functionality(client->adapter, | |
381 | I2C_FUNC_SMBUS_READ_WORD_DATA)) | |
382 | return -ENODEV; | |
383 | ||
8b313ca7 GR |
384 | data = devm_kzalloc(&client->dev, sizeof(struct ltc2978_data), |
385 | GFP_KERNEL); | |
c3ff9a67 GR |
386 | if (!data) |
387 | return -ENOMEM; | |
388 | ||
389 | chip_id = i2c_smbus_read_word_data(client, LTC2978_MFR_SPECIAL_ID); | |
8b313ca7 GR |
390 | if (chip_id < 0) |
391 | return chip_id; | |
c3ff9a67 | 392 | |
fd9175d2 GR |
393 | if (chip_id == LTC2974_ID) { |
394 | data->id = ltc2974; | |
395 | } else if (chip_id == LTC2978_ID_REV1 || chip_id == LTC2978_ID_REV2) { | |
c3ff9a67 | 396 | data->id = ltc2978; |
ddfb41ca GR |
397 | } else if ((chip_id & LTC3880_ID_MASK) == LTC3880_ID) { |
398 | data->id = ltc3880; | |
fd9175d2 GR |
399 | } else if ((chip_id & LTC3883_ID_MASK) == LTC3883_ID) { |
400 | data->id = ltc3883; | |
c3ff9a67 GR |
401 | } else { |
402 | dev_err(&client->dev, "Unsupported chip ID 0x%x\n", chip_id); | |
8b313ca7 | 403 | return -ENODEV; |
c3ff9a67 GR |
404 | } |
405 | if (data->id != id->driver_data) | |
406 | dev_warn(&client->dev, | |
407 | "Device mismatch: Configured %s, detected %s\n", | |
408 | id->name, | |
409 | ltc2978_id[data->id].name); | |
410 | ||
411 | info = &data->info; | |
c3ff9a67 GR |
412 | info->write_word_data = ltc2978_write_word_data; |
413 | ||
c3ff9a67 | 414 | data->vin_min = 0x7bff; |
dbd712c2 | 415 | data->vin_max = 0x7c00; |
3d0d2839 GR |
416 | for (i = 0; i < ARRAY_SIZE(data->vout_min); i++) |
417 | data->vout_min[i] = 0xffff; | |
fd9175d2 GR |
418 | for (i = 0; i < ARRAY_SIZE(data->iout_min); i++) |
419 | data->iout_min[i] = 0xfbff; | |
420 | for (i = 0; i < ARRAY_SIZE(data->iout_max); i++) | |
421 | data->iout_max[i] = 0x7c00; | |
422 | for (i = 0; i < ARRAY_SIZE(data->temp_min); i++) | |
423 | data->temp_min[i] = 0x7bff; | |
8c958c70 GR |
424 | for (i = 0; i < ARRAY_SIZE(data->temp_max); i++) |
425 | data->temp_max[i] = 0x7c00; | |
dbd712c2 | 426 | data->temp2_max = 0x7c00; |
c3ff9a67 | 427 | |
f366fccd | 428 | switch (data->id) { |
fd9175d2 GR |
429 | case ltc2974: |
430 | info->read_word_data = ltc2974_read_word_data; | |
431 | info->pages = LTC2974_NUM_PAGES; | |
432 | info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT | |
433 | | PMBUS_HAVE_TEMP2; | |
434 | for (i = 0; i < info->pages; i++) { | |
435 | info->func[i] |= PMBUS_HAVE_VOUT | |
436 | | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_POUT | |
437 | | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | |
438 | | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT; | |
439 | } | |
440 | break; | |
c3ff9a67 | 441 | case ltc2978: |
ddfb41ca | 442 | info->read_word_data = ltc2978_read_word_data; |
3d0d2839 | 443 | info->pages = LTC2978_NUM_PAGES; |
c3ff9a67 GR |
444 | info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT |
445 | | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | |
446 | | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP; | |
3d0d2839 | 447 | for (i = 1; i < LTC2978_NUM_PAGES; i++) { |
c3ff9a67 GR |
448 | info->func[i] = PMBUS_HAVE_VOUT |
449 | | PMBUS_HAVE_STATUS_VOUT; | |
c3ff9a67 GR |
450 | } |
451 | break; | |
ddfb41ca GR |
452 | case ltc3880: |
453 | info->read_word_data = ltc3880_read_word_data; | |
3d0d2839 | 454 | info->pages = LTC3880_NUM_PAGES; |
ddfb41ca GR |
455 | info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN |
456 | | PMBUS_HAVE_STATUS_INPUT | |
457 | | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | |
458 | | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | |
459 | | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP | |
460 | | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP; | |
461 | info->func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | |
462 | | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | |
463 | | PMBUS_HAVE_POUT | |
464 | | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP; | |
fd9175d2 GR |
465 | break; |
466 | case ltc3883: | |
467 | info->read_word_data = ltc3883_read_word_data; | |
468 | info->pages = LTC3883_NUM_PAGES; | |
469 | info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | |
470 | | PMBUS_HAVE_STATUS_INPUT | |
471 | | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | |
472 | | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | |
473 | | PMBUS_HAVE_PIN | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP | |
474 | | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP; | |
ddfb41ca | 475 | break; |
c3ff9a67 | 476 | default: |
8b313ca7 | 477 | return -ENODEV; |
c3ff9a67 | 478 | } |
8b313ca7 | 479 | return pmbus_do_probe(client, id, info); |
c3ff9a67 GR |
480 | } |
481 | ||
c3ff9a67 GR |
482 | /* This is the driver that will be inserted */ |
483 | static struct i2c_driver ltc2978_driver = { | |
484 | .driver = { | |
485 | .name = "ltc2978", | |
486 | }, | |
487 | .probe = ltc2978_probe, | |
dd285ad7 | 488 | .remove = pmbus_do_remove, |
c3ff9a67 GR |
489 | .id_table = ltc2978_id, |
490 | }; | |
491 | ||
f0967eea | 492 | module_i2c_driver(ltc2978_driver); |
c3ff9a67 GR |
493 | |
494 | MODULE_AUTHOR("Guenter Roeck"); | |
fd9175d2 | 495 | MODULE_DESCRIPTION("PMBus driver for LTC2974, LTC2978, LTC3880, and LTC3883"); |
c3ff9a67 | 496 | MODULE_LICENSE("GPL"); |