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 | /* |
Bob Moore | a8357b0 | 2010-01-22 19:07:36 +0800 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2010, 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> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 46 | #include "accommon.h" |
| 47 | #include "acevents.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | #define _COMPONENT ACPI_HARDWARE |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("hwgpe") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 52 | /* Local prototypes */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 53 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 54 | 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] | 55 | struct acpi_gpe_block_info *gpe_block, |
| 56 | void *context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | /****************************************************************************** |
| 59 | * |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 60 | * FUNCTION: acpi_hw_gpe_register_bit |
| 61 | * |
| 62 | * PARAMETERS: gpe_event_info - Info block for the GPE |
| 63 | * gpe_register_info - Info block for the GPE register |
| 64 | * |
| 65 | * RETURN: Status |
| 66 | * |
| 67 | * DESCRIPTION: Compute GPE enable mask with one bit corresponding to the given |
| 68 | * GPE set. |
| 69 | * |
| 70 | ******************************************************************************/ |
| 71 | |
| 72 | u32 acpi_hw_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info, |
| 73 | struct acpi_gpe_register_info *gpe_register_info) |
| 74 | { |
| 75 | return (u32)1 << (gpe_event_info->gpe_number - |
| 76 | gpe_register_info->base_gpe_number); |
| 77 | } |
| 78 | |
| 79 | /****************************************************************************** |
| 80 | * |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 81 | * FUNCTION: acpi_hw_low_set_gpe |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 82 | * |
| 83 | * PARAMETERS: gpe_event_info - Info block for the GPE to be disabled |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 84 | * action - Enable or disable |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 85 | * |
| 86 | * RETURN: Status |
| 87 | * |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 88 | * DESCRIPTION: Enable or disable a single GPE in its enable register. |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 89 | * |
| 90 | ******************************************************************************/ |
| 91 | |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 92 | acpi_status |
| 93 | acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u8 action) |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 94 | { |
| 95 | struct acpi_gpe_register_info *gpe_register_info; |
| 96 | acpi_status status; |
| 97 | u32 enable_mask; |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 98 | u32 register_bit; |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 99 | |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 100 | ACPI_FUNCTION_ENTRY(); |
| 101 | |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 102 | /* Get the info block for the entire GPE register */ |
| 103 | |
| 104 | gpe_register_info = gpe_event_info->register_info; |
| 105 | if (!gpe_register_info) { |
| 106 | return (AE_NOT_EXIST); |
| 107 | } |
| 108 | |
| 109 | /* Get current value of the enable register that contains this GPE */ |
| 110 | |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 111 | status = acpi_hw_read(&enable_mask, &gpe_register_info->enable_address); |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 112 | if (ACPI_FAILURE(status)) { |
| 113 | return (status); |
| 114 | } |
| 115 | |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 116 | /* Set ot clear just the bit that corresponds to this GPE */ |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 117 | |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 118 | register_bit = acpi_hw_gpe_register_bit(gpe_event_info, |
| 119 | gpe_register_info); |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 120 | switch (action) { |
Rafael J. Wysocki | c9a8bbb | 2010-06-08 10:49:45 +0200 | [diff] [blame^] | 121 | case ACPI_GPE_COND_ENABLE: |
| 122 | if (!(register_bit & gpe_register_info->enable_for_run)) |
| 123 | return (AE_BAD_PARAMETER); |
| 124 | |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 125 | case ACPI_GPE_ENABLE: |
| 126 | ACPI_SET_BIT(enable_mask, register_bit); |
| 127 | break; |
| 128 | |
| 129 | case ACPI_GPE_DISABLE: |
| 130 | ACPI_CLEAR_BIT(enable_mask, register_bit); |
| 131 | break; |
| 132 | |
| 133 | default: |
| 134 | ACPI_ERROR((AE_INFO, "Invalid action\n")); |
| 135 | return (AE_BAD_PARAMETER); |
| 136 | } |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 137 | |
| 138 | /* Write the updated enable mask */ |
| 139 | |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 140 | status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address); |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 141 | return (status); |
| 142 | } |
| 143 | |
| 144 | /****************************************************************************** |
| 145 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | * FUNCTION: acpi_hw_write_gpe_enable_reg |
| 147 | * |
| 148 | * PARAMETERS: gpe_event_info - Info block for the GPE to be enabled |
| 149 | * |
| 150 | * RETURN: Status |
| 151 | * |
| 152 | * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must |
| 153 | * already be cleared or set in the parent register |
| 154 | * enable_for_run mask. |
| 155 | * |
| 156 | ******************************************************************************/ |
| 157 | |
| 158 | acpi_status |
Bob Moore | e38e8a0 | 2008-06-13 08:28:55 +0800 | [diff] [blame] | 159 | 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] | 160 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 161 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 163 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
Rafael J. Wysocki | c9a8bbb | 2010-06-08 10:49:45 +0200 | [diff] [blame^] | 165 | status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_COND_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | return (status); |
| 167 | } |
| 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | /****************************************************************************** |
| 170 | * |
| 171 | * FUNCTION: acpi_hw_clear_gpe |
| 172 | * |
| 173 | * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared |
| 174 | * |
| 175 | * RETURN: Status |
| 176 | * |
| 177 | * DESCRIPTION: Clear the status bit for a single GPE. |
| 178 | * |
| 179 | ******************************************************************************/ |
| 180 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 181 | 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] | 182 | { |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 183 | struct acpi_gpe_register_info *gpe_register_info; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 184 | acpi_status status; |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 185 | u32 register_bit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 187 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 189 | /* Get the info block for the entire GPE register */ |
| 190 | |
| 191 | gpe_register_info = gpe_event_info->register_info; |
| 192 | if (!gpe_register_info) { |
| 193 | return (AE_NOT_EXIST); |
| 194 | } |
| 195 | |
| 196 | register_bit = acpi_hw_gpe_register_bit(gpe_event_info, |
| 197 | gpe_register_info); |
Alexey Starikovskiy | 6987416 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 198 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | /* |
| 200 | * Write a one to the appropriate bit in the status register to |
| 201 | * clear this GPE. |
| 202 | */ |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 203 | status = acpi_hw_write(register_bit, |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 204 | &gpe_register_info->status_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | |
| 206 | return (status); |
| 207 | } |
| 208 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | /****************************************************************************** |
| 210 | * |
| 211 | * FUNCTION: acpi_hw_get_gpe_status |
| 212 | * |
| 213 | * PARAMETERS: gpe_event_info - Info block for the GPE to queried |
| 214 | * event_status - Where the GPE status is returned |
| 215 | * |
| 216 | * RETURN: Status |
| 217 | * |
| 218 | * DESCRIPTION: Return the status of a single GPE. |
| 219 | * |
| 220 | ******************************************************************************/ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 223 | acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, |
| 224 | acpi_event_status * event_status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 226 | u32 in_byte; |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 227 | u32 register_bit; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 228 | struct acpi_gpe_register_info *gpe_register_info; |
| 229 | acpi_status status; |
| 230 | acpi_event_status local_event_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | |
| 234 | if (!event_status) { |
| 235 | return (AE_BAD_PARAMETER); |
| 236 | } |
| 237 | |
| 238 | /* Get the info block for the entire GPE register */ |
| 239 | |
| 240 | gpe_register_info = gpe_event_info->register_info; |
| 241 | |
| 242 | /* Get the register bitmask for this GPE */ |
| 243 | |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 244 | register_bit = acpi_hw_gpe_register_bit(gpe_event_info, |
| 245 | gpe_register_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
| 247 | /* GPE currently enabled? (enabled for runtime?) */ |
| 248 | |
| 249 | if (register_bit & gpe_register_info->enable_for_run) { |
| 250 | local_event_status |= ACPI_EVENT_FLAG_ENABLED; |
| 251 | } |
| 252 | |
| 253 | /* GPE enabled for wake? */ |
| 254 | |
| 255 | if (register_bit & gpe_register_info->enable_for_wake) { |
| 256 | local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED; |
| 257 | } |
| 258 | |
| 259 | /* GPE currently active (status bit == 1)? */ |
| 260 | |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 261 | status = acpi_hw_read(&in_byte, &gpe_register_info->status_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 262 | if (ACPI_FAILURE(status)) { |
Bob Moore | 2147d3f | 2010-01-21 09:08:31 +0800 | [diff] [blame] | 263 | return (status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | if (register_bit & in_byte) { |
| 267 | local_event_status |= ACPI_EVENT_FLAG_SET; |
| 268 | } |
| 269 | |
| 270 | /* Set return value */ |
| 271 | |
| 272 | (*event_status) = local_event_status; |
Bob Moore | 2147d3f | 2010-01-21 09:08:31 +0800 | [diff] [blame] | 273 | return (AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
| 276 | /****************************************************************************** |
| 277 | * |
| 278 | * FUNCTION: acpi_hw_disable_gpe_block |
| 279 | * |
| 280 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info |
| 281 | * gpe_block - Gpe Block info |
| 282 | * |
| 283 | * RETURN: Status |
| 284 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 285 | * DESCRIPTION: Disable all GPEs within a single GPE block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | * |
| 287 | ******************************************************************************/ |
| 288 | |
| 289 | acpi_status |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 290 | acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
| 291 | struct acpi_gpe_block_info *gpe_block, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 293 | u32 i; |
| 294 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
| 296 | /* Examine each GPE Register within the block */ |
| 297 | |
| 298 | for (i = 0; i < gpe_block->register_count; i++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 299 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | /* Disable all GPEs in this register */ |
| 301 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame] | 302 | status = |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 303 | acpi_hw_write(0x00, |
| 304 | &gpe_block->register_info[i].enable_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 305 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | return (status); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | return (AE_OK); |
| 311 | } |
| 312 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | /****************************************************************************** |
| 314 | * |
| 315 | * FUNCTION: acpi_hw_clear_gpe_block |
| 316 | * |
| 317 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info |
| 318 | * gpe_block - Gpe Block info |
| 319 | * |
| 320 | * RETURN: Status |
| 321 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 322 | * DESCRIPTION: Clear status bits for all GPEs within a single GPE block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | * |
| 324 | ******************************************************************************/ |
| 325 | |
| 326 | acpi_status |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 327 | acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
| 328 | struct acpi_gpe_block_info *gpe_block, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 330 | u32 i; |
| 331 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | /* Examine each GPE Register within the block */ |
| 334 | |
| 335 | for (i = 0; i < gpe_block->register_count; i++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | /* Clear status on all GPEs in this register */ |
| 338 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame] | 339 | status = |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 340 | acpi_hw_write(0xFF, |
| 341 | &gpe_block->register_info[i].status_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 342 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | return (status); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | return (AE_OK); |
| 348 | } |
| 349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | /****************************************************************************** |
| 351 | * |
| 352 | * FUNCTION: acpi_hw_enable_runtime_gpe_block |
| 353 | * |
| 354 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info |
| 355 | * gpe_block - Gpe Block info |
| 356 | * |
| 357 | * RETURN: Status |
| 358 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 359 | * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes |
| 360 | * combination wake/run GPEs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | * |
| 362 | ******************************************************************************/ |
| 363 | |
| 364 | acpi_status |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 365 | acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
| 366 | struct acpi_gpe_block_info *gpe_block, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 368 | u32 i; |
| 369 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | |
| 371 | /* NOTE: assumes that all GPEs are currently disabled */ |
| 372 | |
| 373 | /* Examine each GPE Register within the block */ |
| 374 | |
| 375 | for (i = 0; i < gpe_block->register_count; i++) { |
| 376 | if (!gpe_block->register_info[i].enable_for_run) { |
| 377 | continue; |
| 378 | } |
| 379 | |
| 380 | /* Enable all "runtime" GPEs in this register */ |
| 381 | |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 382 | status = |
| 383 | acpi_hw_write(gpe_block->register_info[i].enable_for_run, |
| 384 | &gpe_block->register_info[i].enable_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 385 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | return (status); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | return (AE_OK); |
| 391 | } |
| 392 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | /****************************************************************************** |
| 394 | * |
| 395 | * FUNCTION: acpi_hw_enable_wakeup_gpe_block |
| 396 | * |
| 397 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info |
| 398 | * gpe_block - Gpe Block info |
| 399 | * |
| 400 | * RETURN: Status |
| 401 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 402 | * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes |
| 403 | * combination wake/run GPEs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | * |
| 405 | ******************************************************************************/ |
| 406 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 407 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 408 | 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] | 409 | struct acpi_gpe_block_info *gpe_block, |
| 410 | void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 412 | u32 i; |
| 413 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | |
| 415 | /* Examine each GPE Register within the block */ |
| 416 | |
| 417 | for (i = 0; i < gpe_block->register_count; i++) { |
| 418 | if (!gpe_block->register_info[i].enable_for_wake) { |
| 419 | continue; |
| 420 | } |
| 421 | |
| 422 | /* Enable all "wake" GPEs in this register */ |
| 423 | |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 424 | status = |
| 425 | acpi_hw_write(gpe_block->register_info[i].enable_for_wake, |
| 426 | &gpe_block->register_info[i].enable_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 427 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | return (status); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | return (AE_OK); |
| 433 | } |
| 434 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | /****************************************************************************** |
| 436 | * |
| 437 | * FUNCTION: acpi_hw_disable_all_gpes |
| 438 | * |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 439 | * PARAMETERS: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | * |
| 441 | * RETURN: Status |
| 442 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 443 | * DESCRIPTION: Disable and clear all GPEs in all GPE blocks |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | * |
| 445 | ******************************************************************************/ |
| 446 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 447 | acpi_status acpi_hw_disable_all_gpes(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 449 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 451 | ACPI_FUNCTION_TRACE(hw_disable_all_gpes); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 453 | status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL); |
| 454 | status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 455 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | } |
| 457 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | /****************************************************************************** |
| 459 | * |
| 460 | * FUNCTION: acpi_hw_enable_all_runtime_gpes |
| 461 | * |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 462 | * PARAMETERS: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | * |
| 464 | * RETURN: Status |
| 465 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 466 | * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | * |
| 468 | ******************************************************************************/ |
| 469 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 470 | acpi_status acpi_hw_enable_all_runtime_gpes(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 472 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 474 | ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 476 | 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] | 477 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | } |
| 479 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | /****************************************************************************** |
| 481 | * |
| 482 | * FUNCTION: acpi_hw_enable_all_wakeup_gpes |
| 483 | * |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 484 | * PARAMETERS: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | * |
| 486 | * RETURN: Status |
| 487 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 488 | * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | * |
| 490 | ******************************************************************************/ |
| 491 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 492 | acpi_status acpi_hw_enable_all_wakeup_gpes(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 494 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 496 | ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 498 | 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] | 499 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | } |