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