blob: 1c4f4518611a7211881dac61d2d8f99736288b6b [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;
101 acpi_status status;
102 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
151 /* Write the updated enable mask */
152
Bob Moorec6b57742009-06-24 09:44:06 +0800153 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
Bob Mooree38e8a02008-06-13 08:28:55 +0800154 return (status);
155}
156
157/******************************************************************************
158 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 * FUNCTION: acpi_hw_clear_gpe
160 *
161 * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared
162 *
163 * RETURN: Status
164 *
165 * DESCRIPTION: Clear the status bit for a single GPE.
166 *
167 ******************************************************************************/
168
Len Brown4be44fc2005-08-05 00:44:28 -0400169acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170{
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200171 struct acpi_gpe_register_info *gpe_register_info;
Len Brown4be44fc2005-08-05 00:44:28 -0400172 acpi_status status;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200173 u32 register_bit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Len Brown4be44fc2005-08-05 00:44:28 -0400175 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200177 /* Get the info block for the entire GPE register */
178
179 gpe_register_info = gpe_event_info->register_info;
180 if (!gpe_register_info) {
181 return (AE_NOT_EXIST);
182 }
183
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 /*
185 * Write a one to the appropriate bit in the status register to
186 * clear this GPE.
187 */
Feng Tang1d94e1e2012-08-17 11:10:02 +0800188 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Lin Mingda503372010-12-13 13:39:37 +0800189
Bob Moore1fad8732015-12-29 13:54:36 +0800190 status =
191 acpi_hw_write(register_bit, &gpe_register_info->status_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 return (status);
193}
194
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195/******************************************************************************
196 *
197 * FUNCTION: acpi_hw_get_gpe_status
198 *
199 * PARAMETERS: gpe_event_info - Info block for the GPE to queried
200 * event_status - Where the GPE status is returned
201 *
202 * RETURN: Status
203 *
204 * DESCRIPTION: Return the status of a single GPE.
205 *
206 ******************************************************************************/
Robert Moore44f6c012005-04-18 22:49:35 -0400207
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400209acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
Lv Zhengf19f1a72014-10-10 10:39:39 +0800210 acpi_event_status *event_status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211{
Len Brown4be44fc2005-08-05 00:44:28 -0400212 u32 in_byte;
Rafael J. Wysockie4e9a732010-06-08 10:48:26 +0200213 u32 register_bit;
Len Brown4be44fc2005-08-05 00:44:28 -0400214 struct acpi_gpe_register_info *gpe_register_info;
Len Brown4be44fc2005-08-05 00:44:28 -0400215 acpi_event_status local_event_status = 0;
Lin Mingda503372010-12-13 13:39:37 +0800216 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
Len Brown4be44fc2005-08-05 00:44:28 -0400218 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
220 if (!event_status) {
221 return (AE_BAD_PARAMETER);
222 }
223
Lv Zhenga08f8132014-10-10 10:39:57 +0800224 /* GPE currently handled? */
225
Lv Zheng7c433122015-02-05 15:20:29 +0800226 if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) !=
Lv Zhenga08f8132014-10-10 10:39:57 +0800227 ACPI_GPE_DISPATCH_NONE) {
Lv Zheng2f857232014-10-10 10:40:05 +0800228 local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER;
Lv Zhenga08f8132014-10-10 10:39:57 +0800229 }
230
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 /* Get the info block for the entire GPE register */
232
233 gpe_register_info = gpe_event_info->register_info;
234
235 /* Get the register bitmask for this GPE */
236
Feng Tang1d94e1e2012-08-17 11:10:02 +0800237 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
239 /* GPE currently enabled? (enabled for runtime?) */
240
241 if (register_bit & gpe_register_info->enable_for_run) {
242 local_event_status |= ACPI_EVENT_FLAG_ENABLED;
243 }
244
245 /* GPE enabled for wake? */
246
247 if (register_bit & gpe_register_info->enable_for_wake) {
248 local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED;
249 }
250
Lv Zheng09af8e82015-04-13 11:49:13 +0800251 /* GPE currently enabled (enable bit == 1)? */
252
253 status = acpi_hw_read(&in_byte, &gpe_register_info->enable_address);
254 if (ACPI_FAILURE(status)) {
255 return (status);
256 }
257
258 if (register_bit & in_byte) {
259 local_event_status |= ACPI_EVENT_FLAG_ENABLE_SET;
260 }
261
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 /* GPE currently active (status bit == 1)? */
263
Bob Moorec6b57742009-06-24 09:44:06 +0800264 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400265 if (ACPI_FAILURE(status)) {
Bob Moore2147d3f2010-01-21 09:08:31 +0800266 return (status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 }
268
269 if (register_bit & in_byte) {
Lv Zheng09af8e82015-04-13 11:49:13 +0800270 local_event_status |= ACPI_EVENT_FLAG_STATUS_SET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 }
272
273 /* Set return value */
274
275 (*event_status) = local_event_status;
Bob Moore2147d3f2010-01-21 09:08:31 +0800276 return (AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
279/******************************************************************************
280 *
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100281 * FUNCTION: acpi_hw_gpe_enable_write
282 *
283 * PARAMETERS: enable_mask - Bit mask to write to the GPE register
284 * gpe_register_info - Gpe Register info
285 *
286 * RETURN: Status
287 *
288 * DESCRIPTION: Write the enable mask byte to the given GPE register.
289 *
290 ******************************************************************************/
291
292static acpi_status
293acpi_hw_gpe_enable_write(u8 enable_mask,
294 struct acpi_gpe_register_info *gpe_register_info)
295{
296 acpi_status status;
297
Rafael J. Wysocki0ee0d342015-04-15 04:00:27 +0200298 gpe_register_info->enable_mask = enable_mask;
Lv Zheng5431b652015-12-29 13:52:32 +0800299
Bob Moore1fad8732015-12-29 13:54:36 +0800300 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100301 return (status);
302}
303
304/******************************************************************************
305 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 * FUNCTION: acpi_hw_disable_gpe_block
307 *
308 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
309 * gpe_block - Gpe Block info
310 *
311 * RETURN: Status
312 *
Robert Moore44f6c012005-04-18 22:49:35 -0400313 * DESCRIPTION: Disable all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 *
315 ******************************************************************************/
316
317acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800318acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
319 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320{
Len Brown4be44fc2005-08-05 00:44:28 -0400321 u32 i;
322 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
324 /* Examine each GPE Register within the block */
325
326 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400327
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 /* Disable all GPEs in this register */
329
Bob Mooreecfbbc72008-12-31 02:55:32 +0800330 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100331 acpi_hw_gpe_enable_write(0x00,
332 &gpe_block->register_info[i]);
Len Brown4be44fc2005-08-05 00:44:28 -0400333 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 return (status);
335 }
336 }
337
338 return (AE_OK);
339}
340
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341/******************************************************************************
342 *
343 * FUNCTION: acpi_hw_clear_gpe_block
344 *
345 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
346 * gpe_block - Gpe Block info
347 *
348 * RETURN: Status
349 *
Robert Moore44f6c012005-04-18 22:49:35 -0400350 * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 *
352 ******************************************************************************/
353
354acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800355acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
356 struct acpi_gpe_block_info *gpe_block, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357{
Len Brown4be44fc2005-08-05 00:44:28 -0400358 u32 i;
359 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360
361 /* Examine each GPE Register within the block */
362
363 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 /* Clear status on all GPEs in this register */
366
Bob Mooreecfbbc72008-12-31 02:55:32 +0800367 status =
Bob Moorec6b57742009-06-24 09:44:06 +0800368 acpi_hw_write(0xFF,
369 &gpe_block->register_info[i].status_address);
Len Brown4be44fc2005-08-05 00:44:28 -0400370 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 return (status);
372 }
373 }
374
375 return (AE_OK);
376}
377
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378/******************************************************************************
379 *
380 * FUNCTION: acpi_hw_enable_runtime_gpe_block
381 *
382 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
383 * gpe_block - Gpe Block info
384 *
385 * RETURN: Status
386 *
Robert Moore44f6c012005-04-18 22:49:35 -0400387 * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
388 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 *
390 ******************************************************************************/
391
392acpi_status
Bob Mooree97d6bf2008-12-30 09:45:17 +0800393acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Lv Zheng1f86e8c2012-10-31 02:25:45 +0000394 struct acpi_gpe_block_info * gpe_block,
395 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396{
Len Brown4be44fc2005-08-05 00:44:28 -0400397 u32 i;
398 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100399 struct acpi_gpe_register_info *gpe_register_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
401 /* NOTE: assumes that all GPEs are currently disabled */
402
403 /* Examine each GPE Register within the block */
404
405 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100406 gpe_register_info = &gpe_block->register_info[i];
407 if (!gpe_register_info->enable_for_run) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 continue;
409 }
410
411 /* Enable all "runtime" GPEs in this register */
412
Bob Moorec6b57742009-06-24 09:44:06 +0800413 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100414 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_run,
415 gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400416 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 return (status);
418 }
419 }
420
421 return (AE_OK);
422}
423
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424/******************************************************************************
425 *
426 * FUNCTION: acpi_hw_enable_wakeup_gpe_block
427 *
428 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
429 * gpe_block - Gpe Block info
430 *
431 * RETURN: Status
432 *
Robert Moore44f6c012005-04-18 22:49:35 -0400433 * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
434 * combination wake/run GPEs.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 *
436 ******************************************************************************/
437
Robert Moore44f6c012005-04-18 22:49:35 -0400438static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400439acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Bob Mooree97d6bf2008-12-30 09:45:17 +0800440 struct acpi_gpe_block_info *gpe_block,
441 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442{
Len Brown4be44fc2005-08-05 00:44:28 -0400443 u32 i;
444 acpi_status status;
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100445 struct acpi_gpe_register_info *gpe_register_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
447 /* Examine each GPE Register within the block */
448
449 for (i = 0; i < gpe_block->register_count; i++) {
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100450 gpe_register_info = &gpe_block->register_info[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451
Rafael J. Wysocki5a0b8de2014-09-30 02:24:38 +0200452 /*
453 * Enable all "wake" GPEs in this register and disable the
454 * remaining ones.
455 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456
Bob Moorec6b57742009-06-24 09:44:06 +0800457 status =
Rafael J. Wysockic50f13c2014-12-01 23:50:16 +0100458 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_wake,
459 gpe_register_info);
Len Brown4be44fc2005-08-05 00:44:28 -0400460 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 return (status);
462 }
463 }
464
465 return (AE_OK);
466}
467
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468/******************************************************************************
469 *
470 * FUNCTION: acpi_hw_disable_all_gpes
471 *
Robert Moore73459f72005-06-24 00:00:00 -0400472 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 *
474 * RETURN: Status
475 *
Robert Moore44f6c012005-04-18 22:49:35 -0400476 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 *
478 ******************************************************************************/
479
Len Brown4be44fc2005-08-05 00:44:28 -0400480acpi_status acpi_hw_disable_all_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481{
Len Brown4be44fc2005-08-05 00:44:28 -0400482 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483
Bob Mooreb229cf92006-04-21 17:15:00 -0400484 ACPI_FUNCTION_TRACE(hw_disable_all_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
Bob Mooree97d6bf2008-12-30 09:45:17 +0800486 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
487 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400488 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489}
490
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491/******************************************************************************
492 *
493 * FUNCTION: acpi_hw_enable_all_runtime_gpes
494 *
Robert Moore73459f72005-06-24 00:00:00 -0400495 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 *
497 * RETURN: Status
498 *
Robert Moore44f6c012005-04-18 22:49:35 -0400499 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 *
501 ******************************************************************************/
502
Len Brown4be44fc2005-08-05 00:44:28 -0400503acpi_status acpi_hw_enable_all_runtime_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504{
Len Brown4be44fc2005-08-05 00:44:28 -0400505 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
Bob Mooreb229cf92006-04-21 17:15:00 -0400507 ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
Bob Mooree97d6bf2008-12-30 09:45:17 +0800509 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400510 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511}
512
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513/******************************************************************************
514 *
515 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
516 *
Robert Moore73459f72005-06-24 00:00:00 -0400517 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 *
519 * RETURN: Status
520 *
Robert Moore44f6c012005-04-18 22:49:35 -0400521 * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 *
523 ******************************************************************************/
524
Len Brown4be44fc2005-08-05 00:44:28 -0400525acpi_status acpi_hw_enable_all_wakeup_gpes(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526{
Len Brown4be44fc2005-08-05 00:44:28 -0400527 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528
Bob Mooreb229cf92006-04-21 17:15:00 -0400529 ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530
Bob Mooree97d6bf2008-12-30 09:45:17 +0800531 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL);
Len Brown4be44fc2005-08-05 00:44:28 -0400532 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533}
Bob Moore33620c52012-02-14 18:14:27 +0800534
535#endif /* !ACPI_REDUCED_HARDWARE */