This source file includes following definitions.
- iicprobeinit
- iicprobenc
- iicprobew
- iicprobe
- lm75probe
- adm1032cloneprobe
- iic_ignore_addr
- iic_dump
- iic_probe
- iic_scan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <sys/param.h>
24 #include <sys/systm.h>
25 #include <sys/device.h>
26
27 #define _I2C_PRIVATE
28 #include <dev/i2c/i2cvar.h>
29
30 #undef I2C_DEBUG
31 #define I2C_VERBOSE
32
33 void iic_probe(struct device *, struct i2cbus_attach_args *, u_int8_t);
34
35
36
37
38
39
40
41 struct {
42 u_int8_t start, end;
43 } probe_addrs[] = {
44 { 0x18, 0x18 },
45 { 0x1a, 0x1a },
46 { 0x20, 0x2f },
47 { 0x48, 0x4e }
48 };
49
50 #define MAX_IGNORE 8
51 u_int8_t ignore_addrs[MAX_IGNORE];
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 int skip_fc;
68
69 static i2c_tag_t probe_ic;
70 static u_int8_t probe_addr;
71 static u_int8_t probe_val[256];
72
73 void iicprobeinit(struct i2cbus_attach_args *, u_int8_t);
74 u_int8_t iicprobenc(u_int8_t);
75 u_int8_t iicprobe(u_int8_t);
76 u_int16_t iicprobew(u_int8_t);
77 char *lm75probe(void);
78 char *adm1032cloneprobe(u_int8_t);
79 void iic_dump(struct device *, u_int8_t, char *);
80
81 void
82 iicprobeinit(struct i2cbus_attach_args *iba, u_int8_t addr)
83 {
84 probe_ic = iba->iba_tag;
85 probe_addr = addr;
86 memset(probe_val, 0xff, sizeof probe_val);
87 }
88
89 u_int8_t
90 iicprobenc(u_int8_t cmd)
91 {
92 u_int8_t data;
93
94
95
96
97
98 if (skip_fc && cmd == 0xfc)
99 return (0xff);
100 iic_acquire_bus(probe_ic, 0);
101 if (iic_exec(probe_ic, I2C_OP_READ_WITH_STOP,
102 probe_addr, &cmd, 1, &data, 1, 0) != 0)
103 data = 0xff;
104 iic_release_bus(probe_ic, 0);
105 return (data);
106 }
107
108 u_int16_t
109 iicprobew(u_int8_t cmd)
110 {
111 u_int8_t data[2];
112
113
114
115
116
117 if (skip_fc && cmd == 0xfc)
118 return (0xffff);
119 iic_acquire_bus(probe_ic, 0);
120 if (iic_exec(probe_ic, I2C_OP_READ_WITH_STOP,
121 probe_addr, &cmd, 1, &data, 2, 0) != 0)
122 data[0] = data[1] = 0xff;
123 iic_release_bus(probe_ic, 0);
124 return ((data[0] << 8) | data[1]);
125 }
126
127 u_int8_t
128 iicprobe(u_int8_t cmd)
129 {
130 if (probe_val[cmd] != 0xff)
131 return probe_val[cmd];
132 probe_val[cmd] = iicprobenc(cmd);
133 return (probe_val[cmd]);
134 }
135
136 #define LM75TEMP 0x00
137 #define LM75CONF 0x01
138 #define LM75Thyst 0x02
139 #define LM75Tos 0x03
140 #define LM77Tlow 0x04
141 #define LM77Thigh 0x05
142 #define LM75TMASK 0xff80
143 #define LM77TMASK 0xfff8
144
145
146
147
148
149
150
151
152
153
154
155
156
157 char *
158 lm75probe(void)
159 {
160 u_int16_t temp, thyst, tos, tlow, thigh, mask = LM75TMASK;
161 u_int8_t conf;
162 int i, echocount, ffffcount, score;
163 int echoreg67, echoreg45, ffffreg67, ffffreg45;
164
165 temp = iicprobew(LM75TEMP);
166
167
168
169
170
171 if (temp == 0xffff)
172 temp = iicprobew(LM75TEMP);
173
174 conf = iicprobenc(LM75CONF);
175 thyst = iicprobew(LM75Thyst);
176 tos = iicprobew(LM75Tos);
177
178
179 if (conf == 0xff && temp == 0xffff && thyst == 0xffff)
180 return (NULL);
181
182 temp &= mask;
183 thyst &= mask;
184 tos &= mask;
185
186
187 if (temp == thyst && thyst == tos)
188 return (NULL);
189
190 #if notsure
191
192 if ((temp >> 8) == conf)
193 return (NULL);
194 #endif
195
196
197
198
199
200
201
202
203 for (i = 6, echocount = 2, ffffcount = 0; i <= 7; i++) {
204 if ((iicprobew(LM75TEMP) & mask) != (iicprobew(i) & mask) ||
205 (iicprobew(LM75Thyst) & mask) != (iicprobew(i) & mask) ||
206 (iicprobew(LM75Tos) & mask) != (iicprobew(i) & mask))
207 echocount--;
208 if (iicprobew(i) == 0xffff)
209 ffffcount++;
210 }
211
212
213 if (echocount == 1 || ffffcount == 1)
214 return (NULL);
215
216 echoreg67 = (echocount == 0) ? 0 : 1;
217 ffffreg67 = (ffffcount == 0) ? 0 : 1;
218
219
220
221
222
223
224
225 for (i = 4, echocount = 2, ffffcount = 0; i <= 5; i++) {
226 if ((iicprobew(LM75TEMP) & mask) != (iicprobew(i) & mask) ||
227 (iicprobew(LM75Thyst) & mask) != (iicprobew(i) & mask) ||
228 (iicprobew(LM75Tos) & mask) != (iicprobew(i) & mask))
229 echocount--;
230 if (iicprobew(i) == 0xffff)
231 ffffcount++;
232 }
233
234
235 if (echocount == 1 || ffffcount == 1)
236 return (NULL);
237
238 echoreg45 = (echocount == 0) ? 0 : 1;
239 ffffreg45 = (ffffcount == 0) ? 0 : 1;
240
241
242
243
244
245
246 if (echoreg45 == 0 && ffffreg45 == 0 && echoreg67 == 1) {
247 mask = LM77TMASK;
248
249
250 thyst = iicprobew(LM75Thyst) & mask;
251 tos = iicprobew(LM75Tos) & mask;
252 tlow = iicprobew(LM77Tlow) & mask;
253 thigh = iicprobew(LM77Thigh) & mask;
254 }
255
256
257 for (i = 0x08; i <= 0xf8; i += 8) {
258 if (conf != iicprobenc(LM75CONF + i) ||
259 thyst != (iicprobew(LM75Thyst + i) & mask) ||
260 tos != (iicprobew(LM75Tos + i) & mask))
261 return (NULL);
262
263
264
265
266
267 if (echoreg67 == 1) {
268 tos = iicprobew(LM75Tos) & mask;
269 if (tos != (iicprobew(0x06 + i) & mask) ||
270 tos != (iicprobew(0x07 + i) & mask))
271 return (NULL);
272 } else if (ffffreg67 == 1)
273 if (iicprobew(0x06 + i) != 0xffff ||
274 iicprobew(0x07 + i) != 0xffff)
275 return (NULL);
276
277
278
279
280
281
282
283 if (echoreg45 == 1) {
284 tos = iicprobew(LM75Tos) & mask;
285 if (tos != (iicprobew(LM77Tlow + i) & mask) ||
286 tos != (iicprobew(LM77Thigh + i) & mask))
287 return (NULL);
288 } else if (ffffreg45 == 1) {
289 if (iicprobew(LM77Tlow + i) != 0xffff ||
290 iicprobew(LM77Thigh + i) != 0xffff)
291 return (NULL);
292 } else if (echoreg67 == 1)
293 if (tlow != (iicprobew(LM77Tlow + i) & mask) ||
294 thigh != (iicprobew(LM77Thigh + i) & mask))
295 return (NULL);
296 }
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311 score = (echoreg67 << 3) + (echoreg45 << 2) + (ffffreg67 << 1) +
312 ffffreg45;
313
314 switch (score) {
315 case 12:
316 return ("lm75");
317 case 8:
318 return ("lm77");
319 case 3:
320 return ("lm75a");
321 default:
322 #if defined(I2C_DEBUG)
323 printf("lm75probe: unknown chip, scored %d\n", score);
324 #endif
325 return (NULL);
326 }
327 }
328
329 char *
330 adm1032cloneprobe(u_int8_t addr)
331 {
332 if (addr == 0x18 || addr == 0x1a || addr == 0x29 ||
333 addr == 0x2b || addr == 0x4c || addr == 0x4e) {
334 u_int8_t reg, val;
335 int zero = 0, copy = 0;
336
337 val = iicprobe(0x00);
338 for (reg = 0x00; reg < 0x09; reg++) {
339 if (iicprobe(reg) == 0xff)
340 return (NULL);
341 if (iicprobe(reg) == 0x00)
342 zero++;
343 if (val == iicprobe(reg))
344 copy++;
345 }
346 if (zero > 6 || copy > 6)
347 return (NULL);
348 val = iicprobe(0x09);
349 for (reg = 0x0a; reg < 0xfc; reg++) {
350 if (iicprobe(reg) != val)
351 return (NULL);
352 }
353
354 if (iicprobe(0xfe) == 0x4d)
355 return ("max1617");
356
357
358
359
360
361
362 return ("xeontemp");
363 }
364 return (NULL);
365 }
366
367 void
368 iic_ignore_addr(u_int8_t addr)
369 {
370 int i;
371
372 for (i = 0; i < sizeof(ignore_addrs); i++)
373 if (ignore_addrs[i] == 0) {
374 ignore_addrs[i] = addr;
375 return;
376 }
377 }
378
379 #if defined(I2C_DEBUG) || defined(I2C_VERBOSE)
380 void
381 iic_dump(struct device *dv, u_int8_t addr, char *name)
382 {
383 static u_int8_t iicvalcnt[256];
384 u_int8_t val, val2, max;
385 int i, cnt = 0;
386
387
388
389
390
391
392
393 bzero(iicvalcnt, sizeof iicvalcnt);
394 val = iicprobe(0);
395 iicvalcnt[val]++;
396 for (i = 1; i <= 0xff; i++) {
397 val2 = iicprobe(i);
398 iicvalcnt[val2]++;
399 if (val == val2)
400 cnt++;
401 }
402
403 for (val = max = i = 0; i <= 0xff; i++)
404 if (max < iicvalcnt[i]) {
405 max = iicvalcnt[i];
406 val = i;
407 }
408
409 if (cnt <= 254) {
410 printf("%s: addr 0x%x", dv->dv_xname, addr);
411 for (i = 0; i <= 0xff; i++) {
412 if (iicprobe(i) != val)
413 printf(" %02x=%02x", i, iicprobe(i));
414 }
415 if (name)
416 printf(": %s", name);
417 printf("\n");
418 }
419 }
420 #endif
421
422 void
423 iic_probe(struct device *self, struct i2cbus_attach_args *iba, u_int8_t addr)
424 {
425 struct i2c_attach_args ia;
426 char *name = NULL;
427 int i;
428
429 for (i = 0; i < sizeof(ignore_addrs); i++)
430 if (ignore_addrs[i] == addr)
431 return;
432
433 iicprobeinit(iba, addr);
434 skip_fc = 0;
435
436
437
438
439
440 switch (iicprobe(0x3e)) {
441 case 0x01:
442
443
444
445
446
447
448
449
450 if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
451 iicprobe(0x3f) == 0x73)
452 name = "lm93";
453 else if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
454 iicprobe(0x3f) == 0x68)
455 name = "lm96000";
456 else if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
457 (iicprobe(0x3f) == 0x60 || iicprobe(0x3f) == 0x62))
458 name = "lm85";
459 else if ((addr & 0x7c) == 0x2c &&
460 iicprobe(0x48) == addr &&
461 (iicprobe(0x3f) == 0x03 || iicprobe(0x3f) == 0x04) &&
462 (iicprobe(0x40) & 0x80) == 0x00)
463 name = "lm81";
464 break;
465 case 0x02:
466 if ((iicprobe(0x3f) & 0xfc) == 0x04)
467 name = "lm87";
468 break;
469 case 0x23:
470 if (iicprobe(0x48) == addr &&
471 (iicprobe(0x40) & 0x80) == 0x00 &&
472 (addr & 0x7c) == 0x2c)
473 name = "adm9240";
474 break;
475 case 0x41:
476
477
478
479
480
481 if ((addr == 0x2c || addr == 0x2e || addr == 0x2f) &&
482 iicprobe(0x3d) == 0x70)
483 name = "adt7470";
484 else if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
485 iicprobe(0x3d) == 0x76)
486 name = "adt7476";
487 else if (addr == 0x2e && iicprobe(0x3d) == 0x75)
488 name = "adt7475";
489 else if (iicprobe(0x3d) == 0x27 &&
490 (iicprobe(0x3f) == 0x60 || iicprobe(0x3f) == 0x6a))
491 name = "adm1027";
492 else if (iicprobe(0x3d) == 0x27 &&
493 (iicprobe(0x3f) == 0x62 || iicprobe(0x3f) == 0x6a))
494 name = "adt7460";
495 else if (addr == 0x2e &&
496 iicprobe(0x3d) == 0x68 && (iicprobe(0x3f) & 0xf0) == 0x70)
497 name = "adt7467";
498 else if (iicprobe(0x3d) == 0x33)
499 name = "adm1033";
500 else if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
501 iicprobe(0x3d) == 0x30 &&
502 (iicprobe(0x01) & 0x80) == 0x00 &&
503 (iicprobe(0x0d) & 0x70) == 0x00 &&
504 (iicprobe(0x0e) & 0x70) == 0x00)
505
506
507
508
509
510
511 name = "adm1030";
512 else if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
513 iicprobe(0x3d) == 0x31 &&
514 (iicprobe(0x01) & 0x80) == 0x00 &&
515 (iicprobe(0x0d) & 0x70) == 0x00 &&
516 (iicprobe(0x0e) & 0x70) == 0x00 &&
517 (iicprobe(0x0f) & 0x70) == 0x00)
518 name = "adm1031";
519 else if ((addr & 0x7c) == 0x2c &&
520 (iicprobe(0x3f) & 0xf0) == 0x20 &&
521 (iicprobe(0x40) & 0x80) == 0x00 &&
522 (iicprobe(0x41) & 0xc0) == 0x00 &&
523 (iicprobe(0x42) & 0xbc) == 0x00)
524 name = "adm1025";
525 else if ((addr & 0x7c) == 0x2c &&
526 (iicprobe(0x3f) & 0xf0) == 0x10 &&
527 (iicprobe(0x40) & 0x80) == 0x00)
528 name = "adm1024";
529 else if ((iicprobe(0xff) & 0xf0) == 0x30)
530 name = "adm1023";
531 else if (addr == 0x2e &&
532 (iicprobe(0x3f) & 0xf0) == 0xd0 &&
533 (iicprobe(0x40) & 0x80) == 0x00)
534 name = "adm1028";
535 else if ((addr == 0x2c || addr == 0x2e || addr == 0x2f) &&
536 (iicprobe(0x3f) & 0xf0) == 0xc0 &&
537 (iicprobe(0x40) & 0x80) == 0x00)
538 name = "adm1022";
539 break;
540 case 0x49:
541 if ((addr == 0x2c || addr == 0x2e || addr == 0x2f) &&
542 (iicprobe(0x3f) & 0xf0) == 0xc0 &&
543 (iicprobe(0x40) & 0x80) == 0x00)
544 name = "thmc50";
545 break;
546 case 0x55:
547 if ((addr & 0x7c) == 0x2c &&
548 iicprobe(0x3f) == 0x20 &&
549 (iicprobe(0x47) & 0x70) == 0x00 &&
550 (iicprobe(0x49) & 0xfe) == 0x80)
551 name = "47m192";
552 break;
553 case 0x5c:
554 if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
555 (iicprobe(0x3f) & 0xf0) == 0x60)
556 name = "emc6d100";
557 else if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
558 (iicprobe(0x3f) & 0xf0) == 0x80)
559 name = "sch5017";
560 else if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
561 (iicprobe(0x3f) & 0xf0) == 0xb0)
562 name = "emc6w201";
563 break;
564 case 0xa1:
565 if ((iicprobe(0x3f) & 0xf0) == 0x20 &&
566 (iicprobe(0x40) & 0x80) == 0x00 &&
567 (iicprobe(0x41) & 0xc0) == 0x00 &&
568 (iicprobe(0x42) & 0xbc) == 0x00)
569 name = "ne1619";
570 break;
571 case 0xda:
572 if (iicprobe(0x3f) == 0x01 && iicprobe(0x48) == addr &&
573 (iicprobe(0x40) & 0x80) == 0x00)
574 name = "ds1780";
575 break;
576 }
577
578 switch (iicprobe(0x4e)) {
579 case 0x41:
580 if ((addr == 0x48 || addr == 0x4a || addr == 0x4b) &&
581 (iicprobe(0x4d) == 0x03 || iicprobe(0x4d) == 0x08 ||
582 iicprobe(0x4d) == 0x07))
583 name = "adt7516";
584 break;
585 }
586
587 switch (iicprobe(0xfe)) {
588 case 0x01:
589 if (addr == 0x4c &&
590 iicprobe(0xff) == 0x41 && (iicprobe(0x03) & 0x18) == 0 &&
591 iicprobe(0x04) <= 0x0f && (iicprobe(0xbf) & 0xf8) == 0)
592 name = "lm63";
593 else if (addr == 0x4c &&
594 iicprobe(0xff) == 0x11 && (iicprobe(0x03) & 0x2a) == 0 &&
595 iicprobe(0x04) <= 0x09 && (iicprobe(0xbf) & 0xf8) == 0)
596 name = "lm86";
597 else if (addr == 0x4c &&
598 iicprobe(0xff) == 0x31 && (iicprobe(0x03) & 0x2a) == 0 &&
599 iicprobe(0x04) <= 0x09 && (iicprobe(0xbf) & 0xf8) == 0)
600 name = "lm89";
601 else if (addr == 0x4d &&
602 iicprobe(0xff) == 0x34 && (iicprobe(0x03) & 0x2a) == 0 &&
603 iicprobe(0x04) <= 0x09 && (iicprobe(0xbf) & 0xf8) == 0)
604 name = "lm89-1";
605 else if (addr == 0x4c &&
606 iicprobe(0xff) == 0x21 && (iicprobe(0x03) & 0x2a) == 0 &&
607 iicprobe(0x04) <= 0x09 && (iicprobe(0xbf) & 0xf8) == 0)
608 name = "lm90";
609 break;
610 case 0x23:
611 if ((addr == 0x4c) &&
612 (iicprobe(0x03) & 0x3f) == 0x00 && iicprobe(0x04) <= 0x08)
613
614
615
616
617
618
619 name = "gl523sm";
620 break;
621 case 0x41:
622 if ((addr == 0x4c || addr == 0x4d) &&
623 iicprobe(0xff) == 0x51 &&
624 (iicprobe(0x03) & 0x1f) == 0x04 &&
625 iicprobe(0x04) <= 0x0a) {
626
627 name = "adt7461";
628 } else if ((addr == 0x18 || addr == 0x19 || addr == 0x1a ||
629 addr == 0x29 || addr == 0x2a || addr == 0x2b ||
630 addr == 0x4c || addr == 0x4d || addr == 0x4e) &&
631 (iicprobe(0xff) & 0xf0) == 0x00 &&
632 (iicprobe(0x03) & 0x3f) == 0x00 &&
633 iicprobe(0x04) <= 0x07) {
634 name = "adm1021";
635 skip_fc = 1;
636 } else if ((addr == 0x18 || addr == 0x19 || addr == 0x1a ||
637 addr == 0x29 || addr == 0x2a || addr == 0x2b ||
638 addr == 0x4c || addr == 0x4d || addr == 0x4e) &&
639 (iicprobe(0xff) & 0xf0) == 0x30 &&
640 (iicprobe(0x03) & 0x3f) == 0x00 &&
641 iicprobe(0x04) <= 0x07) {
642 name = "adm1023";
643 skip_fc = 1;
644 } else if ((addr == 0x4c || addr == 0x4d || addr == 0x4e) &&
645 (iicprobe(0x03) & 0x3f) == 0x00 &&
646 iicprobe(0x04) <= 0x0a) {
647 name = "adm1032";
648 skip_fc = 1;
649 }
650 break;
651 case 0x47:
652 if (addr == 0x4c && iicprobe(0xff) == 0x01 &&
653 (iicprobe(0x03) & 0x3f) == 0x00 && iicprobe(0x04) <= 0x08)
654 name = "g781";
655 if (addr == 0x4d && iicprobe(0xff) == 0x03 &&
656 (iicprobe(0x03) & 0x3f) == 0x00 && iicprobe(0x04) <= 0x08)
657 name = "g781-1";
658 break;
659 case 0x4d:
660 if ((addr == 0x18 || addr == 0x19 || addr == 0x1a ||
661 addr == 0x29 || addr == 0x2a || addr == 0x2b ||
662 addr == 0x4c || addr == 0x4d || addr == 0x4e) &&
663 iicprobe(0xff) == 0x08 && (iicprobe(0x02) & 0x03) == 0 &&
664 (iicprobe(0x03) & 0x07) == 0 && iicprobe(0x04) <= 0x08)
665 name = "max6690";
666 else if ((addr == 0x4c || addr == 0x4d || addr == 0x4e) &&
667 iicprobe(0xff) == 0x59 && (iicprobe(0x03) & 0x1f) == 0 &&
668 iicprobe(0x04) <= 0x07)
669 name = "max6646";
670 else if ((addr == 0x4c || addr == 0x4d || addr == 0x4e) &&
671 (iicprobe(0x02) & 0x2b) == 0 &&
672 (iicprobe(0x03) & 0x0f) == 0 && iicprobe(0x04) <= 0x09) {
673 name = "max6657";
674 skip_fc = 1;
675 } else if ((addr >= 0x48 && addr <= 0x4f) &&
676 (iicprobe(0x02) & 0x2b) == 0 &&
677 (iicprobe(0x03) & 0x0f) == 0)
678 name = "max6642";
679 break;
680 }
681
682 if (addr == iicprobe(0x48) &&
683 ((iicprobe(0x4f) == 0x5c && (iicprobe(0x4e) & 0x80)) ||
684 (iicprobe(0x4f) == 0xa3 && !(iicprobe(0x4e) & 0x80)))) {
685
686
687
688
689
690 if ((iicprobe(0x4e) & 0x07) == 0) {
691 switch (iicprobe(0x58)) {
692 case 0x10:
693 case 0x11:
694 name = "w83781d";
695 break;
696 case 0x21:
697 name = "w83627hf";
698 break;
699 case 0x30:
700 name = "w83782d";
701 break;
702 case 0x31:
703 name = "as99127f";
704 break;
705 case 0x40:
706 name = "w83783s";
707 break;
708 case 0x71:
709 name = "w83791d";
710 break;
711 case 0x72:
712 name = "w83791sd";
713 break;
714 case 0x7a:
715 name = "w83792d";
716 break;
717 }
718 } else {
719
720
721
722
723
724 name = "w83781d";
725 }
726 } else if (addr == iicprobe (0x4a) && iicprobe(0x4e) == 0x50 &&
727 iicprobe(0x4c) == 0xa3 && iicprobe(0x4d) == 0x5c) {
728 name = "w83l784r";
729 } else if (addr == 0x2d && iicprobe(0x4e) == 0x60 &&
730 iicprobe(0x4c) == 0xa3 && iicprobe(0x4d) == 0x5c) {
731 name = "w83l785r";
732 } else if (addr == 0x2e && iicprobe(0x4e) == 0x70 &&
733 iicprobe(0x4c) == 0xa3 && iicprobe(0x4d) == 0x5c) {
734 name = "w83l785ts-l";
735 } else if (addr >= 0x28 && addr <= 0x2f &&
736 iicprobe(0x4f) == 0x12 && (iicprobe(0x4e) & 0x80)) {
737
738
739
740
741
742 if (iicprobe(0x58) == 0x31)
743 name = "as99127f";
744 } else if ((addr == 0x2d || addr == 0x2e) &&
745 addr * 2 == iicprobe(0x04) &&
746 iicprobe(0x5d) == 0x19 && iicprobe(0x5e) == 0x34 &&
747 iicprobe(0x5a) == 0x03 && iicprobe(0x5b) == 0x06) {
748 name = "f75375";
749 } else if (addr == 0x2d &&
750 ((iicprobe(0x4f) == 0x06 && (iicprobe(0x4e) & 0x80)) ||
751 (iicprobe(0x4f) == 0x94 && !(iicprobe(0x4e) & 0x80)))) {
752
753
754
755
756
757
758
759
760
761
762
763 if ((iicprobe(0x58) & 0x7f) == 0x31 &&
764 (iicprobe(0x4e) & 0xf) == 0x00)
765 name = "asb100";
766 } else if ((addr == 0x2c || addr == 0x2d) &&
767 iicprobe(0x00) == 0x80 &&
768 (iicprobe(0x01) == 0x00 || iicprobe(0x01) == 0x80) &&
769 iicprobe(0x02) == 0x00 && (iicprobe(0x03) & 0x83) == 0x00 &&
770 (iicprobe(0x0f) & 0x07) == 0x00 &&
771 (iicprobe(0x11) & 0x80) == 0x00 &&
772 (iicprobe(0x12) & 0x80) == 0x00) {
773
774
775
776
777
778
779
780
781
782
783
784
785 name = "gl518sm";
786 } else if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
787 iicprobe(0x16) == 0x41 && ((iicprobe(0x17) & 0xf0) == 0x40)) {
788 name = "adm1026";
789 } else if (name == NULL &&
790 (addr & 0x78) == 0x48) {
791 name = lm75probe();
792 }
793 #if 0
794
795
796
797
798 if (name == NULL && (addr & 0x7c) == 0x48 &&
799 (iicprobew(0xaa) & 0x0007) == 0x0000 &&
800 (iicprobew(0xa1) & 0x0007) == 0x0000 &&
801 (iicprobew(0xa2) & 0x0007) == 0x0000 &&
802 (iicprobe(0xac) & 0x10) == 0x00) {
803 if ((iicprobe(0xac) & 0x7e) == 0x0a &&
804 iicprobe(0xab) == 0x00 && iicprobe(0xa8) == 0x00)
805 name = "ds1624";
806 else if ((iicprobe(0xac) & 0x7e) == 0x0c)
807 name = "ds1631";
808 else if ((iicprobe(0xac) & 0x2e) == 0x2e)
809 name = "ds1721";
810 }
811 #endif
812 if (name == NULL && (addr & 0xf8) == 0x28 && iicprobe(0x48) == addr &&
813 (iicprobe(0x00) & 0x90) == 0x10 && iicprobe(0x58) == 0x90) {
814 if (iicprobe(0x5b) == 0x12)
815 name = "it8712";
816 else if (iicprobe(0x5b) == 0x00)
817 name = "it8712f-a";
818 }
819
820 if (name == NULL && iicprobe(0x48) == addr &&
821 (iicprobe(0x40) & 0x80) == 0x00 && iicprobe(0x58) == 0xac)
822 name = "mtp008";
823
824 if (name == NULL) {
825 name = adm1032cloneprobe(addr);
826 if (name)
827 skip_fc = 1;
828 }
829
830 #ifdef I2C_DEBUG
831 iic_dump(self, addr, name);
832 #endif
833
834 #if !defined(I2C_VERBOSE) && !defined(I2C_DEBUG)
835 if (name == NULL)
836 name = "unknown";
837 #endif
838
839 if (name) {
840 memset(&ia, 0, sizeof(ia));
841 ia.ia_tag = iba->iba_tag;
842 ia.ia_addr = addr;
843 ia.ia_size = 1;
844 ia.ia_name = name;
845 if (config_found(self, &ia, iic_print))
846 return;
847 }
848
849 #if defined(I2C_VERBOSE) && !defined(I2C_DEBUG)
850 iic_dump(self, addr, name);
851 #endif
852 }
853
854 void
855 iic_scan(struct device *self, struct i2cbus_attach_args *iba)
856 {
857 i2c_tag_t ic = iba->iba_tag;
858 u_int8_t cmd = 0, addr;
859 int i;
860
861 bzero(ignore_addrs, sizeof(ignore_addrs));
862 for (i = 0; i < sizeof(probe_addrs)/sizeof(probe_addrs[0]); i++) {
863 for (addr = probe_addrs[i].start; addr <= probe_addrs[i].end;
864 addr++) {
865
866 iic_acquire_bus(ic, 0);
867 if (iic_exec(ic, I2C_OP_READ_WITH_STOP, addr,
868 &cmd, 1, NULL, 0, 0) == 0) {
869 iic_release_bus(ic, 0);
870
871
872 iic_probe(self, iba, addr);
873
874 iic_acquire_bus(ic, 0);
875
876 }
877 iic_release_bus(ic, 0);
878 }
879 }
880 }