diff options
-rw-r--r-- | sys/dev/acpi/acpi.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 80c6c014772..03123a378d8 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.217 2010/10/05 16:59:02 jordan Exp $ */ +/* $OpenBSD: acpi.c,v 1.218 2010/10/05 17:04:48 jordan Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -131,7 +131,8 @@ void acpi_susp_resume_gpewalk(struct acpi_softc *, int, int); int acpi_add_device(struct aml_node *node, void *arg); struct gpe_block *acpi_find_gpe(struct acpi_softc *, int); -void acpi_enable_onegpe(struct acpi_softc *, int, int); +void acpi_enable_onegpe(struct acpi_softc *, int); +void acpi_disable_onegpe(struct acpi_softc *, int); int acpi_gpe(struct acpi_softc *, int, void *); void acpi_disable_allgpes(struct acpi_softc *); @@ -1471,7 +1472,7 @@ acpi_add_device(struct aml_node *node, void *arg) } void -acpi_enable_onegpe(struct acpi_softc *sc, int gpe, int enable) +acpi_enable_onegpe(struct acpi_softc *sc, int gpe) { uint8_t mask, en; int s; @@ -1480,13 +1481,25 @@ acpi_enable_onegpe(struct acpi_softc *sc, int gpe, int enable) s = spltty(); mask = (1L << (gpe & 7)); en = acpi_read_pmreg(sc, ACPIREG_GPE_EN, gpe>>3); - dnprintf(50, "%sabling GPE %.2x (current: %sabled) %.2x\n", - enable ? "en" : "dis", gpe, (en & mask) ? "en" : "dis", en); - if (enable) - en |= mask; - else - en &= ~mask; - acpi_write_pmreg(sc, ACPIREG_GPE_EN, gpe>>3, en); + dnprintf(50, "enabling GPE %.2x (current: %sabled) %.2x\n", + gpe, (en & mask) ? "en" : "dis", en); + acpi_write_pmreg(sc, ACPIREG_GPE_EN, gpe>>3, en | mask); + splx(s); +} + +void +acpi_disable_onegpe(struct acpi_softc *sc, int gpe) +{ + uint8_t mask, en; + int s; + + /* Read enabled register */ + s = spltty(); + mask = (1L << (gpe & 7)); + en = acpi_read_pmreg(sc, ACPIREG_GPE_EN, gpe>>3); + dnprintf(50, "disabling GPE %.2x (current: %sabled) %.2x\n", + gpe, (en & mask) ? "en" : "dis", en); + acpi_write_pmreg(sc, ACPIREG_GPE_EN, gpe>>3, en & ~mask); splx(s); } @@ -1646,9 +1659,12 @@ acpi_susp_resume_gpewalk(struct acpi_softc *sc, int state, wentry->q_state, wentry->q_gpe); - if (state <= wentry->q_state) - acpi_enable_onegpe(sc, wentry->q_gpe, - wake_gpe_state); + if (state <= wentry->q_state) { + if (wake_gpe_state) + acpi_enable_onegpe(sc, wentry->q_gpe); + else + acpi_disable_onegpe(sc, wentry->q_gpe); + } } /* If we are resuming (disabling wake GPEs), enable other GPEs */ @@ -1656,7 +1672,7 @@ acpi_susp_resume_gpewalk(struct acpi_softc *sc, int state, if (wake_gpe_state == 0) { for (gpe = 0; gpe < sc->sc_lastgpe; gpe++) { if (sc->gpe_table[gpe].handler) - acpi_enable_onegpe(sc, gpe, 1); + acpi_enable_onegpe(sc, gpe); } } } @@ -2030,7 +2046,7 @@ acpi_thread(void *arg) /* Enable handled GPEs here */ for (gpe = 0; gpe < sc->sc_lastgpe; gpe++) { if (sc->gpe_table[gpe].handler) - acpi_enable_onegpe(sc, gpe, 1); + acpi_enable_onegpe(sc, gpe); } } |