Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src Pull up (approved by thorpej):
details: https://anonhg.NetBSD.org/src/rev/7351381e7591
branches: netbsd-1-5
changeset: 488850:7351381e7591
user: bouyer <bouyer%NetBSD.org@localhost>
date: Wed Aug 02 17:09:49 2000 +0000
description:
Pull up (approved by thorpej):
sys/dev/ic/nslm7x.c 1.4->1.7
sys/dev/ic/nslm7xvar.h 1.3->1.5
share/man/man4/lm.4 1.5->1.6
Add support for a few winbond hardware monitors.
diffstat:
share/man/man4/lm.4 | 9 +-
sys/dev/ic/nslm7x.c | 666 ++++++++++++++++++++++++++++++++++++++----------
sys/dev/ic/nslm7xvar.h | 52 +++-
3 files changed, 578 insertions(+), 149 deletions(-)
diffs (truncated from 880 to 300 lines):
diff -r 731c94e15b01 -r 7351381e7591 share/man/man4/lm.4
--- a/share/man/man4/lm.4 Wed Aug 02 17:06:17 2000 +0000
+++ b/share/man/man4/lm.4 Wed Aug 02 17:09:49 2000 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: lm.4,v 1.3.4.1 2000/07/03 22:43:18 thorpej Exp $
+.\" $NetBSD: lm.4,v 1.3.4.2 2000/08/02 17:09:49 bouyer Exp $
.\"
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -53,7 +53,7 @@
.Xr envsys 4
API.
.Pp
-These devices possess 11 sensors:
+Most supported devices possess 11 sensors:
.Bl -column "Sensor" "Units" "Typical" -offset indent
.It Sy "Sensor" Ta Sy "Units" Ta Sy "Typical Use"
.It Li "IN0" Ta "uV DC" Ta "Core voltage"
@@ -68,6 +68,8 @@
.It Li "Fan1" Ta "RPM" Ta "Chassis Fan"
.It Li "Fan2" Ta "RPM" Ta "Fan"
.El
+for some devices (such as the W83627HF) sensors names and numbers will be
+different.
.Pp
Sensor names as well as nominal RPMs for fans 0 and 1 may be changed
through the
@@ -91,6 +93,9 @@
.It
.Tn Winbond
W83781D and W83782D (untested)
+.It
+.Tn Winbond
+W83627HF
.El
.Sh SEE ALSO
.Xr envstat 1
diff -r 731c94e15b01 -r 7351381e7591 sys/dev/ic/nslm7x.c
--- a/sys/dev/ic/nslm7x.c Wed Aug 02 17:06:17 2000 +0000
+++ b/sys/dev/ic/nslm7x.c Wed Aug 02 17:09:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nslm7x.c,v 1.3.4.1 2000/07/30 17:54:14 bouyer Exp $ */
+/* $NetBSD: nslm7x.c,v 1.3.4.2 2000/08/02 17:09:49 bouyer Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
#endif
const struct envsys_range lm_ranges[] = { /* sc->sensors sub-intervals */
- /* for each unit type */
+ /* for each unit type */
{ 7, 7, ENVSYS_STEMP },
{ 8, 10, ENVSYS_SFANRPM },
{ 1, 0, ENVSYS_SVOLTS_AC }, /* None */
@@ -78,12 +78,42 @@
{ 1, 0, ENVSYS_SAMPS } /* None */
};
-
+
u_int8_t lm_readreg __P((struct lm_softc *, int));
void lm_writereg __P((struct lm_softc *, int, int));
+
+int lm_match __P((struct lm_softc *));
+int wb_match __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 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 *));
+};
+
+struct lm_chip lm_chips[] = {
+ { wb_match},
+ { lm_match},
+ { def_match} /* Must be last */
+};
+
u_int8_t
lm_readreg(sc, reg)
@@ -147,17 +177,9 @@
{
int i;
- /* See if we have an LM78 or LM79 */
- i = lm_readreg(lmsc, LMD_CHIPID) & LM_ID_MASK;
- printf(": LM7");
- if (i == LM_ID_LM78)
- printf("8\n");
- else if (i == LM_ID_LM78J)
- printf("8J\n");
- else if (i == LM_ID_LM79)
- printf("9\n");
- else
- printf("? - Unknown chip ID (%x)\n", i);
+ for (i = 0; i < sizeof(lm_chips) / sizeof(lm_chips[0]); i++)
+ if (lm_chips[i].chip_match(lmsc))
+ break;
/* Start the monitoring loop */
lm_writereg(lmsc, LMD_CONFIG, 0x01);
@@ -166,45 +188,12 @@
timerclear(&lmsc->lastread);
/* Initialize sensors */
- for (i = 0; i < LM_NUM_SENSORS; ++i) {
+ for (i = 0; i < lmsc->numsensors; ++i) {
lmsc->sensors[i].sensor = lmsc->info[i].sensor = i;
lmsc->sensors[i].validflags = (ENVSYS_FVALID|ENVSYS_FCURVALID);
lmsc->info[i].validflags = ENVSYS_FVALID;
lmsc->sensors[i].warnflags = ENVSYS_WARN_OK;
}
-
- for (i = 0; i < 7; ++i) {
- lmsc->sensors[i].units = lmsc->info[i].units =
- ENVSYS_SVOLTS_DC;
-
- lmsc->info[i].desc[0] = 'I';
- lmsc->info[i].desc[1] = 'N';
- lmsc->info[i].desc[2] = i + '0';
- lmsc->info[i].desc[3] = 0;
- }
-
- /* default correction factors for resistors on higher voltage inputs */
- lmsc->info[0].rfact = lmsc->info[1].rfact =
- lmsc->info[2].rfact = 10000;
- lmsc->info[3].rfact = (int)(( 90.9 / 60.4) * 10000);
- lmsc->info[4].rfact = (int)(( 38.0 / 10.0) * 10000);
- lmsc->info[5].rfact = (int)((210.0 / 60.4) * 10000);
- lmsc->info[6].rfact = (int)(( 90.9 / 60.4) * 10000);
-
- lmsc->sensors[7].units = ENVSYS_STEMP;
- strcpy(lmsc->info[7].desc, "Temp");
-
- for (i = 8; i < 11; ++i) {
- lmsc->sensors[i].units = lmsc->info[i].units = ENVSYS_SFANRPM;
-
- lmsc->info[i].desc[0] = 'F';
- lmsc->info[i].desc[1] = 'a';
- lmsc->info[i].desc[2] = 'n';
- lmsc->info[i].desc[3] = ' ';
- lmsc->info[i].desc[4] = i - 7 + '0';
- lmsc->info[i].desc[5] = 0;
- }
-
/*
* Hook into the System Monitor.
*/
@@ -214,9 +203,9 @@
lmsc->sc_sysmon.sme_cookie = lmsc;
lmsc->sc_sysmon.sme_gtredata = lm_gtredata;
- lmsc->sc_sysmon.sme_streinfo = lm_streinfo;
+ /* sme_streinfo set in chip-specific attach */
- lmsc->sc_sysmon.sme_nsensors = LM_NUM_SENSORS;
+ lmsc->sc_sysmon.sme_nsensors = lmsc->numsensors;
lmsc->sc_sysmon.sme_envsys_version = 1000;
if (sysmon_envsys_register(&lmsc->sc_sysmon))
@@ -224,52 +213,324 @@
lmsc->sc_dev.dv_xname);
}
+int
+lm_match(sc)
+ struct lm_softc *sc;
+{
+ int i;
+
+ /* See if we have an LM78 or LM79 */
+ i = 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;
+ default:
+ return 0;
+ }
+ lm_common_match(sc);
+ return 1;
+}
+
+int
+def_match(sc)
+ struct lm_softc *sc;
+{
+ int i;
+
+ i = lm_readreg(sc, LMD_CHIPID) & LM_ID_MASK;
+ printf(": Unknow chip (ID %d)\n", i);
+ lm_common_match(sc);
+ return 1;
+}
+
+void
+lm_common_match(sc)
+ 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].units = sc->info[i].units =
+ ENVSYS_SVOLTS_DC;
+ sprintf(sc->info[i].desc, "IN %d", i);
+ }
+
+ /* default correction factors for resistors on 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);
+
+ sc->sensors[7].units = ENVSYS_STEMP;
+ strcpy(sc->info[7].desc, "Temp");
+
+ for (i = 8; i < 11; ++i) {
+ sc->sensors[i].units = sc->info[i].units = ENVSYS_SFANRPM;
+ sprintf(sc->info[i].desc, "Fan %d", i - 7);
+ }
+ sc->sc_sysmon.sme_streinfo = lm_streinfo;
+}
+
+int
+wb_match(sc)
+ struct lm_softc *sc;
+{
+ int i, j;
+
+ lm_writereg(sc, WB_BANKSEL, WB_BANKSEL_HBAC);
+ j = lm_readreg(sc, WB_VENDID) << 8;
+ lm_writereg(sc, WB_BANKSEL, 0);
+ j |= lm_readreg(sc, WB_VENDID);
+ DPRINTF(("winbond vend id %d\n", j));
+ if (j != WB_VENDID_WINBOND)
+ return 0;
+ /* 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);
+ }
Home |
Main Index |
Thread Index |
Old Index