Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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: evgpeblk - GPE block creation and initialization.
^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) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define _COMPONENT          ACPI_EVENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) ACPI_MODULE_NAME("evgpeblk")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #if (!ACPI_REDUCED_HARDWARE)	/* Entire module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 			  u32 interrupt_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * FUNCTION:    acpi_ev_install_gpe_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * PARAMETERS:  gpe_block               - New GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *              interrupt_number        - Xrupt to be associated with this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *                                        GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * DESCRIPTION: Install new GPE block with mutex support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 			  u32 interrupt_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	struct acpi_gpe_block_info *next_gpe_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct acpi_gpe_xrupt_info *gpe_xrupt_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	ACPI_FUNCTION_TRACE(ev_install_gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	    acpi_ev_get_gpe_xrupt_block(interrupt_number, &gpe_xrupt_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	/* Install the new block at the end of the list with lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	if (gpe_xrupt_block->gpe_block_list_head) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		next_gpe_block = gpe_xrupt_block->gpe_block_list_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		while (next_gpe_block->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			next_gpe_block = next_gpe_block->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		next_gpe_block->next = gpe_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		gpe_block->previous = next_gpe_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		gpe_xrupt_block->gpe_block_list_head = gpe_block;
^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) 	gpe_block->xrupt_block = gpe_xrupt_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  * FUNCTION:    acpi_ev_delete_gpe_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * PARAMETERS:  gpe_block           - Existing GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * DESCRIPTION: Remove a GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	acpi_cpu_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	ACPI_FUNCTION_TRACE(ev_install_gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	/* Disable all GPEs in this block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	    acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (!gpe_block->previous && !gpe_block->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		/* This is the last gpe_block on this interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		status = acpi_ev_delete_gpe_xrupt(gpe_block->xrupt_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		/* Remove the block on this interrupt with lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		if (gpe_block->previous) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			gpe_block->previous->next = gpe_block->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			gpe_block->xrupt_block->gpe_block_list_head =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			    gpe_block->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		if (gpe_block->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			gpe_block->next->previous = gpe_block->previous;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	acpi_current_gpe_count -= gpe_block->gpe_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	/* Free the gpe_block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	ACPI_FREE(gpe_block->register_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	ACPI_FREE(gpe_block->event_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	ACPI_FREE(gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * FUNCTION:    acpi_ev_create_gpe_info_blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * PARAMETERS:  gpe_block   - New GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * DESCRIPTION: Create the register_info and event_info blocks for this GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	struct acpi_gpe_register_info *gpe_register_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	struct acpi_gpe_event_info *gpe_event_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	struct acpi_gpe_event_info *this_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct acpi_gpe_register_info *this_register;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	u32 j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	ACPI_FUNCTION_TRACE(ev_create_gpe_info_blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	/* Allocate the GPE register information block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	gpe_register_info = ACPI_ALLOCATE_ZEROED((acpi_size)gpe_block->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 						 register_count *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 						 sizeof(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 							acpi_gpe_register_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	if (!gpe_register_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			    "Could not allocate the GpeRegisterInfo table"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	 * Allocate the GPE event_info block. There are eight distinct GPEs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	 * per register. Initialization to zeros is sufficient.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	gpe_event_info = ACPI_ALLOCATE_ZEROED((acpi_size)gpe_block->gpe_count *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 					      sizeof(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 						     acpi_gpe_event_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	if (!gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			    "Could not allocate the GpeEventInfo table"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	/* Save the new Info arrays in the GPE block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	gpe_block->register_info = gpe_register_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	gpe_block->event_info = gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	 * Initialize the GPE Register and Event structures. A goal of these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	 * tables is to hide the fact that there are two separate GPE register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	 * sets in a given GPE hardware block, the status registers occupy the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	 * first half, and the enable registers occupy the second half.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	this_register = gpe_register_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	this_event = gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	for (i = 0; i < gpe_block->register_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		/* Init the register_info for this GPE register (8 GPEs) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		this_register->base_gpe_number = (u16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		    (gpe_block->block_base_number +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		     (i * ACPI_GPE_REGISTER_WIDTH));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		this_register->status_address.address = gpe_block->address + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		this_register->enable_address.address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		    gpe_block->address + i + gpe_block->register_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		this_register->status_address.space_id = gpe_block->space_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		this_register->enable_address.space_id = gpe_block->space_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		/* Init the event_info for each GPE within this register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			this_event->gpe_number =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			    (u8) (this_register->base_gpe_number + j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			this_event->register_info = this_register;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			this_event++;
^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) 		/* Disable all GPEs within this register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		status = acpi_hw_gpe_write(0x00, &this_register->enable_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 			goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		/* Clear any pending GPE events within this register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		status = acpi_hw_gpe_write(0xFF, &this_register->status_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		this_register++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) error_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	if (gpe_register_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		ACPI_FREE(gpe_register_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	if (gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		ACPI_FREE(gpe_event_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^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)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  * FUNCTION:    acpi_ev_create_gpe_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  * PARAMETERS:  gpe_device          - Handle to the parent GPE block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  *              gpe_block_address   - Address and space_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  *              register_count      - Number of GPE register pairs in the block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  *              gpe_block_base_number - Starting GPE number for the block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  *              interrupt_number    - H/W interrupt for the block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)  *              return_gpe_block    - Where the new block descriptor is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)  * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)  *              the block are disabled at exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)  *              Note: Assumes namespace is locked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 			 u64 address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 			 u8 space_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 			 u32 register_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 			 u16 gpe_block_base_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 			 u32 interrupt_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 			 struct acpi_gpe_block_info **return_gpe_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	struct acpi_gpe_block_info *gpe_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	struct acpi_gpe_walk_info walk_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	ACPI_FUNCTION_TRACE(ev_create_gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	if (!register_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	/* Validate the space_ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	    (space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 			    "Unsupported address space: 0x%X", space_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		return_ACPI_STATUS(AE_SUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	if (space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		status = acpi_hw_validate_io_block(address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 						   ACPI_GPE_REGISTER_WIDTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 						   register_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		if (ACPI_FAILURE(status))
^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) 	/* Allocate a new GPE block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	gpe_block = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_block_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	if (!gpe_block) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	/* Initialize the new GPE block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	gpe_block->address = address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	gpe_block->space_id = space_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	gpe_block->node = gpe_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	gpe_block->gpe_count = (u16)(register_count * ACPI_GPE_REGISTER_WIDTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	gpe_block->initialized = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	gpe_block->register_count = register_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	gpe_block->block_base_number = gpe_block_base_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	 * Create the register_info and event_info sub-structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	 * Note: disables and clears all GPEs in the block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	status = acpi_ev_create_gpe_info_blocks(gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		ACPI_FREE(gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	/* Install the new block in the global lists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		ACPI_FREE(gpe_block->register_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		ACPI_FREE(gpe_block->event_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		ACPI_FREE(gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	acpi_gbl_all_gpes_initialized = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	/* Find all GPE methods (_Lxx or_Exx) for this block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	walk_info.gpe_block = gpe_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	walk_info.gpe_device = gpe_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	walk_info.execute_by_owner_id = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	(void)acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 				     ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 				     acpi_ev_match_gpe_method, NULL, &walk_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 				     NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	/* Return the new block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	if (return_gpe_block) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		(*return_gpe_block) = gpe_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 			      "    Initialized GPE %02X to %02X [%4.4s] %u regs on interrupt 0x%X%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 			      (u32)gpe_block->block_base_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 			      (u32)(gpe_block->block_base_number +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 				    (gpe_block->gpe_count - 1)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 			      gpe_device->name.ascii, gpe_block->register_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 			      interrupt_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 			      interrupt_number ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			      acpi_gbl_FADT.sci_interrupt ? " (SCI)" : ""));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	/* Update global count of currently available GPEs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	acpi_current_gpe_count += gpe_block->gpe_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  * FUNCTION:    acpi_ev_initialize_gpe_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)  * PARAMETERS:  acpi_gpe_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)  * DESCRIPTION: Initialize and enable a GPE block. Enable GPEs that have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)  *              associated methods.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)  *              Note: Assumes namespace is locked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			     struct acpi_gpe_block_info *gpe_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 			     void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	u32 gpe_enabled_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	u32 gpe_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	u32 j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	u8 *is_polling_needed = context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	ACPI_ERROR_ONLY(u32 gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	ACPI_FUNCTION_TRACE(ev_initialize_gpe_block);
^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) 	 * Ignore a null GPE block (e.g., if no GPE block 1 exists), and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	 * any GPE blocks that have been initialized already.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	if (!gpe_block || gpe_block->initialized) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	 * Enable all GPEs that have a corresponding method and have the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	 * ACPI_GPE_CAN_WAKE flag unset. Any other GPEs within this block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	 * must be enabled via the acpi_enable_gpe() interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	gpe_enabled_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	for (i = 0; i < gpe_block->register_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 			/* Get the info block for this particular GPE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 			gpe_index = (i * ACPI_GPE_REGISTER_WIDTH) + j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 			gpe_event_info = &gpe_block->event_info[gpe_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 			ACPI_ERROR_ONLY(gpe_number =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 					gpe_block->block_base_number +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 					gpe_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 			gpe_event_info->flags |= ACPI_GPE_INITIALIZED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 			 * Ignore GPEs that have no corresponding _Lxx/_Exx method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 			 * and GPEs that are used for wakeup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 			if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 			     ACPI_GPE_DISPATCH_METHOD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 			    || (gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 			status = acpi_ev_add_gpe_reference(gpe_event_info, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 				ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 					"Could not enable GPE 0x%02X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 					gpe_number));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 				continue;
^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) 			gpe_event_info->flags |= ACPI_GPE_AUTO_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 			if (is_polling_needed &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 			    ACPI_GPE_IS_POLLING_NEEDED(gpe_event_info)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 				*is_polling_needed = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 			gpe_enabled_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	if (gpe_enabled_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 		ACPI_INFO(("Enabled %u GPEs in block %02X to %02X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 			   gpe_enabled_count, (u32)gpe_block->block_base_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 			   (u32)(gpe_block->block_base_number +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 				 (gpe_block->gpe_count - 1))));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	gpe_block->initialized = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) #endif				/* !ACPI_REDUCED_HARDWARE */