diff options
author | 2020-11-15 18:04:10 +0000 | |
---|---|---|
committer | 2020-11-15 18:04:10 +0000 | |
commit | c399e7a9eaa9949052125186ac46a43e2b8352bd (patch) | |
tree | 7df18230418b50960455d7c6b89c2cfdb50fc8f7 | |
parent | Return the specific failure for a "self signed certificate" in the chain (diff) | |
download | wireguard-openbsd-c399e7a9eaa9949052125186ac46a43e2b8352bd.tar.xz wireguard-openbsd-c399e7a9eaa9949052125186ac46a43e2b8352bd.zip |
Add acpige(4), a driver for ACPI generic event devices. This is a rather
simple device that simply reacts to interrupts by invoking _EVT with the
interrupt number. This is used on the HoneyComb LX2K to implement power
button handling.
ok kettenis@
-rw-r--r-- | share/man/man4/Makefile | 4 | ||||
-rw-r--r-- | share/man/man4/acpige.4 | 42 | ||||
-rw-r--r-- | sys/dev/acpi/acpige.c | 128 | ||||
-rw-r--r-- | sys/dev/acpi/files.acpi | 7 |
4 files changed, 178 insertions, 3 deletions
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index d5ea5f7ba3a..bd5747c4c89 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile,v 1.786 2020/11/15 17:44:06 kettenis Exp $ +# $OpenBSD: Makefile,v 1.787 2020/11/15 18:04:10 patrick Exp $ MAN= aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \ acpi.4 acpiac.4 acpials.4 acpiasus.4 acpibat.4 \ acpibtn.4 acpicbkbd.4 acpicpu.4 acpidock.4 acpihve.4 acpiec.4 \ - acpihid.4 \ + acpige.4 acpihid.4 \ acpihpet.4 acpimadt.4 acpimcfg.4 acpipci.4 acpiprt.4 acpipwrres.4 \ acpisbs.4 acpisony.4 acpisurface.4 acpithinkpad.4 acpitoshiba.4 \ acpitimer.4 acpivideo.4 acpivout.4 acpitz.4 \ diff --git a/share/man/man4/acpige.4 b/share/man/man4/acpige.4 new file mode 100644 index 00000000000..98268b50ff7 --- /dev/null +++ b/share/man/man4/acpige.4 @@ -0,0 +1,42 @@ +.\" $OpenBSD: acpige.4,v 1.1 2020/11/15 18:04:10 patrick Exp $ +.\" +.\" Copyright (c) 2020 Patrick Wildt <patrick@blueri.se> +.\" +.\" 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. +.\" +.Dd $Mdocdate: November 15 2020 $ +.Dt ACPIGE 4 +.Os +.Sh NAME +.Nm acpige +.Nd ACPI generic event device +.Sh SYNOPSIS +.Cd "acpige* at acpi?" +.Sh DESCRIPTION +The +.Nm +driver reacts to external events and notifies the corresponding handler. +.Sh SEE ALSO +.Xr acpi 4 , +.Xr intro 4 +.Sh HISTORY +The +.Nm +driver first appeared in +.Ox 6.9 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Patrick Wildt Aq Mt patrick@blueri.se . diff --git a/sys/dev/acpi/acpige.c b/sys/dev/acpi/acpige.c new file mode 100644 index 00000000000..1606f1db55c --- /dev/null +++ b/sys/dev/acpi/acpige.c @@ -0,0 +1,128 @@ +/* $OpenBSD: acpige.c,v 1.1 2020/11/15 18:04:10 patrick Exp $ */ +/* + * Copyright (c) 2020 Patrick Wildt <patrick@blueri.se> + * + * 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/malloc.h> +#include <sys/systm.h> +#include <sys/tty.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> + +struct acpige_softc; +struct acpige_irq { + struct acpige_softc *ai_sc; + void *ai_ih; + uint32_t ai_irq; +}; + +struct acpige_softc { + struct device sc_dev; + struct acpi_softc *sc_acpi; + struct aml_node *sc_devnode; + struct acpige_irq *sc_irq; +}; + +int acpige_match(struct device *, void *, void *); +void acpige_attach(struct device *, struct device *, void *); + +int acpige_intr(void *); +void acpige_event_task(void *, int); + +struct cfattach acpige_ca = { + sizeof(struct acpige_softc), acpige_match, acpige_attach +}; + +struct cfdriver acpige_cd = { + NULL, "acpige", DV_DULL +}; + +const char *acpige_hids[] = { + "ACPI0013", + NULL +}; + +int +acpige_match(struct device *parent, void *match, void *aux) +{ + struct acpi_attach_args *aaa = aux; + struct cfdata *cf = match; + + return acpi_matchhids(aaa, acpige_hids, cf->cf_driver->cd_name); +} + +void +acpige_attach(struct device *parent, struct device *self, void *aux) +{ + struct acpige_softc *sc = (struct acpige_softc *)self; + struct acpi_attach_args *aaa = aux; + struct acpige_irq *ai; + int i; + + sc->sc_acpi = (struct acpi_softc *)parent; + sc->sc_devnode = aaa->aaa_node; + + if (aaa->aaa_nirq < 1) { + printf(": no interrupt\n"); + return; + } + + sc->sc_irq = mallocarray(aaa->aaa_nirq, sizeof(struct acpige_irq), + M_DEVBUF, M_WAITOK); + + for (i = 0; i < aaa->aaa_nirq; i++) { + printf("%s %d", i ? "," : " irq", aaa->aaa_irq[i]); + ai = &sc->sc_irq[i]; + ai->ai_sc = sc; + ai->ai_irq = aaa->aaa_irq[i]; + ai->ai_ih = acpi_intr_establish(aaa->aaa_irq[i], + aaa->aaa_irq_flags[i], IPL_BIO, acpige_intr, ai, + sc->sc_dev.dv_xname); + if (ai->ai_ih == NULL) { + printf(": can't establish interrupt\n"); + return; + } + } + + printf("\n"); +} + +int +acpige_intr(void *arg) +{ + struct acpige_irq *ai = arg; + struct acpige_softc *sc = ai->ai_sc; + + acpi_addtask(sc->sc_acpi, acpige_event_task, sc, ai->ai_irq); + acpi_wakeup(sc->sc_acpi); + return 1; +} + +void +acpige_event_task(void *arg0, int irq) +{ + struct acpige_softc *sc = arg0; + struct aml_value cmd; + + memset(&cmd, 0, sizeof cmd); + cmd.v_integer = irq; + cmd.type = AML_OBJTYPE_INTEGER; + aml_evalname(sc->sc_acpi, sc->sc_devnode, "_EVT", 1, &cmd, NULL); +} diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi index 1d14299b54f..0e6e8f02992 100644 --- a/sys/dev/acpi/files.acpi +++ b/sys/dev/acpi/files.acpi @@ -1,4 +1,4 @@ -# $OpenBSD: files.acpi,v 1.59 2020/11/15 16:47:12 kettenis Exp $ +# $OpenBSD: files.acpi,v 1.60 2020/11/15 18:04:10 patrick Exp $ # # Config file and device description for machine-independent ACPI code. # Included by ports that need it. @@ -50,6 +50,11 @@ device acpiec attach acpiec at acpi file dev/acpi/acpiec.c acpiec +# Generic Event +device acpige +attach acpige at acpi +file dev/acpi/acpige.c acpige + # Thermal Zone device acpitz attach acpitz at acpi |