-/* $OpenBSD: acpi.c,v 1.250 2013/12/23 10:48:43 kettenis Exp $ */
+/* $OpenBSD: acpi.c,v 1.251 2013/12/24 13:23:21 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
struct acpi_q *acpi_maptable(struct acpi_softc *, paddr_t, const char *,
const char *, const char *, int);
+int acpi_enable(struct acpi_softc *);
void acpi_init_states(struct acpi_softc *);
void acpi_gpe_task(void *, int);
struct acpi_rsdp *rsdp;
struct acpi_q *entry;
struct acpi_dsdt *p_dsdt;
- int idx;
#ifndef SMALL_KERNEL
int wakeup_dev_ct;
struct acpi_wakeq *wentry;
/*
* Check if we are able to enable ACPI control
*/
- if (!sc->sc_fadt->smi_cmd ||
+ if (sc->sc_fadt->smi_cmd &&
(!sc->sc_fadt->acpi_enable && !sc->sc_fadt->acpi_disable)) {
printf(", ACPI control unavailable\n");
return;
* This may prevent thermal control on some systems where
* that actually does work
*/
- acpi_write_pmreg(sc, ACPIREG_SMICMD, 0, sc->sc_fadt->acpi_enable);
- idx = 0;
- do {
- if (idx++ > ACPIEN_RETRIES) {
+ if (sc->sc_fadt->smi_cmd) {
+ if (acpi_enable(sc)) {
printf(", can't enable ACPI\n");
return;
}
- } while (!(acpi_read_pmreg(sc, ACPIREG_PM1_CNT, 0) & ACPI_PM1_SCI_EN));
+ }
printf("\n%s: tables", DEVNAME(sc));
SIMPLEQ_FOREACH(entry, &sc->sc_tables, q_next) {
}
}
+int
+acpi_enable(struct acpi_softc *sc)
+{
+ int idx;
+
+ acpi_write_pmreg(sc, ACPIREG_SMICMD, 0, sc->sc_fadt->acpi_enable);
+ idx = 0;
+ do {
+ if (idx++ > ACPIEN_RETRIES) {
+ return ETIMEDOUT;
+ }
+ } while (!(acpi_read_pmreg(sc, ACPIREG_PM1_CNT, 0) & ACPI_PM1_SCI_EN));
+
+ return 0;
+}
+
void
acpi_init_states(struct acpi_softc *sc)
{