summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-03-07 13:32:37 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-03-07 13:32:37 +0000
commitb53c050a45e27b3386e41869ec8f3b62f849fc10 (patch)
treecb0332681d2b972fcb69bcbdf4cbdd495e6c0d1c /sys
parenta886d240ca3215f7f7cc8c9d280e32c8bd72ec6a (diff)
Better battery % computation; ok otto@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/loongson/dev/stsec.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/arch/loongson/dev/stsec.c b/sys/arch/loongson/dev/stsec.c
index 88ba8fd1e5c..f0bb3488f84 100644
--- a/sys/arch/loongson/dev/stsec.c
+++ b/sys/arch/loongson/dev/stsec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stsec.c,v 1.2 2010/03/03 19:43:36 otto Exp $ */
+/* $OpenBSD: stsec.c,v 1.3 2010/03/07 13:32:36 miod Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -57,7 +57,8 @@ extern int gdium_revision;
#define ST7_SIGNATURE 0x04
#define STSIG_EC_CONTROL 0x00
#define STSIG_OS_CONTROL 0xae
-#define STSEC_BAT_MIN_VOLT 500000 /* 0.5V */
+/* rough battery operating state limits */
+#define STSEC_BAT_MIN_VOLT 7000000 /* 7V */
#define STSEC_BAT_MAX_VOLT 8000000 /* 8V */
const struct {
@@ -283,7 +284,10 @@ stsec_sensors_update(void *vsc)
ks = &sc->sc_sensors[STSEC_SENSOR_BATTERY_PRESENCE];
switch (gdium_revision) {
case 0:
- ks->value = batuv > STSEC_BAT_MIN_VOLT;
+ if (ISSET(status, STS_AC_AVAILABLE))
+ ks->value = batuv > 500000;
+ else
+ ks->value = 1;
break;
default:
ks->value = !!ISSET(status, STS_BATTERY_PRESENT);