diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/acpica/acpi.c | 15 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_acad.c | 27 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_battery.c | 6 | ||||
-rw-r--r-- | sys/dev/acpica/acpivar.h | 15 |
4 files changed, 54 insertions, 9 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 3522f23..60e20f9 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -300,8 +300,6 @@ acpi_attach(device_t dev) bzero(sc, sizeof(*sc)); sc->acpi_dev = dev; - acpi_install_wakeup_handler(sc); - #ifdef ENABLE_DEBUGGER if (debugpoint && !strcmp(debugpoint, "spaces")) acpi_EnterDebugger(); @@ -375,6 +373,12 @@ acpi_attach(device_t dev) SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, "lid_switch_state", CTLTYPE_STRING | CTLFLAG_RW, &sc->acpi_lid_switch_sx, 0, acpi_sleep_state_sysctl, "A", ""); + SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), + OID_AUTO, "standby_state", CTLTYPE_STRING | CTLFLAG_RW, + &sc->acpi_standby_sx, 0, acpi_sleep_state_sysctl, "A", ""); + SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), + OID_AUTO, "suspend_state", CTLTYPE_STRING | CTLFLAG_RW, + &sc->acpi_suspend_sx, 0, acpi_sleep_state_sysctl, "A", ""); /* * Dispatch the default sleep state to devices. @@ -383,6 +387,8 @@ acpi_attach(device_t dev) sc->acpi_power_button_sx = ACPI_POWER_BUTTON_DEFAULT_SX; sc->acpi_sleep_button_sx = ACPI_SLEEP_BUTTON_DEFAULT_SX; sc->acpi_lid_switch_sx = ACPI_LID_SWITCH_DEFAULT_SX; + sc->acpi_standby_sx = ACPI_STATE_S1; + sc->acpi_suspend_sx = ACPI_STATE_S3; acpi_enable_fixed_events(sc); @@ -425,6 +431,11 @@ acpi_attach(device_t dev) if (debugpoint && !strcmp(debugpoint, "running")) acpi_EnterDebugger(); #endif + + if ((error = acpi_machdep_init(dev))) { + goto out; + } + error = 0; out: diff --git a/sys/dev/acpica/acpi_acad.c b/sys/dev/acpica/acpi_acad.c index a20d3ee..5b4f751 100644 --- a/sys/dev/acpica/acpi_acad.c +++ b/sys/dev/acpica/acpi_acad.c @@ -207,18 +207,37 @@ acpi_acad_sysctl(SYSCTL_HANDLER_ARGS) { int val; int error; - device_t dev; + + if (acpi_acad_get_acline(&val)) { + return (ENXIO); + } + + val = *(u_int *)oidp->oid_arg1; + error = sysctl_handle_int(oidp, &val, 0, req); + return (error); +} + +/* + * Public interfaces. + */ + +int +acpi_acad_get_acline(int *status) +{ + device_t dev; struct acpi_acad_softc *sc; if ((dev = devclass_get_device(acpi_acad_devclass, 0)) == NULL) { return (ENXIO); } + if ((sc = device_get_softc(dev)) == NULL) { return (ENXIO); } + acpi_acad_get_status(dev); - val = *(u_int *)oidp->oid_arg1; - error = sysctl_handle_int(oidp, &val, 0, req); - return (error); + *status = sc->status; + + return (0); } diff --git a/sys/dev/acpica/acpi_battery.c b/sys/dev/acpica/acpi_battery.c index 9b59293..ac6134a 100644 --- a/sys/dev/acpica/acpi_battery.c +++ b/sys/dev/acpica/acpi_battery.c @@ -65,14 +65,14 @@ static int acpi_batteries_initted = 0; static int acpi_batteries_units = 0; static struct acpi_battinfo acpi_battery_battinfo; -static int +int acpi_battery_get_units(void) { return (acpi_batteries_units); } -static int +int acpi_battery_get_battdesc(int logical_unit, struct acpi_battdesc *battdesc) { int i; @@ -95,7 +95,7 @@ acpi_battery_get_battdesc(int logical_unit, struct acpi_battdesc *battdesc) return (ENXIO); } -static int +int acpi_battery_get_battinfo(int unit, struct acpi_battinfo *battinfo) { int error; diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 566afc4..2fc0f89 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -57,6 +57,9 @@ struct acpi_softc { int acpi_sleep_button_sx; int acpi_lid_switch_sx; + int acpi_standby_sx; + int acpi_suspend_sx; + bus_dma_tag_t acpi_waketag; bus_dmamap_t acpi_wakemap; vm_offset_t acpi_wakeaddr; @@ -303,6 +306,7 @@ extern char *acpi_name(ACPI_HANDLE handle); extern int acpi_avoid(ACPI_HANDLE handle); extern int acpi_disabled(char *subsys); +extern int acpi_machdep_init(device_t dev); extern void acpi_install_wakeup_handler(struct acpi_softc *sc); extern int acpi_sleep_machdep(struct acpi_softc *sc, int state); @@ -310,11 +314,22 @@ extern int acpi_sleep_machdep(struct acpi_softc *sc, int state); * Battery Abstruction. */ struct acpi_battinfo; +struct acpi_battdesc; extern int acpi_battery_register(int, int); +extern int acpi_battery_get_battinfo(int, struct acpi_battinfo *); +extern int acpi_battery_get_units(void); +extern int acpi_battery_get_battdesc(int, struct acpi_battdesc *); + extern int acpi_cmbat_get_battinfo(int, struct acpi_battinfo *); /* + * AC adapter interface. + */ + +extern int acpi_acad_get_acline(int *); + +/* * System power API. * * XXX should this be further generalised? |