| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** | 
 | 2 |  * | 
 | 3 |  * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable | 
 | 4 |  * | 
 | 5 |  *****************************************************************************/ | 
 | 6 |  | 
 | 7 | /* | 
| Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 8 |  * Copyright (C) 2000 - 2006, R. Byron Moore | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 |  * All rights reserved. | 
 | 10 |  * | 
 | 11 |  * Redistribution and use in source and binary forms, with or without | 
 | 12 |  * modification, are permitted provided that the following conditions | 
 | 13 |  * are met: | 
 | 14 |  * 1. Redistributions of source code must retain the above copyright | 
 | 15 |  *    notice, this list of conditions, and the following disclaimer, | 
 | 16 |  *    without modification. | 
 | 17 |  * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 
 | 18 |  *    substantially similar to the "NO WARRANTY" disclaimer below | 
 | 19 |  *    ("Disclaimer") and any redistribution must be conditioned upon | 
 | 20 |  *    including a substantially similar Disclaimer requirement for further | 
 | 21 |  *    binary redistribution. | 
 | 22 |  * 3. Neither the names of the above-listed copyright holders nor the names | 
 | 23 |  *    of any contributors may be used to endorse or promote products derived | 
 | 24 |  *    from this software without specific prior written permission. | 
 | 25 |  * | 
 | 26 |  * Alternatively, this software may be distributed under the terms of the | 
 | 27 |  * GNU General Public License ("GPL") version 2 as published by the Free | 
 | 28 |  * Software Foundation. | 
 | 29 |  * | 
 | 30 |  * NO WARRANTY | 
 | 31 |  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
 | 32 |  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
 | 33 |  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 
 | 34 |  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
 | 35 |  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
 | 36 |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
 | 37 |  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
 | 38 |  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 
 | 39 |  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 
 | 40 |  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
 | 41 |  * POSSIBILITY OF SUCH DAMAGES. | 
 | 42 |  */ | 
 | 43 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> | 
 | 45 | #include <acpi/acevents.h> | 
 | 46 | #include <acpi/acnamesp.h> | 
 | 47 |  | 
 | 48 | #define _COMPONENT          ACPI_EVENTS | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("evxfevnt") | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 |  | 
 | 51 | /******************************************************************************* | 
 | 52 |  * | 
 | 53 |  * FUNCTION:    acpi_enable | 
 | 54 |  * | 
 | 55 |  * PARAMETERS:  None | 
 | 56 |  * | 
 | 57 |  * RETURN:      Status | 
 | 58 |  * | 
 | 59 |  * DESCRIPTION: Transfers the system into ACPI mode. | 
 | 60 |  * | 
 | 61 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 62 | acpi_status acpi_enable(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 64 | 	acpi_status status = AE_OK; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 66 | 	ACPI_FUNCTION_TRACE(acpi_enable); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 68 | 	/* Make sure we have the FADT */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 |  | 
 | 70 | 	if (!acpi_gbl_FADT) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 71 | 		ACPI_WARNING((AE_INFO, "No FADT information present!")); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 72 | 		return_ACPI_STATUS(AE_NO_ACPI_TABLES); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | 	} | 
 | 74 |  | 
 | 75 | 	if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 76 | 		ACPI_DEBUG_PRINT((ACPI_DB_INIT, | 
 | 77 | 				  "System is already in ACPI mode\n")); | 
 | 78 | 	} else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | 		/* Transition to ACPI mode */ | 
 | 80 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 81 | 		status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI); | 
 | 82 | 		if (ACPI_FAILURE(status)) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 83 | 			ACPI_ERROR((AE_INFO, | 
 | 84 | 				    "Could not transition to ACPI mode")); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 85 | 			return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | 		} | 
 | 87 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 88 | 		ACPI_DEBUG_PRINT((ACPI_DB_INIT, | 
 | 89 | 				  "Transition to ACPI mode successful\n")); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | 	} | 
 | 91 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 92 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | } | 
 | 94 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 95 | ACPI_EXPORT_SYMBOL(acpi_enable) | 
 | 96 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | /******************************************************************************* | 
 | 98 |  * | 
 | 99 |  * FUNCTION:    acpi_disable | 
 | 100 |  * | 
 | 101 |  * PARAMETERS:  None | 
 | 102 |  * | 
 | 103 |  * RETURN:      Status | 
 | 104 |  * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 105 |  * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 |  * | 
 | 107 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 108 | acpi_status acpi_disable(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 110 | 	acpi_status status = AE_OK; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 112 | 	ACPI_FUNCTION_TRACE(acpi_disable); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 |  | 
 | 114 | 	if (!acpi_gbl_FADT) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 115 | 		ACPI_WARNING((AE_INFO, "No FADT information present!")); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 116 | 		return_ACPI_STATUS(AE_NO_ACPI_TABLES); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | 	} | 
 | 118 |  | 
 | 119 | 	if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 120 | 		ACPI_DEBUG_PRINT((ACPI_DB_INIT, | 
 | 121 | 				  "System is already in legacy (non-ACPI) mode\n")); | 
 | 122 | 	} else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | 		/* Transition to LEGACY mode */ | 
 | 124 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 125 | 		status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 127 | 		if (ACPI_FAILURE(status)) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 128 | 			ACPI_ERROR((AE_INFO, | 
 | 129 | 				    "Could not exit ACPI mode to legacy mode")); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 130 | 			return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | 		} | 
 | 132 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 133 | 		ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n")); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | 	} | 
 | 135 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 136 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | } | 
 | 138 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 139 | ACPI_EXPORT_SYMBOL(acpi_disable) | 
 | 140 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | /******************************************************************************* | 
 | 142 |  * | 
 | 143 |  * FUNCTION:    acpi_enable_event | 
 | 144 |  * | 
 | 145 |  * PARAMETERS:  Event           - The fixed eventto be enabled | 
 | 146 |  *              Flags           - Reserved | 
 | 147 |  * | 
 | 148 |  * RETURN:      Status | 
 | 149 |  * | 
 | 150 |  * DESCRIPTION: Enable an ACPI event (fixed) | 
 | 151 |  * | 
 | 152 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 153 | acpi_status acpi_enable_event(u32 event, u32 flags) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 155 | 	acpi_status status = AE_OK; | 
 | 156 | 	u32 value; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 158 | 	ACPI_FUNCTION_TRACE(acpi_enable_event); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 |  | 
 | 160 | 	/* Decode the Fixed Event */ | 
 | 161 |  | 
 | 162 | 	if (event > ACPI_EVENT_MAX) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 163 | 		return_ACPI_STATUS(AE_BAD_PARAMETER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | 	} | 
 | 165 |  | 
 | 166 | 	/* | 
 | 167 | 	 * Enable the requested fixed event (by writing a one to the | 
 | 168 | 	 * enable register bit) | 
 | 169 | 	 */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 170 | 	status = | 
 | 171 | 	    acpi_set_register(acpi_gbl_fixed_event_info[event]. | 
 | 172 | 			      enable_register_id, 1, ACPI_MTX_LOCK); | 
 | 173 | 	if (ACPI_FAILURE(status)) { | 
 | 174 | 		return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | 	} | 
 | 176 |  | 
 | 177 | 	/* Make sure that the hardware responded */ | 
 | 178 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 179 | 	status = | 
 | 180 | 	    acpi_get_register(acpi_gbl_fixed_event_info[event]. | 
 | 181 | 			      enable_register_id, &value, ACPI_MTX_LOCK); | 
 | 182 | 	if (ACPI_FAILURE(status)) { | 
 | 183 | 		return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | 	} | 
 | 185 |  | 
 | 186 | 	if (value != 1) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 187 | 		ACPI_ERROR((AE_INFO, | 
 | 188 | 			    "Could not enable %s event", | 
 | 189 | 			    acpi_ut_get_event_name(event))); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 190 | 		return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | 	} | 
 | 192 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 193 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 196 | ACPI_EXPORT_SYMBOL(acpi_enable_event) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 |  | 
 | 198 | /******************************************************************************* | 
 | 199 |  * | 
 | 200 |  * FUNCTION:    acpi_set_gpe_type | 
 | 201 |  * | 
 | 202 |  * PARAMETERS:  gpe_device      - Parent GPE Device | 
 | 203 |  *              gpe_number      - GPE level within the GPE block | 
 | 204 |  *              Type            - New GPE type | 
 | 205 |  * | 
 | 206 |  * RETURN:      Status | 
 | 207 |  * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 208 |  * DESCRIPTION: Set the type of an individual GPE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 |  * | 
 | 210 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 211 | acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | 	acpi_status status = AE_OK; | 
 | 214 | 	struct acpi_gpe_event_info *gpe_event_info; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 216 | 	ACPI_FUNCTION_TRACE(acpi_set_gpe_type); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 |  | 
 | 218 | 	/* Ensure that we have a valid GPE number */ | 
 | 219 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 220 | 	gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | 	if (!gpe_event_info) { | 
 | 222 | 		status = AE_BAD_PARAMETER; | 
 | 223 | 		goto unlock_and_exit; | 
 | 224 | 	} | 
 | 225 |  | 
 | 226 | 	if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 227 | 		return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | 	} | 
 | 229 |  | 
 | 230 | 	/* Set the new type (will disable GPE if currently enabled) */ | 
 | 231 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | 	status = acpi_ev_set_gpe_type(gpe_event_info, type); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 234 |       unlock_and_exit: | 
 | 235 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 238 | ACPI_EXPORT_SYMBOL(acpi_set_gpe_type) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 |  | 
 | 240 | /******************************************************************************* | 
 | 241 |  * | 
 | 242 |  * FUNCTION:    acpi_enable_gpe | 
 | 243 |  * | 
 | 244 |  * PARAMETERS:  gpe_device      - Parent GPE Device | 
 | 245 |  *              gpe_number      - GPE level within the GPE block | 
 | 246 |  *              Flags           - Just enable, or also wake enable? | 
 | 247 |  *                                Called from ISR or not | 
 | 248 |  * | 
 | 249 |  * RETURN:      Status | 
 | 250 |  * | 
 | 251 |  * DESCRIPTION: Enable an ACPI event (general purpose) | 
 | 252 |  * | 
 | 253 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 254 | acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 256 | 	acpi_status status = AE_OK; | 
 | 257 | 	struct acpi_gpe_event_info *gpe_event_info; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 259 | 	ACPI_FUNCTION_TRACE(acpi_enable_gpe); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 |  | 
 | 261 | 	/* Use semaphore lock if not executing at interrupt level */ | 
 | 262 |  | 
 | 263 | 	if (flags & ACPI_NOT_ISR) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 264 | 		status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | 
 | 265 | 		if (ACPI_FAILURE(status)) { | 
 | 266 | 			return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | 		} | 
 | 268 | 	} | 
 | 269 |  | 
 | 270 | 	/* Ensure that we have a valid GPE number */ | 
 | 271 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | 	gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | 	if (!gpe_event_info) { | 
 | 274 | 		status = AE_BAD_PARAMETER; | 
 | 275 | 		goto unlock_and_exit; | 
 | 276 | 	} | 
 | 277 |  | 
 | 278 | 	/* Perform the enable */ | 
 | 279 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 280 | 	status = acpi_ev_enable_gpe(gpe_event_info, TRUE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 282 |       unlock_and_exit: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | 	if (flags & ACPI_NOT_ISR) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 284 | 		(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | 	} | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 286 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 289 | ACPI_EXPORT_SYMBOL(acpi_enable_gpe) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 |  | 
 | 291 | /******************************************************************************* | 
 | 292 |  * | 
 | 293 |  * FUNCTION:    acpi_disable_gpe | 
 | 294 |  * | 
 | 295 |  * PARAMETERS:  gpe_device      - Parent GPE Device | 
 | 296 |  *              gpe_number      - GPE level within the GPE block | 
 | 297 |  *              Flags           - Just disable, or also wake disable? | 
 | 298 |  *                                Called from ISR or not | 
 | 299 |  * | 
 | 300 |  * RETURN:      Status | 
 | 301 |  * | 
 | 302 |  * DESCRIPTION: Disable an ACPI event (general purpose) | 
 | 303 |  * | 
 | 304 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 305 | acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 307 | 	acpi_status status = AE_OK; | 
 | 308 | 	struct acpi_gpe_event_info *gpe_event_info; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 310 | 	ACPI_FUNCTION_TRACE(acpi_disable_gpe); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 |  | 
 | 312 | 	/* Use semaphore lock if not executing at interrupt level */ | 
 | 313 |  | 
 | 314 | 	if (flags & ACPI_NOT_ISR) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 315 | 		status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | 
 | 316 | 		if (ACPI_FAILURE(status)) { | 
 | 317 | 			return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | 		} | 
 | 319 | 	} | 
 | 320 |  | 
 | 321 | 	/* Ensure that we have a valid GPE number */ | 
 | 322 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 323 | 	gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | 	if (!gpe_event_info) { | 
 | 325 | 		status = AE_BAD_PARAMETER; | 
 | 326 | 		goto unlock_and_exit; | 
 | 327 | 	} | 
 | 328 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 329 | 	status = acpi_ev_disable_gpe(gpe_event_info); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 331 |       unlock_and_exit: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | 	if (flags & ACPI_NOT_ISR) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 333 | 		(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | 	} | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 335 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | } | 
 | 337 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 338 | ACPI_EXPORT_SYMBOL(acpi_disable_gpe) | 
 | 339 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | /******************************************************************************* | 
 | 341 |  * | 
 | 342 |  * FUNCTION:    acpi_disable_event | 
 | 343 |  * | 
 | 344 |  * PARAMETERS:  Event           - The fixed eventto be enabled | 
 | 345 |  *              Flags           - Reserved | 
 | 346 |  * | 
 | 347 |  * RETURN:      Status | 
 | 348 |  * | 
 | 349 |  * DESCRIPTION: Disable an ACPI event (fixed) | 
 | 350 |  * | 
 | 351 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 352 | acpi_status acpi_disable_event(u32 event, u32 flags) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 354 | 	acpi_status status = AE_OK; | 
 | 355 | 	u32 value; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 357 | 	ACPI_FUNCTION_TRACE(acpi_disable_event); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 |  | 
 | 359 | 	/* Decode the Fixed Event */ | 
 | 360 |  | 
 | 361 | 	if (event > ACPI_EVENT_MAX) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 362 | 		return_ACPI_STATUS(AE_BAD_PARAMETER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | 	} | 
 | 364 |  | 
 | 365 | 	/* | 
 | 366 | 	 * Disable the requested fixed event (by writing a zero to the | 
 | 367 | 	 * enable register bit) | 
 | 368 | 	 */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 369 | 	status = | 
 | 370 | 	    acpi_set_register(acpi_gbl_fixed_event_info[event]. | 
 | 371 | 			      enable_register_id, 0, ACPI_MTX_LOCK); | 
 | 372 | 	if (ACPI_FAILURE(status)) { | 
 | 373 | 		return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | 	} | 
 | 375 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 376 | 	status = | 
 | 377 | 	    acpi_get_register(acpi_gbl_fixed_event_info[event]. | 
 | 378 | 			      enable_register_id, &value, ACPI_MTX_LOCK); | 
 | 379 | 	if (ACPI_FAILURE(status)) { | 
 | 380 | 		return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | 	} | 
 | 382 |  | 
 | 383 | 	if (value != 0) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 384 | 		ACPI_ERROR((AE_INFO, | 
 | 385 | 			    "Could not disable %s events", | 
 | 386 | 			    acpi_ut_get_event_name(event))); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 387 | 		return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | 	} | 
 | 389 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 390 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 393 | ACPI_EXPORT_SYMBOL(acpi_disable_event) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 |  | 
 | 395 | /******************************************************************************* | 
 | 396 |  * | 
 | 397 |  * FUNCTION:    acpi_clear_event | 
 | 398 |  * | 
 | 399 |  * PARAMETERS:  Event           - The fixed event to be cleared | 
 | 400 |  * | 
 | 401 |  * RETURN:      Status | 
 | 402 |  * | 
 | 403 |  * DESCRIPTION: Clear an ACPI event (fixed) | 
 | 404 |  * | 
 | 405 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 406 | acpi_status acpi_clear_event(u32 event) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 408 | 	acpi_status status = AE_OK; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 410 | 	ACPI_FUNCTION_TRACE(acpi_clear_event); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 |  | 
 | 412 | 	/* Decode the Fixed Event */ | 
 | 413 |  | 
 | 414 | 	if (event > ACPI_EVENT_MAX) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 415 | 		return_ACPI_STATUS(AE_BAD_PARAMETER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | 	} | 
 | 417 |  | 
 | 418 | 	/* | 
 | 419 | 	 * Clear the requested fixed event (By writing a one to the | 
 | 420 | 	 * status register bit) | 
 | 421 | 	 */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 422 | 	status = | 
 | 423 | 	    acpi_set_register(acpi_gbl_fixed_event_info[event]. | 
 | 424 | 			      status_register_id, 1, ACPI_MTX_LOCK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 426 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 429 | ACPI_EXPORT_SYMBOL(acpi_clear_event) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 |  | 
 | 431 | /******************************************************************************* | 
 | 432 |  * | 
 | 433 |  * FUNCTION:    acpi_clear_gpe | 
 | 434 |  * | 
 | 435 |  * PARAMETERS:  gpe_device      - Parent GPE Device | 
 | 436 |  *              gpe_number      - GPE level within the GPE block | 
 | 437 |  *              Flags           - Called from an ISR or not | 
 | 438 |  * | 
 | 439 |  * RETURN:      Status | 
 | 440 |  * | 
 | 441 |  * DESCRIPTION: Clear an ACPI event (general purpose) | 
 | 442 |  * | 
 | 443 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 444 | acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 446 | 	acpi_status status = AE_OK; | 
 | 447 | 	struct acpi_gpe_event_info *gpe_event_info; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 449 | 	ACPI_FUNCTION_TRACE(acpi_clear_gpe); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 |  | 
 | 451 | 	/* Use semaphore lock if not executing at interrupt level */ | 
 | 452 |  | 
 | 453 | 	if (flags & ACPI_NOT_ISR) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 454 | 		status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | 
 | 455 | 		if (ACPI_FAILURE(status)) { | 
 | 456 | 			return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | 		} | 
 | 458 | 	} | 
 | 459 |  | 
 | 460 | 	/* Ensure that we have a valid GPE number */ | 
 | 461 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 462 | 	gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | 	if (!gpe_event_info) { | 
 | 464 | 		status = AE_BAD_PARAMETER; | 
 | 465 | 		goto unlock_and_exit; | 
 | 466 | 	} | 
 | 467 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 468 | 	status = acpi_hw_clear_gpe(gpe_event_info); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 470 |       unlock_and_exit: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | 	if (flags & ACPI_NOT_ISR) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 472 | 		(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | 	} | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 474 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | } | 
 | 476 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 477 | ACPI_EXPORT_SYMBOL(acpi_clear_gpe) | 
 | 478 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | #ifdef ACPI_FUTURE_USAGE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | /******************************************************************************* | 
 | 481 |  * | 
 | 482 |  * FUNCTION:    acpi_get_event_status | 
 | 483 |  * | 
 | 484 |  * PARAMETERS:  Event           - The fixed event | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 485 |  *              event_status    - Where the current status of the event will | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 |  *                                be returned | 
 | 487 |  * | 
 | 488 |  * RETURN:      Status | 
 | 489 |  * | 
 | 490 |  * DESCRIPTION: Obtains and returns the current status of the event | 
 | 491 |  * | 
 | 492 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 493 | acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 495 | 	acpi_status status = AE_OK; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 497 | 	ACPI_FUNCTION_TRACE(acpi_get_event_status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 |  | 
 | 499 | 	if (!event_status) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 500 | 		return_ACPI_STATUS(AE_BAD_PARAMETER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | 	} | 
 | 502 |  | 
 | 503 | 	/* Decode the Fixed Event */ | 
 | 504 |  | 
 | 505 | 	if (event > ACPI_EVENT_MAX) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 506 | 		return_ACPI_STATUS(AE_BAD_PARAMETER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | 	} | 
 | 508 |  | 
 | 509 | 	/* Get the status of the requested fixed event */ | 
 | 510 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 511 | 	status = | 
 | 512 | 	    acpi_get_register(acpi_gbl_fixed_event_info[event]. | 
 | 513 | 			      status_register_id, event_status, ACPI_MTX_LOCK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 515 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | } | 
 | 517 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 518 | ACPI_EXPORT_SYMBOL(acpi_get_event_status) | 
 | 519 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | /******************************************************************************* | 
 | 521 |  * | 
 | 522 |  * FUNCTION:    acpi_get_gpe_status | 
 | 523 |  * | 
 | 524 |  * PARAMETERS:  gpe_device      - Parent GPE Device | 
 | 525 |  *              gpe_number      - GPE level within the GPE block | 
 | 526 |  *              Flags           - Called from an ISR or not | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 527 |  *              event_status    - Where the current status of the event will | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 |  *                                be returned | 
 | 529 |  * | 
 | 530 |  * RETURN:      Status | 
 | 531 |  * | 
 | 532 |  * DESCRIPTION: Get status of an event (general purpose) | 
 | 533 |  * | 
 | 534 |  ******************************************************************************/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 536 | acpi_get_gpe_status(acpi_handle gpe_device, | 
 | 537 | 		    u32 gpe_number, u32 flags, acpi_event_status * event_status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 539 | 	acpi_status status = AE_OK; | 
 | 540 | 	struct acpi_gpe_event_info *gpe_event_info; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 542 | 	ACPI_FUNCTION_TRACE(acpi_get_gpe_status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 |  | 
 | 544 | 	/* Use semaphore lock if not executing at interrupt level */ | 
 | 545 |  | 
 | 546 | 	if (flags & ACPI_NOT_ISR) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 547 | 		status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | 
 | 548 | 		if (ACPI_FAILURE(status)) { | 
 | 549 | 			return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | 		} | 
 | 551 | 	} | 
 | 552 |  | 
 | 553 | 	/* Ensure that we have a valid GPE number */ | 
 | 554 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 555 | 	gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | 	if (!gpe_event_info) { | 
 | 557 | 		status = AE_BAD_PARAMETER; | 
 | 558 | 		goto unlock_and_exit; | 
 | 559 | 	} | 
 | 560 |  | 
 | 561 | 	/* Obtain status on the requested GPE number */ | 
 | 562 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 563 | 	status = acpi_hw_get_gpe_status(gpe_event_info, event_status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 565 |       unlock_and_exit: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | 	if (flags & ACPI_NOT_ISR) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 567 | 		(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | 	} | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 569 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | } | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 571 |  | 
 | 572 | ACPI_EXPORT_SYMBOL(acpi_get_gpe_status) | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 573 | #endif				/*  ACPI_FUTURE_USAGE  */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 |  | 
 | 575 | /******************************************************************************* | 
 | 576 |  * | 
 | 577 |  * FUNCTION:    acpi_install_gpe_block | 
 | 578 |  * | 
 | 579 |  * PARAMETERS:  gpe_device          - Handle to the parent GPE Block Device | 
 | 580 |  *              gpe_block_address   - Address and space_iD | 
 | 581 |  *              register_count      - Number of GPE register pairs in the block | 
| Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 582 |  *              interrupt_number    - H/W interrupt for the block | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 |  * | 
 | 584 |  * RETURN:      Status | 
 | 585 |  * | 
 | 586 |  * DESCRIPTION: Create and Install a block of GPE registers | 
 | 587 |  * | 
 | 588 |  ******************************************************************************/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 590 | acpi_install_gpe_block(acpi_handle gpe_device, | 
 | 591 | 		       struct acpi_generic_address *gpe_block_address, | 
 | 592 | 		       u32 register_count, u32 interrupt_number) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 594 | 	acpi_status status; | 
 | 595 | 	union acpi_operand_object *obj_desc; | 
 | 596 | 	struct acpi_namespace_node *node; | 
 | 597 | 	struct acpi_gpe_block_info *gpe_block; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 599 | 	ACPI_FUNCTION_TRACE(acpi_install_gpe_block); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 601 | 	if ((!gpe_device) || (!gpe_block_address) || (!register_count)) { | 
 | 602 | 		return_ACPI_STATUS(AE_BAD_PARAMETER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | 	} | 
 | 604 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 605 | 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | 
 | 606 | 	if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | 		return (status); | 
 | 608 | 	} | 
 | 609 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 610 | 	node = acpi_ns_map_handle_to_node(gpe_device); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | 	if (!node) { | 
 | 612 | 		status = AE_BAD_PARAMETER; | 
 | 613 | 		goto unlock_and_exit; | 
 | 614 | 	} | 
 | 615 |  | 
 | 616 | 	/* | 
 | 617 | 	 * For user-installed GPE Block Devices, the gpe_block_base_number | 
 | 618 | 	 * is always zero | 
 | 619 | 	 */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 620 | 	status = | 
 | 621 | 	    acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0, | 
 | 622 | 				     interrupt_number, &gpe_block); | 
 | 623 | 	if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | 		goto unlock_and_exit; | 
 | 625 | 	} | 
 | 626 |  | 
| Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 627 | 	/* Run the _PRW methods and enable the GPEs */ | 
 | 628 |  | 
 | 629 | 	status = acpi_ev_initialize_gpe_block(node, gpe_block); | 
 | 630 | 	if (ACPI_FAILURE(status)) { | 
 | 631 | 		goto unlock_and_exit; | 
 | 632 | 	} | 
 | 633 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | 	/* Get the device_object attached to the node */ | 
 | 635 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 636 | 	obj_desc = acpi_ns_get_attached_object(node); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | 	if (!obj_desc) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 638 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | 		/* No object, create a new one */ | 
 | 640 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 641 | 		obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | 		if (!obj_desc) { | 
 | 643 | 			status = AE_NO_MEMORY; | 
 | 644 | 			goto unlock_and_exit; | 
 | 645 | 		} | 
 | 646 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 647 | 		status = | 
 | 648 | 		    acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 |  | 
 | 650 | 		/* Remove local reference to the object */ | 
 | 651 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 652 | 		acpi_ut_remove_reference(obj_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 654 | 		if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | 			goto unlock_and_exit; | 
 | 656 | 		} | 
 | 657 | 	} | 
 | 658 |  | 
 | 659 | 	/* Install the GPE block in the device_object */ | 
 | 660 |  | 
 | 661 | 	obj_desc->device.gpe_block = gpe_block; | 
 | 662 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 663 |       unlock_and_exit: | 
 | 664 | 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 
 | 665 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 668 | ACPI_EXPORT_SYMBOL(acpi_install_gpe_block) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 |  | 
 | 670 | /******************************************************************************* | 
 | 671 |  * | 
 | 672 |  * FUNCTION:    acpi_remove_gpe_block | 
 | 673 |  * | 
 | 674 |  * PARAMETERS:  gpe_device          - Handle to the parent GPE Block Device | 
 | 675 |  * | 
 | 676 |  * RETURN:      Status | 
 | 677 |  * | 
 | 678 |  * DESCRIPTION: Remove a previously installed block of GPE registers | 
 | 679 |  * | 
 | 680 |  ******************************************************************************/ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 681 | acpi_status acpi_remove_gpe_block(acpi_handle gpe_device) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 683 | 	union acpi_operand_object *obj_desc; | 
 | 684 | 	acpi_status status; | 
 | 685 | 	struct acpi_namespace_node *node; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 687 | 	ACPI_FUNCTION_TRACE(acpi_remove_gpe_block); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 |  | 
 | 689 | 	if (!gpe_device) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 690 | 		return_ACPI_STATUS(AE_BAD_PARAMETER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | 	} | 
 | 692 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 693 | 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | 
 | 694 | 	if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | 		return (status); | 
 | 696 | 	} | 
 | 697 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 698 | 	node = acpi_ns_map_handle_to_node(gpe_device); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | 	if (!node) { | 
 | 700 | 		status = AE_BAD_PARAMETER; | 
 | 701 | 		goto unlock_and_exit; | 
 | 702 | 	} | 
 | 703 |  | 
 | 704 | 	/* Get the device_object attached to the node */ | 
 | 705 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 706 | 	obj_desc = acpi_ns_get_attached_object(node); | 
 | 707 | 	if (!obj_desc || !obj_desc->device.gpe_block) { | 
 | 708 | 		return_ACPI_STATUS(AE_NULL_OBJECT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | 	} | 
 | 710 |  | 
 | 711 | 	/* Delete the GPE block (but not the device_object) */ | 
 | 712 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 713 | 	status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block); | 
 | 714 | 	if (ACPI_SUCCESS(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | 		obj_desc->device.gpe_block = NULL; | 
 | 716 | 	} | 
 | 717 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 718 |       unlock_and_exit: | 
 | 719 | 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 
 | 720 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | } | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 722 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 723 | ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block) |