Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/acpi_support/acpi_panasonic.c
| Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
| /* Prototype for HKEY functions for getting/setting a value. */ | /* Prototype for HKEY functions for getting/setting a value. */ | ||||
| typedef int hkey_fn_t(ACPI_HANDLE, int, UINT32 *); | typedef int hkey_fn_t(ACPI_HANDLE, int, UINT32 *); | ||||
| static int acpi_panasonic_probe(device_t dev); | static int acpi_panasonic_probe(device_t dev); | ||||
| static int acpi_panasonic_attach(device_t dev); | static int acpi_panasonic_attach(device_t dev); | ||||
| static int acpi_panasonic_detach(device_t dev); | static int acpi_panasonic_detach(device_t dev); | ||||
| static int acpi_panasonic_shutdown(device_t dev); | static int acpi_panasonic_shutdown(device_t dev); | ||||
| static int acpi_panasonic_resume(device_t dev); | |||||
| static void acpi_panasonic_clear_rfkill(device_t dev); | |||||
| static int acpi_panasonic_sysctl(SYSCTL_HANDLER_ARGS); | static int acpi_panasonic_sysctl(SYSCTL_HANDLER_ARGS); | ||||
| static UINT64 acpi_panasonic_sinf(ACPI_HANDLE h, UINT64 index); | static UINT64 acpi_panasonic_sinf(ACPI_HANDLE h, UINT64 index); | ||||
| static void acpi_panasonic_sset(ACPI_HANDLE h, UINT64 index, | static void acpi_panasonic_sset(ACPI_HANDLE h, UINT64 index, | ||||
| UINT64 val); | UINT64 val); | ||||
| static int acpi_panasonic_hkey_event(struct acpi_panasonic_softc *sc, | static int acpi_panasonic_hkey_event(struct acpi_panasonic_softc *sc, | ||||
| ACPI_HANDLE h, UINT32 *arg); | ACPI_HANDLE h, UINT32 *arg); | ||||
| static void acpi_panasonic_hkey_action(struct acpi_panasonic_softc *sc, | static void acpi_panasonic_hkey_action(struct acpi_panasonic_softc *sc, | ||||
| ACPI_HANDLE h, UINT32 key); | ACPI_HANDLE h, UINT32 key); | ||||
| Show All 20 Lines | static struct { | ||||
| {NULL, NULL} | {NULL, NULL} | ||||
| }; | }; | ||||
| static device_method_t acpi_panasonic_methods[] = { | static device_method_t acpi_panasonic_methods[] = { | ||||
| DEVMETHOD(device_probe, acpi_panasonic_probe), | DEVMETHOD(device_probe, acpi_panasonic_probe), | ||||
| DEVMETHOD(device_attach, acpi_panasonic_attach), | DEVMETHOD(device_attach, acpi_panasonic_attach), | ||||
| DEVMETHOD(device_detach, acpi_panasonic_detach), | DEVMETHOD(device_detach, acpi_panasonic_detach), | ||||
| DEVMETHOD(device_shutdown, acpi_panasonic_shutdown), | DEVMETHOD(device_shutdown, acpi_panasonic_shutdown), | ||||
| DEVMETHOD(device_resume, acpi_panasonic_resume), | |||||
| DEVMETHOD_END | DEVMETHOD_END | ||||
| }; | }; | ||||
| static driver_t acpi_panasonic_driver = { | static driver_t acpi_panasonic_driver = { | ||||
| "acpi_panasonic", | "acpi_panasonic", | ||||
| acpi_panasonic_methods, | acpi_panasonic_methods, | ||||
| sizeof(struct acpi_panasonic_softc), | sizeof(struct acpi_panasonic_softc), | ||||
| Show All 40 Lines | acpi_panasonic_attach(device_t dev) | ||||
| for (i = 0; sysctl_table[i].name != NULL; i++) { | for (i = 0; sysctl_table[i].name != NULL; i++) { | ||||
| SYSCTL_ADD_PROC(&sc->sysctl_ctx, | SYSCTL_ADD_PROC(&sc->sysctl_ctx, | ||||
| SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, | SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, | ||||
| sysctl_table[i].name, | sysctl_table[i].name, | ||||
| CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY | | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY | | ||||
| CTLFLAG_MPSAFE, sc, i, acpi_panasonic_sysctl, "I", ""); | CTLFLAG_MPSAFE, sc, i, acpi_panasonic_sysctl, "I", ""); | ||||
| } | } | ||||
| acpi_panasonic_clear_rfkill(dev); | |||||
adrian: maybe mention the model(s) in question in the comments here? | |||||
| #if 0 | #if 0 | ||||
| /* Activate hotkeys */ | /* Activate hotkeys */ | ||||
| status = AcpiEvaluateObject(sc->handle, "", NULL, NULL); | status = AcpiEvaluateObject(sc->handle, "", NULL, NULL); | ||||
| if (ACPI_FAILURE(status)) { | if (ACPI_FAILURE(status)) { | ||||
| device_printf(dev, "enable FN keys failed\n"); | device_printf(dev, "enable FN keys failed\n"); | ||||
| sysctl_ctx_free(&sc->sysctl_ctx); | sysctl_ctx_free(&sc->sysctl_ctx); | ||||
| return (ENXIO); | return (ENXIO); | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* Handle notifies */ | /* Handle notifies */ | ||||
| status = AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, | status = AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, | ||||
| acpi_panasonic_notify, sc); | acpi_panasonic_notify, sc); | ||||
| if (ACPI_FAILURE(status)) { | if (ACPI_FAILURE(status)) { | ||||
Not Done Inline Actionswe might as well just make this a function, since calling WLSW.SHRF is exactly the same in attach and resume obiwac: we might as well just make this a function, since calling WLSW.SHRF is exactly the same in… | |||||
Done Inline ActionsSure! This is duplicated because i still need to know if this approach is correct. I fixed first time the shutdown issue, then realized it happened on suspend too. Ctrl+v :) seuros: Sure!
This is duplicated because i still need to know if this approach is correct.
I fixed… | |||||
| device_printf(dev, "couldn't install notify handler - %s\n", | device_printf(dev, "couldn't install notify handler - %s\n", | ||||
| AcpiFormatException(status)); | AcpiFormatException(status)); | ||||
| sysctl_ctx_free(&sc->sysctl_ctx); | sysctl_ctx_free(&sc->sysctl_ctx); | ||||
| return (ENXIO); | return (ENXIO); | ||||
| } | } | ||||
| /* Install power profile event handler */ | /* Install power profile event handler */ | ||||
| sc->power_evh = EVENTHANDLER_REGISTER(power_profile_change, | sc->power_evh = EVENTHANDLER_REGISTER(power_profile_change, | ||||
| Show All 28 Lines | acpi_panasonic_shutdown(device_t dev) | ||||
| struct acpi_panasonic_softc *sc; | struct acpi_panasonic_softc *sc; | ||||
| int mute; | int mute; | ||||
| /* Mute the main audio during reboot to prevent static burst to speaker. */ | /* Mute the main audio during reboot to prevent static burst to speaker. */ | ||||
| sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
| mute = 1; | mute = 1; | ||||
| hkey_sound_mute(sc->handle, HKEY_SET, &mute); | hkey_sound_mute(sc->handle, HKEY_SET, &mute); | ||||
| return (0); | return (0); | ||||
| } | |||||
| static int | |||||
| acpi_panasonic_resume(device_t dev) | |||||
| { | |||||
| acpi_panasonic_clear_rfkill(dev); | |||||
| return (0); | |||||
| } | |||||
| static void | |||||
| acpi_panasonic_clear_rfkill(device_t dev) | |||||
| { | |||||
| ACPI_HANDLE wlsw_handle; | |||||
| ACPI_STATUS status; | |||||
| /* | |||||
| * Call WLSW.SHRF to clear wireless RF_KILL on models that have it. | |||||
| * On FZ-Y1 and similar models, the EC latches RF_KILL on shutdown | |||||
| * and suspend, causing the wireless card to boot with hard block | |||||
| * enabled. The SHRF method sets the EC state to deassert RF_KILL | |||||
| * GPIO on mini-PCIe pin 20 via SMI (ASRV call with function | |||||
| * 0x0F/0x03). | |||||
| */ | |||||
| status = AcpiGetHandle(NULL, "\\_SB.WLSW", &wlsw_handle); | |||||
| if (ACPI_SUCCESS(status)) { | |||||
| status = AcpiEvaluateObject(wlsw_handle, "SHRF", NULL, NULL); | |||||
| if (ACPI_FAILURE(status) && bootverbose) | |||||
| device_printf(dev, "WLSW.SHRF failed: %s\n", | |||||
| AcpiFormatException(status)); | |||||
| } | |||||
| } | } | ||||
| static int | static int | ||||
| acpi_panasonic_sysctl(SYSCTL_HANDLER_ARGS) | acpi_panasonic_sysctl(SYSCTL_HANDLER_ARGS) | ||||
| { | { | ||||
| struct acpi_panasonic_softc *sc; | struct acpi_panasonic_softc *sc; | ||||
| UINT32 arg; | UINT32 arg; | ||||
| int function, error; | int function, error; | ||||
| ▲ Show 20 Lines • Show All 277 Lines • Show Last 20 Lines | |||||
maybe mention the model(s) in question in the comments here?