summaryrefslogtreecommitdiff
path: root/sys/dev/acpi/acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/acpi/acpi.c')
-rw-r--r--sys/dev/acpi/acpi.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 46d5558629b..7837f52dcc1 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.320 2017/01/14 11:32:00 kettenis Exp $ */
+/* $OpenBSD: acpi.c,v 1.321 2017/02/22 16:39:56 jcs Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -1113,6 +1113,12 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
bat = malloc(sizeof(*bat), M_DEVBUF, M_WAITOK | M_ZERO);
bat->aba_softc = (struct acpibat_softc *)dev;
SLIST_INSERT_HEAD(&sc->sc_bat, bat, aba_link);
+ } else if (!strcmp(dev->dv_cfdata->cf_driver->cd_name, "acpisbs")) {
+ struct acpi_sbs *sbs;
+
+ sbs = malloc(sizeof(*sbs), M_DEVBUF, M_WAITOK | M_ZERO);
+ sbs->asbs_softc = (struct acpisbs_softc *)dev;
+ SLIST_INSERT_HEAD(&sc->sc_sbs, sbs, asbs_link);
}
}
@@ -1759,17 +1765,18 @@ acpi_sleep_task(void *arg0, int sleepmode)
struct acpi_softc *sc = arg0;
struct acpi_ac *ac;
struct acpi_bat *bat;
+ struct acpi_sbs *sbs;
/* System goes to sleep here.. */
acpi_sleep_state(sc, sleepmode);
/* AC and battery information needs refreshing */
SLIST_FOREACH(ac, &sc->sc_ac, aac_link)
- aml_notify(ac->aac_softc->sc_devnode,
- 0x80);
+ aml_notify(ac->aac_softc->sc_devnode, 0x80);
SLIST_FOREACH(bat, &sc->sc_bat, aba_link)
- aml_notify(bat->aba_softc->sc_devnode,
- 0x80);
+ aml_notify(bat->aba_softc->sc_devnode, 0x80);
+ SLIST_FOREACH(sbs, &sc->sc_sbs, asbs_link)
+ aml_notify(sbs->asbs_softc->sc_devnode, 0x80);
}
#endif /* SMALL_KERNEL */
@@ -2976,6 +2983,7 @@ acpiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
struct acpi_softc *sc;
struct acpi_ac *ac;
struct acpi_bat *bat;
+ struct acpi_sbs *sbs;
struct apm_power_info *pi = (struct apm_power_info *)data;
int bats;
unsigned int remaining, rem, minutes, rate;
@@ -3054,6 +3062,27 @@ acpiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
minutes += bat->aba_softc->sc_bst.bst_capacity;
}
+ SLIST_FOREACH(sbs, &sc->sc_sbs, asbs_link) {
+ if (sbs->asbs_softc->sc_batteries_present == 0)
+ continue;
+
+ if (sbs->asbs_softc->sc_battery.rel_charge == 0)
+ continue;
+
+ bats++;
+ rem = sbs->asbs_softc->sc_battery.rel_charge;
+ if (rem > 100)
+ rem = 100;
+ remaining += rem;
+
+ if (sbs->asbs_softc->sc_battery.run_time ==
+ ACPISBS_VALUE_UNKNOWN)
+ continue;
+
+ rate = 60; /* XXX */
+ minutes += sbs->asbs_softc->sc_battery.run_time;
+ }
+
if (bats == 0) {
pi->battery_state = APM_BATTERY_ABSENT;
pi->battery_life = 0;