1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
/* $OpenBSD: nslm7x.c,v 1.14 2006/01/07 12:42:45 kettenis Exp $ */
/* $NetBSD: nslm7x.c,v 1.17 2002/11/15 14:55:41 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Bill Squier.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/queue.h>
#include <sys/sensors.h>
#include <machine/bus.h>
#include <dev/ic/nslm7xvar.h>
#if defined(LMDEBUG)
#define DPRINTF(x) do { printf x; } while (0)
#else
#define DPRINTF(x)
#endif
struct cfdriver lm_cd = {
NULL, "lm", DV_DULL
};
void setup_fan(struct lm_softc *, int, int);
void setup_temp(struct lm_softc *, int, int);
void wb_setup_volt(struct lm_softc *);
int lm_match(struct lm_softc *);
int wb_match(struct lm_softc *);
int def_match(struct lm_softc *);
void lm_common_match(struct lm_softc *);
void generic_stemp(struct lm_softc *, struct sensor *);
void generic_svolt(struct lm_softc *, struct sensor *);
void generic_fanrpm(struct lm_softc *, struct sensor *);
void lm_refresh_sensor_data(struct lm_softc *);
void wb_svolt(struct lm_softc *);
void wb_stemp(struct lm_softc *, struct sensor *, int);
void wb781_fanrpm(struct lm_softc *, struct sensor *);
void wb_fanrpm(struct lm_softc *, struct sensor *, int);
void wb781_refresh_sensor_data(struct lm_softc *);
void wb782_refresh_sensor_data(struct lm_softc *);
void wb697_refresh_sensor_data(struct lm_softc *);
void lm_refresh(void *);
struct lm_chip {
int (*chip_match)(struct lm_softc *);
};
struct lm_chip lm_chips[] = {
{ wb_match },
{ lm_match },
{ def_match } /* Must be last */
};
/*
* bus independent probe
*/
int
lm_probe(bus_space_tag_t iot, bus_space_handle_t ioh)
{
u_int8_t cr;
int rv;
/* Check for some power-on defaults */
bus_space_write_1(iot, ioh, LMC_ADDR, LMD_CONFIG);
/* Perform LM78 reset */
bus_space_write_1(iot, ioh, LMC_DATA, 0x80);
/* XXX - Why do I have to reselect the register? */
bus_space_write_1(iot, ioh, LMC_ADDR, LMD_CONFIG);
cr = bus_space_read_1(iot, ioh, LMC_DATA);
/* XXX - spec says *only* 0x08! */
if ((cr == 0x08) || (cr == 0x01) || (cr == 0x03))
rv = 1;
else
rv = 0;
DPRINTF(("lm: rv = %d, cr = %x\n", rv, cr));
return (rv);
}
/*
* pre: lmsc contains valid busspace tag and handle
*/
void
lm_attach(struct lm_softc *lmsc)
{
u_int i, config;
for (i = 0; i < sizeof(lm_chips) / sizeof(lm_chips[0]); i++)
if (lm_chips[i].chip_match(lmsc))
break;
if (sensor_task_register(lmsc, lm_refresh, 5)) {
printf("%s: unable to register update task\n",
lmsc->sc_dev.dv_xname);
return;
}
/* Start the monitoring loop */
config = (*lmsc->lm_readreg)(lmsc, LMD_CONFIG);
(*lmsc->lm_writereg)(lmsc, LMD_CONFIG, config | 0x01);
/* Initialize sensors */
for (i = 0; i < lmsc->numsensors; ++i) {
strlcpy(lmsc->sensors[i].device, lmsc->sc_dev.dv_xname,
sizeof(lmsc->sensors[i].device));
SENSOR_ADD(&lmsc->sensors[i]);
}
}
int
lm_match(struct lm_softc *sc)
{
int i;
/* See if we have an LM78 or LM79 */
i = (*sc->lm_readreg)(sc, LMD_CHIPID) & LM_ID_MASK;
switch(i) {
case LM_ID_LM78:
printf(": LM78\n");
break;
case LM_ID_LM78J:
printf(": LM78J\n");
break;
case LM_ID_LM79:
printf(": LM79\n");
break;
case LM_ID_LM81:
printf(": LM81\n");
break;
default:
return 0;
}
lm_common_match(sc);
return 1;
}
int
def_match(struct lm_softc *sc)
{
int i;
i = (*sc->lm_readreg)(sc, LMD_CHIPID) & LM_ID_MASK;
printf(": unknown chip (ID %d)\n", i);
lm_common_match(sc);
return 1;
}
void
lm_common_match(struct lm_softc *sc)
{
int i;
sc->numsensors = LM_NUM_SENSORS;
sc->refresh_sensor_data = lm_refresh_sensor_data;
for (i = 0; i < 7; ++i) {
sc->sensors[i].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[i].desc, sizeof(sc->sensors[i].desc),
"IN%d", i);
}
/* default correction factors for resistors on higher voltage inputs */
sc->sensors[0].rfact = sc->sensors[1].rfact =
sc->sensors[2].rfact = 10000;
sc->sensors[3].rfact = (int)(( 90.9 / 60.4) * 10000);
sc->sensors[4].rfact = (int)(( 38.0 / 10.0) * 10000);
sc->sensors[5].rfact = (int)((210.0 / 60.4) * 10000);
sc->sensors[6].rfact = (int)(( 90.9 / 60.4) * 10000);
sc->sensors[7].type = SENSOR_TEMP;
strlcpy(sc->sensors[7].desc, "Temp", sizeof(sc->sensors[7].desc));
setup_fan(sc, 8, 3);
}
int
wb_match(struct lm_softc *sc)
{
int i, j, banksel;
banksel = (*sc->lm_readreg)(sc, WB_BANKSEL);
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_HBAC);
j = (*sc->lm_readreg)(sc, WB_VENDID) << 8;
(*sc->lm_writereg)(sc, WB_BANKSEL, 0);
j |= (*sc->lm_readreg)(sc, WB_VENDID);
(*sc->lm_writereg)(sc, WB_BANKSEL, banksel);
DPRINTF(("winbond vend id 0x%x\n", j));
if (j != WB_VENDID_WINBOND && j != WB_VENDID_ASUS)
return 0;
/* read device ID */
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_B0);
j = (*sc->lm_readreg)(sc, WB_BANK0_CHIPID);
(*sc->lm_writereg)(sc, WB_BANKSEL, banksel);
DPRINTF(("winbond chip id 0x%x\n", j));
switch(j) {
case WB_CHIPID_83781:
case WB_CHIPID_83781_2:
case AS_CHIPID_99127:
if (j == AS_CHIPID_99127)
printf(": AS99127F\n");
else
printf(": W83781D\n");
for (i = 0; i < 7; ++i) {
sc->sensors[i].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[i].desc,
sizeof(sc->sensors[i].desc), "IN%d", i);
}
/* default correction factors for higher voltage inputs */
sc->sensors[0].rfact = sc->sensors[1].rfact =
sc->sensors[2].rfact = 10000;
sc->sensors[3].rfact = (int)(( 90.9 / 60.4) * 10000);
sc->sensors[4].rfact = (int)(( 38.0 / 10.0) * 10000);
sc->sensors[5].rfact = (int)((210.0 / 60.4) * 10000);
sc->sensors[6].rfact = (int)(( 90.9 / 60.4) * 10000);
setup_temp(sc, 7, 3);
setup_fan(sc, 10, 3);
sc->numsensors = WB83781_NUM_SENSORS;
sc->refresh_sensor_data = wb781_refresh_sensor_data;
return 1;
case WB_CHIPID_83697:
printf(": W83697HF\n");
wb_setup_volt(sc);
setup_temp(sc, 9, 2);
setup_fan(sc, 11, 2);
sc->numsensors = WB83697_NUM_SENSORS;
sc->refresh_sensor_data = wb697_refresh_sensor_data;
return 1;
case WB_CHIPID_83782:
printf(": W83782D\n");
break;
case WB_CHIPID_83627:
printf(": W83627HF\n");
break;
case WB_CHIPID_83627THF:
printf(": W83627THF\n");
break;
case WB_CHIPID_83791:
case WB_CHIPID_83791_2:
printf(": W83791D\n");
break;
default:
printf(": unknown winbond chip ID 0x%x\n", j);
/* handle as a standart lm7x */
lm_common_match(sc);
return 1;
}
/* common code for the W83782D and W83627HF */
wb_setup_volt(sc);
setup_temp(sc, 9, 3);
setup_fan(sc, 12, 3);
sc->numsensors = WB_NUM_SENSORS;
sc->refresh_sensor_data = wb782_refresh_sensor_data;
return 1;
}
void
wb_setup_volt(struct lm_softc *sc)
{
sc->sensors[0].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[0].desc, sizeof(sc->sensors[0].desc), "VCORE_A");
sc->sensors[0].rfact = 10000;
sc->sensors[1].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[1].desc, sizeof(sc->sensors[1].desc), "VCORE_B");
sc->sensors[1].rfact = 10000;
sc->sensors[2].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[2].desc, sizeof(sc->sensors[2].desc), "+3.3V");
sc->sensors[2].rfact = 10000;
sc->sensors[3].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[3].desc, sizeof(sc->sensors[3].desc), "+5V");
sc->sensors[3].rfact = 16778;
sc->sensors[4].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[4].desc, sizeof(sc->sensors[4].desc), "+12V");
sc->sensors[4].rfact = 38000;
sc->sensors[5].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[5].desc, sizeof(sc->sensors[5].desc), "-12V");
sc->sensors[5].rfact = 10000;
sc->sensors[6].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[6].desc, sizeof(sc->sensors[6].desc), "-5V");
sc->sensors[6].rfact = 10000;
sc->sensors[7].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[7].desc, sizeof(sc->sensors[7].desc), "+5VSB");
sc->sensors[7].rfact = 15151;
sc->sensors[8].type = SENSOR_VOLTS_DC;
snprintf(sc->sensors[8].desc, sizeof(sc->sensors[8].desc), "VBAT");
sc->sensors[8].rfact = 10000;
}
void
setup_temp(struct lm_softc *sc, int start, int n)
{
int i;
for (i = 0; i < n; i++) {
sc->sensors[start + i].type = SENSOR_TEMP;
snprintf(sc->sensors[start + i].desc,
sizeof(sc->sensors[start + i].desc), "Temp%d", i + 1);
}
}
void
setup_fan(struct lm_softc *sc, int start, int n)
{
int i;
for (i = 0; i < n; ++i) {
sc->sensors[start + i].type = SENSOR_FANRPM;
snprintf(sc->sensors[start + i].desc,
sizeof(sc->sensors[start + i].desc), "Fan%d", i + 1);
}
}
void
generic_stemp(struct lm_softc *sc, struct sensor *sensor)
{
int sdata = (*sc->lm_readreg)(sc, LMD_SENSORBASE + 7);
DPRINTF(("sdata[temp] 0x%x\n", sdata));
/* temp is given in deg. C, we convert to uK */
sensor->value = sdata * 1000000 + 273150000;
}
void
generic_svolt(struct lm_softc *sc, struct sensor *sensors)
{
int i, sdata;
for (i = 0; i < 7; i++) {
sdata = (*sc->lm_readreg)(sc, LMD_SENSORBASE + i);
DPRINTF(("sdata[volt%d] 0x%x\n", i, sdata));
/* voltage returned as (mV >> 4), we convert to uVDC */
sensors[i].value = (sdata << 4);
/* rfact is (factor * 10^4) */
sensors[i].value *= sensors[i].rfact;
/* division by 10 gets us back to uVDC */
sensors[i].value /= 10;
/* these two are negative voltages */
if ( (i == 5) || (i == 6) )
sensors[i].value *= -1;
}
}
void
generic_fanrpm(struct lm_softc *sc, struct sensor *sensors)
{
int i, sdata, divisor, vidfan;
for (i = 0; i < 3; i++) {
sdata = (*sc->lm_readreg)(sc, LMD_SENSORBASE + 8 + i);
vidfan = (*sc->lm_readreg)(sc, LMD_VIDFAN);
DPRINTF(("sdata[fan%d] 0x%x", i, sdata));
if (i == 2)
divisor = 1; /* Fixed divisor for FAN3 */
else if (i == 1) /* Bits 7 & 6 of VID/FAN */
divisor = (vidfan >> 6) & 0x3;
else
divisor = (vidfan >> 4) & 0x3;
DPRINTF((", divisor %d\n", 2 << divisor));
if (sdata == 0xff) {
/* XXX Changing the fan divisor is too dangerous */
#if 0
/* Fan can be too slow, try to adjust the divisor */
if (i < 2 && divisor < 3) {
divisor++;
vidfan &= ~(0x3 << (i == 0 ? 4 : 6));
vidfan |= (divisor & 0x3) << (i == 0 ? 4 : 6);
(*sc->lm_writereg)(sc, LMD_VIDFAN, vidfan);
}
#endif
sensors[i].value = 0;
} else if (sdata == 0x00) {
sensors[i].flags |= SENSOR_FINVALID;
sensors[i].value = 0;
} else {
sensors[i].flags &= ~SENSOR_FINVALID;
sensors[i].value = 1350000 / (sdata << divisor);
}
}
}
/*
* pre: last read occurred >= 1.5 seconds ago
* post: sensors[] current data are the latest from the chip
*/
void
lm_refresh_sensor_data(struct lm_softc *sc)
{
/* Refresh our stored data for every sensor */
generic_stemp(sc, &sc->sensors[7]);
generic_svolt(sc, &sc->sensors[0]);
generic_fanrpm(sc, &sc->sensors[8]);
}
void
wb_svolt(struct lm_softc *sc)
{
int i, sdata;
for (i = 0; i < 9; ++i) {
if (i < 7) {
sdata = (*sc->lm_readreg)(sc, LMD_SENSORBASE + i);
} else {
/* from bank5 */
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_B5);
sdata = (*sc->lm_readreg)(sc, (i == 7) ?
WB_BANK5_5VSB : WB_BANK5_VBAT);
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_B0);
}
DPRINTF(("sdata[volt%d] 0x%x\n", i, sdata));
/* voltage returned as (mV >> 4), we convert to uV */
sdata = sdata << 4;
/* special case for negative voltages */
if (i == 5) {
/*
* -12Vdc, assume Winbond recommended values for
* resistors
*/
sdata = ((sdata * 1000) - (3600 * 806)) / 194;
} else if (i == 6) {
/*
* -5Vdc, assume Winbond recommended values for
* resistors
*/
sdata = ((sdata * 1000) - (3600 * 682)) / 318;
}
/* rfact is (factor * 10^4) */
sc->sensors[i].value = sdata * (int64_t)sc->sensors[i].rfact;
/* division by 10 gets us back to uVDC */
sc->sensors[i].value /= 10;
}
}
void
wb_stemp(struct lm_softc *sc, struct sensor *sensors, int n)
{
int sdata;
/* temperatures. Given in dC, we convert to uK */
sdata = (*sc->lm_readreg)(sc, LMD_SENSORBASE + 7);
DPRINTF(("sdata[temp0] 0x%x\n", sdata));
sensors[0].value = sdata * 1000000 + 273150000;
/* from bank1 */
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_B1);
sdata = (*sc->lm_readreg)(sc, WB_BANK1_T2H) << 1;
sdata |= ((*sc->lm_readreg)(sc, WB_BANK1_T2L) & 0x80) >> 7;
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_B0);
DPRINTF(("sdata[temp1] 0x%x\n", sdata));
sensors[1].value = (sdata * 1000000) / 2 + 273150000;
if (n < 3)
return;
/* from bank2 */
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_B2);
sdata = (*sc->lm_readreg)(sc, WB_BANK2_T3H) << 1;
sdata |= ((*sc->lm_readreg)(sc, WB_BANK2_T3L) & 0x80) >> 7;
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_B0);
DPRINTF(("sdata[temp2] 0x%x\n", sdata));
sensors[2].value = (sdata * 1000000) / 2 + 273150000;
}
void
wb781_fanrpm(struct lm_softc *sc, struct sensor *sensors)
{
int i, divisor, sdata;
for (i = 0; i < 3; i++) {
sdata = (*sc->lm_readreg)(sc, LMD_SENSORBASE + i + 8);
DPRINTF(("sdata[fan%d] 0x%x\n", i, sdata));
if (i == 0)
divisor = ((*sc->lm_readreg)(sc,
LMD_VIDFAN) >> 4) & 0x3;
else if (i == 1)
divisor = ((*sc->lm_readreg)(sc,
LMD_VIDFAN) >> 6) & 0x3;
else
divisor = ((*sc->lm_readreg)(sc, WB_PIN) >> 6) & 0x3;
DPRINTF(("sdata[%d] 0x%x div 0x%x\n", i, sdata, divisor));
if (sdata == 0xff) {
sensors[i].flags |= SENSOR_FINVALID;
} else if (sdata == 0x00) {
sensors[i].value = 0;
} else {
sensors[i].value = 1350000 / (sdata << divisor);
}
}
}
void
wb_fanrpm(struct lm_softc *sc, struct sensor *sensors, int n)
{
int i, divisor, sdata;
for (i = 0; i < n; i++) {
sdata = (*sc->lm_readreg)(sc, LMD_SENSORBASE + i + 8);
DPRINTF(("sdata[fan%d] 0x%x\n", i, sdata));
if (i == 0)
divisor = ((*sc->lm_readreg)(sc,
LMD_VIDFAN) >> 4) & 0x3;
else if (i == 1)
divisor = ((*sc->lm_readreg)(sc,
LMD_VIDFAN) >> 6) & 0x3;
else
divisor = ((*sc->lm_readreg)(sc, WB_PIN) >> 6) & 0x3;
divisor |= ((*sc->lm_readreg)(sc,
WB_BANK0_FANBAT) >> (i + 3)) & 0x4;
DPRINTF(("sdata[%d] 0x%x div 0x%x\n", i, sdata, divisor));
if (sdata == 0xff) {
sensors[i].flags |= SENSOR_FINVALID;
} else if (sdata == 0x00) {
sensors[i].value = 0;
} else {
sensors[i].value = 1350000 / (sdata << divisor);
}
}
}
void
wb781_refresh_sensor_data(struct lm_softc *sc)
{
int banksel;
/* Refresh our stored data for every sensor */
banksel = (*sc->lm_readreg)(sc, WB_BANKSEL);
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_B0);
generic_svolt(sc, &sc->sensors[0]);
wb_stemp(sc, &sc->sensors[7], 3);
wb781_fanrpm(sc, &sc->sensors[10]);
(*sc->lm_writereg)(sc, WB_BANKSEL, banksel);
}
void
wb782_refresh_sensor_data(struct lm_softc *sc)
{
int banksel;
/* Refresh our stored data for every sensor */
banksel = (*sc->lm_readreg)(sc, WB_BANKSEL);
(*sc->lm_writereg)(sc, WB_BANKSEL, WB_BANKSEL_B0);
wb_svolt(sc);
wb_stemp(sc, &sc->sensors[9], 3);
wb_fanrpm(sc, &sc->sensors[12], 3);
(*sc->lm_writereg)(sc, WB_BANKSEL, banksel);
}
void
wb697_refresh_sensor_data(struct lm_softc *sc)
{
int banksel;
/* Refresh our stored data for every sensor */
banksel = (*sc->lm_readreg)(sc, WB_BANKSEL);
(*sc->lm_writereg)(sc, WB_BANKSEL, 0);
wb_svolt(sc);
wb_stemp(sc, &sc->sensors[9], 2);
wb_fanrpm(sc, &sc->sensors[11], 2);
(*sc->lm_writereg)(sc, WB_BANKSEL, banksel);
}
void
lm_refresh(void *arg)
{
struct lm_softc *sc = (struct lm_softc *)arg;
sc->refresh_sensor_data(sc);
}
|