Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
| 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: hwgpe - Low level GPE enable/disable/clear functions |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
Len Brown | 75a44ce | 2008-04-23 23:00:13 -0400 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2008, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * All rights reserved. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions, and the following disclaimer, |
| 17 | * without modification. |
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 21 | * including a substantially similar Disclaimer requirement for further |
| 22 | * binary redistribution. |
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 24 | * of any contributors may be used to endorse or promote products derived |
| 25 | * from this software without specific prior written permission. |
| 26 | * |
| 27 | * Alternatively, this software may be distributed under the terms of the |
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 29 | * Software Foundation. |
| 30 | * |
| 31 | * NO WARRANTY |
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 42 | * POSSIBILITY OF SUCH DAMAGES. |
| 43 | */ |
| 44 | |
| 45 | #include <acpi/acpi.h> |
| 46 | #include <acpi/acevents.h> |
| 47 | |
| 48 | #define _COMPONENT ACPI_HARDWARE |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("hwgpe") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 51 | /* Local prototypes */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 52 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 53 | acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 54 | struct acpi_gpe_block_info *gpe_block, |
| 55 | void *context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | /****************************************************************************** |
| 58 | * |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 59 | * FUNCTION: acpi_hw_low_disable_gpe |
| 60 | * |
| 61 | * PARAMETERS: gpe_event_info - Info block for the GPE to be disabled |
| 62 | * |
| 63 | * RETURN: Status |
| 64 | * |
| 65 | * DESCRIPTION: Disable a single GPE in the enable register. |
| 66 | * |
| 67 | ******************************************************************************/ |
| 68 | |
| 69 | acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) |
| 70 | { |
| 71 | struct acpi_gpe_register_info *gpe_register_info; |
| 72 | acpi_status status; |
| 73 | u32 enable_mask; |
| 74 | |
| 75 | /* Get the info block for the entire GPE register */ |
| 76 | |
| 77 | gpe_register_info = gpe_event_info->register_info; |
| 78 | if (!gpe_register_info) { |
| 79 | return (AE_NOT_EXIST); |
| 80 | } |
| 81 | |
| 82 | /* Get current value of the enable register that contains this GPE */ |
| 83 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 84 | status = acpi_read(&enable_mask, &gpe_register_info->enable_address); |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 85 | if (ACPI_FAILURE(status)) { |
| 86 | return (status); |
| 87 | } |
| 88 | |
| 89 | /* Clear just the bit that corresponds to this GPE */ |
| 90 | |
| 91 | ACPI_CLEAR_BIT(enable_mask, |
| 92 | ((u32) 1 << |
| 93 | (gpe_event_info->gpe_number - |
| 94 | gpe_register_info->base_gpe_number))); |
| 95 | |
| 96 | /* Write the updated enable mask */ |
| 97 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 98 | status = acpi_write(enable_mask, &gpe_register_info->enable_address); |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 99 | return (status); |
| 100 | } |
| 101 | |
| 102 | /****************************************************************************** |
| 103 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | * FUNCTION: acpi_hw_write_gpe_enable_reg |
| 105 | * |
| 106 | * PARAMETERS: gpe_event_info - Info block for the GPE to be enabled |
| 107 | * |
| 108 | * RETURN: Status |
| 109 | * |
| 110 | * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must |
| 111 | * already be cleared or set in the parent register |
| 112 | * enable_for_run mask. |
| 113 | * |
| 114 | ******************************************************************************/ |
| 115 | |
| 116 | acpi_status |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 117 | acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 119 | struct acpi_gpe_register_info *gpe_register_info; |
| 120 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 122 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
| 124 | /* Get the info block for the entire GPE register */ |
| 125 | |
| 126 | gpe_register_info = gpe_event_info->register_info; |
| 127 | if (!gpe_register_info) { |
| 128 | return (AE_NOT_EXIST); |
| 129 | } |
| 130 | |
| 131 | /* Write the entire GPE (runtime) enable register */ |
| 132 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 133 | status = acpi_write(gpe_register_info->enable_for_run, |
| 134 | &gpe_register_info->enable_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
| 136 | return (status); |
| 137 | } |
| 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | /****************************************************************************** |
| 140 | * |
| 141 | * FUNCTION: acpi_hw_clear_gpe |
| 142 | * |
| 143 | * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared |
| 144 | * |
| 145 | * RETURN: Status |
| 146 | * |
| 147 | * DESCRIPTION: Clear the status bit for a single GPE. |
| 148 | * |
| 149 | ******************************************************************************/ |
| 150 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 151 | acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 153 | acpi_status status; |
Alexey Starikovskiy | 6987416 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 154 | u8 register_bit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 156 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Alexey Starikovskiy | 6987416 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 158 | register_bit = (u8) |
| 159 | (1 << |
| 160 | (gpe_event_info->gpe_number - |
| 161 | gpe_event_info->register_info->base_gpe_number)); |
| 162 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | /* |
| 164 | * Write a one to the appropriate bit in the status register to |
| 165 | * clear this GPE. |
| 166 | */ |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 167 | status = acpi_write(register_bit, |
| 168 | &gpe_event_info->register_info->status_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
| 170 | return (status); |
| 171 | } |
| 172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | /****************************************************************************** |
| 174 | * |
| 175 | * FUNCTION: acpi_hw_get_gpe_status |
| 176 | * |
| 177 | * PARAMETERS: gpe_event_info - Info block for the GPE to queried |
| 178 | * event_status - Where the GPE status is returned |
| 179 | * |
| 180 | * RETURN: Status |
| 181 | * |
| 182 | * DESCRIPTION: Return the status of a single GPE. |
| 183 | * |
| 184 | ******************************************************************************/ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 187 | acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, |
| 188 | acpi_event_status * event_status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 190 | u32 in_byte; |
| 191 | u8 register_bit; |
| 192 | struct acpi_gpe_register_info *gpe_register_info; |
| 193 | acpi_status status; |
| 194 | acpi_event_status local_event_status = 0; |
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 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | |
| 198 | if (!event_status) { |
| 199 | return (AE_BAD_PARAMETER); |
| 200 | } |
| 201 | |
| 202 | /* Get the info block for the entire GPE register */ |
| 203 | |
| 204 | gpe_register_info = gpe_event_info->register_info; |
| 205 | |
| 206 | /* Get the register bitmask for this GPE */ |
| 207 | |
Alexey Starikovskiy | 6987416 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 208 | register_bit = (u8) |
| 209 | (1 << |
| 210 | (gpe_event_info->gpe_number - |
| 211 | gpe_event_info->register_info->base_gpe_number)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | |
| 213 | /* GPE currently enabled? (enabled for runtime?) */ |
| 214 | |
| 215 | if (register_bit & gpe_register_info->enable_for_run) { |
| 216 | local_event_status |= ACPI_EVENT_FLAG_ENABLED; |
| 217 | } |
| 218 | |
| 219 | /* GPE enabled for wake? */ |
| 220 | |
| 221 | if (register_bit & gpe_register_info->enable_for_wake) { |
| 222 | local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED; |
| 223 | } |
| 224 | |
| 225 | /* GPE currently active (status bit == 1)? */ |
| 226 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 227 | status = acpi_read(&in_byte, &gpe_register_info->status_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 228 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | goto unlock_and_exit; |
| 230 | } |
| 231 | |
| 232 | if (register_bit & in_byte) { |
| 233 | local_event_status |= ACPI_EVENT_FLAG_SET; |
| 234 | } |
| 235 | |
| 236 | /* Set return value */ |
| 237 | |
| 238 | (*event_status) = local_event_status; |
| 239 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 240 | unlock_and_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | return (status); |
| 242 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | |
| 244 | /****************************************************************************** |
| 245 | * |
| 246 | * FUNCTION: acpi_hw_disable_gpe_block |
| 247 | * |
| 248 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info |
| 249 | * gpe_block - Gpe Block info |
| 250 | * |
| 251 | * RETURN: Status |
| 252 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 253 | * DESCRIPTION: Disable all GPEs within a single GPE block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | * |
| 255 | ******************************************************************************/ |
| 256 | |
| 257 | acpi_status |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 258 | acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
| 259 | struct acpi_gpe_block_info *gpe_block, void *context) |
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 | u32 i; |
| 262 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
| 264 | /* Examine each GPE Register within the block */ |
| 265 | |
| 266 | for (i = 0; i < gpe_block->register_count; i++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 267 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | /* Disable all GPEs in this register */ |
| 269 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 270 | status = |
| 271 | acpi_write(0x00, |
| 272 | &gpe_block->register_info[i].enable_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 273 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | return (status); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | return (AE_OK); |
| 279 | } |
| 280 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | /****************************************************************************** |
| 282 | * |
| 283 | * FUNCTION: acpi_hw_clear_gpe_block |
| 284 | * |
| 285 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info |
| 286 | * gpe_block - Gpe Block info |
| 287 | * |
| 288 | * RETURN: Status |
| 289 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 290 | * DESCRIPTION: Clear status bits for all GPEs within a single GPE block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | * |
| 292 | ******************************************************************************/ |
| 293 | |
| 294 | acpi_status |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 295 | acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
| 296 | struct acpi_gpe_block_info *gpe_block, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 298 | u32 i; |
| 299 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
| 301 | /* Examine each GPE Register within the block */ |
| 302 | |
| 303 | for (i = 0; i < gpe_block->register_count; i++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 304 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | /* Clear status on all GPEs in this register */ |
| 306 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 307 | status = |
| 308 | acpi_write(0xFF, |
| 309 | &gpe_block->register_info[i].status_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 310 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | return (status); |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | return (AE_OK); |
| 316 | } |
| 317 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | /****************************************************************************** |
| 319 | * |
| 320 | * FUNCTION: acpi_hw_enable_runtime_gpe_block |
| 321 | * |
| 322 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info |
| 323 | * gpe_block - Gpe Block info |
| 324 | * |
| 325 | * RETURN: Status |
| 326 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 327 | * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes |
| 328 | * combination wake/run GPEs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | * |
| 330 | ******************************************************************************/ |
| 331 | |
| 332 | acpi_status |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 333 | acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
| 334 | struct acpi_gpe_block_info *gpe_block, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 336 | u32 i; |
| 337 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
| 339 | /* NOTE: assumes that all GPEs are currently disabled */ |
| 340 | |
| 341 | /* Examine each GPE Register within the block */ |
| 342 | |
| 343 | for (i = 0; i < gpe_block->register_count; i++) { |
| 344 | if (!gpe_block->register_info[i].enable_for_run) { |
| 345 | continue; |
| 346 | } |
| 347 | |
| 348 | /* Enable all "runtime" GPEs in this register */ |
| 349 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 350 | status = acpi_write(gpe_block->register_info[i].enable_for_run, |
| 351 | &gpe_block->register_info[i]. |
| 352 | enable_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 353 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | return (status); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | return (AE_OK); |
| 359 | } |
| 360 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | /****************************************************************************** |
| 362 | * |
| 363 | * FUNCTION: acpi_hw_enable_wakeup_gpe_block |
| 364 | * |
| 365 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info |
| 366 | * gpe_block - Gpe Block info |
| 367 | * |
| 368 | * RETURN: Status |
| 369 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 370 | * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes |
| 371 | * combination wake/run GPEs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | * |
| 373 | ******************************************************************************/ |
| 374 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 375 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 376 | acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 377 | struct acpi_gpe_block_info *gpe_block, |
| 378 | void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 380 | u32 i; |
| 381 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | |
| 383 | /* Examine each GPE Register within the block */ |
| 384 | |
| 385 | for (i = 0; i < gpe_block->register_count; i++) { |
| 386 | if (!gpe_block->register_info[i].enable_for_wake) { |
| 387 | continue; |
| 388 | } |
| 389 | |
| 390 | /* Enable all "wake" GPEs in this register */ |
| 391 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 392 | status = acpi_write(gpe_block->register_info[i].enable_for_wake, |
| 393 | &gpe_block->register_info[i]. |
| 394 | enable_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 395 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | return (status); |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | return (AE_OK); |
| 401 | } |
| 402 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | /****************************************************************************** |
| 404 | * |
| 405 | * FUNCTION: acpi_hw_disable_all_gpes |
| 406 | * |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 407 | * PARAMETERS: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | * |
| 409 | * RETURN: Status |
| 410 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 411 | * DESCRIPTION: Disable and clear all GPEs in all GPE blocks |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | * |
| 413 | ******************************************************************************/ |
| 414 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 415 | acpi_status acpi_hw_disable_all_gpes(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 417 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 419 | ACPI_FUNCTION_TRACE(hw_disable_all_gpes); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 421 | status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL); |
| 422 | status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); |
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 | } |
| 425 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | /****************************************************************************** |
| 427 | * |
| 428 | * FUNCTION: acpi_hw_enable_all_runtime_gpes |
| 429 | * |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 430 | * PARAMETERS: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | * |
| 432 | * RETURN: Status |
| 433 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 434 | * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | * |
| 436 | ******************************************************************************/ |
| 437 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 438 | acpi_status acpi_hw_enable_all_runtime_gpes(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 440 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 442 | ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 444 | status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block, NULL); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 445 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | } |
| 447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | /****************************************************************************** |
| 449 | * |
| 450 | * FUNCTION: acpi_hw_enable_all_wakeup_gpes |
| 451 | * |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 452 | * PARAMETERS: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | * |
| 454 | * RETURN: Status |
| 455 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 456 | * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | * |
| 458 | ******************************************************************************/ |
| 459 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 460 | acpi_status acpi_hw_enable_all_wakeup_gpes(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 462 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 464 | ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 466 | status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 467 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | } |