summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2007-02-22 20:44:52 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2007-02-22 20:44:52 +0000
commit441a2f6f0393e060ac1789616e4e86611d18f326 (patch)
tree90cdaf696d49505a18708bed0ff2dc5310f8cee2 /sys
parentaa226f0ce3131d043966709c1dc60128a3b9a303 (diff)
Add support for Winbond W83627EHF chips.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/lm78.c53
-rw-r--r--sys/dev/ic/lm78var.h6
2 files changed, 56 insertions, 3 deletions
diff --git a/sys/dev/ic/lm78.c b/sys/dev/ic/lm78.c
index 79cfd382fe0..7f670e7f6ec 100644
--- a/sys/dev/ic/lm78.c
+++ b/sys/dev/ic/lm78.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lm78.c,v 1.12 2007/01/07 21:24:29 kettenis Exp $ */
+/* $OpenBSD: lm78.c,v 1.13 2007/02/22 20:44:51 kettenis Exp $ */
/*
* Copyright (c) 2005, 2006 Mark Kettenis
@@ -62,6 +62,7 @@ void lm_refresh_fanrpm(struct lm_softc *, int);
void wb_refresh_sensor_data(struct lm_softc *);
void wb_w83637hf_refresh_vcore(struct lm_softc *, int);
void wb_refresh_nvolt(struct lm_softc *, int);
+void wb_w83627ehf_refresh_nvolt(struct lm_softc *, int);
void wb_refresh_temp(struct lm_softc *, int);
void wb_refresh_fanrpm(struct lm_softc *, int);
void wb_w83792d_refresh_fanrpm(struct lm_softc *, int);
@@ -124,6 +125,39 @@ struct lm_sensor w83627hf_sensors[] = {
{ NULL }
};
+/*
+ * The W83627EHF can measure voltages up to 2.048 V instead of the
+ * traditional 4.096 V. For measuring positive voltages, this can be
+ * accounted for by halving the resistor factor. Negative voltages
+ * need special treatment, also because the reference voltage is 2.048 V
+ * instead of the traditional 3.6 V.
+ */
+struct lm_sensor w83627ehf_sensors[] = {
+ /* Voltage */
+ { "VCore", SENSOR_VOLTS_DC, 0, 0x20, lm_refresh_volt, RFACT_NONE / 2},
+ { "+12V", SENSOR_VOLTS_DC, 0, 0x21, lm_refresh_volt, RFACT(56, 10) / 2 },
+ { "+3.3V", SENSOR_VOLTS_DC, 0, 0x22, lm_refresh_volt, RFACT(34, 34) / 2 },
+ { "+3.3V", SENSOR_VOLTS_DC, 0, 0x23, lm_refresh_volt, RFACT(34, 24) / 2 },
+ { "-12V", SENSOR_VOLTS_DC, 0, 0x24, wb_w83627ehf_refresh_nvolt },
+ { "", SENSOR_VOLTS_DC, 0, 0x25, lm_refresh_volt, RFACT_NONE / 2 },
+ { "", SENSOR_VOLTS_DC, 0, 0x26, lm_refresh_volt, RFACT_NONE / 2 },
+ { "3.3VSB", SENSOR_VOLTS_DC, 5, 0x50, lm_refresh_volt, RFACT(34, 34) / 2 },
+ { "VBAT", SENSOR_VOLTS_DC, 5, 0x51, lm_refresh_volt, RFACT_NONE / 2 },
+ { "", SENSOR_VOLTS_DC, 5, 0x52, lm_refresh_volt, RFACT_NONE / 2 },
+
+ /* Temperature */
+ { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp },
+ { "", SENSOR_TEMP, 1, 0x50, wb_refresh_temp },
+ { "", SENSOR_TEMP, 2, 0x50, wb_refresh_temp },
+
+ /* Fans */
+ { "", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm },
+ { "", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm },
+ { "", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm },
+
+ { NULL }
+};
+
struct lm_sensor w83637hf_sensors[] = {
/* Voltage */
{ "VCore", SENSOR_VOLTS_DC, 0, 0x20, wb_w83637hf_refresh_vcore },
@@ -440,6 +474,10 @@ wb_match(struct lm_softc *sc)
printf(": W83627THF\n");
lm_setup_sensors(sc, w83637hf_sensors);
break;
+ case WB_CHIPID_W83627EHF:
+ printf(": W83627EHF\n");
+ lm_setup_sensors(sc, w83627ehf_sensors);
+ break;
case WB_CHIPID_W83637HF:
printf(": W83637HF\n");
sc->lm_writereg(sc, WB_BANKSEL, WB_BANKSEL_B0);
@@ -654,6 +692,19 @@ wb_refresh_nvolt(struct lm_softc *sc, int n)
}
void
+wb_w83627ehf_refresh_nvolt(struct lm_softc *sc, int n)
+{
+ struct sensor *sensor = &sc->sensors[n];
+ int data;
+
+ data = sc->lm_readreg(sc, sc->lm_sensors[n].reg);
+ sensor->value = ((data << 3) - WB_W83627EHF_VREF);
+ sensor->value *= RFACT(232, 10);
+ sensor->value /= 10;
+ sensor->value += WB_W83627EHF_VREF * 1000;
+}
+
+void
wb_refresh_temp(struct lm_softc *sc, int n)
{
struct sensor *sensor = &sc->sensors[n];
diff --git a/sys/dev/ic/lm78var.h b/sys/dev/ic/lm78var.h
index 5e42b889dae..eff056f1154 100644
--- a/sys/dev/ic/lm78var.h
+++ b/sys/dev/ic/lm78var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lm78var.h,v 1.9 2007/01/08 22:18:50 kettenis Exp $ */
+/* $OpenBSD: lm78var.h,v 1.10 2007/02/22 20:44:51 kettenis Exp $ */
/*
* Copyright (c) 2005, 2006 Mark Kettenis
@@ -112,12 +112,14 @@
#define WB_CHIPID_W83792D 0x7a
#define WB_CHIPID_W83637HF 0x80
#define WB_CHIPID_W83627THF 0x90
+#define WB_CHIPID_W83627EHF 0xa1
/* Config bits */
#define WB_CONFIG_VMR9 0x01
/* Reference voltage (mV) */
-#define WB_VREF 3600
+#define WB_VREF 3600
+#define WB_W83627EHF_VREF 2048
#define WB_MAX_SENSORS 19