blob: 494027f5c06771d7b97472a8222f5ed5716b0cb8 [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 Moorefbb7a2d2014-02-08 09:42:25 +08008 * Copyright (C) 2000 - 2014, 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
57/******************************************************************************
58 *
Lin Mingb76df672010-07-01 10:07:17 +080059 * FUNCTION: acpi_hw_get_gpe_register_bit
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020060 *
61 * PARAMETERS: gpe_event_info - Info block for the GPE
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020062 *
Lin Mingda503372010-12-13 13:39:37 +080063 * RETURN: Register mask with a one in the GPE bit position
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020064 *
Lin Mingda503372010-12-13 13:39:37 +080065 * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
66 * correct position for the input GPE.
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020067 *
68 ******************************************************************************/
69
Feng Tang1d94e1e2012-08-17 11:10:02 +080070u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info)
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020071{
Lv Zheng9c0d7932012-12-19 05:37:21 +000072
73 return ((u32)1 <<
74 (gpe_event_info->gpe_number -
75 gpe_event_info->register_info->base_gpe_number));
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020076}
77
78/******************************************************************************
79 *
Rafael J. Wysockifd247442010-06-08 10:49:08 +020080 * FUNCTION: acpi_hw_low_set_gpe
Bob Mooree38e8a02008-06-13 08:28:55 +080081 *
82 * PARAMETERS: gpe_event_info - Info block for the GPE to be disabled
Rafael J. Wysockifd247442010-06-08 10:49:08 +020083 * action - Enable or disable
Bob Mooree38e8a02008-06-13 08:28:55 +080084 *
85 * RETURN: Status
86 *
Lin Mingda503372010-12-13 13:39:37 +080087 * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
Bob Mooree38e8a02008-06-13 08:28:55 +080088 *
89 ******************************************************************************/
90
Rafael J. Wysockifd247442010-06-08 10:49:08 +020091acpi_status
Lin Mingda503372010-12-13 13:39:37 +080092acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
Bob Mooree38e8a02008-06-13 08:28:55 +080093{
94 struct acpi_gpe_register_info *gpe_register_info;
95 acpi_status status;
96 u32 enable_mask;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +020097 u32 register_bit;
Bob Mooree38e8a02008-06-13 08:28:55 +080098
Rafael J. Wysockifd247442010-06-08 10:49:08 +020099 ACPI_FUNCTION_ENTRY();
100
Bob Mooree38e8a02008-06-13 08:28:55 +0800101 /* Get the info block for the entire GPE register */
102
103 gpe_register_info = gpe_event_info->register_info;
104 if (!gpe_register_info) {
105 return (AE_NOT_EXIST);
106 }
107
108 /* Get current value of the enable register that contains this GPE */
109
Bob Moorec6b57742009-06-24 09:44:06 +0800110 status = acpi_hw_read(&enable_mask, &gpe_register_info->enable_address);
Bob Mooree38e8a02008-06-13 08:28:55 +0800111 if (ACPI_FAILURE(status)) {
112 return (status);
113 }
114
Lin Mingda503372010-12-13 13:39:37 +0800115 /* Set or clear just the bit that corresponds to this GPE */
Bob Mooree38e8a02008-06-13 08:28:55 +0800116
Feng Tang1d94e1e2012-08-17 11:10:02 +0800117 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100118 switch (action & ~ACPI_GPE_SAVE_MASK) {
Lin Ming3a378982010-12-13 13:36:15 +0800119 case ACPI_GPE_CONDITIONAL_ENABLE:
Lin Mingda503372010-12-13 13:39:37 +0800120
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100121 /* Only enable if the corresponding enable_mask bit is set */
Lin Mingda503372010-12-13 13:39:37 +0800122
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100123 if (!(register_bit & gpe_register_info->enable_mask)) {
Rafael J. Wysockic9a8bbb2010-06-08 10:49:45 +0200124 return (AE_BAD_PARAMETER);
Lin Mingda503372010-12-13 13:39:37 +0800125 }
126
127 /*lint -fallthrough */
Rafael J. Wysockic9a8bbb2010-06-08 10:49:45 +0200128
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200129 case ACPI_GPE_ENABLE:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000130
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200131 ACPI_SET_BIT(enable_mask, register_bit);
132 break;
133
134 case ACPI_GPE_DISABLE:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000135
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200136 ACPI_CLEAR_BIT(enable_mask, register_bit);
137 break;
138
139 default:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000140
Bob Moore5e30a962013-01-25 05:41:16 +0000141 ACPI_ERROR((AE_INFO, "Invalid GPE Action, %u", action));
Rafael J. Wysockifd247442010-06-08 10:49:08 +0200142 return (AE_BAD_PARAMETER);
143 }
Bob Mooree38e8a02008-06-13 08:28:55 +0800144
145 /* Write the updated enable mask */
146
Bob Moorec6b57742009-06-24 09:44:06 +0800147 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100148 if (ACPI_SUCCESS(status) && (action & ACPI_GPE_SAVE_MASK)) {
149 gpe_register_info->enable_mask = enable_mask;
150 }
Bob Mooree38e8a02008-06-13 08:28:55 +0800151 return (status);
152}
153
154/******************************************************************************
155 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 * FUNCTION: acpi_hw_clear_gpe
157 *
158 * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared
159 *
160 * RETURN: Status
161 *
162 * DESCRIPTION: Clear the status bit for a single GPE.
163 *
164 ******************************************************************************/
165
Len Brown4be44fc2005-08-05 00:44:28 -0400166acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200168 struct acpi_gpe_register_info *gpe_register_info;
Len Brown4be44fc2005-08-05 00:44:28 -0400169 acpi_status status;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200170 u32 register_bit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
Len Brown4be44fc2005-08-05 00:44:28 -0400172 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200174 /* Get the info block for the entire GPE register */
175
176 gpe_register_info = gpe_event_info->register_info;
177 if (!gpe_register_info) {
178 return (AE_NOT_EXIST);
179 }
180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 /*
182 * Write a one to the appropriate bit in the status register to
183 * clear this GPE.
184 */
Feng Tang1d94e1e2012-08-17 11:10:02 +0800185 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Lin Mingda503372010-12-13 13:39:37 +0800186
Bob Moorec6b57742009-06-24 09:44:06 +0800187 status = acpi_hw_write(register_bit,
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200188 &gpe_register_info->status_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
190 return (status);
191}
192
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193/******************************************************************************
194 *
195 * FUNCTION: acpi_hw_get_gpe_status
196 *
197 * PARAMETERS: gpe_event_info - Info block for the GPE to queried
198 * event_status - Where the GPE status is returned
199 *
200 * RETURN: Status
201 *
202 * DESCRIPTION: Return the status of a single GPE.
203 *
204 ******************************************************************************/
Robert Moore44f6c012005-04-18 22:49:35 -0400205
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400207acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
Lv Zhengf19f1a72014-10-10 10:39:39 +0800208 acpi_event_status *event_status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209{
Len Brown4be44fc2005-08-05 00:44:28 -0400210 u32 in_byte;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200211 u32 register_bit;
Len Brown4be44fc2005-08-05 00:44:28 -0400212 struct acpi_gpe_register_info *gpe_register_info;
Len Brown4be44fc2005-08-05 00:44:28 -0400213 acpi_event_status local_event_status = 0;
Lin Mingda503372010-12-13 13:39:37 +0800214 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
Len Brown4be44fc2005-08-05 00:44:28 -0400216 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
218 if (!event_status) {
219 return (AE_BAD_PARAMETER);
220 }
221
Lv Zhenga08f8132014-10-10 10:39:57 +0800222 /* GPE currently handled? */
223
224 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) !=
225 ACPI_GPE_DISPATCH_NONE) {
Lv Zheng2f857232014-10-10 10:40:05 +0800226 local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER;
Lv Zhenga08f8132014-10-10 10:39:57 +0800227 }
228
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 /* Get the info block for the entire GPE register */
230
231 gpe_register_info = gpe_event_info->register_info;
232
233 /* Get the register bitmask for this GPE */
234
Feng Tang1d94e1e2012-08-17 11:10:02 +0800235 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 /* GPE currently enabled? (enabled for runtime?) */
238
239 if (register_bit & gpe_register_info->enable_for_run) {
240 local_event_status |= ACPI_EVENT_FLAG_ENABLED;
241 }
242
243 /* GPE enabled for wake? */
244
245 if (register_bit & gpe_register_info->enable_for_wake) {
246 local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED;
247 }
248
249 /* GPE currently active (status bit == 1)? */
250
Bob Moorec6b57742009-06-24 09:44:06 +0800251 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400252 if (ACPI_FAILURE(status)) {
Bob Moore2147d3f2010-01-21 09:08:31 +0800253 return (status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 }
255
256 if (register_bit & in_byte) {
257 local_event_status |= ACPI_EVENT_FLAG_SET;
258 }
259
260 /* Set return value */
261
262 (*event_status) = local_event_status;
Bob Moore2147d3f2010-01-21 09:08:31 +0800263 return (AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
266/******************************************************************************
267 *
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100268 * FUNCTION: acpi_hw_gpe_enable_write
269 *
270 * PARAMETERS: enable_mask - Bit mask to write to the GPE register
271 * gpe_register_info - Gpe Register info
272 *
273 * RETURN: Status
274 *
275 * DESCRIPTION: Write the enable mask byte to the given GPE register.
276 *
277 ******************************************************************************/
278
279static acpi_status
280acpi_hw_gpe_enable_write(u8 enable_mask,
281 struct acpi_gpe_register_info *gpe_register_info)
282{
283 acpi_status status;
284
285 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
286 if (ACPI_SUCCESS(status)) {
287 gpe_register_info->enable_mask = enable_mask;
288 }
289 return (status);
290}
291
292/******************************************************************************
293 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 * FUNCTION: acpi_hw_disable_gpe_block
295 *
296 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
297 * gpe_block - Gpe Block info
298 *
299 * RETURN: Status
300 *
Robert Moore44f6c012005-04-18 22:49:35 -0400301 * DESCRIPTION: Disable all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 *
303 ******************************************************************************/
304
305acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800306acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
307 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308{
Len Brown4be44fc2005-08-05 00:44:28 -0400309 u32 i;
310 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
312 /* Examine each GPE Register within the block */
313
314 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400315
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 /* Disable all GPEs in this register */
317
Bob Mooreecfbbc72008-12-31 02:55:32 +0800318 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100319 acpi_hw_gpe_enable_write(0x00,
320 &gpe_block->register_info[i]);
Len Brown4be44fc2005-08-05 00:44:28 -0400321 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 return (status);
323 }
324 }
325
326 return (AE_OK);
327}
328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329/******************************************************************************
330 *
331 * FUNCTION: acpi_hw_clear_gpe_block
332 *
333 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
334 * gpe_block - Gpe Block info
335 *
336 * RETURN: Status
337 *
Robert Moore44f6c012005-04-18 22:49:35 -0400338 * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 *
340 ******************************************************************************/
341
342acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800343acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
344 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345{
Len Brown4be44fc2005-08-05 00:44:28 -0400346 u32 i;
347 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348
349 /* Examine each GPE Register within the block */
350
351 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 /* Clear status on all GPEs in this register */
354
Bob Mooreecfbbc72008-12-31 02:55:32 +0800355 status =
Bob Moorec6b57742009-06-24 09:44:06 +0800356 acpi_hw_write(0xFF,
357 &gpe_block->register_info[i].status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400358 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 return (status);
360 }
361 }
362
363 return (AE_OK);
364}
365
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366/******************************************************************************
367 *
368 * FUNCTION: acpi_hw_enable_runtime_gpe_block
369 *
370 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
371 * gpe_block - Gpe Block info
372 *
373 * RETURN: Status
374 *
Robert Moore44f6c012005-04-18 22:49:35 -0400375 * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
376 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 *
378 ******************************************************************************/
379
380acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800381acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Lv Zheng1f86e8c2012-10-31 02:25:45 +0000382 struct acpi_gpe_block_info * gpe_block,
383 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384{
Len Brown4be44fc2005-08-05 00:44:28 -0400385 u32 i;
386 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100387 struct acpi_gpe_register_info *gpe_register_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388
389 /* NOTE: assumes that all GPEs are currently disabled */
390
391 /* Examine each GPE Register within the block */
392
393 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100394 gpe_register_info = &gpe_block->register_info[i];
395 if (!gpe_register_info->enable_for_run) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 continue;
397 }
398
399 /* Enable all "runtime" GPEs in this register */
400
Bob Moorec6b57742009-06-24 09:44:06 +0800401 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100402 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_run,
403 gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400404 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 return (status);
406 }
407 }
408
409 return (AE_OK);
410}
411
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412/******************************************************************************
413 *
414 * FUNCTION: acpi_hw_enable_wakeup_gpe_block
415 *
416 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
417 * gpe_block - Gpe Block info
418 *
419 * RETURN: Status
420 *
Robert Moore44f6c012005-04-18 22:49:35 -0400421 * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
422 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 *
424 ******************************************************************************/
425
Robert Moore44f6c012005-04-18 22:49:35 -0400426static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400427acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Bob Mooree97d6bf2008-12-30 09:45:17 +0800428 struct acpi_gpe_block_info *gpe_block,
429 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430{
Len Brown4be44fc2005-08-05 00:44:28 -0400431 u32 i;
432 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100433 struct acpi_gpe_register_info *gpe_register_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434
435 /* Examine each GPE Register within the block */
436
437 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100438 gpe_register_info = &gpe_block->register_info[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
Rafael J. Wysocki5a0b8de2014-09-30 02:24:38 +0200440 /*
441 * Enable all "wake" GPEs in this register and disable the
442 * remaining ones.
443 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
Bob Moorec6b57742009-06-24 09:44:06 +0800445 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100446 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_wake,
447 gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400448 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 return (status);
450 }
451 }
452
453 return (AE_OK);
454}
455
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456/******************************************************************************
457 *
458 * FUNCTION: acpi_hw_disable_all_gpes
459 *
Robert Moore73459f72005-06-24 00:00:00 -0400460 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 *
462 * RETURN: Status
463 *
Robert Moore44f6c012005-04-18 22:49:35 -0400464 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 *
466 ******************************************************************************/
467
Len Brown4be44fc2005-08-05 00:44:28 -0400468acpi_status acpi_hw_disable_all_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469{
Len Brown4be44fc2005-08-05 00:44:28 -0400470 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
Bob Mooreb229cf92006-04-21 17:15:00 -0400472 ACPI_FUNCTION_TRACE(hw_disable_all_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Bob Mooree97d6bf2008-12-30 09:45:17 +0800474 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
475 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400476 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477}
478
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479/******************************************************************************
480 *
481 * FUNCTION: acpi_hw_enable_all_runtime_gpes
482 *
Robert Moore73459f72005-06-24 00:00:00 -0400483 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 *
485 * RETURN: Status
486 *
Robert Moore44f6c012005-04-18 22:49:35 -0400487 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 *
489 ******************************************************************************/
490
Len Brown4be44fc2005-08-05 00:44:28 -0400491acpi_status acpi_hw_enable_all_runtime_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492{
Len Brown4be44fc2005-08-05 00:44:28 -0400493 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494
Bob Mooreb229cf92006-04-21 17:15:00 -0400495 ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496
Bob Mooree97d6bf2008-12-30 09:45:17 +0800497 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400498 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499}
500
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501/******************************************************************************
502 *
503 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
504 *
Robert Moore73459f72005-06-24 00:00:00 -0400505 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 *
507 * RETURN: Status
508 *
Robert Moore44f6c012005-04-18 22:49:35 -0400509 * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 *
511 ******************************************************************************/
512
Len Brown4be44fc2005-08-05 00:44:28 -0400513acpi_status acpi_hw_enable_all_wakeup_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514{
Len Brown4be44fc2005-08-05 00:44:28 -0400515 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516
Bob Mooreb229cf92006-04-21 17:15:00 -0400517 ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518
Bob Mooree97d6bf2008-12-30 09:45:17 +0800519 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400520 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521}
Bob Moore33620c52012-02-14 18:14:27 +0800522
523#endif /* !ACPI_REDUCED_HARDWARE */