2 /******************************************************************************
4 * Module Name: hwgpe - Low level GPE enable/disable/clear functions
6 *****************************************************************************/
9 * Copyright (C) 2000 - 2005, R. Byron Moore
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
45 #include <acpi/acpi.h>
46 #include <acpi/acevents.h>
48 #define _COMPONENT ACPI_HARDWARE
49 ACPI_MODULE_NAME ("hwgpe")
52 /******************************************************************************
54 * FUNCTION: acpi_hw_write_gpe_enable_reg
56 * PARAMETERS: gpe_event_info - Info block for the GPE to be enabled
60 * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must
61 * already be cleared or set in the parent register
62 * enable_for_run mask.
64 ******************************************************************************/
67 acpi_hw_write_gpe_enable_reg (
68 struct acpi_gpe_event_info *gpe_event_info)
70 struct acpi_gpe_register_info *gpe_register_info;
74 ACPI_FUNCTION_ENTRY ();
77 /* Get the info block for the entire GPE register */
79 gpe_register_info = gpe_event_info->register_info;
80 if (!gpe_register_info) {
81 return (AE_NOT_EXIST);
84 /* Write the entire GPE (runtime) enable register */
86 status = acpi_hw_low_level_write (8, gpe_register_info->enable_for_run,
87 &gpe_register_info->enable_address);
93 /******************************************************************************
95 * FUNCTION: acpi_hw_clear_gpe
97 * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared
101 * DESCRIPTION: Clear the status bit for a single GPE.
103 ******************************************************************************/
107 struct acpi_gpe_event_info *gpe_event_info)
112 ACPI_FUNCTION_ENTRY ();
116 * Write a one to the appropriate bit in the status register to
119 status = acpi_hw_low_level_write (8, gpe_event_info->register_bit,
120 &gpe_event_info->register_info->status_address);
126 /******************************************************************************
128 * FUNCTION: acpi_hw_get_gpe_status
130 * PARAMETERS: gpe_event_info - Info block for the GPE to queried
131 * event_status - Where the GPE status is returned
135 * DESCRIPTION: Return the status of a single GPE.
137 ******************************************************************************/
138 #ifdef ACPI_FUTURE_USAGE
140 acpi_hw_get_gpe_status (
141 struct acpi_gpe_event_info *gpe_event_info,
142 acpi_event_status *event_status)
146 struct acpi_gpe_register_info *gpe_register_info;
148 acpi_event_status local_event_status = 0;
151 ACPI_FUNCTION_ENTRY ();
155 return (AE_BAD_PARAMETER);
158 /* Get the info block for the entire GPE register */
160 gpe_register_info = gpe_event_info->register_info;
162 /* Get the register bitmask for this GPE */
164 register_bit = gpe_event_info->register_bit;
166 /* GPE currently enabled? (enabled for runtime?) */
168 if (register_bit & gpe_register_info->enable_for_run) {
169 local_event_status |= ACPI_EVENT_FLAG_ENABLED;
172 /* GPE enabled for wake? */
174 if (register_bit & gpe_register_info->enable_for_wake) {
175 local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED;
178 /* GPE currently active (status bit == 1)? */
180 status = acpi_hw_low_level_read (8, &in_byte, &gpe_register_info->status_address);
181 if (ACPI_FAILURE (status)) {
182 goto unlock_and_exit;
185 if (register_bit & in_byte) {
186 local_event_status |= ACPI_EVENT_FLAG_SET;
189 /* Set return value */
191 (*event_status) = local_event_status;
197 #endif /* ACPI_FUTURE_USAGE */
200 /******************************************************************************
202 * FUNCTION: acpi_hw_disable_gpe_block
204 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
205 * gpe_block - Gpe Block info
209 * DESCRIPTION: Disable all GPEs within a GPE block
211 ******************************************************************************/
214 acpi_hw_disable_gpe_block (
215 struct acpi_gpe_xrupt_info *gpe_xrupt_info,
216 struct acpi_gpe_block_info *gpe_block)
222 /* Examine each GPE Register within the block */
224 for (i = 0; i < gpe_block->register_count; i++) {
225 /* Disable all GPEs in this register */
227 status = acpi_hw_low_level_write (8, 0x00,
228 &gpe_block->register_info[i].enable_address);
229 if (ACPI_FAILURE (status)) {
238 /******************************************************************************
240 * FUNCTION: acpi_hw_clear_gpe_block
242 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
243 * gpe_block - Gpe Block info
247 * DESCRIPTION: Clear status bits for all GPEs within a GPE block
249 ******************************************************************************/
252 acpi_hw_clear_gpe_block (
253 struct acpi_gpe_xrupt_info *gpe_xrupt_info,
254 struct acpi_gpe_block_info *gpe_block)
260 /* Examine each GPE Register within the block */
262 for (i = 0; i < gpe_block->register_count; i++) {
263 /* Clear status on all GPEs in this register */
265 status = acpi_hw_low_level_write (8, 0xFF,
266 &gpe_block->register_info[i].status_address);
267 if (ACPI_FAILURE (status)) {
276 /******************************************************************************
278 * FUNCTION: acpi_hw_enable_runtime_gpe_block
280 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
281 * gpe_block - Gpe Block info
285 * DESCRIPTION: Enable all "runtime" GPEs within a GPE block. (Includes
286 * combination wake/run GPEs.)
288 ******************************************************************************/
291 acpi_hw_enable_runtime_gpe_block (
292 struct acpi_gpe_xrupt_info *gpe_xrupt_info,
293 struct acpi_gpe_block_info *gpe_block)
299 /* NOTE: assumes that all GPEs are currently disabled */
301 /* Examine each GPE Register within the block */
303 for (i = 0; i < gpe_block->register_count; i++) {
304 if (!gpe_block->register_info[i].enable_for_run) {
308 /* Enable all "runtime" GPEs in this register */
310 status = acpi_hw_low_level_write (8, gpe_block->register_info[i].enable_for_run,
311 &gpe_block->register_info[i].enable_address);
312 if (ACPI_FAILURE (status)) {
321 /******************************************************************************
323 * FUNCTION: acpi_hw_enable_wakeup_gpe_block
325 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
326 * gpe_block - Gpe Block info
330 * DESCRIPTION: Enable all "wake" GPEs within a GPE block. (Includes
331 * combination wake/run GPEs.)
333 ******************************************************************************/
336 acpi_hw_enable_wakeup_gpe_block (
337 struct acpi_gpe_xrupt_info *gpe_xrupt_info,
338 struct acpi_gpe_block_info *gpe_block)
344 /* Examine each GPE Register within the block */
346 for (i = 0; i < gpe_block->register_count; i++) {
347 if (!gpe_block->register_info[i].enable_for_wake) {
351 /* Enable all "wake" GPEs in this register */
353 status = acpi_hw_low_level_write (8, gpe_block->register_info[i].enable_for_wake,
354 &gpe_block->register_info[i].enable_address);
355 if (ACPI_FAILURE (status)) {
364 /******************************************************************************
366 * FUNCTION: acpi_hw_disable_all_gpes
368 * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR
372 * DESCRIPTION: Disable and clear all GPEs
374 ******************************************************************************/
377 acpi_hw_disable_all_gpes (
383 ACPI_FUNCTION_TRACE ("hw_disable_all_gpes");
386 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, flags);
387 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, flags);
388 return_ACPI_STATUS (status);
392 /******************************************************************************
394 * FUNCTION: acpi_hw_enable_all_runtime_gpes
396 * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR
400 * DESCRIPTION: Enable all GPEs of the given type
402 ******************************************************************************/
405 acpi_hw_enable_all_runtime_gpes (
411 ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes");
414 status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block, flags);
415 return_ACPI_STATUS (status);
419 /******************************************************************************
421 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
423 * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR
427 * DESCRIPTION: Enable all GPEs of the given type
429 ******************************************************************************/
432 acpi_hw_enable_all_wakeup_gpes (
438 ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes");
441 status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block, flags);
442 return_ACPI_STATUS (status);