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