blob: 84bc550f4f1d2bd9b8c3dec7b4dab9fdee013cf2 [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
253 /* GPE currently active (status bit == 1)? */
254
Bob Moorec6b57742009-06-24 09:44:06 +0800255 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400256 if (ACPI_FAILURE(status)) {
Bob Moore2147d3f2010-01-21 09:08:31 +0800257 return (status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 }
259
260 if (register_bit & in_byte) {
261 local_event_status |= ACPI_EVENT_FLAG_SET;
262 }
263
264 /* Set return value */
265
266 (*event_status) = local_event_status;
Bob Moore2147d3f2010-01-21 09:08:31 +0800267 return (AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
270/******************************************************************************
271 *
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100272 * FUNCTION: acpi_hw_gpe_enable_write
273 *
274 * PARAMETERS: enable_mask - Bit mask to write to the GPE register
275 * gpe_register_info - Gpe Register info
276 *
277 * RETURN: Status
278 *
279 * DESCRIPTION: Write the enable mask byte to the given GPE register.
280 *
281 ******************************************************************************/
282
283static acpi_status
284acpi_hw_gpe_enable_write(u8 enable_mask,
285 struct acpi_gpe_register_info *gpe_register_info)
286{
287 acpi_status status;
288
289 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
290 if (ACPI_SUCCESS(status)) {
291 gpe_register_info->enable_mask = enable_mask;
292 }
293 return (status);
294}
295
296/******************************************************************************
297 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 * FUNCTION: acpi_hw_disable_gpe_block
299 *
300 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
301 * gpe_block - Gpe Block info
302 *
303 * RETURN: Status
304 *
Robert Moore44f6c012005-04-18 22:49:35 -0400305 * DESCRIPTION: Disable all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 *
307 ******************************************************************************/
308
309acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800310acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
311 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312{
Len Brown4be44fc2005-08-05 00:44:28 -0400313 u32 i;
314 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316 /* Examine each GPE Register within the block */
317
318 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400319
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 /* Disable all GPEs in this register */
321
Bob Mooreecfbbc72008-12-31 02:55:32 +0800322 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100323 acpi_hw_gpe_enable_write(0x00,
324 &gpe_block->register_info[i]);
Len Brown4be44fc2005-08-05 00:44:28 -0400325 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 return (status);
327 }
328 }
329
330 return (AE_OK);
331}
332
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333/******************************************************************************
334 *
335 * FUNCTION: acpi_hw_clear_gpe_block
336 *
337 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
338 * gpe_block - Gpe Block info
339 *
340 * RETURN: Status
341 *
Robert Moore44f6c012005-04-18 22:49:35 -0400342 * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 *
344 ******************************************************************************/
345
346acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800347acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
348 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349{
Len Brown4be44fc2005-08-05 00:44:28 -0400350 u32 i;
351 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /* Examine each GPE Register within the block */
354
355 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400356
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 /* Clear status on all GPEs in this register */
358
Bob Mooreecfbbc72008-12-31 02:55:32 +0800359 status =
Bob Moorec6b57742009-06-24 09:44:06 +0800360 acpi_hw_write(0xFF,
361 &gpe_block->register_info[i].status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400362 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 return (status);
364 }
365 }
366
367 return (AE_OK);
368}
369
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370/******************************************************************************
371 *
372 * FUNCTION: acpi_hw_enable_runtime_gpe_block
373 *
374 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
375 * gpe_block - Gpe Block info
376 *
377 * RETURN: Status
378 *
Robert Moore44f6c012005-04-18 22:49:35 -0400379 * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
380 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 *
382 ******************************************************************************/
383
384acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800385acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Lv Zheng1f86e8c2012-10-31 02:25:45 +0000386 struct acpi_gpe_block_info * gpe_block,
387 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388{
Len Brown4be44fc2005-08-05 00:44:28 -0400389 u32 i;
390 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100391 struct acpi_gpe_register_info *gpe_register_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
393 /* NOTE: assumes that all GPEs are currently disabled */
394
395 /* Examine each GPE Register within the block */
396
397 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100398 gpe_register_info = &gpe_block->register_info[i];
399 if (!gpe_register_info->enable_for_run) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 continue;
401 }
402
403 /* Enable all "runtime" GPEs in this register */
404
Bob Moorec6b57742009-06-24 09:44:06 +0800405 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100406 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_run,
407 gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400408 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 return (status);
410 }
411 }
412
413 return (AE_OK);
414}
415
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416/******************************************************************************
417 *
418 * FUNCTION: acpi_hw_enable_wakeup_gpe_block
419 *
420 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
421 * gpe_block - Gpe Block info
422 *
423 * RETURN: Status
424 *
Robert Moore44f6c012005-04-18 22:49:35 -0400425 * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
426 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 *
428 ******************************************************************************/
429
Robert Moore44f6c012005-04-18 22:49:35 -0400430static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400431acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Bob Mooree97d6bf2008-12-30 09:45:17 +0800432 struct acpi_gpe_block_info *gpe_block,
433 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
Len Brown4be44fc2005-08-05 00:44:28 -0400435 u32 i;
436 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100437 struct acpi_gpe_register_info *gpe_register_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
439 /* Examine each GPE Register within the block */
440
441 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100442 gpe_register_info = &gpe_block->register_info[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Rafael J. Wysocki5a0b8de2014-09-30 02:24:38 +0200444 /*
445 * Enable all "wake" GPEs in this register and disable the
446 * remaining ones.
447 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
Bob Moorec6b57742009-06-24 09:44:06 +0800449 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100450 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_wake,
451 gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400452 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 return (status);
454 }
455 }
456
457 return (AE_OK);
458}
459
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460/******************************************************************************
461 *
462 * FUNCTION: acpi_hw_disable_all_gpes
463 *
Robert Moore73459f72005-06-24 00:00:00 -0400464 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 *
466 * RETURN: Status
467 *
Robert Moore44f6c012005-04-18 22:49:35 -0400468 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 *
470 ******************************************************************************/
471
Len Brown4be44fc2005-08-05 00:44:28 -0400472acpi_status acpi_hw_disable_all_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473{
Len Brown4be44fc2005-08-05 00:44:28 -0400474 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
Bob Mooreb229cf92006-04-21 17:15:00 -0400476 ACPI_FUNCTION_TRACE(hw_disable_all_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
Bob Mooree97d6bf2008-12-30 09:45:17 +0800478 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
479 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400480 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481}
482
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483/******************************************************************************
484 *
485 * FUNCTION: acpi_hw_enable_all_runtime_gpes
486 *
Robert Moore73459f72005-06-24 00:00:00 -0400487 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 *
489 * RETURN: Status
490 *
Robert Moore44f6c012005-04-18 22:49:35 -0400491 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 *
493 ******************************************************************************/
494
Len Brown4be44fc2005-08-05 00:44:28 -0400495acpi_status acpi_hw_enable_all_runtime_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496{
Len Brown4be44fc2005-08-05 00:44:28 -0400497 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
Bob Mooreb229cf92006-04-21 17:15:00 -0400499 ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
Bob Mooree97d6bf2008-12-30 09:45:17 +0800501 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400502 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503}
504
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505/******************************************************************************
506 *
507 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
508 *
Robert Moore73459f72005-06-24 00:00:00 -0400509 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 *
511 * RETURN: Status
512 *
Robert Moore44f6c012005-04-18 22:49:35 -0400513 * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 *
515 ******************************************************************************/
516
Len Brown4be44fc2005-08-05 00:44:28 -0400517acpi_status acpi_hw_enable_all_wakeup_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518{
Len Brown4be44fc2005-08-05 00:44:28 -0400519 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520
Bob Mooreb229cf92006-04-21 17:15:00 -0400521 ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522
Bob Mooree97d6bf2008-12-30 09:45:17 +0800523 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400524 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525}
Bob Moore33620c52012-02-14 18:14:27 +0800526
527#endif /* !ACPI_REDUCED_HARDWARE */