summaryrefslogtreecommitdiff
path: root/sys/dev/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r--sys/dev/acpi/acpibat.c108
-rw-r--r--sys/dev/acpi/acpidev.h9
2 files changed, 109 insertions, 8 deletions
diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c
index ce5938cc252..96dc335f40b 100644
--- a/sys/dev/acpi/acpibat.c
+++ b/sys/dev/acpi/acpibat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpibat.c,v 1.3 2005/12/16 04:16:59 marco Exp $ */
+/* $OpenBSD: acpibat.c,v 1.4 2005/12/28 03:08:33 marco Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -25,6 +25,8 @@
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpidev.h>
+#include <dev/acpi/amltypes.h>
+#include <dev/acpi/dsdt.h>
int acpibat_match(struct device *, void *, void *);
void acpibat_attach(struct device *, struct device *, void *);
@@ -34,6 +36,12 @@ struct acpibat_softc {
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
+
+ struct acpi_softc *sc_acpi;
+ struct aml_node *sc_devnode;
+
+ struct acpibat_bif sc_bif;
+ struct acpibat_bst sc_bst;
};
struct cfattach acpibat_ca = {
@@ -44,6 +52,9 @@ struct cfdriver acpibat_cd = {
NULL, "acpibat", DV_DULL
};
+void acpibat_getbif(struct acpibat_softc *);
+void acpibat_getbst(struct acpibat_softc *);
+
int
acpibat_match(struct device *parent, void *match, void *aux)
{
@@ -62,13 +73,98 @@ acpibat_match(struct device *parent, void *match, void *aux)
void
acpibat_attach(struct device *parent, struct device *self, void *aux)
{
-/*
struct acpibat_softc *sc = (struct acpibat_softc *) self;
- struct acpi_softc *psc = (struct acpi_softc *) parent;
struct acpi_attach_args *aa = aux;
- bus_addr_t address;
- bus_size_t size;
-*/
printf("\n");
+
+ sc->sc_acpi = (struct acpi_softc *)parent;
+ sc->sc_devnode = aa->aaa_node->child;
+ /* acpibat_getbif(sc); */
+
+ printf("\n");
+}
+
+void
+acpibat_getbif(struct acpibat_softc *sc)
+{
+ struct aml_value res, env;
+
+ memset(&res, 0, sizeof(res));
+ memset(&env, 0, sizeof(env));
+
+ if (aml_eval_name(sc->sc_acpi, sc->sc_devnode, "_BIF", &res, &env)) {
+ dprintf(50, "%s: no _BIF\n",
+ DEVNAME(sc));
+ return;
+ }
+
+ if (res.length != 13) {
+ printf("%s: invalid _BIF, battery information not saved\n",
+ DEVNAME(sc));
+ return;
+ }
+
+ sc->sc_bif.bif_power_unit = aml_intval(&res.v_package[0]);
+ sc->sc_bif.bif_capacity = aml_intval(&res.v_package[1]);
+ sc->sc_bif.bif_last_capacity = aml_intval(&res.v_package[2]);
+ sc->sc_bif.bif_technology = aml_intval(&res.v_package[3]);
+ sc->sc_bif.bif_voltage = aml_intval(&res.v_package[4]);
+ sc->sc_bif.bif_warning = aml_intval(&res.v_package[5]);
+ sc->sc_bif.bif_low = aml_intval(&res.v_package[6]);
+ sc->sc_bif.bif_cap_granu1 = aml_intval(&res.v_package[7]);
+ sc->sc_bif.bif_cap_granu2 = aml_intval(&res.v_package[8]);
+ sc->sc_bif.bif_model = aml_strval(&res.v_package[9]);
+ sc->sc_bif.bif_serial = aml_strval(&res.v_package[10]);
+ sc->sc_bif.bif_type = aml_strval(&res.v_package[11]);
+ sc->sc_bif.bif_oem = aml_strval(&res.v_package[12]);
+
+ dprintf(20, "power_unit: %u capacity: %u last_cap: %u tech: %u "
+ "volt: %u warn: %u low: %u gran1: %u gran2: %d model: %s "
+ "serial: %s type: %s oem: %s\n",
+ sc->sc_bif.bif_power_unit,
+ sc->sc_bif.bif_capacity,
+ sc->sc_bif.bif_last_capacity,
+ sc->sc_bif.bif_technology,
+ sc->sc_bif.bif_voltage,
+ sc->sc_bif.bif_warning,
+ sc->sc_bif.bif_low,
+ sc->sc_bif.bif_cap_granu1,
+ sc->sc_bif.bif_cap_granu2,
+ sc->sc_bif.bif_model,
+ sc->sc_bif.bif_serial,
+ sc->sc_bif.bif_type,
+ sc->sc_bif.bif_oem);
+}
+
+void
+acpibat_getbst(struct acpibat_softc *sc)
+{
+ struct aml_value res, env;
+
+ memset(&res, 0, sizeof(res));
+ memset(&env, 0, sizeof(env));
+
+ if (aml_eval_name(sc->sc_acpi, sc->sc_devnode, "_BST", &res, &env)) {
+ dprintf(50, "%s: no _BST\n",
+ DEVNAME(sc));
+ return;
+ }
+
+ if (res.length != 4) {
+ printf("%s: invalid _BST, battery status not saved\n",
+ DEVNAME(sc));
+ return;
+ }
+
+ sc->sc_bst.bst_state = aml_intval(&res.v_package[0]);
+ sc->sc_bst.bst_rate = aml_intval(&res.v_package[1]);
+ sc->sc_bst.bst_capacity = aml_intval(&res.v_package[2]);
+ sc->sc_bst.bst_voltage = aml_intval(&res.v_package[3]);
+
+ dprintf(20, "state: %u rate: %u cap: %u volt: %u ",
+ sc->sc_bst.bst_state,
+ sc->sc_bst.bst_rate,
+ sc->sc_bst.bst_capacity,
+ sc->sc_bst.bst_voltage);
}
diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h
index b3b2396a810..415a97e694b 100644
--- a/sys/dev/acpi/acpidev.h
+++ b/sys/dev/acpi/acpidev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpidev.h,v 1.2 2005/12/16 21:11:51 marco Exp $ */
+/* $OpenBSD: acpidev.h,v 1.3 2005/12/28 03:08:33 marco Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
@@ -19,6 +19,8 @@
#ifndef __DEV_ACPI_ACPIDEV_H__
#define __DEV_ACPI_ACPIDEV_H__
+#define DEVNAME(s) ((s)->sc_dev.dv_xname)
+
/*
* _BIF (Battery InFormation)
* Arguments: none
@@ -55,7 +57,10 @@ struct acpibat_bif {
u_int32_t bif_low;
u_int32_t bif_cap_granu1;
u_int32_t bif_cap_granu2;
- char bif_data[]; /* 4 strings */
+ const char *bif_model;
+ const char *bif_serial;
+ const char *bif_type;
+ const char *bif_oem;
};
/*