Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Add support for the W83781D and W83782D hardware ...
details: https://anonhg.NetBSD.org/src/rev/259fcfe599ff
branches: trunk
changeset: 495534:259fcfe599ff
user: bouyer <bouyer%NetBSD.org@localhost>
date: Sun Jul 30 22:23:53 2000 +0000
description:
Add support for the W83781D and W83782D hardware monitors.
diffstat:
sys/dev/ic/nslm7x.c | 373 ++++++++++++++++++++++++++++++++----------------
sys/dev/ic/nslm7xvar.h | 18 +-
2 files changed, 260 insertions(+), 131 deletions(-)
diffs (truncated from 522 to 300 lines):
diff -r c6a4647c1de0 -r 259fcfe599ff sys/dev/ic/nslm7x.c
--- a/sys/dev/ic/nslm7x.c Sun Jul 30 21:48:54 2000 +0000
+++ b/sys/dev/ic/nslm7x.c Sun Jul 30 22:23:53 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nslm7x.c,v 1.6 2000/07/30 17:22:26 bouyer Exp $ */
+/* $NetBSD: nslm7x.c,v 1.7 2000/07/30 22:23:53 bouyer Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -83,17 +83,26 @@
void lm_writereg __P((struct lm_softc *, int, int));
int lm_match __P((struct lm_softc *));
-void lm_refresh_sensor_data __P((struct lm_softc *));
-
int wb_match __P((struct lm_softc *));
-void wb_refresh_sensor_data __P((struct lm_softc *));
-
int def_match __P((struct lm_softc *));
void lm_common_match __P((struct lm_softc *));
+void generic_stemp __P((struct lm_softc *, struct envsys_tre_data *));
+void generic_svolt __P((struct lm_softc *, struct envsys_tre_data *,
+ struct envsys_basic_info *));
+void generic_fanrpm __P((struct lm_softc *, struct envsys_tre_data *));
+void lm_refresh_sensor_data __P((struct lm_softc *));
+void wb_temp __P((struct lm_softc *, struct envsys_tre_data *));
+void wb781_refresh_sensor_data __P((struct lm_softc *));
+void wb782_refresh_sensor_data __P((struct lm_softc *));
+
int lm_gtredata __P((struct sysmon_envsys *, struct envsys_tre_data *));
+
+int generic_streinfo_fan __P((struct lm_softc *, struct envsys_basic_info *,
+ int, struct envsys_basic_info *));
int lm_streinfo __P((struct sysmon_envsys *, struct envsys_basic_info *));
-int wb_streinfo __P((struct sysmon_envsys *, struct envsys_basic_info *));
+int wb781_streinfo __P((struct sysmon_envsys *, struct envsys_basic_info *));
+int wb782_streinfo __P((struct sysmon_envsys *, struct envsys_basic_info *));
struct lm_chip {
int (*chip_match) __P((struct lm_softc *));
@@ -279,8 +288,6 @@
{
int i, j;
- /* See if we have a winbond */
- i = lm_readreg(sc, LMD_CHIPID) & LM_ID_MASK;
lm_writereg(sc, WB_BANKSEL, WB_BANKSEL_HBAC);
j = lm_readreg(sc, WB_VENDID) << 8;
lm_writereg(sc, WB_BANKSEL, 0);
@@ -288,9 +295,58 @@
DPRINTF(("winbond vend id %d\n", j));
if (j != WB_VENDID_WINBOND)
return 0;
- printf(": W83627HF (device ID %d)\n", i);
+ /* read device ID */
+ lm_writereg(sc, WB_BANKSEL, WB_BANKSEL_B0);
+ j = lm_readreg(sc, WB_BANK0_CHIPID);
+ DPRINTF(("winbond chip id %d\n", j));
+ switch(j) {
+ case WB_CHIPID_83781:
+ printf(": W83781D\n");
+ sc->numsensors = WB83781_NUM_SENSORS;
+ sc->refresh_sensor_data = wb781_refresh_sensor_data;
+
+ for (i = 0; i < 7; ++i) {
+ sc->sensors[i].units = sc->info[i].units =
+ ENVSYS_SVOLTS_DC;
+ sprintf(sc->info[i].desc, "IN %d", i);
+ }
+
+ /* default correction factors for higher voltage inputs */
+ sc->info[0].rfact = sc->info[1].rfact =
+ sc->info[2].rfact = 10000;
+ sc->info[3].rfact = (int)(( 90.9 / 60.4) * 10000);
+ sc->info[4].rfact = (int)(( 38.0 / 10.0) * 10000);
+ sc->info[5].rfact = (int)((210.0 / 60.4) * 10000);
+ sc->info[6].rfact = (int)(( 90.9 / 60.4) * 10000);
+
+ for (i = 7; i < 10; ++i) {
+ sc->sensors[i].units = sc->info[i].units =
+ ENVSYS_STEMP;
+ sprintf(sc->info[i].desc, "Temp%d", i - 6);
+ }
+
+ for (i = 10; i < 13; ++i) {
+ sc->sensors[i].units = sc->info[i].units =
+ ENVSYS_SFANRPM;
+ sprintf(sc->info[i].desc, "Fan %d", i - 9);
+ }
+ sc->sc_sysmon.sme_streinfo = wb781_streinfo;
+ return 1;
+ case WB_CHIPID_83782:
+ printf(": W83782D\n");
+ break;
+ case WB_CHIPID_83627:
+ printf(": W83627HF\n");
+ break;
+ default:
+ printf(": unknow winbond chip ID 0x%x\n", j);
+ /* handle as a standart lm7x */
+ lm_common_match(sc);
+ return 1;
+ }
+
sc->numsensors = WB_NUM_SENSORS;
- sc->refresh_sensor_data = wb_refresh_sensor_data;
+ sc->refresh_sensor_data = wb782_refresh_sensor_data;
sc->sensors[0].units = sc->info[0].units = ENVSYS_SVOLTS_DC;
sprintf(sc->info[0].desc, "VCORE A");
@@ -331,7 +387,7 @@
sc->sensors[i].units = sc->info[i].units = ENVSYS_SFANRPM;
sprintf(sc->info[i].desc, "Fan %d", i - 11);
}
- sc->sc_sysmon.sme_streinfo = wb_streinfo;
+ sc->sc_sysmon.sme_streinfo = wb782_streinfo;
return 1;
}
@@ -364,67 +420,105 @@
}
int
+generic_streinfo_fan(sc, info, n, binfo)
+ struct lm_softc *sc;
+ struct envsys_basic_info *info;
+ int n;
+ struct envsys_basic_info *binfo;
+{
+ u_int8_t sdata;
+ int divisor;
+
+ /* FAN1 and FAN2 can have divisors set, but not FAN3 */
+ if ((sc->info[binfo->sensor].units == ENVSYS_SFANRPM)
+ && (binfo->sensor != 2)) {
+ if (binfo->rpms == 0) {
+ binfo->validflags = 0;
+ return (0);
+ }
+
+ /* 153 is the nominal FAN speed value */
+ divisor = 1350000 / (binfo->rpms * 153);
+
+ /* ...but we need lg(divisor) */
+ if (divisor <= 1)
+ divisor = 0;
+ else if (divisor <= 2)
+ divisor = 1;
+ else if (divisor <= 4)
+ divisor = 2;
+ else
+ divisor = 3;
+
+ /*
+ * FAN1 div is in bits <5:4>, FAN2 div is
+ * in <7:6>
+ */
+ sdata = lm_readreg(sc, LMD_VIDFAN);
+ if ( binfo->sensor == 0 ) { /* FAN1 */
+ divisor <<= 4;
+ sdata = (sdata & 0xCF) | divisor;
+ } else { /* FAN2 */
+ divisor <<= 6;
+ sdata = (sdata & 0x3F) | divisor;
+ }
+
+ lm_writereg(sc, LMD_VIDFAN, sdata);
+ }
+ return (0);
+
+}
+
+int
lm_streinfo(sme, binfo)
struct sysmon_envsys *sme;
struct envsys_basic_info *binfo;
{
struct lm_softc *sc = sme->sme_cookie;
- int divisor;
- u_int8_t sdata;
if (sc->info[binfo->sensor].units == ENVSYS_SVOLTS_DC)
sc->info[binfo->sensor].rfact = binfo->rfact;
else {
- /* FAN1 and FAN2 can have divisors set, but not FAN3 */
- if ((sc->info[binfo->sensor].units == ENVSYS_SFANRPM)
- && (binfo->sensor != 10)) {
-
- if (binfo->rpms == 0) {
- binfo->validflags = 0;
- return (0);
- }
-
- /* 153 is the nominal FAN speed value */
- divisor = 1350000 / (binfo->rpms * 153);
-
- /* ...but we need lg(divisor) */
- if (divisor <= 1)
- divisor = 0;
- else if (divisor <= 2)
- divisor = 1;
- else if (divisor <= 4)
- divisor = 2;
- else
- divisor = 3;
+ if (sc->info[binfo->sensor].units == ENVSYS_SFANRPM) {
+ generic_streinfo_fan(sc, &sc->info[binfo->sensor],
+ binfo->sensor - 8, binfo);
+ }
+ memcpy(sc->info[binfo->sensor].desc, binfo->desc,
+ sizeof(sc->info[binfo->sensor].desc));
+ sc->info[binfo->sensor].desc[
+ sizeof(sc->info[binfo->sensor].desc) - 1] = '\0';
- /*
- * FAN1 div is in bits <5:4>, FAN2 div is
- * in <7:6>
- */
- sdata = lm_readreg(sc, LMD_VIDFAN);
- if ( binfo->sensor == 8 ) { /* FAN1 */
- divisor <<= 4;
- sdata = (sdata & 0xCF) | divisor;
- } else { /* FAN2 */
- divisor <<= 6;
- sdata = (sdata & 0x3F) | divisor;
- }
-
- lm_writereg(sc, LMD_VIDFAN, sdata);
- }
-
- memcpy(sc->info[binfo->sensor].desc, binfo->desc,
- sizeof(sc->info[binfo->sensor].desc));
- sc->info[binfo->sensor].desc[
- sizeof(sc->info[binfo->sensor].desc) - 1] = '\0';
-
- binfo->validflags = ENVSYS_FVALID;
+ binfo->validflags = ENVSYS_FVALID;
}
return (0);
}
int
-wb_streinfo(sme, binfo)
+wb781_streinfo(sme, binfo)
+ struct sysmon_envsys *sme;
+ struct envsys_basic_info *binfo;
+{
+ struct lm_softc *sc = sme->sme_cookie;
+
+ if (sc->info[binfo->sensor].units == ENVSYS_SVOLTS_DC)
+ sc->info[binfo->sensor].rfact = binfo->rfact;
+ else {
+ if (sc->info[binfo->sensor].units == ENVSYS_SFANRPM) {
+ generic_streinfo_fan(sc, &sc->info[binfo->sensor],
+ binfo->sensor - 10, binfo);
+ }
+ memcpy(sc->info[binfo->sensor].desc, binfo->desc,
+ sizeof(sc->info[binfo->sensor].desc));
+ sc->info[binfo->sensor].desc[
+ sizeof(sc->info[binfo->sensor].desc) - 1] = '\0';
+
+ binfo->validflags = ENVSYS_FVALID;
+ }
+ return (0);
+}
+
+int
+wb782_streinfo(sme, binfo)
struct sysmon_envsys *sme;
struct envsys_basic_info *binfo;
{
@@ -437,7 +531,6 @@
sc->info[binfo->sensor].rfact = binfo->rfact;
else {
if (sc->info[binfo->sensor].units == ENVSYS_SFANRPM) {
-
if (binfo->rpms == 0) {
binfo->validflags = 0;
return (0);
@@ -492,6 +585,62 @@
return (0);
}
+void
+generic_stemp(sc, sensor)
+ struct lm_softc *sc;
+ struct envsys_tre_data *sensor;
+{
+ int sdata = lm_readreg(sc, LMD_SENSORBASE + 7);
+ /* temp is given in deg. C, we convert to uK */
+ sensor->cur.data_us = sdata * 1000000 + 273150000;
+}
+
+void
+generic_svolt(sc, sensors, infos)
+ struct lm_softc *sc;
+ struct envsys_tre_data *sensors;
+ struct envsys_basic_info *infos;
+{
Home |
Main Index |
Thread Index |
Old Index