^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define EXPORT_ACPI_INTERFACES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define _COMPONENT ACPI_EVENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ACPI_MODULE_NAME("evxfgpe")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * FUNCTION: acpi_update_all_gpes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * PARAMETERS: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * associated _Lxx or _Exx methods and are not pointed to by any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * device _PRW methods (this indicates that these GPEs are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * generally intended for system or device wakeup. Such GPEs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * have to be enabled directly when the devices whose _PRW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * methods point to them are set up for wakeup signaling.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * NOTE: Should be called after any GPEs are added to the system. Primarily,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * after the system _PRW methods have been run, but also after a GPE Block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * Device has been added or if any new GPE methods have been added via a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * dynamic table load.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) acpi_status acpi_update_all_gpes(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u8 is_polling_needed = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ACPI_FUNCTION_TRACE(acpi_update_all_gpes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (acpi_gbl_all_gpes_initialized) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) status = acpi_ev_walk_gpe_list(acpi_ev_initialize_gpe_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) &is_polling_needed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) acpi_gbl_all_gpes_initialized = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) if (is_polling_needed && acpi_gbl_all_gpes_initialized) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* Poll GPEs to handle already triggered events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) acpi_ev_gpe_detect(acpi_gbl_gpe_xrupt_list_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ACPI_EXPORT_SYMBOL(acpi_update_all_gpes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * FUNCTION: acpi_enable_gpe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * hardware-enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) acpi_status status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) ACPI_FUNCTION_TRACE(acpi_enable_gpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * Ensure that we have a valid GPE number and that there is some way
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * of handling the GPE (handler or a GPE method). In other words, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * won't allow a valid GPE to be enabled if there is no way to handle it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) if (gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ACPI_GPE_DISPATCH_NONE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) status = acpi_ev_add_gpe_reference(gpe_event_info, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) if (ACPI_SUCCESS(status) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ACPI_GPE_IS_POLLING_NEEDED(gpe_event_info)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /* Poll edge-triggered GPEs to handle existing events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) (void)acpi_ev_detect_gpe(gpe_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) gpe_event_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) status = AE_NO_HANDLER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * FUNCTION: acpi_disable_gpe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * DESCRIPTION: Remove a reference to a GPE. When the last reference is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * removed, only then is the GPE disabled (for runtime GPEs), or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * the GPE mask bit disabled (for wake GPEs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) acpi_status status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ACPI_FUNCTION_TRACE(acpi_disable_gpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /* Ensure that we have a valid GPE number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) status = acpi_ev_remove_gpe_reference(gpe_event_info) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * FUNCTION: acpi_set_gpe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * the reference count mechanism used in the acpi_enable_gpe(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * acpi_disable_gpe() interfaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * This API is typically used by the GPE raw handler mode driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * to switch between the polling mode and the interrupt mode after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * the driver has enabled the GPE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * The APIs should be invoked in this order:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * acpi_enable_gpe() <- Ensure the reference count > 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * acpi_set_gpe(ACPI_GPE_DISABLE) <- Enter polling mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * acpi_set_gpe(ACPI_GPE_ENABLE) <- Leave polling mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * acpi_disable_gpe() <- Decrease the reference count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * Note: If a GPE is shared by 2 silicon components, then both the drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * should support GPE polling mode or disabling the GPE for long period
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * for one driver may break the other. So use it with care since all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * firmware _Lxx/_Exx handlers currently rely on the GPE interrupt mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) acpi_status acpi_set_gpe(acpi_handle gpe_device, u32 gpe_number, u8 action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) ACPI_FUNCTION_TRACE(acpi_set_gpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /* Ensure that we have a valid GPE number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if (!gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /* Perform the action */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) switch (action) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) case ACPI_GPE_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) gpe_event_info->disable_for_dispatch = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) case ACPI_GPE_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) gpe_event_info->disable_for_dispatch = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) ACPI_EXPORT_SYMBOL(acpi_set_gpe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * FUNCTION: acpi_mask_gpe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * is_masked - Whether the GPE is masked or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * DESCRIPTION: Unconditionally mask/unmask the an individual GPE, ex., to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * prevent a GPE flooding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) acpi_status acpi_mask_gpe(acpi_handle gpe_device, u32 gpe_number, u8 is_masked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ACPI_FUNCTION_TRACE(acpi_mask_gpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) /* Ensure that we have a valid GPE number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (!gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) status = acpi_ev_mask_gpe(gpe_event_info, is_masked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) ACPI_EXPORT_SYMBOL(acpi_mask_gpe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * FUNCTION: acpi_mark_gpe_for_wake
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * sets the ACPI_GPE_CAN_WAKE flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) * Some potential callers of acpi_setup_gpe_for_wake may know in advance that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * there won't be any notify handlers installed for device wake notifications
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * from the given GPE (one example is a button GPE in Linux). For these cases,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * acpi_mark_gpe_for_wake should be used instead of acpi_setup_gpe_for_wake.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * setup implicit wake notification for it (since there's no handler method).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) acpi_status acpi_mark_gpe_for_wake(acpi_handle gpe_device, u32 gpe_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) acpi_status status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) ACPI_FUNCTION_TRACE(acpi_mark_gpe_for_wake);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) /* Ensure that we have a valid GPE number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) if (gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) /* Mark the GPE as a possible wake event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) ACPI_EXPORT_SYMBOL(acpi_mark_gpe_for_wake)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * FUNCTION: acpi_setup_gpe_for_wake
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * PARAMETERS: wake_device - Device associated with the GPE (via _PRW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) * gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * interface is intended to be used as the host executes the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * _PRW methods (Power Resources for Wake) in the system tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * Each _PRW appears under a Device Object (The wake_device), and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * contains the info for the wake GPE associated with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * wake_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) acpi_setup_gpe_for_wake(acpi_handle wake_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) acpi_handle gpe_device, u32 gpe_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) struct acpi_namespace_node *device_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) struct acpi_gpe_notify_info *notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) struct acpi_gpe_notify_info *new_notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) ACPI_FUNCTION_TRACE(acpi_setup_gpe_for_wake);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) /* Parameter Validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) if (!wake_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) * By forcing wake_device to be valid, we automatically enable the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) * implicit notify feature on all hosts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /* Handle root object case */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) if (wake_device == ACPI_ROOT_OBJECT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) device_node = acpi_gbl_root_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) device_node =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) ACPI_CAST_PTR(struct acpi_namespace_node, wake_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) /* Validate wake_device is of type Device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) if (device_node->type != ACPI_TYPE_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) return_ACPI_STATUS (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) * Allocate a new notify object up front, in case it is needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) * Memory allocation while holding a spinlock is a big no-no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * on some hosts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) new_notify = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_notify_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) if (!new_notify) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) /* Ensure that we have a valid GPE number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (!gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * If there is no method or handler for this GPE, then the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) * wake_device will be notified whenever this GPE fires. This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * known as an "implicit notify". Note: The GPE is assumed to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) * level-triggered (for windows compatibility).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) ACPI_GPE_DISPATCH_NONE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) * This is the first device for implicit notify on this GPE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) * Just set the flags here, and enter the NOTIFY block below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) gpe_event_info->flags =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) } else if (gpe_event_info->flags & ACPI_GPE_AUTO_ENABLED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) * A reference to this GPE has been added during the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * initialization, so drop it now to prevent the GPE from being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * permanently enabled and clear its ACPI_GPE_AUTO_ENABLED flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) (void)acpi_ev_remove_gpe_reference(gpe_event_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) gpe_event_info->flags &= ~ACPI_GPE_AUTO_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) * If we already have an implicit notify on this GPE, add
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) * this device to the notify list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) ACPI_GPE_DISPATCH_NOTIFY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) /* Ensure that the device is not already in the list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) notify = gpe_event_info->dispatch.notify_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) while (notify) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) if (notify->device_node == device_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) status = AE_ALREADY_EXISTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) notify = notify->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /* Add this device to the notify list for this GPE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) new_notify->device_node = device_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) new_notify->next = gpe_event_info->dispatch.notify_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) gpe_event_info->dispatch.notify_list = new_notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) new_notify = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) /* Mark the GPE as a possible wake event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) /* Delete the notify object if it was not used above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) if (new_notify) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) ACPI_FREE(new_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) ACPI_EXPORT_SYMBOL(acpi_setup_gpe_for_wake)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * FUNCTION: acpi_set_gpe_wake_mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) * action - Enable or Disable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * already be marked as a WAKE GPE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) struct acpi_gpe_register_info *gpe_register_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) u32 register_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) ACPI_FUNCTION_TRACE(acpi_set_gpe_wake_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) * Ensure that we have a valid GPE number and that this GPE is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * fact a wake GPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) if (!gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) gpe_register_info = gpe_event_info->register_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) if (!gpe_register_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) status = AE_NOT_EXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) /* Perform the action */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) switch (action) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) case ACPI_GPE_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) ACPI_SET_BIT(gpe_register_info->enable_for_wake,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) (u8)register_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) case ACPI_GPE_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) (u8)register_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) ACPI_ERROR((AE_INFO, "%u, Invalid action", action));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) ACPI_EXPORT_SYMBOL(acpi_set_gpe_wake_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) * FUNCTION: acpi_clear_gpe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) * DESCRIPTION: Clear an ACPI event (general purpose)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) ACPI_FUNCTION_TRACE(acpi_clear_gpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) /* Ensure that we have a valid GPE number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) if (!gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) status = acpi_hw_clear_gpe(gpe_event_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) * FUNCTION: acpi_get_gpe_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) * event_status - Where the current status of the event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) * will be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) acpi_get_gpe_status(acpi_handle gpe_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) u32 gpe_number, acpi_event_status *event_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) ACPI_FUNCTION_TRACE(acpi_get_gpe_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) /* Ensure that we have a valid GPE number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) if (!gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) /* Obtain status on the requested GPE number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) * FUNCTION: acpi_gispatch_gpe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) * DESCRIPTION: Detect and dispatch a General Purpose Event to either a function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) * (e.g. EC) or method (e.g. _Lxx/_Exx) handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) u32 acpi_dispatch_gpe(acpi_handle gpe_device, u32 gpe_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) ACPI_FUNCTION_TRACE(acpi_dispatch_gpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) return acpi_ev_detect_gpe(gpe_device, NULL, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) ACPI_EXPORT_SYMBOL(acpi_dispatch_gpe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) * FUNCTION: acpi_finish_gpe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) * PARAMETERS: gpe_device - Namespace node for the GPE Block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) * (NULL for FADT defined GPEs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) * gpe_number - GPE level within the GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) * DESCRIPTION: Clear and conditionally re-enable a GPE. This completes the GPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) * processing. Intended for use by asynchronous host-installed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) * GPE handlers. The GPE is only re-enabled if the enable_for_run bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) * is set in the GPE info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) acpi_status acpi_finish_gpe(acpi_handle gpe_device, u32 gpe_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) ACPI_FUNCTION_TRACE(acpi_finish_gpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) /* Ensure that we have a valid GPE number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) if (!gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) status = acpi_ev_finish_gpe(gpe_event_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) ACPI_EXPORT_SYMBOL(acpi_finish_gpe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) * FUNCTION: acpi_disable_all_gpes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) * PARAMETERS: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) acpi_status acpi_disable_all_gpes(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) ACPI_FUNCTION_TRACE(acpi_disable_all_gpes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) status = acpi_hw_disable_all_gpes();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) ACPI_EXPORT_SYMBOL(acpi_disable_all_gpes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) * FUNCTION: acpi_enable_all_runtime_gpes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) * PARAMETERS: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) acpi_status acpi_enable_all_runtime_gpes(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) status = acpi_hw_enable_all_runtime_gpes();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) ACPI_EXPORT_SYMBOL(acpi_enable_all_runtime_gpes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) * FUNCTION: acpi_enable_all_wakeup_gpes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) * PARAMETERS: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) * DESCRIPTION: Enable all "wakeup" GPEs and disable all of the other GPEs, in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) * all GPE blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) acpi_status acpi_enable_all_wakeup_gpes(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) ACPI_FUNCTION_TRACE(acpi_enable_all_wakeup_gpes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) status = acpi_hw_enable_all_wakeup_gpes();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) ACPI_EXPORT_SYMBOL(acpi_enable_all_wakeup_gpes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) * FUNCTION: acpi_any_gpe_status_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) * PARAMETERS: gpe_skip_number - Number of the GPE to skip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) * RETURN: Whether or not the status bit is set for any GPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) * DESCRIPTION: Check the status bits of all enabled GPEs, except for the one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) * represented by the "skip" argument, and return TRUE if any of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) * them is set or FALSE otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) u32 acpi_any_gpe_status_set(u32 gpe_skip_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) acpi_handle gpe_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) u8 ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) ACPI_FUNCTION_TRACE(acpi_any_gpe_status_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) return (FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) status = acpi_get_gpe_device(gpe_skip_number, &gpe_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) gpe_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) ret = acpi_hw_check_all_gpes(gpe_device, gpe_skip_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) return (ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) ACPI_EXPORT_SYMBOL(acpi_any_gpe_status_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) * FUNCTION: acpi_install_gpe_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) * gpe_block_address - Address and space_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) * register_count - Number of GPE register pairs in the block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) * interrupt_number - H/W interrupt for the block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) * enabled here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) acpi_install_gpe_block(acpi_handle gpe_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) struct acpi_generic_address *gpe_block_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) u32 register_count, u32 interrupt_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) struct acpi_gpe_block_info *gpe_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) ACPI_FUNCTION_TRACE(acpi_install_gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) node = acpi_ns_validate_handle(gpe_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) /* Validate the parent device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) if (node->type != ACPI_TYPE_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) if (node->object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) status = AE_ALREADY_EXISTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) * For user-installed GPE Block Devices, the gpe_block_base_number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) * is always zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) status = acpi_ev_create_gpe_block(node, gpe_block_address->address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) gpe_block_address->space_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) register_count, 0, interrupt_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) &gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) /* Install block in the device_object attached to the node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) obj_desc = acpi_ns_get_attached_object(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) * No object, create a new one (Device nodes do not always have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) * an attached object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) /* Remove local reference to the object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) acpi_ut_remove_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) /* Now install the GPE block in the device_object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) obj_desc->device.gpe_block = gpe_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) ACPI_EXPORT_SYMBOL(acpi_install_gpe_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) * FUNCTION: acpi_remove_gpe_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) * DESCRIPTION: Remove a previously installed block of GPE registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) ACPI_FUNCTION_TRACE(acpi_remove_gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) if (!gpe_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) node = acpi_ns_validate_handle(gpe_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) /* Validate the parent device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) if (node->type != ACPI_TYPE_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) /* Get the device_object attached to the node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) obj_desc = acpi_ns_get_attached_object(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) if (!obj_desc || !obj_desc->device.gpe_block) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) return_ACPI_STATUS(AE_NULL_OBJECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) /* Delete the GPE block (but not the device_object) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) obj_desc->device.gpe_block = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) * FUNCTION: acpi_get_gpe_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) * PARAMETERS: index - System GPE index (0-current_gpe_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) * gpe_device - Where the parent GPE Device is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) * gpe device indicates that the gpe number is contained in one of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) * the FADT-defined gpe blocks. Otherwise, the GPE block device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) acpi_status acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) struct acpi_gpe_device_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) ACPI_FUNCTION_TRACE(acpi_get_gpe_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) if (!gpe_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) if (index >= acpi_current_gpe_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) return_ACPI_STATUS(AE_NOT_EXIST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) /* Setup and walk the GPE list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) info.index = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) info.status = AE_NOT_EXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) info.gpe_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) info.next_block_base_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) status = acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device, &info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) *gpe_device = ACPI_CAST_PTR(acpi_handle, info.gpe_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) return_ACPI_STATUS(info.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) #endif /* !ACPI_REDUCED_HARDWARE */