diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2006-02-20 00:48:11 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2006-02-20 00:48:11 +0000 |
commit | a136077725164e18d93d6472d12ef74cedcdf915 (patch) | |
tree | a7d0cb398d5fefff52a58b26c86fe1d3a25df471 | |
parent | 6557ea86b6eebe82ff9710ced47a795afb596313 (diff) |
Add acpibtn device. Remains disabled for now.
-rw-r--r-- | sys/arch/amd64/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/dev/acpi/acpi.c | 9 | ||||
-rw-r--r-- | sys/dev/acpi/acpibtn.c | 154 | ||||
-rw-r--r-- | sys/dev/acpi/files.acpi | 7 |
5 files changed, 167 insertions, 9 deletions
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index f67a9f3ba79..08a7c2604b7 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.112 2006/02/14 18:11:03 miod Exp $ +# $OpenBSD: GENERIC,v 1.113 2006/02/20 00:48:09 marco Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -50,6 +50,7 @@ pci* at mainbus0 #hpet* at acpi? #acpiac* at acpi? #acpibat* at acpi? +#acpibtn* at acpi? ipmi0 at mainbus? # IPMI diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 9ef3c7dd147..aa807fcfaa0 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.470 2006/02/14 18:11:03 miod Exp $ +# $OpenBSD: GENERIC,v 1.471 2006/02/20 00:48:10 marco Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -67,6 +67,7 @@ option ACPIVERBOSE #hpet* at acpi? #acpiac* at acpi? #acpibat* at acpi? +#acpibtn* at acpi? option PCIVERBOSE option EISAVERBOSE diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 06111abcad1..2ab7e9a01f8 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.36 2006/02/19 21:32:30 jordan Exp $ */ +/* $OpenBSD: acpi.c,v 1.37 2006/02/20 00:48:10 marco Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -527,10 +527,8 @@ acpi_foundhid(struct aml_node *node, void *arg) aaa.aaa_memt = sc->sc_memt; aaa.aaa_node = node->parent; config_found(self, &aaa, acpi_print); - } else if (!strcmp(dev, ACPI_DEV_LD) || - !strcmp(dev, ACPI_DEV_PBD) || - !strcmp(dev, ACPI_DEV_SBD)) { -#if 0 + } else if (!strcmp(dev, ACPI_DEV_LD) || !strcmp(dev, ACPI_DEV_PBD) || + !strcmp(dev, ACPI_DEV_SBD)) { struct acpi_attach_args aaa; memset(&aaa, 0, sizeof(aaa)); @@ -539,7 +537,6 @@ acpi_foundhid(struct aml_node *node, void *arg) aaa.aaa_memt = sc->sc_memt; aaa.aaa_node = node->parent; config_found(self, &aaa, acpi_print); -#endif } } diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c new file mode 100644 index 00000000000..cbd4895c3f6 --- /dev/null +++ b/sys/dev/acpi/acpibtn.c @@ -0,0 +1,154 @@ +/* $OpenBSD: acpibtn.c,v 1.1 2006/02/20 00:48:10 marco Exp $ */ +/* + * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/malloc.h> + +#include <machine/bus.h> + +#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> + +#include <sys/sensors.h> + +int acpibtn_match(struct device *, void *, void *); +void acpibtn_attach(struct device *, struct device *, void *); +int acpibtn_notify(struct aml_node *, int, void *); + +struct acpibtn_softc { + struct device sc_dev; + + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + + struct acpi_softc *sc_acpi; + struct aml_node *sc_devnode; + + int sc_pwr_btn; + int sc_lid_btn; + int sc_sleep_btn; +#if 0 + struct sensor sens[3]; /* XXX debug only */ +#endif +}; + + +#if 0 +void acpibtn_refresh(void *); +#endif +int acpibtn_getsta(struct acpibtn_softc *); + +struct cfattach acpibtn_ca = { + sizeof(struct acpibtn_softc), acpibtn_match, acpibtn_attach +}; + +struct cfdriver acpibtn_cd = { + NULL, "acpibtn", DV_DULL +}; + +int +acpibtn_match(struct device *parent, void *match, void *aux) +{ + struct acpi_attach_args *aa = aux; + struct cfdata *cf = match; + + /* sanity */ + if (aa->aaa_name == NULL || + strcmp(aa->aaa_name, cf->cf_driver->cd_name) != 0 || + aa->aaa_table != NULL) + return (0); + + return (1); +} + +void +acpibtn_attach(struct device *parent, struct device *self, void *aux) +{ + struct acpibtn_softc *sc = (struct acpibtn_softc *)self; + struct acpi_attach_args *aa = aux; + + sc->sc_acpi = (struct acpi_softc *)parent; + sc->sc_devnode = aa->aaa_node->child; + + acpibtn_getsta(sc); + + /* XXX print which buttons are available and state */ + printf("\n"); + + aml_register_notify(sc->sc_devnode->parent, acpibtn_notify, sc); + + /* XXX: fixme */ + sc->sc_acpi->sc_pbtndev = sc->sc_devnode; + sc->sc_acpi->sc_sbtndev = sc->sc_devnode; +#if 0 + strlcpy(sc->sens[0].device, DEVNAME(sc), sizeof(sc->sens[0].device)); + strlcpy(sc->sens[0].desc, "power supply", sizeof(sc->sens[2].desc)); + sc->sens[0].type = SENSOR_INDICATOR; + sensor_add(&sc->sens[0]); + sc->sens[0].value = sc->sc_ac_stat; + + if (sensor_task_register(sc, acpibtn_refresh, 10)) + printf(", unable to register update task\n"); +#endif +} + +#if 0 +/* XXX this is for debug only, remove later */ +void +acpibtn_refresh(void *arg) +{ + struct acpibtn_softc *sc = arg; + + acpibtn_getsta(sc); + + sc->sens[0].value = sc->sc_ac_stat; +} +#endif + +int +acpibtn_getsta(struct acpibtn_softc *sc) +{ + struct aml_value res, env; + struct acpi_context *ctx; + + memset(&res, 0, sizeof(res)); + memset(&env, 0, sizeof(env)); + + ctx = NULL; + if (aml_eval_name(sc->sc_acpi, sc->sc_devnode, "_STA", &res, &env)) { + dnprintf(10, "%s: no _STA\n", + DEVNAME(sc)); + /* XXX this should fall through */ + return (1); + } + + return (0); +} + +int +acpibtn_notify(struct aml_node *node, int notify_type, void *arg) +{ + struct acpibtn_softc *sc = arg; + + printf("acpibtn_notify: %.2x %s\n", notify_type, sc->sc_devnode->name); + return (0); +} diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi index d112ce0f6fe..357d7981c90 100644 --- a/sys/dev/acpi/files.acpi +++ b/sys/dev/acpi/files.acpi @@ -1,4 +1,4 @@ -# $OpenBSD: files.acpi,v 1.6 2005/12/16 00:08:53 jordan Exp $ +# $OpenBSD: files.acpi,v 1.7 2006/02/20 00:48:10 marco Exp $ # # Config file and device description for machine-independent ACPI code. # Included by ports that need it. @@ -25,6 +25,11 @@ device acpibat attach acpibat at acpi file dev/acpi/acpibat.c acpibat +# button device +device acpibtn +attach acpibtn at acpi +file dev/acpi/acpibtn.c acpibtn + # High Precision Event Timer device hpet attach hpet at acpi |