blob: 76b0e350f5bb0de70f41d51db70deea785b12f84 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: hwgpe - Low level GPE enable/disable/clear functions
4 *
5 *****************************************************************************/
6
7/*
Bob Moorec8100dc2016-01-15 08:17:03 +08008 * Copyright (C) 2000 - 2016, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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 Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acevents.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48#define _COMPONENT ACPI_HARDWARE
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("hwgpe")
Bob Moore33620c52012-02-14 18:14:27 +080050#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
Robert Moore44f6c012005-04-18 22:49:35 -040051/* Local prototypes */
Robert Moore44f6c012005-04-18 22:49:35 -040052static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040053acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Bob Mooree97d6bf2008-12-30 09:45:17 +080054 struct acpi_gpe_block_info *gpe_block,
55 void *context);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Lv Zheng1c4c81a2015-02-05 15:19:48 +080057static acpi_status
58acpi_hw_gpe_enable_write(u8 enable_mask,
59 struct acpi_gpe_register_info *gpe_register_info);
60
Linus Torvalds1da177e2005-04-16 15:20:36 -070061/******************************************************************************
62 *
Lin Mingb76df672010-07-01 10:07:17 +080063 * FUNCTION: acpi_hw_get_gpe_register_bit
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020064 *
65 * PARAMETERS: gpe_event_info - Info block for the GPE
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020066 *
Lin Mingda503372010-12-13 13:39:37 +080067 * RETURN: Register mask with a one in the GPE bit position
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020068 *
Lin Mingda503372010-12-13 13:39:37 +080069 * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
70 * correct position for the input GPE.
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020071 *
72 ******************************************************************************/
73
Feng Tang1d94e1e2012-08-17 11:10:02 +080074u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info)
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020075{
Lv Zheng9c0d7932012-12-19 05:37:21 +000076
77 return ((u32)1 <<
78 (gpe_event_info->gpe_number -
79 gpe_event_info->register_info->base_gpe_number));
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020080}
81
82/******************************************************************************
83 *
Rafael J. Wysockifd247442010-06-08 10:49:08 +020084 * FUNCTION: acpi_hw_low_set_gpe
Bob Mooree38e8a02008-06-13 08:28:55 +080085 *
86 * PARAMETERS: gpe_event_info - Info block for the GPE to be disabled
Rafael J. Wysockifd247442010-06-08 10:49:08 +020087 * action - Enable or disable
Bob Mooree38e8a02008-06-13 08:28:55 +080088 *
89 * RETURN: Status
90 *
Lin Mingda503372010-12-13 13:39:37 +080091 * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
Rafael J. Wysocki0ee0d342015-04-15 04:00:27 +020092 * The enable_mask field of the involved GPE register must be
93 * updated by the caller if necessary.
Bob Mooree38e8a02008-06-13 08:28:55 +080094 *
95 ******************************************************************************/
96
Rafael J. Wysockifd247442010-06-08 10:49:08 +020097acpi_status
Lin Mingda503372010-12-13 13:39:37 +080098acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
Bob Mooree38e8a02008-06-13 08:28:55 +080099{
100 struct acpi_gpe_register_info *gpe_register_info;
Lv Zheng2af52c22016-08-04 16:43:39 +0800101 acpi_status status = AE_OK;
Bob Mooree38e8a02008-06-13 08:28:55 +0800102 u32 enable_mask;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200103 u32 register_bit;
Bob Mooree38e8a02008-06-13 08:28:55 +0800104
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200105 ACPI_FUNCTION_ENTRY();
106
Bob Mooree38e8a02008-06-13 08:28:55 +0800107 /* 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 Moorec6b57742009-06-24 09:44:06 +0800116 status = acpi_hw_read(&enable_mask, &gpe_register_info->enable_address);
Bob Mooree38e8a02008-06-13 08:28:55 +0800117 if (ACPI_FAILURE(status)) {
118 return (status);
119 }
120
Lin Mingda503372010-12-13 13:39:37 +0800121 /* Set or clear just the bit that corresponds to this GPE */
Bob Mooree38e8a02008-06-13 08:28:55 +0800122
Feng Tang1d94e1e2012-08-17 11:10:02 +0800123 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Rafael J. Wysocki0ee0d342015-04-15 04:00:27 +0200124 switch (action) {
Lin Ming3a378982010-12-13 13:36:15 +0800125 case ACPI_GPE_CONDITIONAL_ENABLE:
Lin Mingda503372010-12-13 13:39:37 +0800126
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100127 /* Only enable if the corresponding enable_mask bit is set */
Lin Mingda503372010-12-13 13:39:37 +0800128
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100129 if (!(register_bit & gpe_register_info->enable_mask)) {
Rafael J. Wysockic9a8bbb2010-06-08 10:49:45 +0200130 return (AE_BAD_PARAMETER);
Lin Mingda503372010-12-13 13:39:37 +0800131 }
132
133 /*lint -fallthrough */
Rafael J. Wysockic9a8bbb2010-06-08 10:49:45 +0200134
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200135 case ACPI_GPE_ENABLE:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000136
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200137 ACPI_SET_BIT(enable_mask, register_bit);
138 break;
139
140 case ACPI_GPE_DISABLE:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000141
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200142 ACPI_CLEAR_BIT(enable_mask, register_bit);
143 break;
144
145 default:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000146
Bob Moore5e30a962013-01-25 05:41:16 +0000147 ACPI_ERROR((AE_INFO, "Invalid GPE Action, %u", action));
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200148 return (AE_BAD_PARAMETER);
149 }
Bob Mooree38e8a02008-06-13 08:28:55 +0800150
Lv Zheng2af52c22016-08-04 16:43:39 +0800151 if (!(register_bit & gpe_register_info->mask_for_run)) {
Bob Mooree38e8a02008-06-13 08:28:55 +0800152
Lv Zheng2af52c22016-08-04 16:43:39 +0800153 /* Write the updated enable mask */
154
155 status =
156 acpi_hw_write(enable_mask,
157 &gpe_register_info->enable_address);
158 }
Bob Mooree38e8a02008-06-13 08:28:55 +0800159 return (status);
160}
161
162/******************************************************************************
163 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 * FUNCTION: acpi_hw_clear_gpe
165 *
166 * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared
167 *
168 * RETURN: Status
169 *
170 * DESCRIPTION: Clear the status bit for a single GPE.
171 *
172 ******************************************************************************/
173
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800174acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175{
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200176 struct acpi_gpe_register_info *gpe_register_info;
Len Brown4be44fc2005-08-05 00:44:28 -0400177 acpi_status status;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200178 u32 register_bit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
Len Brown4be44fc2005-08-05 00:44:28 -0400180 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200182 /* Get the info block for the entire GPE register */
183
184 gpe_register_info = gpe_event_info->register_info;
185 if (!gpe_register_info) {
186 return (AE_NOT_EXIST);
187 }
188
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 /*
190 * Write a one to the appropriate bit in the status register to
191 * clear this GPE.
192 */
Feng Tang1d94e1e2012-08-17 11:10:02 +0800193 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Lin Mingda503372010-12-13 13:39:37 +0800194
Bob Moore1fad8732015-12-29 13:54:36 +0800195 status =
196 acpi_hw_write(register_bit, &gpe_register_info->status_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 return (status);
198}
199
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200/******************************************************************************
201 *
202 * FUNCTION: acpi_hw_get_gpe_status
203 *
204 * PARAMETERS: gpe_event_info - Info block for the GPE to queried
205 * event_status - Where the GPE status is returned
206 *
207 * RETURN: Status
208 *
209 * DESCRIPTION: Return the status of a single GPE.
210 *
211 ******************************************************************************/
Robert Moore44f6c012005-04-18 22:49:35 -0400212
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213acpi_status
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800214acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,
Lv Zhengf19f1a72014-10-10 10:39:39 +0800215 acpi_event_status *event_status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216{
Len Brown4be44fc2005-08-05 00:44:28 -0400217 u32 in_byte;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200218 u32 register_bit;
Len Brown4be44fc2005-08-05 00:44:28 -0400219 struct acpi_gpe_register_info *gpe_register_info;
Len Brown4be44fc2005-08-05 00:44:28 -0400220 acpi_event_status local_event_status = 0;
Lin Mingda503372010-12-13 13:39:37 +0800221 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
Len Brown4be44fc2005-08-05 00:44:28 -0400223 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
225 if (!event_status) {
226 return (AE_BAD_PARAMETER);
227 }
228
Lv Zhenga08f8132014-10-10 10:39:57 +0800229 /* GPE currently handled? */
230
Lv Zheng7c433122015-02-05 15:20:29 +0800231 if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) !=
Lv Zhenga08f8132014-10-10 10:39:57 +0800232 ACPI_GPE_DISPATCH_NONE) {
Lv Zheng2f857232014-10-10 10:40:05 +0800233 local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER;
Lv Zhenga08f8132014-10-10 10:39:57 +0800234 }
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 /* Get the info block for the entire GPE register */
237
238 gpe_register_info = gpe_event_info->register_info;
239
240 /* Get the register bitmask for this GPE */
241
Feng Tang1d94e1e2012-08-17 11:10:02 +0800242 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
244 /* GPE currently enabled? (enabled for runtime?) */
245
246 if (register_bit & gpe_register_info->enable_for_run) {
247 local_event_status |= ACPI_EVENT_FLAG_ENABLED;
248 }
249
Lv Zheng2af52c22016-08-04 16:43:39 +0800250 /* GPE currently masked? (masked for runtime?) */
251
252 if (register_bit & gpe_register_info->mask_for_run) {
253 local_event_status |= ACPI_EVENT_FLAG_MASKED;
254 }
255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 /* GPE enabled for wake? */
257
258 if (register_bit & gpe_register_info->enable_for_wake) {
259 local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED;
260 }
261
Lv Zheng09af8e82015-04-13 11:49:13 +0800262 /* GPE currently enabled (enable bit == 1)? */
263
264 status = acpi_hw_read(&in_byte, &gpe_register_info->enable_address);
265 if (ACPI_FAILURE(status)) {
266 return (status);
267 }
268
269 if (register_bit & in_byte) {
270 local_event_status |= ACPI_EVENT_FLAG_ENABLE_SET;
271 }
272
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 /* GPE currently active (status bit == 1)? */
274
Bob Moorec6b57742009-06-24 09:44:06 +0800275 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400276 if (ACPI_FAILURE(status)) {
Bob Moore2147d3f2010-01-21 09:08:31 +0800277 return (status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 }
279
280 if (register_bit & in_byte) {
Lv Zheng09af8e82015-04-13 11:49:13 +0800281 local_event_status |= ACPI_EVENT_FLAG_STATUS_SET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 }
283
284 /* Set return value */
285
286 (*event_status) = local_event_status;
Bob Moore2147d3f2010-01-21 09:08:31 +0800287 return (AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
290/******************************************************************************
291 *
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100292 * FUNCTION: acpi_hw_gpe_enable_write
293 *
294 * PARAMETERS: enable_mask - Bit mask to write to the GPE register
295 * gpe_register_info - Gpe Register info
296 *
297 * RETURN: Status
298 *
299 * DESCRIPTION: Write the enable mask byte to the given GPE register.
300 *
301 ******************************************************************************/
302
303static acpi_status
304acpi_hw_gpe_enable_write(u8 enable_mask,
305 struct acpi_gpe_register_info *gpe_register_info)
306{
307 acpi_status status;
308
Rafael J. Wysocki0ee0d342015-04-15 04:00:27 +0200309 gpe_register_info->enable_mask = enable_mask;
Lv Zheng5431b652015-12-29 13:52:32 +0800310
Bob Moore1fad8732015-12-29 13:54:36 +0800311 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100312 return (status);
313}
314
315/******************************************************************************
316 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 * FUNCTION: acpi_hw_disable_gpe_block
318 *
319 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
320 * gpe_block - Gpe Block info
321 *
322 * RETURN: Status
323 *
Robert Moore44f6c012005-04-18 22:49:35 -0400324 * DESCRIPTION: Disable all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 *
326 ******************************************************************************/
327
328acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800329acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
330 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
Len Brown4be44fc2005-08-05 00:44:28 -0400332 u32 i;
333 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
335 /* Examine each GPE Register within the block */
336
337 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400338
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 /* Disable all GPEs in this register */
340
Bob Mooreecfbbc72008-12-31 02:55:32 +0800341 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100342 acpi_hw_gpe_enable_write(0x00,
343 &gpe_block->register_info[i]);
Len Brown4be44fc2005-08-05 00:44:28 -0400344 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 return (status);
346 }
347 }
348
349 return (AE_OK);
350}
351
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352/******************************************************************************
353 *
354 * FUNCTION: acpi_hw_clear_gpe_block
355 *
356 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
357 * gpe_block - Gpe Block info
358 *
359 * RETURN: Status
360 *
Robert Moore44f6c012005-04-18 22:49:35 -0400361 * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 *
363 ******************************************************************************/
364
365acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800366acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
367 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368{
Len Brown4be44fc2005-08-05 00:44:28 -0400369 u32 i;
370 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
372 /* Examine each GPE Register within the block */
373
374 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400375
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 /* Clear status on all GPEs in this register */
377
Bob Mooreecfbbc72008-12-31 02:55:32 +0800378 status =
Bob Moorec6b57742009-06-24 09:44:06 +0800379 acpi_hw_write(0xFF,
380 &gpe_block->register_info[i].status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400381 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 return (status);
383 }
384 }
385
386 return (AE_OK);
387}
388
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389/******************************************************************************
390 *
391 * FUNCTION: acpi_hw_enable_runtime_gpe_block
392 *
393 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
394 * gpe_block - Gpe Block info
395 *
396 * RETURN: Status
397 *
Robert Moore44f6c012005-04-18 22:49:35 -0400398 * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
399 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 *
401 ******************************************************************************/
402
403acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800404acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800405 struct acpi_gpe_block_info *gpe_block,
Lv Zheng1f86e8c2012-10-31 02:25:45 +0000406 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407{
Len Brown4be44fc2005-08-05 00:44:28 -0400408 u32 i;
409 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100410 struct acpi_gpe_register_info *gpe_register_info;
Lv Zheng2af52c22016-08-04 16:43:39 +0800411 u8 enable_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
413 /* NOTE: assumes that all GPEs are currently disabled */
414
415 /* Examine each GPE Register within the block */
416
417 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100418 gpe_register_info = &gpe_block->register_info[i];
419 if (!gpe_register_info->enable_for_run) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 continue;
421 }
422
423 /* Enable all "runtime" GPEs in this register */
424
Lv Zheng2af52c22016-08-04 16:43:39 +0800425 enable_mask = gpe_register_info->enable_for_run &
426 ~gpe_register_info->mask_for_run;
Bob Moorec6b57742009-06-24 09:44:06 +0800427 status =
Lv Zheng2af52c22016-08-04 16:43:39 +0800428 acpi_hw_gpe_enable_write(enable_mask, gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400429 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 return (status);
431 }
432 }
433
434 return (AE_OK);
435}
436
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437/******************************************************************************
438 *
439 * FUNCTION: acpi_hw_enable_wakeup_gpe_block
440 *
441 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
442 * gpe_block - Gpe Block info
443 *
444 * RETURN: Status
445 *
Robert Moore44f6c012005-04-18 22:49:35 -0400446 * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
447 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 *
449 ******************************************************************************/
450
Robert Moore44f6c012005-04-18 22:49:35 -0400451static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400452acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Bob Mooree97d6bf2008-12-30 09:45:17 +0800453 struct acpi_gpe_block_info *gpe_block,
454 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455{
Len Brown4be44fc2005-08-05 00:44:28 -0400456 u32 i;
457 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100458 struct acpi_gpe_register_info *gpe_register_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459
460 /* Examine each GPE Register within the block */
461
462 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100463 gpe_register_info = &gpe_block->register_info[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464
Rafael J. Wysocki5a0b8de2014-09-30 02:24:38 +0200465 /*
466 * Enable all "wake" GPEs in this register and disable the
467 * remaining ones.
468 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
Bob Moorec6b57742009-06-24 09:44:06 +0800470 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100471 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_wake,
472 gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400473 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 return (status);
475 }
476 }
477
478 return (AE_OK);
479}
480
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481/******************************************************************************
482 *
483 * FUNCTION: acpi_hw_disable_all_gpes
484 *
Robert Moore73459f72005-06-24 00:00:00 -0400485 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 *
487 * RETURN: Status
488 *
Robert Moore44f6c012005-04-18 22:49:35 -0400489 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 *
491 ******************************************************************************/
492
Len Brown4be44fc2005-08-05 00:44:28 -0400493acpi_status acpi_hw_disable_all_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494{
Len Brown4be44fc2005-08-05 00:44:28 -0400495 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496
Bob Mooreb229cf92006-04-21 17:15:00 -0400497 ACPI_FUNCTION_TRACE(hw_disable_all_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
Bob Mooree97d6bf2008-12-30 09:45:17 +0800499 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
500 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400501 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502}
503
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504/******************************************************************************
505 *
506 * FUNCTION: acpi_hw_enable_all_runtime_gpes
507 *
Robert Moore73459f72005-06-24 00:00:00 -0400508 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 *
510 * RETURN: Status
511 *
Robert Moore44f6c012005-04-18 22:49:35 -0400512 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 *
514 ******************************************************************************/
515
Len Brown4be44fc2005-08-05 00:44:28 -0400516acpi_status acpi_hw_enable_all_runtime_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517{
Len Brown4be44fc2005-08-05 00:44:28 -0400518 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519
Bob Mooreb229cf92006-04-21 17:15:00 -0400520 ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521
Bob Mooree97d6bf2008-12-30 09:45:17 +0800522 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400523 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524}
525
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526/******************************************************************************
527 *
528 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
529 *
Robert Moore73459f72005-06-24 00:00:00 -0400530 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 *
532 * RETURN: Status
533 *
Robert Moore44f6c012005-04-18 22:49:35 -0400534 * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 *
536 ******************************************************************************/
537
Len Brown4be44fc2005-08-05 00:44:28 -0400538acpi_status acpi_hw_enable_all_wakeup_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539{
Len Brown4be44fc2005-08-05 00:44:28 -0400540 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541
Bob Mooreb229cf92006-04-21 17:15:00 -0400542 ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543
Bob Mooree97d6bf2008-12-30 09:45:17 +0800544 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400545 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546}
Bob Moore33620c52012-02-14 18:14:27 +0800547
548#endif /* !ACPI_REDUCED_HARDWARE */