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 | |
| 44 | #include <linux/module.h> |
| 45 | |
| 46 | #include <acpi/acpi.h> |
| 47 | #include <acpi/acevents.h> |
| 48 | #include <acpi/acnamesp.h> |
| 49 | |
| 50 | #define _COMPONENT ACPI_EVENTS |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 51 | ACPI_MODULE_NAME("evxfevnt") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | /******************************************************************************* |
| 54 | * |
| 55 | * FUNCTION: acpi_enable |
| 56 | * |
| 57 | * PARAMETERS: None |
| 58 | * |
| 59 | * RETURN: Status |
| 60 | * |
| 61 | * DESCRIPTION: Transfers the system into ACPI mode. |
| 62 | * |
| 63 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 64 | acpi_status acpi_enable(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 66 | acpi_status status = AE_OK; |
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 | ACPI_FUNCTION_TRACE("acpi_enable"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 70 | /* Make sure we have the FADT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | if (!acpi_gbl_FADT) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame^] | 73 | ACPI_WARNING((AE_INFO, "No FADT information present!")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 74 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 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 | |
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 | ******************************************************************************/ |
| 108 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 109 | acpi_status acpi_disable(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 111 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 113 | ACPI_FUNCTION_TRACE("acpi_disable"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | if (!acpi_gbl_FADT) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame^] | 116 | ACPI_WARNING((AE_INFO, "No FADT information present!")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 121 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
| 122 | "System is already in legacy (non-ACPI) mode\n")); |
| 123 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | /* Transition to LEGACY mode */ |
| 125 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 126 | status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 128 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame^] | 129 | ACPI_ERROR((AE_INFO, |
| 130 | "Could not exit ACPI mode to legacy mode")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 131 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 134 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 137 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | /******************************************************************************* |
| 141 | * |
| 142 | * FUNCTION: acpi_enable_event |
| 143 | * |
| 144 | * PARAMETERS: Event - The fixed eventto be enabled |
| 145 | * Flags - Reserved |
| 146 | * |
| 147 | * RETURN: Status |
| 148 | * |
| 149 | * DESCRIPTION: Enable an ACPI event (fixed) |
| 150 | * |
| 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 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -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 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 196 | 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 | ******************************************************************************/ |
| 211 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 212 | 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] | 213 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 214 | acpi_status status = AE_OK; |
| 215 | struct acpi_gpe_event_info *gpe_event_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 217 | ACPI_FUNCTION_TRACE("acpi_set_gpe_type"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | |
| 219 | /* Ensure that we have a valid GPE number */ |
| 220 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 221 | 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] | 222 | if (!gpe_event_info) { |
| 223 | status = AE_BAD_PARAMETER; |
| 224 | goto unlock_and_exit; |
| 225 | } |
| 226 | |
| 227 | if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 228 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /* Set the new type (will disable GPE if currently enabled) */ |
| 232 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 233 | status = acpi_ev_set_gpe_type(gpe_event_info, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 235 | unlock_and_exit: |
| 236 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 239 | EXPORT_SYMBOL(acpi_set_gpe_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
| 241 | /******************************************************************************* |
| 242 | * |
| 243 | * FUNCTION: acpi_enable_gpe |
| 244 | * |
| 245 | * PARAMETERS: gpe_device - Parent GPE Device |
| 246 | * gpe_number - GPE level within the GPE block |
| 247 | * Flags - Just enable, or also wake enable? |
| 248 | * Called from ISR or not |
| 249 | * |
| 250 | * RETURN: Status |
| 251 | * |
| 252 | * DESCRIPTION: Enable an ACPI event (general purpose) |
| 253 | * |
| 254 | ******************************************************************************/ |
| 255 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 256 | 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] | 257 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 258 | acpi_status status = AE_OK; |
| 259 | struct acpi_gpe_event_info *gpe_event_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 261 | ACPI_FUNCTION_TRACE("acpi_enable_gpe"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
| 263 | /* Use semaphore lock if not executing at interrupt level */ |
| 264 | |
| 265 | if (flags & ACPI_NOT_ISR) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 266 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
| 267 | if (ACPI_FAILURE(status)) { |
| 268 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | |
| 272 | /* Ensure that we have a valid GPE number */ |
| 273 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 274 | 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] | 275 | if (!gpe_event_info) { |
| 276 | status = AE_BAD_PARAMETER; |
| 277 | goto unlock_and_exit; |
| 278 | } |
| 279 | |
| 280 | /* Perform the enable */ |
| 281 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 282 | status = acpi_ev_enable_gpe(gpe_event_info, TRUE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 284 | unlock_and_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | if (flags & ACPI_NOT_ISR) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 286 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 288 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 291 | EXPORT_SYMBOL(acpi_enable_gpe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
| 293 | /******************************************************************************* |
| 294 | * |
| 295 | * FUNCTION: acpi_disable_gpe |
| 296 | * |
| 297 | * PARAMETERS: gpe_device - Parent GPE Device |
| 298 | * gpe_number - GPE level within the GPE block |
| 299 | * Flags - Just disable, or also wake disable? |
| 300 | * Called from ISR or not |
| 301 | * |
| 302 | * RETURN: Status |
| 303 | * |
| 304 | * DESCRIPTION: Disable an ACPI event (general purpose) |
| 305 | * |
| 306 | ******************************************************************************/ |
| 307 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 308 | 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] | 309 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 310 | acpi_status status = AE_OK; |
| 311 | struct acpi_gpe_event_info *gpe_event_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 313 | ACPI_FUNCTION_TRACE("acpi_disable_gpe"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
| 315 | /* Use semaphore lock if not executing at interrupt level */ |
| 316 | |
| 317 | if (flags & ACPI_NOT_ISR) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 318 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
| 319 | if (ACPI_FAILURE(status)) { |
| 320 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | |
| 324 | /* Ensure that we have a valid GPE number */ |
| 325 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 326 | 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] | 327 | if (!gpe_event_info) { |
| 328 | status = AE_BAD_PARAMETER; |
| 329 | goto unlock_and_exit; |
| 330 | } |
| 331 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 332 | status = acpi_ev_disable_gpe(gpe_event_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 334 | unlock_and_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | if (flags & ACPI_NOT_ISR) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 336 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 338 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | } |
| 340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | /******************************************************************************* |
| 342 | * |
| 343 | * FUNCTION: acpi_disable_event |
| 344 | * |
| 345 | * PARAMETERS: Event - The fixed eventto be enabled |
| 346 | * Flags - Reserved |
| 347 | * |
| 348 | * RETURN: Status |
| 349 | * |
| 350 | * DESCRIPTION: Disable an ACPI event (fixed) |
| 351 | * |
| 352 | ******************************************************************************/ |
| 353 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 354 | acpi_status acpi_disable_event(u32 event, u32 flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 356 | acpi_status status = AE_OK; |
| 357 | u32 value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 359 | ACPI_FUNCTION_TRACE("acpi_disable_event"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
| 361 | /* Decode the Fixed Event */ |
| 362 | |
| 363 | if (event > ACPI_EVENT_MAX) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 364 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | /* |
| 368 | * Disable the requested fixed event (by writing a zero to the |
| 369 | * enable register bit) |
| 370 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 371 | status = |
| 372 | acpi_set_register(acpi_gbl_fixed_event_info[event]. |
| 373 | enable_register_id, 0, ACPI_MTX_LOCK); |
| 374 | if (ACPI_FAILURE(status)) { |
| 375 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 378 | status = |
| 379 | acpi_get_register(acpi_gbl_fixed_event_info[event]. |
| 380 | enable_register_id, &value, ACPI_MTX_LOCK); |
| 381 | if (ACPI_FAILURE(status)) { |
| 382 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | if (value != 0) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame^] | 386 | ACPI_ERROR((AE_INFO, |
| 387 | "Could not disable %s events", |
| 388 | acpi_ut_get_event_name(event))); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 389 | return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 392 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 395 | EXPORT_SYMBOL(acpi_disable_event); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | |
| 397 | /******************************************************************************* |
| 398 | * |
| 399 | * FUNCTION: acpi_clear_event |
| 400 | * |
| 401 | * PARAMETERS: Event - The fixed event to be cleared |
| 402 | * |
| 403 | * RETURN: Status |
| 404 | * |
| 405 | * DESCRIPTION: Clear an ACPI event (fixed) |
| 406 | * |
| 407 | ******************************************************************************/ |
| 408 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 409 | acpi_status acpi_clear_event(u32 event) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 411 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 413 | ACPI_FUNCTION_TRACE("acpi_clear_event"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | |
| 415 | /* Decode the Fixed Event */ |
| 416 | |
| 417 | if (event > ACPI_EVENT_MAX) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 418 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | /* |
| 422 | * Clear the requested fixed event (By writing a one to the |
| 423 | * status register bit) |
| 424 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 425 | status = |
| 426 | acpi_set_register(acpi_gbl_fixed_event_info[event]. |
| 427 | status_register_id, 1, ACPI_MTX_LOCK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 429 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 432 | EXPORT_SYMBOL(acpi_clear_event); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
| 434 | /******************************************************************************* |
| 435 | * |
| 436 | * FUNCTION: acpi_clear_gpe |
| 437 | * |
| 438 | * PARAMETERS: gpe_device - Parent GPE Device |
| 439 | * gpe_number - GPE level within the GPE block |
| 440 | * Flags - Called from an ISR or not |
| 441 | * |
| 442 | * RETURN: Status |
| 443 | * |
| 444 | * DESCRIPTION: Clear an ACPI event (general purpose) |
| 445 | * |
| 446 | ******************************************************************************/ |
| 447 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 448 | 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] | 449 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 450 | acpi_status status = AE_OK; |
| 451 | struct acpi_gpe_event_info *gpe_event_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 453 | ACPI_FUNCTION_TRACE("acpi_clear_gpe"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | |
| 455 | /* Use semaphore lock if not executing at interrupt level */ |
| 456 | |
| 457 | if (flags & ACPI_NOT_ISR) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 458 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
| 459 | if (ACPI_FAILURE(status)) { |
| 460 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | } |
| 462 | } |
| 463 | |
| 464 | /* Ensure that we have a valid GPE number */ |
| 465 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 466 | 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] | 467 | if (!gpe_event_info) { |
| 468 | status = AE_BAD_PARAMETER; |
| 469 | goto unlock_and_exit; |
| 470 | } |
| 471 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 472 | status = acpi_hw_clear_gpe(gpe_event_info); |
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 | unlock_and_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | if (flags & ACPI_NOT_ISR) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 476 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 478 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | } |
| 480 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | #ifdef ACPI_FUTURE_USAGE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | /******************************************************************************* |
| 483 | * |
| 484 | * FUNCTION: acpi_get_event_status |
| 485 | * |
| 486 | * PARAMETERS: Event - The fixed event |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 487 | * event_status - Where the current status of the event will |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | * be returned |
| 489 | * |
| 490 | * RETURN: Status |
| 491 | * |
| 492 | * DESCRIPTION: Obtains and returns the current status of the event |
| 493 | * |
| 494 | ******************************************************************************/ |
| 495 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 496 | 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] | 497 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 498 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 500 | ACPI_FUNCTION_TRACE("acpi_get_event_status"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
| 502 | if (!event_status) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 503 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | /* Decode the Fixed Event */ |
| 507 | |
| 508 | if (event > ACPI_EVENT_MAX) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 509 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | /* Get the status of the requested fixed event */ |
| 513 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 514 | status = |
| 515 | acpi_get_register(acpi_gbl_fixed_event_info[event]. |
| 516 | status_register_id, event_status, ACPI_MTX_LOCK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 518 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | } |
| 520 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | /******************************************************************************* |
| 522 | * |
| 523 | * FUNCTION: acpi_get_gpe_status |
| 524 | * |
| 525 | * PARAMETERS: gpe_device - Parent GPE Device |
| 526 | * gpe_number - GPE level within the GPE block |
| 527 | * Flags - Called from an ISR or not |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 528 | * event_status - Where the current status of the event will |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | * be returned |
| 530 | * |
| 531 | * RETURN: Status |
| 532 | * |
| 533 | * DESCRIPTION: Get status of an event (general purpose) |
| 534 | * |
| 535 | ******************************************************************************/ |
| 536 | |
| 537 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 538 | acpi_get_gpe_status(acpi_handle gpe_device, |
| 539 | u32 gpe_number, u32 flags, acpi_event_status * event_status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 541 | acpi_status status = AE_OK; |
| 542 | struct acpi_gpe_event_info *gpe_event_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 544 | ACPI_FUNCTION_TRACE("acpi_get_gpe_status"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | |
| 546 | /* Use semaphore lock if not executing at interrupt level */ |
| 547 | |
| 548 | if (flags & ACPI_NOT_ISR) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 549 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
| 550 | if (ACPI_FAILURE(status)) { |
| 551 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | } |
| 553 | } |
| 554 | |
| 555 | /* Ensure that we have a valid GPE number */ |
| 556 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 557 | 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] | 558 | if (!gpe_event_info) { |
| 559 | status = AE_BAD_PARAMETER; |
| 560 | goto unlock_and_exit; |
| 561 | } |
| 562 | |
| 563 | /* Obtain status on the requested GPE number */ |
| 564 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 565 | status = acpi_hw_get_gpe_status(gpe_event_info, event_status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 567 | unlock_and_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | if (flags & ACPI_NOT_ISR) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 569 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 571 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | } |
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 | ******************************************************************************/ |
| 589 | |
| 590 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 591 | acpi_install_gpe_block(acpi_handle gpe_device, |
| 592 | struct acpi_generic_address *gpe_block_address, |
| 593 | u32 register_count, u32 interrupt_number) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 595 | acpi_status status; |
| 596 | union acpi_operand_object *obj_desc; |
| 597 | struct acpi_namespace_node *node; |
| 598 | struct acpi_gpe_block_info *gpe_block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 600 | ACPI_FUNCTION_TRACE("acpi_install_gpe_block"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 602 | if ((!gpe_device) || (!gpe_block_address) || (!register_count)) { |
| 603 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | } |
| 605 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 606 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 607 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | return (status); |
| 609 | } |
| 610 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 611 | node = acpi_ns_map_handle_to_node(gpe_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | if (!node) { |
| 613 | status = AE_BAD_PARAMETER; |
| 614 | goto unlock_and_exit; |
| 615 | } |
| 616 | |
| 617 | /* |
| 618 | * For user-installed GPE Block Devices, the gpe_block_base_number |
| 619 | * is always zero |
| 620 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 621 | status = |
| 622 | acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0, |
| 623 | interrupt_number, &gpe_block); |
| 624 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | goto unlock_and_exit; |
| 626 | } |
| 627 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 628 | /* Run the _PRW methods and enable the GPEs */ |
| 629 | |
| 630 | status = acpi_ev_initialize_gpe_block(node, gpe_block); |
| 631 | if (ACPI_FAILURE(status)) { |
| 632 | goto unlock_and_exit; |
| 633 | } |
| 634 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | /* Get the device_object attached to the node */ |
| 636 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 637 | obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | if (!obj_desc) { |
| 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 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 668 | 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 | ******************************************************************************/ |
| 681 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 682 | acpi_status acpi_remove_gpe_block(acpi_handle gpe_device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 684 | union acpi_operand_object *obj_desc; |
| 685 | acpi_status status; |
| 686 | struct acpi_namespace_node *node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 688 | ACPI_FUNCTION_TRACE("acpi_remove_gpe_block"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | |
| 690 | if (!gpe_device) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 691 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | } |
| 693 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 694 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 695 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | return (status); |
| 697 | } |
| 698 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 699 | node = acpi_ns_map_handle_to_node(gpe_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | if (!node) { |
| 701 | status = AE_BAD_PARAMETER; |
| 702 | goto unlock_and_exit; |
| 703 | } |
| 704 | |
| 705 | /* Get the device_object attached to the node */ |
| 706 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 707 | obj_desc = acpi_ns_get_attached_object(node); |
| 708 | if (!obj_desc || !obj_desc->device.gpe_block) { |
| 709 | return_ACPI_STATUS(AE_NULL_OBJECT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | /* Delete the GPE block (but not the device_object) */ |
| 713 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 714 | status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block); |
| 715 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | obj_desc->device.gpe_block = NULL; |
| 717 | } |
| 718 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 719 | unlock_and_exit: |
| 720 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
| 721 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 723 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | EXPORT_SYMBOL(acpi_remove_gpe_block); |