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