blob: d7be3cbff1518a80a2344a2cf8d67b44575edb51 [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/*
David E. Box82a80942015-02-05 15:20:45 +08008 * Copyright (C) 2000 - 2015, 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.
Bob Mooree38e8a02008-06-13 08:28:55 +080092 *
93 ******************************************************************************/
94
Rafael J. Wysockifd247442010-06-08 10:49:08 +020095acpi_status
Lin Mingda503372010-12-13 13:39:37 +080096acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
Bob Mooree38e8a02008-06-13 08:28:55 +080097{
98 struct acpi_gpe_register_info *gpe_register_info;
99 acpi_status status;
100 u32 enable_mask;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200101 u32 register_bit;
Bob Mooree38e8a02008-06-13 08:28:55 +0800102
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200103 ACPI_FUNCTION_ENTRY();
104
Bob Mooree38e8a02008-06-13 08:28:55 +0800105 /* Get the info block for the entire GPE register */
106
107 gpe_register_info = gpe_event_info->register_info;
108 if (!gpe_register_info) {
109 return (AE_NOT_EXIST);
110 }
111
112 /* Get current value of the enable register that contains this GPE */
113
Bob Moorec6b57742009-06-24 09:44:06 +0800114 status = acpi_hw_read(&enable_mask, &gpe_register_info->enable_address);
Bob Mooree38e8a02008-06-13 08:28:55 +0800115 if (ACPI_FAILURE(status)) {
116 return (status);
117 }
118
Lin Mingda503372010-12-13 13:39:37 +0800119 /* Set or clear just the bit that corresponds to this GPE */
Bob Mooree38e8a02008-06-13 08:28:55 +0800120
Feng Tang1d94e1e2012-08-17 11:10:02 +0800121 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100122 switch (action & ~ACPI_GPE_SAVE_MASK) {
Lin Ming3a378982010-12-13 13:36:15 +0800123 case ACPI_GPE_CONDITIONAL_ENABLE:
Lin Mingda503372010-12-13 13:39:37 +0800124
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100125 /* Only enable if the corresponding enable_mask bit is set */
Lin Mingda503372010-12-13 13:39:37 +0800126
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100127 if (!(register_bit & gpe_register_info->enable_mask)) {
Rafael J. Wysockic9a8bbb2010-06-08 10:49:45 +0200128 return (AE_BAD_PARAMETER);
Lin Mingda503372010-12-13 13:39:37 +0800129 }
130
131 /*lint -fallthrough */
Rafael J. Wysockic9a8bbb2010-06-08 10:49:45 +0200132
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200133 case ACPI_GPE_ENABLE:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000134
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200135 ACPI_SET_BIT(enable_mask, register_bit);
136 break;
137
138 case ACPI_GPE_DISABLE:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000139
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200140 ACPI_CLEAR_BIT(enable_mask, register_bit);
141 break;
142
143 default:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000144
Bob Moore5e30a962013-01-25 05:41:16 +0000145 ACPI_ERROR((AE_INFO, "Invalid GPE Action, %u", action));
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200146 return (AE_BAD_PARAMETER);
147 }
Bob Mooree38e8a02008-06-13 08:28:55 +0800148
149 /* Write the updated enable mask */
150
Bob Moorec6b57742009-06-24 09:44:06 +0800151 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100152 if (ACPI_SUCCESS(status) && (action & ACPI_GPE_SAVE_MASK)) {
David E. Boxd6c02662015-02-05 15:20:38 +0800153 gpe_register_info->enable_mask = (u8)enable_mask;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100154 }
Bob Mooree38e8a02008-06-13 08:28:55 +0800155 return (status);
156}
157
158/******************************************************************************
159 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 * FUNCTION: acpi_hw_clear_gpe
161 *
162 * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared
163 *
164 * RETURN: Status
165 *
166 * DESCRIPTION: Clear the status bit for a single GPE.
167 *
168 ******************************************************************************/
169
Len Brown4be44fc2005-08-05 00:44:28 -0400170acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171{
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200172 struct acpi_gpe_register_info *gpe_register_info;
Len Brown4be44fc2005-08-05 00:44:28 -0400173 acpi_status status;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200174 u32 register_bit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
Len Brown4be44fc2005-08-05 00:44:28 -0400176 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200178 /* Get the info block for the entire GPE register */
179
180 gpe_register_info = gpe_event_info->register_info;
181 if (!gpe_register_info) {
182 return (AE_NOT_EXIST);
183 }
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 /*
186 * Write a one to the appropriate bit in the status register to
187 * clear this GPE.
188 */
Feng Tang1d94e1e2012-08-17 11:10:02 +0800189 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Lin Mingda503372010-12-13 13:39:37 +0800190
Bob Moorec6b57742009-06-24 09:44:06 +0800191 status = acpi_hw_write(register_bit,
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200192 &gpe_register_info->status_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
194 return (status);
195}
196
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197/******************************************************************************
198 *
199 * FUNCTION: acpi_hw_get_gpe_status
200 *
201 * PARAMETERS: gpe_event_info - Info block for the GPE to queried
202 * event_status - Where the GPE status is returned
203 *
204 * RETURN: Status
205 *
206 * DESCRIPTION: Return the status of a single GPE.
207 *
208 ******************************************************************************/
Robert Moore44f6c012005-04-18 22:49:35 -0400209
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400211acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
Lv Zhengf19f1a72014-10-10 10:39:39 +0800212 acpi_event_status *event_status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213{
Len Brown4be44fc2005-08-05 00:44:28 -0400214 u32 in_byte;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200215 u32 register_bit;
Len Brown4be44fc2005-08-05 00:44:28 -0400216 struct acpi_gpe_register_info *gpe_register_info;
Len Brown4be44fc2005-08-05 00:44:28 -0400217 acpi_event_status local_event_status = 0;
Lin Mingda503372010-12-13 13:39:37 +0800218 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Len Brown4be44fc2005-08-05 00:44:28 -0400220 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222 if (!event_status) {
223 return (AE_BAD_PARAMETER);
224 }
225
Lv Zhenga08f8132014-10-10 10:39:57 +0800226 /* GPE currently handled? */
227
Lv Zheng7c433122015-02-05 15:20:29 +0800228 if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) !=
Lv Zhenga08f8132014-10-10 10:39:57 +0800229 ACPI_GPE_DISPATCH_NONE) {
Lv Zheng2f857232014-10-10 10:40:05 +0800230 local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER;
Lv Zhenga08f8132014-10-10 10:39:57 +0800231 }
232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 /* Get the info block for the entire GPE register */
234
235 gpe_register_info = gpe_event_info->register_info;
236
237 /* Get the register bitmask for this GPE */
238
Feng Tang1d94e1e2012-08-17 11:10:02 +0800239 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
241 /* GPE currently enabled? (enabled for runtime?) */
242
243 if (register_bit & gpe_register_info->enable_for_run) {
244 local_event_status |= ACPI_EVENT_FLAG_ENABLED;
245 }
246
247 /* GPE enabled for wake? */
248
249 if (register_bit & gpe_register_info->enable_for_wake) {
250 local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED;
251 }
252
Lv Zheng09af8e82015-04-13 11:49:13 +0800253 /* GPE currently enabled (enable bit == 1)? */
254
255 status = acpi_hw_read(&in_byte, &gpe_register_info->enable_address);
256 if (ACPI_FAILURE(status)) {
257 return (status);
258 }
259
260 if (register_bit & in_byte) {
261 local_event_status |= ACPI_EVENT_FLAG_ENABLE_SET;
262 }
263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 /* GPE currently active (status bit == 1)? */
265
Bob Moorec6b57742009-06-24 09:44:06 +0800266 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400267 if (ACPI_FAILURE(status)) {
Bob Moore2147d3f2010-01-21 09:08:31 +0800268 return (status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 }
270
271 if (register_bit & in_byte) {
Lv Zheng09af8e82015-04-13 11:49:13 +0800272 local_event_status |= ACPI_EVENT_FLAG_STATUS_SET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 }
274
275 /* Set return value */
276
277 (*event_status) = local_event_status;
Bob Moore2147d3f2010-01-21 09:08:31 +0800278 return (AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
281/******************************************************************************
282 *
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100283 * FUNCTION: acpi_hw_gpe_enable_write
284 *
285 * PARAMETERS: enable_mask - Bit mask to write to the GPE register
286 * gpe_register_info - Gpe Register info
287 *
288 * RETURN: Status
289 *
290 * DESCRIPTION: Write the enable mask byte to the given GPE register.
291 *
292 ******************************************************************************/
293
294static acpi_status
295acpi_hw_gpe_enable_write(u8 enable_mask,
296 struct acpi_gpe_register_info *gpe_register_info)
297{
298 acpi_status status;
299
300 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
301 if (ACPI_SUCCESS(status)) {
302 gpe_register_info->enable_mask = enable_mask;
303 }
304 return (status);
305}
306
307/******************************************************************************
308 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 * FUNCTION: acpi_hw_disable_gpe_block
310 *
311 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
312 * gpe_block - Gpe Block info
313 *
314 * RETURN: Status
315 *
Robert Moore44f6c012005-04-18 22:49:35 -0400316 * DESCRIPTION: Disable all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 *
318 ******************************************************************************/
319
320acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800321acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
322 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323{
Len Brown4be44fc2005-08-05 00:44:28 -0400324 u32 i;
325 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
327 /* Examine each GPE Register within the block */
328
329 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400330
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 /* Disable all GPEs in this register */
332
Bob Mooreecfbbc72008-12-31 02:55:32 +0800333 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100334 acpi_hw_gpe_enable_write(0x00,
335 &gpe_block->register_info[i]);
Len Brown4be44fc2005-08-05 00:44:28 -0400336 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 return (status);
338 }
339 }
340
341 return (AE_OK);
342}
343
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344/******************************************************************************
345 *
346 * FUNCTION: acpi_hw_clear_gpe_block
347 *
348 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
349 * gpe_block - Gpe Block info
350 *
351 * RETURN: Status
352 *
Robert Moore44f6c012005-04-18 22:49:35 -0400353 * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 *
355 ******************************************************************************/
356
357acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800358acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
359 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360{
Len Brown4be44fc2005-08-05 00:44:28 -0400361 u32 i;
362 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363
364 /* Examine each GPE Register within the block */
365
366 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400367
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 /* Clear status on all GPEs in this register */
369
Bob Mooreecfbbc72008-12-31 02:55:32 +0800370 status =
Bob Moorec6b57742009-06-24 09:44:06 +0800371 acpi_hw_write(0xFF,
372 &gpe_block->register_info[i].status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400373 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 return (status);
375 }
376 }
377
378 return (AE_OK);
379}
380
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381/******************************************************************************
382 *
383 * FUNCTION: acpi_hw_enable_runtime_gpe_block
384 *
385 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
386 * gpe_block - Gpe Block info
387 *
388 * RETURN: Status
389 *
Robert Moore44f6c012005-04-18 22:49:35 -0400390 * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
391 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 *
393 ******************************************************************************/
394
395acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800396acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Lv Zheng1f86e8c2012-10-31 02:25:45 +0000397 struct acpi_gpe_block_info * gpe_block,
398 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399{
Len Brown4be44fc2005-08-05 00:44:28 -0400400 u32 i;
401 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100402 struct acpi_gpe_register_info *gpe_register_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
404 /* NOTE: assumes that all GPEs are currently disabled */
405
406 /* Examine each GPE Register within the block */
407
408 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100409 gpe_register_info = &gpe_block->register_info[i];
410 if (!gpe_register_info->enable_for_run) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 continue;
412 }
413
414 /* Enable all "runtime" GPEs in this register */
415
Bob Moorec6b57742009-06-24 09:44:06 +0800416 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100417 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_run,
418 gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400419 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 return (status);
421 }
422 }
423
424 return (AE_OK);
425}
426
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427/******************************************************************************
428 *
429 * FUNCTION: acpi_hw_enable_wakeup_gpe_block
430 *
431 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
432 * gpe_block - Gpe Block info
433 *
434 * RETURN: Status
435 *
Robert Moore44f6c012005-04-18 22:49:35 -0400436 * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
437 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 *
439 ******************************************************************************/
440
Robert Moore44f6c012005-04-18 22:49:35 -0400441static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400442acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Bob Mooree97d6bf2008-12-30 09:45:17 +0800443 struct acpi_gpe_block_info *gpe_block,
444 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445{
Len Brown4be44fc2005-08-05 00:44:28 -0400446 u32 i;
447 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100448 struct acpi_gpe_register_info *gpe_register_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
450 /* Examine each GPE Register within the block */
451
452 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100453 gpe_register_info = &gpe_block->register_info[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
Rafael J. Wysocki5a0b8de2014-09-30 02:24:38 +0200455 /*
456 * Enable all "wake" GPEs in this register and disable the
457 * remaining ones.
458 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459
Bob Moorec6b57742009-06-24 09:44:06 +0800460 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100461 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_wake,
462 gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400463 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 return (status);
465 }
466 }
467
468 return (AE_OK);
469}
470
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471/******************************************************************************
472 *
473 * FUNCTION: acpi_hw_disable_all_gpes
474 *
Robert Moore73459f72005-06-24 00:00:00 -0400475 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 *
477 * RETURN: Status
478 *
Robert Moore44f6c012005-04-18 22:49:35 -0400479 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 *
481 ******************************************************************************/
482
Len Brown4be44fc2005-08-05 00:44:28 -0400483acpi_status acpi_hw_disable_all_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484{
Len Brown4be44fc2005-08-05 00:44:28 -0400485 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486
Bob Mooreb229cf92006-04-21 17:15:00 -0400487 ACPI_FUNCTION_TRACE(hw_disable_all_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488
Bob Mooree97d6bf2008-12-30 09:45:17 +0800489 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
490 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400491 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492}
493
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494/******************************************************************************
495 *
496 * FUNCTION: acpi_hw_enable_all_runtime_gpes
497 *
Robert Moore73459f72005-06-24 00:00:00 -0400498 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 *
500 * RETURN: Status
501 *
Robert Moore44f6c012005-04-18 22:49:35 -0400502 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 *
504 ******************************************************************************/
505
Len Brown4be44fc2005-08-05 00:44:28 -0400506acpi_status acpi_hw_enable_all_runtime_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507{
Len Brown4be44fc2005-08-05 00:44:28 -0400508 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509
Bob Mooreb229cf92006-04-21 17:15:00 -0400510 ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511
Bob Mooree97d6bf2008-12-30 09:45:17 +0800512 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400513 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514}
515
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516/******************************************************************************
517 *
518 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
519 *
Robert Moore73459f72005-06-24 00:00:00 -0400520 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 *
522 * RETURN: Status
523 *
Robert Moore44f6c012005-04-18 22:49:35 -0400524 * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 *
526 ******************************************************************************/
527
Len Brown4be44fc2005-08-05 00:44:28 -0400528acpi_status acpi_hw_enable_all_wakeup_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529{
Len Brown4be44fc2005-08-05 00:44:28 -0400530 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531
Bob Mooreb229cf92006-04-21 17:15:00 -0400532 ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533
Bob Mooree97d6bf2008-12-30 09:45:17 +0800534 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400535 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536}
Bob Moore33620c52012-02-14 18:14:27 +0800537
538#endif /* !ACPI_REDUCED_HARDWARE */