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")
51 /* Local prototypes */
54 acpi_hw_enable_wakeup_gpe_block (
55 struct acpi_gpe_xrupt_info
*gpe_xrupt_info
,
56 struct acpi_gpe_block_info
*gpe_block
);
59 /******************************************************************************
61 * FUNCTION: acpi_hw_write_gpe_enable_reg
63 * PARAMETERS: gpe_event_info - Info block for the GPE to be enabled
67 * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must
68 * already be cleared or set in the parent register
69 * enable_for_run mask.
71 ******************************************************************************/
74 acpi_hw_write_gpe_enable_reg (
75 struct acpi_gpe_event_info
*gpe_event_info
)
77 struct acpi_gpe_register_info
*gpe_register_info
;
81 ACPI_FUNCTION_ENTRY ();
84 /* Get the info block for the entire GPE register */
86 gpe_register_info
= gpe_event_info
->register_info
;
87 if (!gpe_register_info
) {
88 return (AE_NOT_EXIST
);
91 /* Write the entire GPE (runtime) enable register */
93 status
= acpi_hw_low_level_write (8, gpe_register_info
->enable_for_run
,
94 &gpe_register_info
->enable_address
);
100 /******************************************************************************
102 * FUNCTION: acpi_hw_clear_gpe
104 * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared
108 * DESCRIPTION: Clear the status bit for a single GPE.
110 ******************************************************************************/
114 struct acpi_gpe_event_info
*gpe_event_info
)
119 ACPI_FUNCTION_ENTRY ();
123 * Write a one to the appropriate bit in the status register to
126 status
= acpi_hw_low_level_write (8, gpe_event_info
->register_bit
,
127 &gpe_event_info
->register_info
->status_address
);
133 /******************************************************************************
135 * FUNCTION: acpi_hw_get_gpe_status
137 * PARAMETERS: gpe_event_info - Info block for the GPE to queried
138 * event_status - Where the GPE status is returned
142 * DESCRIPTION: Return the status of a single GPE.
144 ******************************************************************************/
146 #ifdef ACPI_FUTURE_USAGE
148 acpi_hw_get_gpe_status (
149 struct acpi_gpe_event_info
*gpe_event_info
,
150 acpi_event_status
*event_status
)
154 struct acpi_gpe_register_info
*gpe_register_info
;
156 acpi_event_status local_event_status
= 0;
159 ACPI_FUNCTION_ENTRY ();
163 return (AE_BAD_PARAMETER
);
166 /* Get the info block for the entire GPE register */
168 gpe_register_info
= gpe_event_info
->register_info
;
170 /* Get the register bitmask for this GPE */
172 register_bit
= gpe_event_info
->register_bit
;
174 /* GPE currently enabled? (enabled for runtime?) */
176 if (register_bit
& gpe_register_info
->enable_for_run
) {
177 local_event_status
|= ACPI_EVENT_FLAG_ENABLED
;
180 /* GPE enabled for wake? */
182 if (register_bit
& gpe_register_info
->enable_for_wake
) {
183 local_event_status
|= ACPI_EVENT_FLAG_WAKE_ENABLED
;
186 /* GPE currently active (status bit == 1)? */
188 status
= acpi_hw_low_level_read (8, &in_byte
, &gpe_register_info
->status_address
);
189 if (ACPI_FAILURE (status
)) {
190 goto unlock_and_exit
;
193 if (register_bit
& in_byte
) {
194 local_event_status
|= ACPI_EVENT_FLAG_SET
;
197 /* Set return value */
199 (*event_status
) = local_event_status
;
205 #endif /* ACPI_FUTURE_USAGE */
208 /******************************************************************************
210 * FUNCTION: acpi_hw_disable_gpe_block
212 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
213 * gpe_block - Gpe Block info
217 * DESCRIPTION: Disable all GPEs within a single GPE block
219 ******************************************************************************/
222 acpi_hw_disable_gpe_block (
223 struct acpi_gpe_xrupt_info
*gpe_xrupt_info
,
224 struct acpi_gpe_block_info
*gpe_block
)
230 /* Examine each GPE Register within the block */
232 for (i
= 0; i
< gpe_block
->register_count
; i
++) {
233 /* Disable all GPEs in this register */
235 status
= acpi_hw_low_level_write (8, 0x00,
236 &gpe_block
->register_info
[i
].enable_address
);
237 if (ACPI_FAILURE (status
)) {
246 /******************************************************************************
248 * FUNCTION: acpi_hw_clear_gpe_block
250 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
251 * gpe_block - Gpe Block info
255 * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
257 ******************************************************************************/
260 acpi_hw_clear_gpe_block (
261 struct acpi_gpe_xrupt_info
*gpe_xrupt_info
,
262 struct acpi_gpe_block_info
*gpe_block
)
268 /* Examine each GPE Register within the block */
270 for (i
= 0; i
< gpe_block
->register_count
; i
++) {
271 /* Clear status on all GPEs in this register */
273 status
= acpi_hw_low_level_write (8, 0xFF,
274 &gpe_block
->register_info
[i
].status_address
);
275 if (ACPI_FAILURE (status
)) {
284 /******************************************************************************
286 * FUNCTION: acpi_hw_enable_runtime_gpe_block
288 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
289 * gpe_block - Gpe Block info
293 * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
294 * combination wake/run GPEs.
296 ******************************************************************************/
299 acpi_hw_enable_runtime_gpe_block (
300 struct acpi_gpe_xrupt_info
*gpe_xrupt_info
,
301 struct acpi_gpe_block_info
*gpe_block
)
307 /* NOTE: assumes that all GPEs are currently disabled */
309 /* Examine each GPE Register within the block */
311 for (i
= 0; i
< gpe_block
->register_count
; i
++) {
312 if (!gpe_block
->register_info
[i
].enable_for_run
) {
316 /* Enable all "runtime" GPEs in this register */
318 status
= acpi_hw_low_level_write (8, gpe_block
->register_info
[i
].enable_for_run
,
319 &gpe_block
->register_info
[i
].enable_address
);
320 if (ACPI_FAILURE (status
)) {
329 /******************************************************************************
331 * FUNCTION: acpi_hw_enable_wakeup_gpe_block
333 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
334 * gpe_block - Gpe Block info
338 * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
339 * combination wake/run GPEs.
341 ******************************************************************************/
344 acpi_hw_enable_wakeup_gpe_block (
345 struct acpi_gpe_xrupt_info
*gpe_xrupt_info
,
346 struct acpi_gpe_block_info
*gpe_block
)
352 /* Examine each GPE Register within the block */
354 for (i
= 0; i
< gpe_block
->register_count
; i
++) {
355 if (!gpe_block
->register_info
[i
].enable_for_wake
) {
359 /* Enable all "wake" GPEs in this register */
361 status
= acpi_hw_low_level_write (8,
362 gpe_block
->register_info
[i
].enable_for_wake
,
363 &gpe_block
->register_info
[i
].enable_address
);
364 if (ACPI_FAILURE (status
)) {
373 /******************************************************************************
375 * FUNCTION: acpi_hw_disable_all_gpes
381 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
383 ******************************************************************************/
386 acpi_hw_disable_all_gpes (
392 ACPI_FUNCTION_TRACE ("hw_disable_all_gpes");
395 status
= acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block
);
396 status
= acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block
);
397 return_ACPI_STATUS (status
);
401 /******************************************************************************
403 * FUNCTION: acpi_hw_enable_all_runtime_gpes
409 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
411 ******************************************************************************/
414 acpi_hw_enable_all_runtime_gpes (
420 ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes");
423 status
= acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block
);
424 return_ACPI_STATUS (status
);
428 /******************************************************************************
430 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
436 * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
438 ******************************************************************************/
441 acpi_hw_enable_all_wakeup_gpes (
447 ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes");
450 status
= acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block
);
451 return_ACPI_STATUS (status
);