| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: nslm7x.c,v 1.64 2016/06/01 08:06:38 pgoyette Exp $ */ | | 1 | /* $NetBSD: nslm7x.c,v 1.64.10.1 2017/11/22 14:56:30 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Bill Squier. | | 8 | * by Bill Squier. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,103 +20,112 @@ | | | @@ -20,103 +20,112 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.64 2016/06/01 08:06:38 pgoyette Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.64.10.1 2017/11/22 14:56:30 martin Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | #include <sys/kernel.h> | | 37 | #include <sys/kernel.h> |
38 | #include <sys/proc.h> | | 38 | #include <sys/proc.h> |
39 | #include <sys/device.h> | | 39 | #include <sys/device.h> |
40 | #include <sys/module.h> | | 40 | #include <sys/module.h> |
41 | #include <sys/conf.h> | | 41 | #include <sys/conf.h> |
42 | #include <sys/time.h> | | 42 | #include <sys/time.h> |
43 | | | 43 | |
44 | #include <sys/bus.h> | | 44 | #include <sys/bus.h> |
45 | | | 45 | |
46 | #include <dev/isa/isareg.h> | | 46 | #include <dev/isa/isareg.h> |
47 | #include <dev/isa/isavar.h> | | 47 | #include <dev/isa/isavar.h> |
| | | 48 | #include <dev/isa/wbsioreg.h> |
48 | | | 49 | |
49 | #include <dev/sysmon/sysmonvar.h> | | 50 | #include <dev/sysmon/sysmonvar.h> |
50 | | | 51 | |
51 | #include <dev/ic/nslm7xvar.h> | | 52 | #include <dev/ic/nslm7xvar.h> |
52 | | | 53 | |
53 | #include <sys/intr.h> | | 54 | #include <sys/intr.h> |
54 | | | 55 | |
55 | #if defined(LMDEBUG) | | 56 | #if defined(LMDEBUG) |
56 | #define DPRINTF(x) do { printf x; } while (0) | | 57 | #define DPRINTF(x) do { printf x; } while (0) |
57 | #else | | 58 | #else |
58 | #define DPRINTF(x) | | 59 | #define DPRINTF(x) |
59 | #endif | | 60 | #endif |
60 | | | 61 | |
61 | /* | | 62 | /* |
62 | * LM78-compatible chips can typically measure voltages up to 4.096 V. | | 63 | * LM78-compatible chips can typically measure voltages up to 4.096 V. |
63 | * To measure higher voltages the input is attenuated with (external) | | 64 | * To measure higher voltages the input is attenuated with (external) |
64 | * resistors. Negative voltages are measured using inverting op amps | | 65 | * resistors. Negative voltages are measured using inverting op amps |
65 | * and resistors. So we have to convert the sensor values back to | | 66 | * and resistors. So we have to convert the sensor values back to |
66 | * real voltages by applying the appropriate resistor factor. | | 67 | * real voltages by applying the appropriate resistor factor. |
67 | */ | | 68 | */ |
68 | #define RFACT_NONE 10000 | | 69 | #define RFACT_NONE 10000 |
69 | #define RFACT(x, y) (RFACT_NONE * ((x) + (y)) / (y)) | | 70 | #define RFACT(x, y) (RFACT_NONE * ((x) + (y)) / (y)) |
70 | #define NRFACT(x, y) (-RFACT_NONE * (x) / (y)) | | 71 | #define NRFACT(x, y) (-RFACT_NONE * (x) / (y)) |
71 | | | 72 | |
72 | #define LM_REFRESH_TIMO (2 * hz) /* 2 seconds */ | | 73 | #define LM_REFRESH_TIMO (2 * hz) /* 2 seconds */ |
73 | | | 74 | |
74 | static int lm_match(struct lm_softc *); | | 75 | static const struct wb_product *wb_lookup(struct lm_softc *, |
| | | 76 | const struct wb_product *, uint16_t); |
75 | static int wb_match(struct lm_softc *); | | 77 | static int wb_match(struct lm_softc *); |
| | | 78 | static int wb_attach(struct lm_softc *); |
| | | 79 | static int nslm_match(struct lm_softc *); |
| | | 80 | static int nslm_attach(struct lm_softc *); |
76 | static int def_match(struct lm_softc *); | | 81 | static int def_match(struct lm_softc *); |
| | | 82 | static int def_attach(struct lm_softc *); |
77 | static void wb_temp_diode_type(struct lm_softc *, int); | | 83 | static void wb_temp_diode_type(struct lm_softc *, int); |
| | | 84 | static uint16_t wb_read_vendorid(struct lm_softc *); |
78 | | | 85 | |
79 | static void lm_refresh(void *); | | 86 | static void lm_refresh(void *); |
80 | | | 87 | |
81 | static void lm_generic_banksel(struct lm_softc *, int); | | 88 | static void lm_generic_banksel(struct lm_softc *, uint8_t); |
82 | static void lm_setup_sensors(struct lm_softc *, struct lm_sensor *); | | 89 | static void lm_setup_sensors(struct lm_softc *, const struct lm_sensor *); |
83 | static void lm_refresh_sensor_data(struct lm_softc *); | | 90 | static void lm_refresh_sensor_data(struct lm_softc *); |
84 | static void lm_refresh_volt(struct lm_softc *, int); | | 91 | static void lm_refresh_volt(struct lm_softc *, int); |
85 | static void lm_refresh_temp(struct lm_softc *, int); | | 92 | static void lm_refresh_temp(struct lm_softc *, int); |
86 | static void lm_refresh_fanrpm(struct lm_softc *, int); | | 93 | static void lm_refresh_fanrpm(struct lm_softc *, int); |
87 | | | 94 | |
88 | static void wb_refresh_sensor_data(struct lm_softc *); | | 95 | static void wb_refresh_sensor_data(struct lm_softc *); |
89 | static void wb_w83637hf_refresh_vcore(struct lm_softc *, int); | | 96 | static void wb_w83637hf_refresh_vcore(struct lm_softc *, int); |
90 | static void wb_refresh_nvolt(struct lm_softc *, int); | | 97 | static void wb_refresh_nvolt(struct lm_softc *, int); |
91 | static void wb_w83627ehf_refresh_nvolt(struct lm_softc *, int); | | 98 | static void wb_w83627ehf_refresh_nvolt(struct lm_softc *, int); |
92 | static void wb_refresh_temp(struct lm_softc *, int); | | 99 | static void wb_refresh_temp(struct lm_softc *, int); |
93 | static void wb_refresh_fanrpm(struct lm_softc *, int); | | 100 | static void wb_refresh_fanrpm(struct lm_softc *, int); |
94 | static void wb_w83792d_refresh_fanrpm(struct lm_softc *, int); | | 101 | static void wb_w83792d_refresh_fanrpm(struct lm_softc *, int); |
95 | static void wb_nct6776f_refresh_fanrpm(struct lm_softc *, int); | | 102 | static void wb_nct6776f_refresh_fanrpm(struct lm_softc *, int); |
| | | 103 | |
96 | static void as_refresh_temp(struct lm_softc *, int); | | 104 | static void as_refresh_temp(struct lm_softc *, int); |
97 | | | 105 | |
98 | struct lm_chip { | | 106 | struct lm_chip { |
99 | int (*chip_match)(struct lm_softc *); | | 107 | int (*chip_match)(struct lm_softc *); |
| | | 108 | int (*chip_attach)(struct lm_softc *); |
100 | }; | | 109 | }; |
101 | | | 110 | |
102 | static struct lm_chip lm_chips[] = { | | 111 | static struct lm_chip lm_chips[] = { |
103 | { wb_match }, | | 112 | { wb_match, wb_attach }, |
104 | { lm_match }, | | 113 | { nslm_match, nslm_attach }, |
105 | { def_match } /* Must be last */ | | 114 | { def_match, def_attach } /* Must be last */ |
106 | }; | | 115 | }; |
107 | | | 116 | |
108 | /* LM78/78J/79/81 */ | | 117 | /* LM78/78J/79/81 */ |
109 | static struct lm_sensor lm78_sensors[] = { | | 118 | static const struct lm_sensor lm78_sensors[] = { |
110 | /* Voltage */ | | 119 | /* Voltage */ |
111 | { | | 120 | { |
112 | .desc = "VCore A", | | 121 | .desc = "VCore A", |
113 | .type = ENVSYS_SVOLTS_DC, | | 122 | .type = ENVSYS_SVOLTS_DC, |
114 | .bank = 0, | | 123 | .bank = 0, |
115 | .reg = 0x20, | | 124 | .reg = 0x20, |
116 | .refresh = lm_refresh_volt, | | 125 | .refresh = lm_refresh_volt, |
117 | .rfact = RFACT_NONE | | 126 | .rfact = RFACT_NONE |
118 | }, | | 127 | }, |
119 | { | | 128 | { |
120 | .desc = "VCore B", | | 129 | .desc = "VCore B", |
121 | .type = ENVSYS_SVOLTS_DC, | | 130 | .type = ENVSYS_SVOLTS_DC, |
122 | .bank = 0, | | 131 | .bank = 0, |
| @@ -195,27 +204,27 @@ static struct lm_sensor lm78_sensors[] = | | | @@ -195,27 +204,27 @@ static struct lm_sensor lm78_sensors[] = |
195 | { | | 204 | { |
196 | .desc = "Fan2", | | 205 | .desc = "Fan2", |
197 | .type = ENVSYS_SFANRPM, | | 206 | .type = ENVSYS_SFANRPM, |
198 | .bank = 0, | | 207 | .bank = 0, |
199 | .reg = 0x2a, | | 208 | .reg = 0x2a, |
200 | .refresh = lm_refresh_fanrpm, | | 209 | .refresh = lm_refresh_fanrpm, |
201 | .rfact = 0 | | 210 | .rfact = 0 |
202 | }, | | 211 | }, |
203 | | | 212 | |
204 | { .desc = NULL } | | 213 | { .desc = NULL } |
205 | }; | | 214 | }; |
206 | | | 215 | |
207 | /* W83627HF */ | | 216 | /* W83627HF */ |
208 | static struct lm_sensor w83627hf_sensors[] = { | | 217 | static const struct lm_sensor w83627hf_sensors[] = { |
209 | /* Voltage */ | | 218 | /* Voltage */ |
210 | { | | 219 | { |
211 | .desc = "VCore A", | | 220 | .desc = "VCore A", |
212 | .type = ENVSYS_SVOLTS_DC, | | 221 | .type = ENVSYS_SVOLTS_DC, |
213 | .bank = 0, | | 222 | .bank = 0, |
214 | .reg = 0x20, | | 223 | .reg = 0x20, |
215 | .refresh = lm_refresh_volt, | | 224 | .refresh = lm_refresh_volt, |
216 | .rfact = RFACT_NONE | | 225 | .rfact = RFACT_NONE |
217 | }, | | 226 | }, |
218 | { | | 227 | { |
219 | .desc = "VCore B", | | 228 | .desc = "VCore B", |
220 | .type = ENVSYS_SVOLTS_DC, | | 229 | .type = ENVSYS_SVOLTS_DC, |
221 | .bank = 0, | | 230 | .bank = 0, |
| @@ -334,27 +343,27 @@ static struct lm_sensor w83627hf_sensors | | | @@ -334,27 +343,27 @@ static struct lm_sensor w83627hf_sensors |
334 | | | 343 | |
335 | { .desc = NULL } | | 344 | { .desc = NULL } |
336 | }; | | 345 | }; |
337 | | | 346 | |
338 | /* W8627EHF */ | | 347 | /* W8627EHF */ |
339 | | | 348 | |
340 | /* | | 349 | /* |
341 | * The W83627EHF can measure voltages up to 2.048 V instead of the | | 350 | * The W83627EHF can measure voltages up to 2.048 V instead of the |
342 | * traditional 4.096 V. For measuring positive voltages, this can be | | 351 | * traditional 4.096 V. For measuring positive voltages, this can be |
343 | * accounted for by halving the resistor factor. Negative voltages | | 352 | * accounted for by halving the resistor factor. Negative voltages |
344 | * need special treatment, also because the reference voltage is 2.048 V | | 353 | * need special treatment, also because the reference voltage is 2.048 V |
345 | * instead of the traditional 3.6 V. | | 354 | * instead of the traditional 3.6 V. |
346 | */ | | 355 | */ |
347 | static struct lm_sensor w83627ehf_sensors[] = { | | 356 | static const struct lm_sensor w83627ehf_sensors[] = { |
348 | /* Voltage */ | | 357 | /* Voltage */ |
349 | { | | 358 | { |
350 | .desc = "VCore", | | 359 | .desc = "VCore", |
351 | .type = ENVSYS_SVOLTS_DC, | | 360 | .type = ENVSYS_SVOLTS_DC, |
352 | .bank = 0, | | 361 | .bank = 0, |
353 | .reg = 0x20, | | 362 | .reg = 0x20, |
354 | .refresh = lm_refresh_volt, | | 363 | .refresh = lm_refresh_volt, |
355 | .rfact = RFACT_NONE / 2 | | 364 | .rfact = RFACT_NONE / 2 |
356 | }, | | 365 | }, |
357 | { | | 366 | { |
358 | .desc = "+12V", | | 367 | .desc = "+12V", |
359 | .type = ENVSYS_SVOLTS_DC, | | 368 | .type = ENVSYS_SVOLTS_DC, |
360 | .bank = 0, | | 369 | .bank = 0, |
| @@ -473,27 +482,27 @@ static struct lm_sensor w83627ehf_sensor | | | @@ -473,27 +482,27 @@ static struct lm_sensor w83627ehf_sensor |
473 | { | | 482 | { |
474 | .desc = "Fan2", | | 483 | .desc = "Fan2", |
475 | .type = ENVSYS_SFANRPM, | | 484 | .type = ENVSYS_SFANRPM, |
476 | .bank = 0, | | 485 | .bank = 0, |
477 | .reg = 0x2a, | | 486 | .reg = 0x2a, |
478 | .refresh = wb_refresh_fanrpm, | | 487 | .refresh = wb_refresh_fanrpm, |
479 | .rfact = 0 | | 488 | .rfact = 0 |
480 | }, | | 489 | }, |
481 | | | 490 | |
482 | { .desc = NULL } | | 491 | { .desc = NULL } |
483 | }; | | 492 | }; |
484 | | | 493 | |
485 | /* W83627DHG */ | | 494 | /* W83627DHG */ |
486 | static struct lm_sensor w83627dhg_sensors[] = { | | 495 | static const struct lm_sensor w83627dhg_sensors[] = { |
487 | /* Voltage */ | | 496 | /* Voltage */ |
488 | { | | 497 | { |
489 | .desc = "VCore", | | 498 | .desc = "VCore", |
490 | .type = ENVSYS_SVOLTS_DC, | | 499 | .type = ENVSYS_SVOLTS_DC, |
491 | .bank = 0, | | 500 | .bank = 0, |
492 | .reg = 0x20, | | 501 | .reg = 0x20, |
493 | .refresh = lm_refresh_volt, | | 502 | .refresh = lm_refresh_volt, |
494 | .rfact = RFACT_NONE / 2 | | 503 | .rfact = RFACT_NONE / 2 |
495 | }, | | 504 | }, |
496 | { | | 505 | { |
497 | .desc = "+12V", | | 506 | .desc = "+12V", |
498 | .type = ENVSYS_SVOLTS_DC, | | 507 | .type = ENVSYS_SVOLTS_DC, |
499 | .bank = 0, | | 508 | .bank = 0, |
| @@ -604,27 +613,27 @@ static struct lm_sensor w83627dhg_sensor | | | @@ -604,27 +613,27 @@ static struct lm_sensor w83627dhg_sensor |
604 | { | | 613 | { |
605 | .desc = "Aux Fan", | | 614 | .desc = "Aux Fan", |
606 | .type = ENVSYS_SFANRPM, | | 615 | .type = ENVSYS_SFANRPM, |
607 | .bank = 0, | | 616 | .bank = 0, |
608 | .reg = 0x2a, | | 617 | .reg = 0x2a, |
609 | .refresh = wb_refresh_fanrpm, | | 618 | .refresh = wb_refresh_fanrpm, |
610 | .rfact = 0 | | 619 | .rfact = 0 |
611 | }, | | 620 | }, |
612 | | | 621 | |
613 | { .desc = NULL } | | 622 | { .desc = NULL } |
614 | }; | | 623 | }; |
615 | | | 624 | |
616 | /* W83637HF */ | | 625 | /* W83637HF */ |
617 | static struct lm_sensor w83637hf_sensors[] = { | | 626 | static const struct lm_sensor w83637hf_sensors[] = { |
618 | /* Voltage */ | | 627 | /* Voltage */ |
619 | { | | 628 | { |
620 | .desc = "VCore", | | 629 | .desc = "VCore", |
621 | .type = ENVSYS_SVOLTS_DC, | | 630 | .type = ENVSYS_SVOLTS_DC, |
622 | .bank = 0, | | 631 | .bank = 0, |
623 | .reg = 0x20, | | 632 | .reg = 0x20, |
624 | .refresh = wb_w83637hf_refresh_vcore, | | 633 | .refresh = wb_w83637hf_refresh_vcore, |
625 | .rfact = 0 | | 634 | .rfact = 0 |
626 | }, | | 635 | }, |
627 | { | | 636 | { |
628 | .desc = "+12V", | | 637 | .desc = "+12V", |
629 | .type = ENVSYS_SVOLTS_DC, | | 638 | .type = ENVSYS_SVOLTS_DC, |
630 | .bank = 0, | | 639 | .bank = 0, |
| @@ -719,27 +728,27 @@ static struct lm_sensor w83637hf_sensors | | | @@ -719,27 +728,27 @@ static struct lm_sensor w83637hf_sensors |
719 | { | | 728 | { |
720 | .desc = "Fan2", | | 729 | .desc = "Fan2", |
721 | .type = ENVSYS_SFANRPM, | | 730 | .type = ENVSYS_SFANRPM, |
722 | .bank = 0, | | 731 | .bank = 0, |
723 | .reg = 0x2a, | | 732 | .reg = 0x2a, |
724 | .refresh = wb_refresh_fanrpm, | | 733 | .refresh = wb_refresh_fanrpm, |
725 | .rfact = 0 | | 734 | .rfact = 0 |
726 | }, | | 735 | }, |
727 | | | 736 | |
728 | { .desc = NULL } | | 737 | { .desc = NULL } |
729 | }; | | 738 | }; |
730 | | | 739 | |
731 | /* W83697HF */ | | 740 | /* W83697HF */ |
732 | static struct lm_sensor w83697hf_sensors[] = { | | 741 | static const struct lm_sensor w83697hf_sensors[] = { |
733 | /* Voltage */ | | 742 | /* Voltage */ |
734 | { | | 743 | { |
735 | .desc = "VCore", | | 744 | .desc = "VCore", |
736 | .type = ENVSYS_SVOLTS_DC, | | 745 | .type = ENVSYS_SVOLTS_DC, |
737 | .bank = 0, | | 746 | .bank = 0, |
738 | .reg = 0x20, | | 747 | .reg = 0x20, |
739 | .refresh = lm_refresh_volt, | | 748 | .refresh = lm_refresh_volt, |
740 | .rfact = RFACT_NONE | | 749 | .rfact = RFACT_NONE |
741 | }, | | 750 | }, |
742 | { | | 751 | { |
743 | .desc = "+3.3V", | | 752 | .desc = "+3.3V", |
744 | .type = ENVSYS_SVOLTS_DC, | | 753 | .type = ENVSYS_SVOLTS_DC, |
745 | .bank = 0, | | 754 | .bank = 0, |
| @@ -832,27 +841,27 @@ static struct lm_sensor w83697hf_sensors | | | @@ -832,27 +841,27 @@ static struct lm_sensor w83697hf_sensors |
832 | .rfact = 0 | | 841 | .rfact = 0 |
833 | }, | | 842 | }, |
834 | | | 843 | |
835 | { .desc = NULL } | | 844 | { .desc = NULL } |
836 | }; | | 845 | }; |
837 | | | 846 | |
838 | /* W83781D */ | | 847 | /* W83781D */ |
839 | | | 848 | |
840 | /* | | 849 | /* |
841 | * The datasheet doesn't mention the (internal) resistors used for the | | 850 | * The datasheet doesn't mention the (internal) resistors used for the |
842 | * +5V, but using the values from the W83782D datasheets seems to | | 851 | * +5V, but using the values from the W83782D datasheets seems to |
843 | * provide sensible results. | | 852 | * provide sensible results. |
844 | */ | | 853 | */ |
845 | static struct lm_sensor w83781d_sensors[] = { | | 854 | static const struct lm_sensor w83781d_sensors[] = { |
846 | /* Voltage */ | | 855 | /* Voltage */ |
847 | { | | 856 | { |
848 | .desc = "VCore A", | | 857 | .desc = "VCore A", |
849 | .type = ENVSYS_SVOLTS_DC, | | 858 | .type = ENVSYS_SVOLTS_DC, |
850 | .bank = 0, | | 859 | .bank = 0, |
851 | .reg = 0x20, | | 860 | .reg = 0x20, |
852 | .refresh = lm_refresh_volt, | | 861 | .refresh = lm_refresh_volt, |
853 | .rfact = RFACT_NONE | | 862 | .rfact = RFACT_NONE |
854 | }, | | 863 | }, |
855 | { | | 864 | { |
856 | .desc = "VCore B", | | 865 | .desc = "VCore B", |
857 | .type = ENVSYS_SVOLTS_DC, | | 866 | .type = ENVSYS_SVOLTS_DC, |
858 | .bank = 0, | | 867 | .bank = 0, |
| @@ -947,27 +956,27 @@ static struct lm_sensor w83781d_sensors[ | | | @@ -947,27 +956,27 @@ static struct lm_sensor w83781d_sensors[ |
947 | { | | 956 | { |
948 | .desc = "Fan2", | | 957 | .desc = "Fan2", |
949 | .type = ENVSYS_SFANRPM, | | 958 | .type = ENVSYS_SFANRPM, |
950 | .bank = 0, | | 959 | .bank = 0, |
951 | .reg = 0x2a, | | 960 | .reg = 0x2a, |
952 | .refresh = lm_refresh_fanrpm, | | 961 | .refresh = lm_refresh_fanrpm, |
953 | .rfact = 0 | | 962 | .rfact = 0 |
954 | }, | | 963 | }, |
955 | | | 964 | |
956 | { .desc = NULL } | | 965 | { .desc = NULL } |
957 | }; | | 966 | }; |
958 | | | 967 | |
959 | /* W83782D */ | | 968 | /* W83782D */ |
960 | static struct lm_sensor w83782d_sensors[] = { | | 969 | static const struct lm_sensor w83782d_sensors[] = { |
961 | /* Voltage */ | | 970 | /* Voltage */ |
962 | { | | 971 | { |
963 | .desc = "VCore", | | 972 | .desc = "VCore", |
964 | .type = ENVSYS_SVOLTS_DC, | | 973 | .type = ENVSYS_SVOLTS_DC, |
965 | .bank = 0, | | 974 | .bank = 0, |
966 | .reg = 0x20, | | 975 | .reg = 0x20, |
967 | .refresh = lm_refresh_volt, | | 976 | .refresh = lm_refresh_volt, |
968 | .rfact = RFACT_NONE | | 977 | .rfact = RFACT_NONE |
969 | }, | | 978 | }, |
970 | { | | 979 | { |
971 | .desc = "VINR0", | | 980 | .desc = "VINR0", |
972 | .type = ENVSYS_SVOLTS_DC, | | 981 | .type = ENVSYS_SVOLTS_DC, |
973 | .bank = 0, | | 982 | .bank = 0, |
| @@ -1078,27 +1087,27 @@ static struct lm_sensor w83782d_sensors[ | | | @@ -1078,27 +1087,27 @@ static struct lm_sensor w83782d_sensors[ |
1078 | { | | 1087 | { |
1079 | .desc = "Fan2", | | 1088 | .desc = "Fan2", |
1080 | .type = ENVSYS_SFANRPM, | | 1089 | .type = ENVSYS_SFANRPM, |
1081 | .bank = 0, | | 1090 | .bank = 0, |
1082 | .reg = 0x2a, | | 1091 | .reg = 0x2a, |
1083 | .refresh = wb_refresh_fanrpm, | | 1092 | .refresh = wb_refresh_fanrpm, |
1084 | .rfact = 0 | | 1093 | .rfact = 0 |
1085 | }, | | 1094 | }, |
1086 | | | 1095 | |
1087 | { .desc = NULL } | | 1096 | { .desc = NULL } |
1088 | }; | | 1097 | }; |
1089 | | | 1098 | |
1090 | /* W83783S */ | | 1099 | /* W83783S */ |
1091 | static struct lm_sensor w83783s_sensors[] = { | | 1100 | static const struct lm_sensor w83783s_sensors[] = { |
1092 | /* Voltage */ | | 1101 | /* Voltage */ |
1093 | { | | 1102 | { |
1094 | .desc = "VCore", | | 1103 | .desc = "VCore", |
1095 | .type = ENVSYS_SVOLTS_DC, | | 1104 | .type = ENVSYS_SVOLTS_DC, |
1096 | .bank = 0, | | 1105 | .bank = 0, |
1097 | .reg = 0x20, | | 1106 | .reg = 0x20, |
1098 | .refresh = lm_refresh_volt, | | 1107 | .refresh = lm_refresh_volt, |
1099 | .rfact = RFACT_NONE | | 1108 | .rfact = RFACT_NONE |
1100 | }, | | 1109 | }, |
1101 | { | | 1110 | { |
1102 | .desc = "+3.3V", | | 1111 | .desc = "+3.3V", |
1103 | .type = ENVSYS_SVOLTS_DC, | | 1112 | .type = ENVSYS_SVOLTS_DC, |
1104 | .bank = 0, | | 1113 | .bank = 0, |
| @@ -1177,27 +1186,27 @@ static struct lm_sensor w83783s_sensors[ | | | @@ -1177,27 +1186,27 @@ static struct lm_sensor w83783s_sensors[ |
1177 | { | | 1186 | { |
1178 | .desc = "Fan2", | | 1187 | .desc = "Fan2", |
1179 | .type = ENVSYS_SFANRPM, | | 1188 | .type = ENVSYS_SFANRPM, |
1180 | .bank = 0, | | 1189 | .bank = 0, |
1181 | .reg = 0x2a, | | 1190 | .reg = 0x2a, |
1182 | .refresh = wb_refresh_fanrpm, | | 1191 | .refresh = wb_refresh_fanrpm, |
1183 | .rfact = 0 | | 1192 | .rfact = 0 |
1184 | }, | | 1193 | }, |
1185 | | | 1194 | |
1186 | { .desc = NULL } | | 1195 | { .desc = NULL } |
1187 | }; | | 1196 | }; |
1188 | | | 1197 | |
1189 | /* W83791D */ | | 1198 | /* W83791D */ |
1190 | static struct lm_sensor w83791d_sensors[] = { | | 1199 | static const struct lm_sensor w83791d_sensors[] = { |
1191 | /* Voltage */ | | 1200 | /* Voltage */ |
1192 | { | | 1201 | { |
1193 | .desc = "VCore", | | 1202 | .desc = "VCore", |
1194 | .type = ENVSYS_SVOLTS_DC, | | 1203 | .type = ENVSYS_SVOLTS_DC, |
1195 | .bank = 0, | | 1204 | .bank = 0, |
1196 | .reg = 0x20, | | 1205 | .reg = 0x20, |
1197 | .refresh = lm_refresh_volt, | | 1206 | .refresh = lm_refresh_volt, |
1198 | .rfact = 10000 | | 1207 | .rfact = 10000 |
1199 | }, | | 1208 | }, |
1200 | { | | 1209 | { |
1201 | .desc = "VINR0", | | 1210 | .desc = "VINR0", |
1202 | .type = ENVSYS_SVOLTS_DC, | | 1211 | .type = ENVSYS_SVOLTS_DC, |
1203 | .bank = 0, | | 1212 | .bank = 0, |
| @@ -1332,27 +1341,27 @@ static struct lm_sensor w83791d_sensors[ | | | @@ -1332,27 +1341,27 @@ static struct lm_sensor w83791d_sensors[ |
1332 | { | | 1341 | { |
1333 | .desc = "Fan4", | | 1342 | .desc = "Fan4", |
1334 | .type = ENVSYS_SFANRPM, | | 1343 | .type = ENVSYS_SFANRPM, |
1335 | .bank = 0, | | 1344 | .bank = 0, |
1336 | .reg = 0xbb, | | 1345 | .reg = 0xbb, |
1337 | .refresh = wb_refresh_fanrpm, | | 1346 | .refresh = wb_refresh_fanrpm, |
1338 | .rfact = 0 | | 1347 | .rfact = 0 |
1339 | }, | | 1348 | }, |
1340 | | | 1349 | |
1341 | { .desc = NULL } | | 1350 | { .desc = NULL } |
1342 | }; | | 1351 | }; |
1343 | | | 1352 | |
1344 | /* W83792D */ | | 1353 | /* W83792D */ |
1345 | static struct lm_sensor w83792d_sensors[] = { | | 1354 | static const struct lm_sensor w83792d_sensors[] = { |
1346 | /* Voltage */ | | 1355 | /* Voltage */ |
1347 | { | | 1356 | { |
1348 | .desc = "VCore A", | | 1357 | .desc = "VCore A", |
1349 | .type = ENVSYS_SVOLTS_DC, | | 1358 | .type = ENVSYS_SVOLTS_DC, |
1350 | .bank = 0, | | 1359 | .bank = 0, |
1351 | .reg = 0x20, | | 1360 | .reg = 0x20, |
1352 | .refresh = lm_refresh_volt, | | 1361 | .refresh = lm_refresh_volt, |
1353 | .rfact = RFACT_NONE | | 1362 | .rfact = RFACT_NONE |
1354 | }, | | 1363 | }, |
1355 | { | | 1364 | { |
1356 | .desc = "VCore B", | | 1365 | .desc = "VCore B", |
1357 | .type = ENVSYS_SVOLTS_DC, | | 1366 | .type = ENVSYS_SVOLTS_DC, |
1358 | .bank = 0, | | 1367 | .bank = 0, |
| @@ -1495,27 +1504,27 @@ static struct lm_sensor w83792d_sensors[ | | | @@ -1495,27 +1504,27 @@ static struct lm_sensor w83792d_sensors[ |
1495 | { | | 1504 | { |
1496 | .desc = "Fan6", | | 1505 | .desc = "Fan6", |
1497 | .type = ENVSYS_SFANRPM, | | 1506 | .type = ENVSYS_SFANRPM, |
1498 | .bank = 0, | | 1507 | .bank = 0, |
1499 | .reg = 0xbe, | | 1508 | .reg = 0xbe, |
1500 | .refresh = wb_w83792d_refresh_fanrpm, | | 1509 | .refresh = wb_w83792d_refresh_fanrpm, |
1501 | .rfact = 0 | | 1510 | .rfact = 0 |
1502 | }, | | 1511 | }, |
1503 | | | 1512 | |
1504 | { .desc = NULL } | | 1513 | { .desc = NULL } |
1505 | }; | | 1514 | }; |
1506 | | | 1515 | |
1507 | /* AS99127F */ | | 1516 | /* AS99127F */ |
1508 | static struct lm_sensor as99127f_sensors[] = { | | 1517 | static const struct lm_sensor as99127f_sensors[] = { |
1509 | /* Voltage */ | | 1518 | /* Voltage */ |
1510 | { | | 1519 | { |
1511 | .desc = "VCore A", | | 1520 | .desc = "VCore A", |
1512 | .type = ENVSYS_SVOLTS_DC, | | 1521 | .type = ENVSYS_SVOLTS_DC, |
1513 | .bank = 0, | | 1522 | .bank = 0, |
1514 | .reg = 0x20, | | 1523 | .reg = 0x20, |
1515 | .refresh = lm_refresh_volt, | | 1524 | .refresh = lm_refresh_volt, |
1516 | .rfact = RFACT_NONE | | 1525 | .rfact = RFACT_NONE |
1517 | }, | | 1526 | }, |
1518 | { | | 1527 | { |
1519 | .desc = "VCore B", | | 1528 | .desc = "VCore B", |
1520 | .type = ENVSYS_SVOLTS_DC, | | 1529 | .type = ENVSYS_SVOLTS_DC, |
1521 | .bank = 0, | | 1530 | .bank = 0, |
| @@ -1609,28 +1618,28 @@ static struct lm_sensor as99127f_sensors | | | @@ -1609,28 +1618,28 @@ static struct lm_sensor as99127f_sensors |
1609 | }, | | 1618 | }, |
1610 | { | | 1619 | { |
1611 | .desc = "Fan2", | | 1620 | .desc = "Fan2", |
1612 | .type = ENVSYS_SFANRPM, | | 1621 | .type = ENVSYS_SFANRPM, |
1613 | .bank = 0, | | 1622 | .bank = 0, |
1614 | .reg = 0x2a, | | 1623 | .reg = 0x2a, |
1615 | .refresh = lm_refresh_fanrpm, | | 1624 | .refresh = lm_refresh_fanrpm, |
1616 | .rfact = 0 | | 1625 | .rfact = 0 |
1617 | }, | | 1626 | }, |
1618 | | | 1627 | |
1619 | { .desc = NULL } | | 1628 | { .desc = NULL } |
1620 | }; | | 1629 | }; |
1621 | | | 1630 | |
1622 | /* NCT6776F */ | | 1631 | /* NCT6776F */ |
1623 | static struct lm_sensor nct6776f_sensors[] = { | | 1632 | static const struct lm_sensor nct6776f_sensors[] = { |
1624 | /* Voltage */ | | 1633 | /* Voltage */ |
1625 | { | | 1634 | { |
1626 | .desc = "VCore", | | 1635 | .desc = "VCore", |
1627 | .type = ENVSYS_SVOLTS_DC, | | 1636 | .type = ENVSYS_SVOLTS_DC, |
1628 | .bank = 0, | | 1637 | .bank = 0, |
1629 | .reg = 0x20, | | 1638 | .reg = 0x20, |
1630 | .refresh = lm_refresh_volt, | | 1639 | .refresh = lm_refresh_volt, |
1631 | .rfact = RFACT_NONE / 2 | | 1640 | .rfact = RFACT_NONE / 2 |
1632 | }, | | 1641 | }, |
1633 | { | | 1642 | { |
1634 | .desc = "+12V", | | 1643 | .desc = "+12V", |
1635 | .type = ENVSYS_SVOLTS_DC, | | 1644 | .type = ENVSYS_SVOLTS_DC, |
1636 | .bank = 0, | | 1645 | .bank = 0, |
| @@ -1757,79 +1766,497 @@ static struct lm_sensor nct6776f_sensors | | | @@ -1757,79 +1766,497 @@ static struct lm_sensor nct6776f_sensors |
1757 | | | 1766 | |
1758 | { | | 1767 | { |
1759 | .desc = "Aux Fan2", | | 1768 | .desc = "Aux Fan2", |
1760 | .type = ENVSYS_SFANRPM, | | 1769 | .type = ENVSYS_SFANRPM, |
1761 | .bank = 6, | | 1770 | .bank = 6, |
1762 | .reg = 0x5e, | | 1771 | .reg = 0x5e, |
1763 | .refresh = wb_nct6776f_refresh_fanrpm, | | 1772 | .refresh = wb_nct6776f_refresh_fanrpm, |
1764 | .rfact = 0 | | 1773 | .rfact = 0 |
1765 | }, | | 1774 | }, |
1766 | | | 1775 | |
1767 | { .desc = NULL } | | 1776 | { .desc = NULL } |
1768 | }; | | 1777 | }; |
1769 | | | 1778 | |
| | | 1779 | /* NCT610[246]D */ |
| | | 1780 | static const struct lm_sensor nct6102d_sensors[] = { |
| | | 1781 | /* Voltage */ |
| | | 1782 | { |
| | | 1783 | .desc = "VCore", |
| | | 1784 | .type = ENVSYS_SVOLTS_DC, |
| | | 1785 | .bank = 0, |
| | | 1786 | .reg = 0x00, |
| | | 1787 | .refresh = lm_refresh_volt, |
| | | 1788 | .rfact = RFACT_NONE |
| | | 1789 | }, |
| | | 1790 | { |
| | | 1791 | .desc = "VIN0", |
| | | 1792 | .type = ENVSYS_SVOLTS_DC, |
| | | 1793 | .bank = 0, |
| | | 1794 | .reg = 0x01, |
| | | 1795 | .refresh = lm_refresh_volt, |
| | | 1796 | .rfact = RFACT_NONE |
| | | 1797 | }, |
| | | 1798 | { |
| | | 1799 | .desc = "AVCC", |
| | | 1800 | .type = ENVSYS_SVOLTS_DC, |
| | | 1801 | .bank = 0, |
| | | 1802 | .reg = 0x02, |
| | | 1803 | .refresh = lm_refresh_volt, |
| | | 1804 | .rfact = RFACT(34, 34) / 2 |
| | | 1805 | }, |
| | | 1806 | { |
| | | 1807 | .desc = "3VCC", |
| | | 1808 | .type = ENVSYS_SVOLTS_DC, |
| | | 1809 | .bank = 0, |
| | | 1810 | .reg = 0x03, |
| | | 1811 | .refresh = lm_refresh_volt, |
| | | 1812 | .rfact = RFACT(34, 34) / 2 |
| | | 1813 | }, |
| | | 1814 | { |
| | | 1815 | .desc = "VIN1", |
| | | 1816 | .type = ENVSYS_SVOLTS_DC, |
| | | 1817 | .bank = 0, |
| | | 1818 | .reg = 0x04, |
| | | 1819 | .refresh = lm_refresh_volt, |
| | | 1820 | .rfact = RFACT_NONE |
| | | 1821 | }, |
| | | 1822 | { |
| | | 1823 | .desc = "VIN2", |
| | | 1824 | .type = ENVSYS_SVOLTS_DC, |
| | | 1825 | .bank = 0, |
| | | 1826 | .reg = 0x05, |
| | | 1827 | .refresh = lm_refresh_volt, |
| | | 1828 | .rfact = RFACT(34, 34) / 2 |
| | | 1829 | }, |
| | | 1830 | { |
| | | 1831 | .desc = "+3.3VSB", |
| | | 1832 | .type = ENVSYS_SVOLTS_DC, |
| | | 1833 | .bank = 0, |
| | | 1834 | .reg = 0x07, |
| | | 1835 | .refresh = lm_refresh_volt, |
| | | 1836 | .rfact = RFACT(34, 34) / 2 |
| | | 1837 | }, |
| | | 1838 | { |
| | | 1839 | .desc = "VBAT", |
| | | 1840 | .type = ENVSYS_SVOLTS_DC, |
| | | 1841 | .bank = 0, |
| | | 1842 | .reg = 0x08, |
| | | 1843 | .refresh = lm_refresh_volt, |
| | | 1844 | .rfact = RFACT(34, 34) / 2 |
| | | 1845 | }, |
| | | 1846 | { |
| | | 1847 | .desc = "VTT", |
| | | 1848 | .type = ENVSYS_SVOLTS_DC, |
| | | 1849 | .bank = 0, |
| | | 1850 | .reg = 0x09, |
| | | 1851 | .refresh = lm_refresh_volt, |
| | | 1852 | .rfact = RFACT_NONE |
| | | 1853 | }, |
| | | 1854 | |
| | | 1855 | /* Temperature */ |
| | | 1856 | { |
| | | 1857 | .desc = "MB Temperature", |
| | | 1858 | .type = ENVSYS_STEMP, |
| | | 1859 | .bank = 0, |
| | | 1860 | .reg = 0x18, |
| | | 1861 | .refresh = lm_refresh_temp, |
| | | 1862 | .rfact = 0 |
| | | 1863 | }, |
| | | 1864 | { |
| | | 1865 | .desc = "CPU Temperature", |
| | | 1866 | .type = ENVSYS_STEMP, |
| | | 1867 | .bank = 0, |
| | | 1868 | .reg = 0x19, |
| | | 1869 | .refresh = lm_refresh_temp, |
| | | 1870 | .rfact = 0 |
| | | 1871 | }, |
| | | 1872 | { |
| | | 1873 | .desc = "Aux Temp", |
| | | 1874 | .type = ENVSYS_STEMP, |
| | | 1875 | .bank = 0, |
| | | 1876 | .reg = 0x1a, |
| | | 1877 | .refresh = lm_refresh_temp, |
| | | 1878 | .rfact = 0 |
| | | 1879 | }, |
| | | 1880 | |
| | | 1881 | /* Fans */ |
| | | 1882 | { |
| | | 1883 | .desc = "System Fan", |
| | | 1884 | .type = ENVSYS_SFANRPM, |
| | | 1885 | .bank = 0, |
| | | 1886 | .reg = 0x30, |
| | | 1887 | .refresh = wb_nct6776f_refresh_fanrpm, |
| | | 1888 | .rfact = 0 |
| | | 1889 | }, |
| | | 1890 | { |
| | | 1891 | .desc = "CPU Fan", |
| | | 1892 | .type = ENVSYS_SFANRPM, |
| | | 1893 | .bank = 0, |
| | | 1894 | .reg = 0x32, |
| | | 1895 | .refresh = wb_nct6776f_refresh_fanrpm, |
| | | 1896 | .rfact = 0 |
| | | 1897 | }, |
| | | 1898 | { |
| | | 1899 | .desc = "Aux Fan", |
| | | 1900 | .type = ENVSYS_SFANRPM, |
| | | 1901 | .bank = 0, |
| | | 1902 | .reg = 0x34, |
| | | 1903 | .refresh = wb_nct6776f_refresh_fanrpm, |
| | | 1904 | .rfact = 0 |
| | | 1905 | }, |
| | | 1906 | |
| | | 1907 | { .desc = NULL } |
| | | 1908 | }; |
| | | 1909 | |
| | | 1910 | /* NCT6779D */ |
| | | 1911 | static const struct lm_sensor nct6779d_sensors[] = { |
| | | 1912 | /* Voltage */ |
| | | 1913 | { |
| | | 1914 | .desc = "VCore", |
| | | 1915 | .type = ENVSYS_SVOLTS_DC, |
| | | 1916 | .bank = 4, |
| | | 1917 | .reg = 0x80, |
| | | 1918 | .refresh = lm_refresh_volt, |
| | | 1919 | .rfact = RFACT_NONE / 2 |
| | | 1920 | }, |
| | | 1921 | { |
| | | 1922 | .desc = "VIN1", |
| | | 1923 | .type = ENVSYS_SVOLTS_DC, |
| | | 1924 | .bank = 4, |
| | | 1925 | .reg = 0x81, |
| | | 1926 | .refresh = lm_refresh_volt, |
| | | 1927 | .rfact = RFACT(56, 10) / 2 |
| | | 1928 | }, |
| | | 1929 | { |
| | | 1930 | .desc = "AVCC", |
| | | 1931 | .type = ENVSYS_SVOLTS_DC, |
| | | 1932 | .bank = 4, |
| | | 1933 | .reg = 0x82, |
| | | 1934 | .refresh = lm_refresh_volt, |
| | | 1935 | .rfact = RFACT(34, 34) / 2 |
| | | 1936 | }, |
| | | 1937 | { |
| | | 1938 | .desc = "+3.3V", |
| | | 1939 | .type = ENVSYS_SVOLTS_DC, |
| | | 1940 | .bank = 4, |
| | | 1941 | .reg = 0x83, |
| | | 1942 | .refresh = lm_refresh_volt, |
| | | 1943 | .rfact = RFACT(34, 34) / 2 |
| | | 1944 | }, |
| | | 1945 | { |
| | | 1946 | .desc = "VIN0", |
| | | 1947 | .type = ENVSYS_SVOLTS_DC, |
| | | 1948 | .bank = 4, |
| | | 1949 | .reg = 0x84, |
| | | 1950 | .refresh = lm_refresh_volt, |
| | | 1951 | .rfact = RFACT(48600, 10000) |
| | | 1952 | }, |
| | | 1953 | { |
| | | 1954 | .desc = "VIN8", |
| | | 1955 | .type = ENVSYS_SVOLTS_DC, |
| | | 1956 | .bank = 4, |
| | | 1957 | .reg = 0x85, |
| | | 1958 | .refresh = lm_refresh_volt, |
| | | 1959 | .rfact = RFACT_NONE / 2 |
| | | 1960 | }, |
| | | 1961 | { |
| | | 1962 | .desc = "VIN4", |
| | | 1963 | .type = ENVSYS_SVOLTS_DC, |
| | | 1964 | .bank = 4, |
| | | 1965 | .reg = 0x86, |
| | | 1966 | .refresh = lm_refresh_volt, |
| | | 1967 | .rfact = RFACT_NONE |
| | | 1968 | }, |
| | | 1969 | { |
| | | 1970 | .desc = "+3.3VSB", |
| | | 1971 | .type = ENVSYS_SVOLTS_DC, |
| | | 1972 | .bank = 4, |
| | | 1973 | .reg = 0x87, |
| | | 1974 | .refresh = lm_refresh_volt, |
| | | 1975 | .rfact = RFACT(34, 34) / 2 |
| | | 1976 | }, |
| | | 1977 | { |
| | | 1978 | .desc = "VBAT", |
| | | 1979 | .type = ENVSYS_SVOLTS_DC, |
| | | 1980 | .bank = 4, |
| | | 1981 | .reg = 0x88, |
| | | 1982 | .refresh = lm_refresh_volt, |
| | | 1983 | .rfact = RFACT_NONE |
| | | 1984 | }, |
| | | 1985 | { |
| | | 1986 | .desc = "VTT", |
| | | 1987 | .type = ENVSYS_SVOLTS_DC, |
| | | 1988 | .bank = 4, |
| | | 1989 | .reg = 0x89, |
| | | 1990 | .refresh = lm_refresh_volt, |
| | | 1991 | .rfact = RFACT_NONE |
| | | 1992 | }, |
| | | 1993 | { |
| | | 1994 | .desc = "VIN5", |
| | | 1995 | .type = ENVSYS_SVOLTS_DC, |
| | | 1996 | .bank = 4, |
| | | 1997 | .reg = 0x8a, |
| | | 1998 | .refresh = lm_refresh_volt, |
| | | 1999 | .rfact = RFACT_NONE |
| | | 2000 | }, |
| | | 2001 | { |
| | | 2002 | .desc = "VIN6", |
| | | 2003 | .type = ENVSYS_SVOLTS_DC, |
| | | 2004 | .bank = 4, |
| | | 2005 | .reg = 0x8b, |
| | | 2006 | .refresh = lm_refresh_volt, |
| | | 2007 | .rfact = RFACT_NONE |
| | | 2008 | }, |
| | | 2009 | { |
| | | 2010 | .desc = "VIN2", |
| | | 2011 | .type = ENVSYS_SVOLTS_DC, |
| | | 2012 | .bank = 4, |
| | | 2013 | .reg = 0x8c, |
| | | 2014 | .refresh = lm_refresh_volt, |
| | | 2015 | .rfact = RFACT_NONE |
| | | 2016 | }, |
| | | 2017 | { |
| | | 2018 | .desc = "VIN3", |
| | | 2019 | .type = ENVSYS_SVOLTS_DC, |
| | | 2020 | .bank = 4, |
| | | 2021 | .reg = 0x8d, |
| | | 2022 | .refresh = lm_refresh_volt, |
| | | 2023 | .rfact = RFACT(14414, 10000) |
| | | 2024 | }, |
| | | 2025 | { |
| | | 2026 | .desc = "VIN7", |
| | | 2027 | .type = ENVSYS_SVOLTS_DC, |
| | | 2028 | .bank = 4, |
| | | 2029 | .reg = 0x8e, |
| | | 2030 | .refresh = lm_refresh_volt, |
| | | 2031 | .rfact = RFACT_NONE / 2 |
| | | 2032 | }, |
| | | 2033 | |
| | | 2034 | /* Temperature */ |
| | | 2035 | { |
| | | 2036 | .desc = "MB Temperature", |
| | | 2037 | .type = ENVSYS_STEMP, |
| | | 2038 | .bank = 4, |
| | | 2039 | .reg = 0x90, |
| | | 2040 | .refresh = lm_refresh_temp, |
| | | 2041 | .rfact = 0 |
| | | 2042 | }, |
| | | 2043 | { |
| | | 2044 | .desc = "CPU Temperature", |
| | | 2045 | .type = ENVSYS_STEMP, |
| | | 2046 | .bank = 4, |
| | | 2047 | .reg = 0x91, |
| | | 2048 | .refresh = wb_refresh_temp, |
| | | 2049 | .rfact = 0 |
| | | 2050 | }, |
| | | 2051 | { |
| | | 2052 | .desc = "Aux Temp0", |
| | | 2053 | .type = ENVSYS_STEMP, |
| | | 2054 | .bank = 4, |
| | | 2055 | .reg = 0x92, |
| | | 2056 | .refresh = wb_refresh_temp, |
| | | 2057 | .rfact = 0 |
| | | 2058 | }, |
| | | 2059 | { |
| | | 2060 | .desc = "Aux Temp1", |
| | | 2061 | .type = ENVSYS_STEMP, |
| | | 2062 | .bank = 4, |
| | | 2063 | .reg = 0x93, |
| | | 2064 | .refresh = wb_refresh_temp, |
| | | 2065 | .rfact = 0 |
| | | 2066 | }, |
| | | 2067 | { |
| | | 2068 | .desc = "Aux Temp2", |
| | | 2069 | .type = ENVSYS_STEMP, |
| | | 2070 | .bank = 4, |
| | | 2071 | .reg = 0x94, |
| | | 2072 | .refresh = wb_refresh_temp, |
| | | 2073 | .rfact = 0 |
| | | 2074 | }, |
| | | 2075 | { |
| | | 2076 | .desc = "Aux Temp3", |
| | | 2077 | .type = ENVSYS_STEMP, |
| | | 2078 | .bank = 4, |
| | | 2079 | .reg = 0x95, |
| | | 2080 | .refresh = wb_refresh_temp, |
| | | 2081 | .rfact = 0 |
| | | 2082 | }, |
| | | 2083 | |
| | | 2084 | /* Fans */ |
| | | 2085 | { |
| | | 2086 | .desc = "System Fan", |
| | | 2087 | .type = ENVSYS_SFANRPM, |
| | | 2088 | .bank = 4, |
| | | 2089 | .reg = 0xc0, |
| | | 2090 | .refresh = wb_nct6776f_refresh_fanrpm, |
| | | 2091 | .rfact = 0 |
| | | 2092 | }, |
| | | 2093 | { |
| | | 2094 | .desc = "CPU Fan", |
| | | 2095 | .type = ENVSYS_SFANRPM, |
| | | 2096 | .bank = 4, |
| | | 2097 | .reg = 0xc2, |
| | | 2098 | .refresh = wb_nct6776f_refresh_fanrpm, |
| | | 2099 | .rfact = 0 |
| | | 2100 | }, |
| | | 2101 | { |
| | | 2102 | .desc = "Aux Fan0", |
| | | 2103 | .type = ENVSYS_SFANRPM, |
| | | 2104 | .bank = 4, |
| | | 2105 | .reg = 0xc4, |
| | | 2106 | .refresh = wb_nct6776f_refresh_fanrpm, |
| | | 2107 | .rfact = 0 |
| | | 2108 | }, |
| | | 2109 | { |
| | | 2110 | .desc = "Aux Fan1", |
| | | 2111 | .type = ENVSYS_SFANRPM, |
| | | 2112 | .bank = 4, |
| | | 2113 | .reg = 0xc6, |
| | | 2114 | .refresh = wb_nct6776f_refresh_fanrpm, |
| | | 2115 | .rfact = 0 |
| | | 2116 | }, |
| | | 2117 | { |
| | | 2118 | .desc = "Aux Fan2", |
| | | 2119 | .type = ENVSYS_SFANRPM, |
| | | 2120 | .bank = 4, |
| | | 2121 | .reg = 0xc8, |
| | | 2122 | .refresh = wb_nct6776f_refresh_fanrpm, |
| | | 2123 | .rfact = 0 |
| | | 2124 | }, |
| | | 2125 | |
| | | 2126 | { .desc = NULL } |
| | | 2127 | }; |
| | | 2128 | |
| | | 2129 | static const struct wb_product wb_products[] = { |
| | | 2130 | { WB_CHIPID_W83627HF, "W83627HF", w83627hf_sensors, NULL }, |
| | | 2131 | { WB_CHIPID_W83627THF, "W83627THF",w83637hf_sensors, NULL }, |
| | | 2132 | { WB_CHIPID_W83627EHF_A,"W83627EHF-A",w83627ehf_sensors,NULL }, |
| | | 2133 | { WB_CHIPID_W83627EHF, "W83627EHF",w83627ehf_sensors,NULL }, |
| | | 2134 | { WB_CHIPID_W83627DHG, NULL, NULL, NULL }, |
| | | 2135 | { WB_CHIPID_W83637HF, "W83637HF", w83637hf_sensors, NULL }, |
| | | 2136 | { WB_CHIPID_W83697HF, "W83697HF", w83697hf_sensors, NULL }, |
| | | 2137 | { WB_CHIPID_W83781D, "W83781D", w83781d_sensors, NULL }, |
| | | 2138 | { WB_CHIPID_W83781D_2, "W83781D", w83781d_sensors, NULL }, |
| | | 2139 | { WB_CHIPID_W83782D, "W83782D", w83782d_sensors, NULL }, |
| | | 2140 | { WB_CHIPID_W83783S, "W83783S", w83783s_sensors, NULL }, |
| | | 2141 | { WB_CHIPID_W83791D, "W83791D", w83791d_sensors, NULL }, |
| | | 2142 | { WB_CHIPID_W83791SD, "W83791SD", NULL, NULL }, |
| | | 2143 | { WB_CHIPID_W83792D, "W83792D", w83792d_sensors, NULL }, |
| | | 2144 | { WB_CHIPID_AS99127F, NULL, NULL, NULL }, |
| | | 2145 | { 0, NULL, NULL, NULL } |
| | | 2146 | }; |
| | | 2147 | |
| | | 2148 | static const struct wb_product wbsio_products[] = { |
| | | 2149 | { WBSIO_ID_W83627DHG, "W83627DHG",w83627dhg_sensors,NULL }, |
| | | 2150 | { WBSIO_ID_NCT6775F, "NCT6775F", nct6776f_sensors, NULL }, |
| | | 2151 | { WBSIO_ID_NCT6776F, "NCT6776F", nct6776f_sensors, NULL }, |
| | | 2152 | { WBSIO_ID_NCT5104D, "NCT5104D or 610[246]D",nct6102d_sensors,NULL }, |
| | | 2153 | { WBSIO_ID_NCT6779D, "NCT6779D", nct6779d_sensors, NULL }, |
| | | 2154 | { WBSIO_ID_NCT6791D, "NCT6791D", nct6779d_sensors, NULL }, |
| | | 2155 | { WBSIO_ID_NCT6792D, "NCT6792D", nct6779d_sensors, NULL }, |
| | | 2156 | { WBSIO_ID_NCT6793D, "NCT6793D", nct6779d_sensors, NULL }, |
| | | 2157 | { WBSIO_ID_NCT6795D, "NCT6795D", nct6779d_sensors, NULL }, |
| | | 2158 | { 0, NULL, NULL, NULL } |
| | | 2159 | }; |
| | | 2160 | |
| | | 2161 | static const struct wb_product as99127f_products[] = { |
| | | 2162 | { WB_VENDID_ASUS, "AS99127F", w83781d_sensors, NULL }, |
| | | 2163 | { WB_VENDID_WINBOND, "AS99127F rev 2",as99127f_sensors,NULL }, |
| | | 2164 | { 0, NULL, NULL, NULL } |
| | | 2165 | }; |
| | | 2166 | |
1770 | static void | | 2167 | static void |
1771 | lm_generic_banksel(struct lm_softc *lmsc, int bank) | | 2168 | lm_generic_banksel(struct lm_softc *lmsc, uint8_t bank) |
1772 | { | | 2169 | { |
1773 | (*lmsc->lm_writereg)(lmsc, WB_BANKSEL, bank); | | 2170 | (*lmsc->lm_writereg)(lmsc, WB_BANKSEL, bank); |
1774 | } | | 2171 | } |
1775 | | | 2172 | |
1776 | /* | | 2173 | /* |
1777 | * bus independent probe | | 2174 | * bus independent match |
1778 | * | | 2175 | * |
1779 | * prerequisites: lmsc contains valid lm_{read,write}reg() routines | | 2176 | * prerequisites: lmsc contains valid lm_{read,write}reg() routines |
1780 | * and associated bus access data is present in attachment's softc | | 2177 | * and associated bus access data is present in attachment's softc |
1781 | */ | | 2178 | */ |
1782 | int | | 2179 | int |
1783 | lm_probe(struct lm_softc *lmsc) | | 2180 | lm_match(struct lm_softc *lmsc) |
1784 | { | | 2181 | { |
1785 | uint8_t cr; | | 2182 | uint8_t cr; |
1786 | int rv; | | 2183 | int i, rv; |
1787 | | | 2184 | |
1788 | /* Perform LM78 reset */ | | 2185 | /* Perform LM78 reset */ |
1789 | /*(*lmsc->lm_writereg)(lmsc, LMD_CONFIG, 0x80); */ | | 2186 | /*(*lmsc->lm_writereg)(lmsc, LMD_CONFIG, 0x80); */ |
1790 | | | 2187 | |
1791 | cr = (*lmsc->lm_readreg)(lmsc, LMD_CONFIG); | | 2188 | cr = (*lmsc->lm_readreg)(lmsc, LMD_CONFIG); |
1792 | | | 2189 | |
1793 | /* XXX - spec says *only* 0x08! */ | | 2190 | /* XXX - spec says *only* 0x08! */ |
1794 | if ((cr == 0x08) || (cr == 0x01) || (cr == 0x03) || (cr == 0x06)) | | 2191 | if ((cr != 0x08) && (cr != 0x01) && (cr != 0x03) && (cr != 0x06)) |
1795 | rv = 1; | | 2192 | return 0; |
1796 | else | | 2193 | |
1797 | rv = 0; | | 2194 | DPRINTF(("%s: 0x80 check: cr = %x\n", __func__, cr)); |
| | | 2195 | |
| | | 2196 | for (i = 0; i < __arraycount(lm_chips); i++) |
| | | 2197 | if ((rv = lm_chips[i].chip_match(lmsc)) != 0) |
| | | 2198 | return rv; |
| | | 2199 | |
| | | 2200 | return 0; |
| | | 2201 | } |
1798 | | | 2202 | |
1799 | DPRINTF(("%s: rv = %d, cr = %x\n", __func__, rv, cr)); | | 2203 | int |
| | | 2204 | nslm_match(struct lm_softc *sc) |
| | | 2205 | { |
| | | 2206 | uint8_t chipid; |
1800 | | | 2207 | |
1801 | return rv; | | 2208 | /* See if we have an LM78/LM78J/LM79 or LM81 */ |
| | | 2209 | chipid = (*sc->lm_readreg)(sc, LMD_CHIPID) & LM_ID_MASK; |
| | | 2210 | switch(chipid) { |
| | | 2211 | case LM_ID_LM78: |
| | | 2212 | case LM_ID_LM78J: |
| | | 2213 | case LM_ID_LM79: |
| | | 2214 | case LM_ID_LM81: |
| | | 2215 | break; |
| | | 2216 | default: |
| | | 2217 | return 0; |
| | | 2218 | } |
| | | 2219 | DPRINTF(("%s: chipid %x\n", __func__, chipid)); |
| | | 2220 | return 1; |
1802 | } | | 2221 | } |
1803 | | | 2222 | |
1804 | void | | 2223 | void |
1805 | lm_attach(struct lm_softc *lmsc) | | 2224 | lm_attach(struct lm_softc *lmsc) |
1806 | { | | 2225 | { |
1807 | uint32_t i; | | 2226 | uint32_t i; |
| | | 2227 | int rv; |
1808 | | | 2228 | |
1809 | for (i = 0; i < __arraycount(lm_chips); i++) | | 2229 | for (i = 0; i < __arraycount(lm_chips); i++) { |
1810 | if (lm_chips[i].chip_match(lmsc)) | | 2230 | if (lm_chips[i].chip_match(lmsc) != 0) { |
1811 | break; | | 2231 | if (lm_chips[i].chip_attach(lmsc) == 0) |
| | | 2232 | break; |
| | | 2233 | else |
| | | 2234 | return; |
| | | 2235 | } |
| | | 2236 | } |
1812 | | | 2237 | |
1813 | /* Start the monitoring loop */ | | 2238 | /* Start the monitoring loop */ |
1814 | (*lmsc->lm_writereg)(lmsc, LMD_CONFIG, 0x01); | | 2239 | (*lmsc->lm_writereg)(lmsc, LMD_CONFIG, 0x01); |
1815 | | | 2240 | |
1816 | lmsc->sc_sme = sysmon_envsys_create(); | | 2241 | lmsc->sc_sme = sysmon_envsys_create(); |
1817 | /* Initialize sensors */ | | 2242 | /* Initialize sensors */ |
1818 | for (i = 0; i < lmsc->numsensors; i++) { | | 2243 | for (i = 0; i < lmsc->numsensors; i++) { |
1819 | lmsc->sensors[i].state = ENVSYS_SINVALID; | | 2244 | lmsc->sensors[i].state = ENVSYS_SINVALID; |
1820 | if (sysmon_envsys_sensor_attach(lmsc->sc_sme, | | 2245 | if ((rv = sysmon_envsys_sensor_attach(lmsc->sc_sme, |
1821 | &lmsc->sensors[i])) { | | 2246 | &lmsc->sensors[i])) != 0) { |
1822 | sysmon_envsys_destroy(lmsc->sc_sme); | | 2247 | sysmon_envsys_destroy(lmsc->sc_sme); |
| | | 2248 | aprint_error_dev(lmsc->sc_dev, |
| | | 2249 | "sysmon_envsys_sensor_attach() returned %d\n", rv); |
1823 | return; | | 2250 | return; |
1824 | } | | 2251 | } |
1825 | } | | 2252 | } |
1826 | | | 2253 | |
1827 | /* | | 2254 | /* |
1828 | * Setup the callout to refresh sensor data every 2 seconds. | | 2255 | * Setup the callout to refresh sensor data every 2 seconds. |
1829 | */ | | 2256 | */ |
1830 | callout_init(&lmsc->sc_callout, 0); | | 2257 | callout_init(&lmsc->sc_callout, 0); |
1831 | callout_setfunc(&lmsc->sc_callout, lm_refresh, lmsc); | | 2258 | callout_setfunc(&lmsc->sc_callout, lm_refresh, lmsc); |
1832 | callout_schedule(&lmsc->sc_callout, LM_REFRESH_TIMO); | | 2259 | callout_schedule(&lmsc->sc_callout, LM_REFRESH_TIMO); |
1833 | | | 2260 | |
1834 | /* | | 2261 | /* |
1835 | * Hook into the System Monitor. | | 2262 | * Hook into the System Monitor. |
| @@ -1856,79 +2283,86 @@ lm_detach(struct lm_softc *lmsc) | | | @@ -1856,79 +2283,86 @@ lm_detach(struct lm_softc *lmsc) |
1856 | sysmon_envsys_unregister(lmsc->sc_sme); | | 2283 | sysmon_envsys_unregister(lmsc->sc_sme); |
1857 | } | | 2284 | } |
1858 | | | 2285 | |
1859 | static void | | 2286 | static void |
1860 | lm_refresh(void *arg) | | 2287 | lm_refresh(void *arg) |
1861 | { | | 2288 | { |
1862 | struct lm_softc *lmsc = arg; | | 2289 | struct lm_softc *lmsc = arg; |
1863 | | | 2290 | |
1864 | lmsc->refresh_sensor_data(lmsc); | | 2291 | lmsc->refresh_sensor_data(lmsc); |
1865 | callout_schedule(&lmsc->sc_callout, LM_REFRESH_TIMO); | | 2292 | callout_schedule(&lmsc->sc_callout, LM_REFRESH_TIMO); |
1866 | } | | 2293 | } |
1867 | | | 2294 | |
1868 | static int | | 2295 | static int |
1869 | lm_match(struct lm_softc *sc) | | 2296 | nslm_attach(struct lm_softc *sc) |
1870 | { | | 2297 | { |
1871 | const char *model = NULL; | | 2298 | const char *model = NULL; |
1872 | int chipid; | | 2299 | uint8_t chipid; |
1873 | | | 2300 | |
1874 | /* See if we have an LM78/LM78J/LM79 or LM81 */ | | 2301 | /* See if we have an LM78/LM78J/LM79 or LM81 */ |
1875 | chipid = (*sc->lm_readreg)(sc, LMD_CHIPID) & LM_ID_MASK; | | 2302 | chipid = (*sc->lm_readreg)(sc, LMD_CHIPID) & LM_ID_MASK; |
1876 | switch(chipid) { | | 2303 | switch(chipid) { |
1877 | case LM_ID_LM78: | | 2304 | case LM_ID_LM78: |
1878 | model = "LM78"; | | 2305 | model = "LM78"; |
1879 | break; | | 2306 | break; |
1880 | case LM_ID_LM78J: | | 2307 | case LM_ID_LM78J: |
1881 | model = "LM78J"; | | 2308 | model = "LM78J"; |
1882 | break; | | 2309 | break; |
1883 | case LM_ID_LM79: | | 2310 | case LM_ID_LM79: |
1884 | model = "LM79"; | | 2311 | model = "LM79"; |
1885 | break; | | 2312 | break; |
1886 | case LM_ID_LM81: | | 2313 | case LM_ID_LM81: |
1887 | model = "LM81"; | | 2314 | model = "LM81"; |
1888 | break; | | 2315 | break; |
1889 | default: | | 2316 | default: |
1890 | return 0; | | 2317 | return -1; |
1891 | } | | 2318 | } |
1892 | | | 2319 | |
1893 | aprint_naive("\n"); | | 2320 | aprint_naive("\n"); |
1894 | aprint_normal("\n"); | | 2321 | aprint_normal("\n"); |
1895 | aprint_normal_dev(sc->sc_dev, | | 2322 | aprint_normal_dev(sc->sc_dev, |
1896 | "National Semiconductor %s Hardware monitor\n", model); | | 2323 | "National Semiconductor %s Hardware monitor\n", model); |
1897 | | | 2324 | |
1898 | lm_setup_sensors(sc, lm78_sensors); | | 2325 | lm_setup_sensors(sc, lm78_sensors); |
1899 | sc->refresh_sensor_data = lm_refresh_sensor_data; | | 2326 | sc->refresh_sensor_data = lm_refresh_sensor_data; |
1900 | return 1; | | 2327 | return 0; |
1901 | } | | 2328 | } |
1902 | | | 2329 | |
1903 | static int | | 2330 | static int |
1904 | def_match(struct lm_softc *sc) | | 2331 | def_match(struct lm_softc *sc) |
1905 | { | | 2332 | { |
1906 | int chipid; | | 2333 | |
| | | 2334 | return 1; |
| | | 2335 | } |
| | | 2336 | |
| | | 2337 | static int |
| | | 2338 | def_attach(struct lm_softc *sc) |
| | | 2339 | { |
| | | 2340 | uint8_t chipid; |
1907 | | | 2341 | |
1908 | chipid = (*sc->lm_readreg)(sc, LMD_CHIPID) & LM_ID_MASK; | | 2342 | chipid = (*sc->lm_readreg)(sc, LMD_CHIPID) & LM_ID_MASK; |
1909 | aprint_naive("\n"); | | 2343 | aprint_naive("\n"); |
1910 | aprint_normal("\n"); | | 2344 | aprint_normal("\n"); |
1911 | aprint_error_dev(sc->sc_dev, "Unknown chip (ID %d)\n", chipid); | | 2345 | aprint_error_dev(sc->sc_dev, "Unknown chip (ID 0x%02x)\n", chipid); |
1912 | | | 2346 | |
1913 | lm_setup_sensors(sc, lm78_sensors); | | 2347 | lm_setup_sensors(sc, lm78_sensors); |
1914 | sc->refresh_sensor_data = lm_refresh_sensor_data; | | 2348 | sc->refresh_sensor_data = lm_refresh_sensor_data; |
1915 | return 1; | | 2349 | return 0; |
1916 | } | | 2350 | } |
1917 | | | 2351 | |
1918 | static void | | 2352 | static void |
1919 | wb_temp_diode_type(struct lm_softc *sc, int diode_type) | | 2353 | wb_temp_diode_type(struct lm_softc *sc, int diode_type) |
1920 | { | | 2354 | { |
1921 | int regval, banksel; | | 2355 | uint8_t regval, banksel; |
1922 | | | 2356 | |
1923 | banksel = (*sc->lm_readreg)(sc, WB_BANKSEL); | | 2357 | banksel = (*sc->lm_readreg)(sc, WB_BANKSEL); |
1924 | switch (diode_type) { | | 2358 | switch (diode_type) { |
1925 | case 1: /* Switch to Pentium-II diode mode */ | | 2359 | case 1: /* Switch to Pentium-II diode mode */ |
1926 | lm_generic_banksel(sc, WB_BANKSEL_B0); | | 2360 | lm_generic_banksel(sc, WB_BANKSEL_B0); |
1927 | regval = (*sc->lm_readreg)(sc, WB_BANK0_VBAT); | | 2361 | regval = (*sc->lm_readreg)(sc, WB_BANK0_VBAT); |
1928 | regval |= 0x0e; | | 2362 | regval |= 0x0e; |
1929 | (*sc->lm_writereg)(sc, WB_BANK0_VBAT, regval); | | 2363 | (*sc->lm_writereg)(sc, WB_BANK0_VBAT, regval); |
1930 | regval = (*sc->lm_readreg)(sc, WB_BANK0_RESVD1); | | 2364 | regval = (*sc->lm_readreg)(sc, WB_BANK0_RESVD1); |
1931 | regval |= 0x70; | | 2365 | regval |= 0x70; |
1932 | (*sc->lm_writereg)(sc, WB_BANK0_RESVD1, 0x0); | | 2366 | (*sc->lm_writereg)(sc, WB_BANK0_RESVD1, 0x0); |
1933 | lm_generic_banksel(sc, banksel); | | 2367 | lm_generic_banksel(sc, banksel); |
1934 | aprint_verbose_dev(sc->sc_dev, "Pentium-II diode temp sensors\n"); | | 2368 | aprint_verbose_dev(sc->sc_dev, "Pentium-II diode temp sensors\n"); |
| @@ -1953,156 +2387,260 @@ wb_temp_diode_type(struct lm_softc *sc, | | | @@ -1953,156 +2387,260 @@ wb_temp_diode_type(struct lm_softc *sc, |
1953 | aprint_verbose_dev(sc->sc_dev, "Thermistor temp sensors\n"); | | 2387 | aprint_verbose_dev(sc->sc_dev, "Thermistor temp sensors\n"); |
1954 | break; | | 2388 | break; |
1955 | case 0: /* Unspecified - use default */ | | 2389 | case 0: /* Unspecified - use default */ |
1956 | aprint_verbose_dev(sc->sc_dev, "Using default temp sensors\n"); | | 2390 | aprint_verbose_dev(sc->sc_dev, "Using default temp sensors\n"); |
1957 | break; | | 2391 | break; |
1958 | default: | | 2392 | default: |
1959 | aprint_error_dev(sc->sc_dev, | | 2393 | aprint_error_dev(sc->sc_dev, |
1960 | "Ignoring invalid temp sensor mode %d\n", | | 2394 | "Ignoring invalid temp sensor mode %d\n", |
1961 | diode_type); | | 2395 | diode_type); |
1962 | break; | | 2396 | break; |
1963 | } | | 2397 | } |
1964 | } | | 2398 | } |
1965 | | | 2399 | |
1966 | static int | | 2400 | static const struct wb_product * |
1967 | wb_match(struct lm_softc *sc) | | 2401 | wb_lookup(struct lm_softc *sc, const struct wb_product *products, uint16_t id) |
1968 | { | | 2402 | { |
1969 | const char *model = NULL; | | 2403 | const struct wb_product *prod = products; |
1970 | const char *vendor = "Winbond"; | | 2404 | int i = 0; |
1971 | int banksel, vendid, cf_flags; | | | |
1972 | | | 2405 | |
1973 | aprint_naive("\n"); | | 2406 | while (prod[i].id != 0) { |
1974 | aprint_normal("\n"); | | 2407 | if (prod[i].id != id) { |
1975 | /* Read vendor ID */ | | 2408 | i++; |
| | | 2409 | continue; |
| | | 2410 | } |
| | | 2411 | if (prod[i].str == NULL) { |
| | | 2412 | if (products == wb_products) { |
| | | 2413 | if (id == WB_CHIPID_W83627DHG) { |
| | | 2414 | /* |
| | | 2415 | * Lookup wbsio_products |
| | | 2416 | * with WBSIO_ID. |
| | | 2417 | */ |
| | | 2418 | return wb_lookup(sc, wbsio_products, |
| | | 2419 | sc->sioid); |
| | | 2420 | } else if (id == WB_CHIPID_AS99127F) { |
| | | 2421 | /* |
| | | 2422 | * Lookup as99127f_products |
| | | 2423 | * with WB_VENDID. |
| | | 2424 | */ |
| | | 2425 | return wb_lookup(sc, as99127f_products, |
| | | 2426 | wb_read_vendorid(sc)); |
| | | 2427 | } else |
| | | 2428 | return NULL; /* not occur */ |
| | | 2429 | } |
| | | 2430 | return NULL; /* not occur */ |
| | | 2431 | } |
| | | 2432 | return &prod[i]; |
| | | 2433 | } |
| | | 2434 | |
| | | 2435 | /* Not found */ |
| | | 2436 | return NULL; |
| | | 2437 | } |
| | | 2438 | |
| | | 2439 | static uint16_t |
| | | 2440 | wb_read_vendorid(struct lm_softc *sc) |
| | | 2441 | { |
| | | 2442 | uint16_t vendid; |
| | | 2443 | uint8_t vendidreg; |
| | | 2444 | uint8_t banksel; |
| | | 2445 | |
| | | 2446 | /* Save bank */ |
1976 | banksel = (*sc->lm_readreg)(sc, WB_BANKSEL); | | 2447 | banksel = (*sc->lm_readreg)(sc, WB_BANKSEL); |
| | | 2448 | |
| | | 2449 | /* Check default vendor ID register first */ |
| | | 2450 | vendidreg = WB_VENDID; |
| | | 2451 | |
| | | 2452 | retry: |
| | | 2453 | /* Read vendor ID */ |
1977 | lm_generic_banksel(sc, WB_BANKSEL_HBAC); | | 2454 | lm_generic_banksel(sc, WB_BANKSEL_HBAC); |
1978 | vendid = (*sc->lm_readreg)(sc, WB_VENDID) << 8; | | 2455 | vendid = (*sc->lm_readreg)(sc, vendidreg) << 8; |
1979 | lm_generic_banksel(sc, 0); | | 2456 | lm_generic_banksel(sc, 0); |
1980 | vendid |= (*sc->lm_readreg)(sc, WB_VENDID); | | 2457 | vendid |= (*sc->lm_readreg)(sc, vendidreg); |
1981 | DPRINTF(("%s: winbond vend id 0x%x\n", __func__, vendid)); | | | |
1982 | if (vendid != WB_VENDID_WINBOND && vendid != WB_VENDID_ASUS) | | | |
1983 | return 0; | | | |
1984 | | | 2458 | |
1985 | /* Read device/chip ID */ | | 2459 | if ((vendidreg == WB_VENDID) |
| | | 2460 | && (vendid != WB_VENDID_WINBOND && vendid != WB_VENDID_ASUS)) { |
| | | 2461 | /* If it failed, try NCT6102 vendor ID register */ |
| | | 2462 | vendidreg = WB_NCT6102_VENDID; |
| | | 2463 | goto retry; |
| | | 2464 | } else if ((vendidreg == WB_NCT6102_VENDID) |
| | | 2465 | && (vendid != WB_VENDID_WINBOND)) |
| | | 2466 | vendid = 0; /* XXX */ |
| | | 2467 | |
| | | 2468 | /* Restore bank */ |
| | | 2469 | lm_generic_banksel(sc, banksel); |
| | | 2470 | |
| | | 2471 | return vendid; |
| | | 2472 | } |
| | | 2473 | |
| | | 2474 | static uint8_t |
| | | 2475 | wb_read_chipid(struct lm_softc *sc) |
| | | 2476 | { |
| | | 2477 | const struct wb_product *prod; |
| | | 2478 | uint8_t chipidreg, chipid, banksel; |
| | | 2479 | |
| | | 2480 | /* Save bank */ |
| | | 2481 | banksel = (*sc->lm_readreg)(sc, WB_BANKSEL); |
| | | 2482 | |
| | | 2483 | /* Check default vendor ID register first */ |
| | | 2484 | chipidreg = WB_BANK0_CHIPID; |
1986 | lm_generic_banksel(sc, WB_BANKSEL_B0); | | 2485 | lm_generic_banksel(sc, WB_BANKSEL_B0); |
| | | 2486 | |
| | | 2487 | retry: |
1987 | (void)(*sc->lm_readreg)(sc, LMD_CHIPID); | | 2488 | (void)(*sc->lm_readreg)(sc, LMD_CHIPID); |
1988 | sc->chipid = (*sc->lm_readreg)(sc, WB_BANK0_CHIPID); | | 2489 | chipid = (*sc->lm_readreg)(sc, chipidreg); |
| | | 2490 | prod = wb_lookup(sc, wb_products, chipid); |
| | | 2491 | if (prod == NULL) { |
| | | 2492 | if (chipidreg == WB_BANK0_CHIPID) { |
| | | 2493 | chipidreg = WB_BANK0_NCT6102_CHIPID; |
| | | 2494 | goto retry; |
| | | 2495 | } else |
| | | 2496 | chipid = 0; |
| | | 2497 | } |
| | | 2498 | /* Restore bank */ |
1989 | lm_generic_banksel(sc, banksel); | | 2499 | lm_generic_banksel(sc, banksel); |
1990 | cf_flags = device_cfdata(sc->sc_dev)->cf_flags; | | 2500 | |
| | | 2501 | return chipid; |
| | | 2502 | } |
| | | 2503 | |
| | | 2504 | static int |
| | | 2505 | wb_match(struct lm_softc *sc) |
| | | 2506 | { |
| | | 2507 | const struct wb_product *prod; |
| | | 2508 | uint16_t vendid; |
| | | 2509 | uint8_t chipid; |
| | | 2510 | |
| | | 2511 | /* Read vendor ID */ |
| | | 2512 | vendid = wb_read_vendorid(sc); |
| | | 2513 | DPRINTF(("%s: winbond vend id 0x%x\n", __func__, vendid)); |
| | | 2514 | if ((vendid != WB_VENDID_WINBOND && vendid != WB_VENDID_ASUS)) |
| | | 2515 | return 0; |
| | | 2516 | |
| | | 2517 | /* Read device/chip ID */ |
| | | 2518 | chipid = wb_read_chipid(sc); |
| | | 2519 | DPRINTF(("%s: winbond chip id 0x%x\n", __func__, chipid)); |
| | | 2520 | prod = wb_lookup(sc, wb_products, chipid); |
| | | 2521 | |
| | | 2522 | if (prod == NULL) { |
| | | 2523 | if (vendid == WB_VENDID_WINBOND) |
| | | 2524 | return 1; /* Generic match */ |
| | | 2525 | else |
| | | 2526 | return 0; |
| | | 2527 | } |
| | | 2528 | DPRINTF(("%s: chipid %02x, sioid = %04x\n", __func__, chipid, |
| | | 2529 | sc->sioid)); |
| | | 2530 | |
| | | 2531 | return 10; /* found */ |
| | | 2532 | } |
| | | 2533 | |
| | | 2534 | static int |
| | | 2535 | wb_attach(struct lm_softc *sc) |
| | | 2536 | { |
| | | 2537 | device_t dev = sc->sc_dev; |
| | | 2538 | const struct wb_product *prod; |
| | | 2539 | const char *model = NULL; |
| | | 2540 | const char *vendor = "Winbond"; |
| | | 2541 | const struct lm_sensor *sensors; |
| | | 2542 | uint16_t vendid; |
| | | 2543 | uint8_t banksel; |
| | | 2544 | int cf_flags; |
| | | 2545 | |
| | | 2546 | aprint_naive("\n"); |
| | | 2547 | aprint_normal("\n"); |
| | | 2548 | /* Read device/chip ID */ |
| | | 2549 | sc->chipid = wb_read_chipid(sc); |
1991 | DPRINTF(("%s: winbond chip id 0x%x\n", __func__, sc->chipid)); | | 2550 | DPRINTF(("%s: winbond chip id 0x%x\n", __func__, sc->chipid)); |
1992 | | | 2551 | |
| | | 2552 | if ((prod = wb_lookup(sc, wb_products, sc->chipid)) != NULL) { |
| | | 2553 | switch (prod->str[0]) { |
| | | 2554 | case 'W': |
| | | 2555 | vendor = "Winbond"; |
| | | 2556 | break; |
| | | 2557 | case 'A': |
| | | 2558 | vendor = "ASUS"; |
| | | 2559 | break; |
| | | 2560 | case 'N': |
| | | 2561 | vendor = "Nuvoton"; |
| | | 2562 | break; |
| | | 2563 | default: |
| | | 2564 | aprint_error_dev(dev, "Unknown model (%s)\n", model); |
| | | 2565 | return -1; |
| | | 2566 | } |
| | | 2567 | model = prod->str; |
| | | 2568 | sensors = prod->sensors; |
| | | 2569 | sc->refresh_sensor_data = wb_refresh_sensor_data; |
| | | 2570 | if (prod->extattach != NULL) |
| | | 2571 | prod->extattach(sc); |
| | | 2572 | } else { |
| | | 2573 | vendid = wb_read_vendorid(sc); |
| | | 2574 | if (vendid == WB_VENDID_WINBOND) { |
| | | 2575 | vendor = "Winbond"; |
| | | 2576 | model = "unknown-model"; |
| | | 2577 | |
| | | 2578 | /* Handle as a standard LM78. */ |
| | | 2579 | sensors = lm78_sensors; |
| | | 2580 | sc->refresh_sensor_data = lm_refresh_sensor_data; |
| | | 2581 | } else { |
| | | 2582 | aprint_error_dev(dev, "Unknown chip (ID %02x)\n", |
| | | 2583 | sc->chipid); |
| | | 2584 | return -1; |
| | | 2585 | } |
| | | 2586 | } |
| | | 2587 | |
| | | 2588 | cf_flags = device_cfdata(dev)->cf_flags; |
| | | 2589 | |
| | | 2590 | if (sensors != NULL) { |
| | | 2591 | lm_setup_sensors(sc, sensors); |
| | | 2592 | |
| | | 2593 | /* XXX Is this correct? Check all datasheets. */ |
| | | 2594 | switch (sc->chipid) { |
| | | 2595 | case WB_CHIPID_W83627EHF_A: |
| | | 2596 | case WB_CHIPID_W83781D: |
| | | 2597 | case WB_CHIPID_W83781D_2: |
| | | 2598 | case WB_CHIPID_W83791SD: |
| | | 2599 | case WB_CHIPID_W83792D: |
| | | 2600 | case WB_CHIPID_AS99127F: |
| | | 2601 | break; |
| | | 2602 | default: |
| | | 2603 | wb_temp_diode_type(sc, cf_flags); |
| | | 2604 | break; |
| | | 2605 | } |
| | | 2606 | } |
| | | 2607 | |
| | | 2608 | /* XXX Is this correct? Check all datasheets. */ |
| | | 2609 | banksel = (*sc->lm_readreg)(sc, WB_BANKSEL); |
1993 | switch(sc->chipid) { | | 2610 | switch(sc->chipid) { |
1994 | case WB_CHIPID_W83627HF: | | | |
1995 | model = "W83627HF"; | | | |
1996 | lm_setup_sensors(sc, w83627hf_sensors); | | | |
1997 | wb_temp_diode_type(sc, cf_flags); | | | |
1998 | break; | | | |
1999 | case WB_CHIPID_W83627THF: | | 2611 | case WB_CHIPID_W83627THF: |
2000 | model = "W83627THF"; | | | |
2001 | lm_generic_banksel(sc, WB_BANKSEL_B0); | | 2612 | lm_generic_banksel(sc, WB_BANKSEL_B0); |
2002 | if ((*sc->lm_readreg)(sc, WB_BANK0_CONFIG) & WB_CONFIG_VMR9) | | 2613 | if ((*sc->lm_readreg)(sc, WB_BANK0_CONFIG) & WB_CONFIG_VMR9) |
2003 | sc->vrm9 = 1; | | 2614 | sc->vrm9 = 1; |
2004 | lm_generic_banksel(sc, banksel); | | 2615 | lm_generic_banksel(sc, banksel); |
2005 | lm_setup_sensors(sc, w83637hf_sensors); | | | |
2006 | wb_temp_diode_type(sc, cf_flags); | | | |
2007 | break; | | | |
2008 | case WB_CHIPID_W83627EHF_A: | | | |
2009 | model = "W83627EHF-A"; | | | |
2010 | lm_setup_sensors(sc, w83627ehf_sensors); | | | |
2011 | break; | | | |
2012 | case WB_CHIPID_W83627EHF: | | | |
2013 | model = "W83627EHF"; | | | |
2014 | lm_setup_sensors(sc, w83627ehf_sensors); | | | |
2015 | wb_temp_diode_type(sc, cf_flags); | | | |
2016 | break; | | | |
2017 | case WB_CHIPID_W83627DHG: | | | |
2018 | if (sc->sioid == WBSIO_ID_NCT6776F) { | | | |
2019 | vendor = "Nuvoton"; | | | |
2020 | model = "NCT6776F"; | | | |
2021 | lm_setup_sensors(sc, nct6776f_sensors); | | | |
2022 | } else { | | | |
2023 | model = "W83627DHG"; | | | |
2024 | lm_setup_sensors(sc, w83627dhg_sensors); | | | |
2025 | } | | | |
2026 | wb_temp_diode_type(sc, cf_flags); | | | |
2027 | break; | | 2616 | break; |
2028 | case WB_CHIPID_W83637HF: | | 2617 | case WB_CHIPID_W83637HF: |
2029 | model = "W83637HF"; | | | |
2030 | lm_generic_banksel(sc, WB_BANKSEL_B0); | | 2618 | lm_generic_banksel(sc, WB_BANKSEL_B0); |
2031 | if ((*sc->lm_readreg)(sc, WB_BANK0_CONFIG) & WB_CONFIG_VMR9) | | 2619 | if ((*sc->lm_readreg)(sc, WB_BANK0_CONFIG) & WB_CONFIG_VMR9) |
2032 | sc->vrm9 = 1; | | 2620 | sc->vrm9 = 1; |
2033 | lm_generic_banksel(sc, banksel); | | 2621 | lm_generic_banksel(sc, banksel); |
2034 | lm_setup_sensors(sc, w83637hf_sensors); | | | |
2035 | wb_temp_diode_type(sc, cf_flags); | | | |
2036 | break; | | | |
2037 | case WB_CHIPID_W83697HF: | | | |
2038 | model = "W83697HF"; | | | |
2039 | lm_setup_sensors(sc, w83697hf_sensors); | | | |
2040 | wb_temp_diode_type(sc, cf_flags); | | | |
2041 | break; | | | |
2042 | case WB_CHIPID_W83781D: | | | |
2043 | case WB_CHIPID_W83781D_2: | | | |
2044 | model = "W83781D"; | | | |
2045 | lm_setup_sensors(sc, w83781d_sensors); | | | |
2046 | break; | | | |
2047 | case WB_CHIPID_W83782D: | | | |
2048 | model = "W83782D"; | | | |
2049 | lm_setup_sensors(sc, w83782d_sensors); | | | |
2050 | wb_temp_diode_type(sc, cf_flags); | | | |
2051 | break; | | | |
2052 | case WB_CHIPID_W83783S: | | | |
2053 | model = "W83783S"; | | | |
2054 | lm_setup_sensors(sc, w83783s_sensors); | | | |
2055 | wb_temp_diode_type(sc, cf_flags); | | | |
2056 | break; | | | |
2057 | case WB_CHIPID_W83791D: | | | |
2058 | model = "W83791D"; | | | |
2059 | lm_setup_sensors(sc, w83791d_sensors); | | | |
2060 | wb_temp_diode_type(sc, cf_flags); | | | |
2061 | break; | | | |
2062 | case WB_CHIPID_W83791SD: | | | |
2063 | model = "W83791SD"; | | | |
2064 | break; | | | |
2065 | case WB_CHIPID_W83792D: | | | |
2066 | model = "W83792D"; | | | |
2067 | lm_setup_sensors(sc, w83792d_sensors); | | | |
2068 | break; | | | |
2069 | case WB_CHIPID_AS99127F: | | | |
2070 | vendor = "ASUS"; | | | |
2071 | if (vendid == WB_VENDID_ASUS) { | | | |
2072 | model = "AS99127F"; | | | |
2073 | lm_setup_sensors(sc, w83781d_sensors); | | | |
2074 | } else { | | | |
2075 | model = "AS99127F rev 2"; | | | |
2076 | lm_setup_sensors(sc, as99127f_sensors); | | | |
2077 | } | | | |
2078 | break; | | 2622 | break; |
2079 | default: | | 2623 | default: |
2080 | aprint_normal_dev(sc->sc_dev, | | 2624 | break; |
2081 | "unknown Winbond chip (ID 0x%x)\n", sc->chipid); | | | |
2082 | /* Handle as a standard LM78. */ | | | |
2083 | lm_setup_sensors(sc, lm78_sensors); | | | |
2084 | sc->refresh_sensor_data = lm_refresh_sensor_data; | | | |
2085 | return 1; | | | |
2086 | } | | 2625 | } |
2087 | | | 2626 | |
2088 | aprint_normal_dev(sc->sc_dev, "%s %s Hardware monitor\n", vendor, model); | | 2627 | aprint_normal_dev(dev, "%s %s Hardware monitor\n", vendor, model); |
2089 | | | 2628 | |
2090 | sc->refresh_sensor_data = wb_refresh_sensor_data; | | 2629 | return 0; |
2091 | return 1; | | | |
2092 | } | | 2630 | } |
2093 | | | 2631 | |
2094 | static void | | 2632 | static void |
2095 | lm_setup_sensors(struct lm_softc *sc, struct lm_sensor *sensors) | | 2633 | lm_setup_sensors(struct lm_softc *sc, const struct lm_sensor *sensors) |
2096 | { | | 2634 | { |
2097 | int i; | | 2635 | int i; |
2098 | | | 2636 | |
2099 | for (i = 0; sensors[i].desc; i++) { | | 2637 | for (i = 0; sensors[i].desc; i++) { |
2100 | sc->sensors[i].units = sensors[i].type; | | 2638 | sc->sensors[i].units = sensors[i].type; |
2101 | if (sc->sensors[i].units == ENVSYS_SVOLTS_DC) | | 2639 | if (sc->sensors[i].units == ENVSYS_SVOLTS_DC) |
2102 | sc->sensors[i].flags = ENVSYS_FCHANGERFACT; | | 2640 | sc->sensors[i].flags = ENVSYS_FCHANGERFACT; |
2103 | strlcpy(sc->sensors[i].desc, sensors[i].desc, | | 2641 | strlcpy(sc->sensors[i].desc, sensors[i].desc, |
2104 | sizeof(sc->sensors[i].desc)); | | 2642 | sizeof(sc->sensors[i].desc)); |
2105 | sc->numsensors++; | | 2643 | sc->numsensors++; |
2106 | } | | 2644 | } |
2107 | sc->lm_sensors = sensors; | | 2645 | sc->lm_sensors = sensors; |
2108 | } | | 2646 | } |
| @@ -2188,27 +2726,28 @@ lm_refresh_fanrpm(struct lm_softc *sc, i | | | @@ -2188,27 +2726,28 @@ lm_refresh_fanrpm(struct lm_softc *sc, i |
2188 | if (data == 0xff || data == 0x00) | | 2726 | if (data == 0xff || data == 0x00) |
2189 | sc->sensors[n].state = ENVSYS_SINVALID; | | 2727 | sc->sensors[n].state = ENVSYS_SINVALID; |
2190 | else { | | 2728 | else { |
2191 | sc->sensors[n].state = ENVSYS_SVALID; | | 2729 | sc->sensors[n].state = ENVSYS_SVALID; |
2192 | sc->sensors[n].value_cur = 1350000 / (data << divisor); | | 2730 | sc->sensors[n].value_cur = 1350000 / (data << divisor); |
2193 | } | | 2731 | } |
2194 | DPRINTF(("%s: fan[%d] data=0x%x value_cur=%d\n", | | 2732 | DPRINTF(("%s: fan[%d] data=0x%x value_cur=%d\n", |
2195 | __func__, n, data, sc->sensors[n].value_cur)); | | 2733 | __func__, n, data, sc->sensors[n].value_cur)); |
2196 | } | | 2734 | } |
2197 | | | 2735 | |
2198 | static void | | 2736 | static void |
2199 | wb_refresh_sensor_data(struct lm_softc *sc) | | 2737 | wb_refresh_sensor_data(struct lm_softc *sc) |
2200 | { | | 2738 | { |
2201 | int banksel, bank, i; | | 2739 | uint8_t banksel, bank; |
| | | 2740 | int i; |
2202 | | | 2741 | |
2203 | /* | | 2742 | /* |
2204 | * Properly save and restore bank selection register. | | 2743 | * Properly save and restore bank selection register. |
2205 | */ | | 2744 | */ |
2206 | banksel = bank = sc->lm_readreg(sc, WB_BANKSEL); | | 2745 | banksel = bank = sc->lm_readreg(sc, WB_BANKSEL); |
2207 | for (i = 0; i < sc->numsensors; i++) { | | 2746 | for (i = 0; i < sc->numsensors; i++) { |
2208 | if (bank != sc->lm_sensors[i].bank) { | | 2747 | if (bank != sc->lm_sensors[i].bank) { |
2209 | bank = sc->lm_sensors[i].bank; | | 2748 | bank = sc->lm_sensors[i].bank; |
2210 | lm_generic_banksel(sc, bank); | | 2749 | lm_generic_banksel(sc, bank); |
2211 | } | | 2750 | } |
2212 | sc->lm_sensors[i].refresh(sc, i); | | 2751 | sc->lm_sensors[i].refresh(sc, i); |
2213 | } | | 2752 | } |
2214 | lm_generic_banksel(sc, banksel); | | 2753 | lm_generic_banksel(sc, banksel); |
| @@ -2357,27 +2896,28 @@ wb_nct6776f_refresh_fanrpm(struct lm_sof | | | @@ -2357,27 +2896,28 @@ wb_nct6776f_refresh_fanrpm(struct lm_sof |
2357 | datal = (*sc->lm_readreg)(sc, sc->lm_sensors[n].reg + 1); | | 2896 | datal = (*sc->lm_readreg)(sc, sc->lm_sensors[n].reg + 1); |
2358 | | | 2897 | |
2359 | if ((datah == 0xff) || (datah == 0)) { | | 2898 | if ((datah == 0xff) || (datah == 0)) { |
2360 | sc->sensors[n].state = ENVSYS_SINVALID; | | 2899 | sc->sensors[n].state = ENVSYS_SINVALID; |
2361 | } else { | | 2900 | } else { |
2362 | sc->sensors[n].state = ENVSYS_SVALID; | | 2901 | sc->sensors[n].state = ENVSYS_SVALID; |
2363 | sc->sensors[n].value_cur = (datah << 8) | datal; | | 2902 | sc->sensors[n].value_cur = (datah << 8) | datal; |
2364 | } | | 2903 | } |
2365 | } | | 2904 | } |
2366 | | | 2905 | |
2367 | static void | | 2906 | static void |
2368 | wb_w83792d_refresh_fanrpm(struct lm_softc *sc, int n) | | 2907 | wb_w83792d_refresh_fanrpm(struct lm_softc *sc, int n) |
2369 | { | | 2908 | { |
2370 | int reg, shift, data, divisor = 1; | | 2909 | int shift, data, divisor = 1; |
| | | 2910 | uint8_t reg; |
2371 | | | 2911 | |
2372 | shift = 0; | | 2912 | shift = 0; |
2373 | | | 2913 | |
2374 | switch (sc->lm_sensors[n].reg) { | | 2914 | switch (sc->lm_sensors[n].reg) { |
2375 | case 0x28: | | 2915 | case 0x28: |
2376 | reg = 0x47; shift = 0; | | 2916 | reg = 0x47; shift = 0; |
2377 | break; | | 2917 | break; |
2378 | case 0x29: | | 2918 | case 0x29: |
2379 | reg = 0x47; shift = 4; | | 2919 | reg = 0x47; shift = 4; |
2380 | break; | | 2920 | break; |
2381 | case 0x2a: | | 2921 | case 0x2a: |
2382 | reg = 0x5b; shift = 0; | | 2922 | reg = 0x5b; shift = 0; |
2383 | break; | | 2923 | break; |