diff options
author | Gordon Willem Klok <gwk@cvs.openbsd.org> | 2006-04-11 02:28:11 +0000 |
---|---|---|
committer | Gordon Willem Klok <gwk@cvs.openbsd.org> | 2006-04-11 02:28:11 +0000 |
commit | 7a1e6e2ecdeadbb20c6dda6a5840cf5822200190 (patch) | |
tree | 071195facd293a3158c9b21b01f23c2fa495a24b | |
parent | 6748bf3f1d552fd22e660a6d3ca52d46f0f87f84 (diff) |
Discover some ACPI sleep related methods, and call them at the
appropriate time in acpi_enter_sleep_state().
ok marco@
-rw-r--r-- | sys/dev/acpi/acpi.c | 55 | ||||
-rw-r--r-- | sys/dev/acpi/acpivar.h | 10 |
2 files changed, 62 insertions, 3 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 9739b91b6ea..4276662b654 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.45 2006/02/26 04:39:09 marco Exp $ */ +/* $OpenBSD: acpi.c,v 1.46 2006/04/11 02:28:10 gwk Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -67,6 +67,7 @@ void acpi_load_dsdt(paddr_t, struct acpi_q **); void acpi_init_states(struct acpi_softc *); void acpi_init_gpes(struct acpi_softc *); +void acpi_init_pm(struct acpi_softc *); void acpi_filtdetach(struct knote *); int acpi_filtread(struct knote *, long); @@ -650,6 +651,9 @@ acpi_attach(struct device *parent, struct device *self, void *aux) /* Initialize GPE handlers */ acpi_init_gpes(sc); + /* Find available sleep/resume related methods. */ + acpi_init_pm(sc); + /* * Set up a pointer to the firmware control structure */ @@ -1005,9 +1009,20 @@ acpi_init_states(struct acpi_softc *sc) } void +acpi_init_pm(struct acpi_softc *sc) +{ + sc->sc_tts = aml_searchname(aml_root.child, "_TTS"); + sc->sc_pts = aml_searchname(aml_root.child, "_PTS"); + sc->sc_wak = aml_searchname(aml_root.child, "_WAK"); + sc->sc_bfs = aml_searchname(aml_root.child, "_BFS"); + sc->sc_gts = aml_searchname(aml_root.child, "_GTS"); +} + +void acpi_enter_sleep_state(struct acpi_softc *sc, int state) { #ifdef ACPI_ENABLE + struct aml_value res, env; u_int16_t rega, regb; int retries; @@ -1020,6 +1035,44 @@ acpi_enter_sleep_state(struct acpi_softc *sc, int state) return; } + env.type = AML_OBJTYPE_INTEGER; + env.v_integer = state; + /* _TTS(state) */ + if (sc->sc_tts) { + if (aml_eval_object(sc, sc->sc_tts, &res, 1, &env)) { + dnprintf(10, "%s evaluating method _TTS failed.\n", + DEVNAME(sc)); + return; + } + } + switch (state) { + case ACPI_STATE_S1: + case ACPI_STATE_S2: + resettodr(); + dopowerhooks(PWR_SUSPEND); + break; + case ACPI_STATE_S3: + resettodr(); + dopowerhooks(PWR_STANDBY); + break; + } + /* _PTS(state) */ + if (sc->sc_pts) { + if (aml_eval_object(sc, sc->sc_pts, &res, 1, &env)) { + dnprintf(10, "%s evaluating method _PTS failed.\n", + DEVNAME(sc)); + return; + } + } + sc->sc_state = state; + /* _GTS(state) */ + if (sc->sc_gts) { + if (aml_eval_object(sc, sc->sc_gts, &res, 1, &env)) { + dnprintf(10, "%s evaluating method _GTS failed.\n", + DEVNAME(sc)); + return; + } + } disable_intr(); /* Clear WAK_STS bit */ diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index e60369979ea..53c4c1ed244 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.20 2006/02/22 19:29:24 jordan Exp $ */ +/* $OpenBSD: acpivar.h,v 1.21 2006/04/11 02:28:10 gwk Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -148,7 +148,13 @@ struct acpi_softc { u_int32_t sc_gpe_sts; u_int32_t sc_gpe_en; struct acpi_thread *sc_thread; - + + struct aml_node *sc_tts; + struct aml_node *sc_pts; + struct aml_node *sc_bfs; + struct aml_node *sc_gts; + struct aml_node *sc_wak; + int sc_state; }; #define GPE_NONE 0x00 |