- Kai Germaschewski: ISDN update (including Makefiles)
[davej-history.git] / drivers / acpi / hardware / hwgpe.c
blob2b413fac803b44022ef0d0f15df81ea576ac9381
1 /******************************************************************************
3 * Module Name: hwgpe - Low level GPE enable/disable/clear functions
4 * $Revision: 25 $
6 *****************************************************************************/
8 /*
9 * Copyright (C) 2000 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "acpi.h"
27 #include "achware.h"
28 #include "acnamesp.h"
29 #include "acevents.h"
31 #define _COMPONENT HARDWARE
32 MODULE_NAME ("hwgpe")
35 /******************************************************************************
37 * FUNCTION: Acpi_hw_enable_gpe
39 * PARAMETERS: Gpe_number - The GPE
41 * RETURN: None
43 * DESCRIPTION: Enable a single GPE.
45 ******************************************************************************/
47 void
48 acpi_hw_enable_gpe (
49 u32 gpe_number)
51 u8 in_byte;
52 u32 register_index;
53 u8 bit_mask;
56 * Translate GPE number to index into global registers array.
58 register_index = acpi_gbl_gpe_valid[gpe_number];
61 * Figure out the bit offset for this GPE within the target register.
63 bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
66 * Read the current value of the register, set the appropriate bit
67 * to enable the GPE, and write out the new register.
69 in_byte = acpi_os_in8 (acpi_gbl_gpe_registers[register_index].enable_addr);
70 acpi_os_out8 (acpi_gbl_gpe_registers[register_index].enable_addr,
71 (u8)(in_byte | bit_mask));
75 /******************************************************************************
77 * FUNCTION: Acpi_hw_disable_gpe
79 * PARAMETERS: Gpe_number - The GPE
81 * RETURN: None
83 * DESCRIPTION: Disable a single GPE.
85 ******************************************************************************/
87 void
88 acpi_hw_disable_gpe (
89 u32 gpe_number)
91 u8 in_byte;
92 u32 register_index;
93 u8 bit_mask;
96 * Translate GPE number to index into global registers array.
98 register_index = acpi_gbl_gpe_valid[gpe_number];
101 * Figure out the bit offset for this GPE within the target register.
103 bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
106 * Read the current value of the register, clear the appropriate bit,
107 * and write out the new register value to disable the GPE.
109 in_byte = acpi_os_in8 (acpi_gbl_gpe_registers[register_index].enable_addr);
110 acpi_os_out8 (acpi_gbl_gpe_registers[register_index].enable_addr,
111 (u8)(in_byte & ~bit_mask));
115 /******************************************************************************
117 * FUNCTION: Acpi_hw_clear_gpe
119 * PARAMETERS: Gpe_number - The GPE
121 * RETURN: None
123 * DESCRIPTION: Clear a single GPE.
125 ******************************************************************************/
127 void
128 acpi_hw_clear_gpe (
129 u32 gpe_number)
131 u32 register_index;
132 u8 bit_mask;
135 * Translate GPE number to index into global registers array.
137 register_index = acpi_gbl_gpe_valid[gpe_number];
140 * Figure out the bit offset for this GPE within the target register.
142 bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
145 * Write a one to the appropriate bit in the status register to
146 * clear this GPE.
148 acpi_os_out8 (acpi_gbl_gpe_registers[register_index].status_addr, bit_mask);
152 /******************************************************************************
154 * FUNCTION: Acpi_hw_get_gpe_status
156 * PARAMETERS: Gpe_number - The GPE
158 * RETURN: None
160 * DESCRIPTION: Return the status of a single GPE.
162 ******************************************************************************/
164 void
165 acpi_hw_get_gpe_status (
166 u32 gpe_number,
167 ACPI_EVENT_STATUS *event_status)
169 u8 in_byte = 0;
170 u32 register_index = 0;
171 u8 bit_mask = 0;
173 if (!event_status) {
174 return;
177 (*event_status) = 0;
180 * Translate GPE number to index into global registers array.
182 register_index = acpi_gbl_gpe_valid[gpe_number];
185 * Figure out the bit offset for this GPE within the target register.
187 bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
190 * Enabled?:
192 in_byte = acpi_os_in8 (acpi_gbl_gpe_registers[register_index].enable_addr);
194 if (bit_mask & in_byte) {
195 (*event_status) |= ACPI_EVENT_FLAG_ENABLED;
199 * Set?
201 in_byte = acpi_os_in8 (acpi_gbl_gpe_registers[register_index].status_addr);
203 if (bit_mask & in_byte) {
204 (*event_status) |= ACPI_EVENT_FLAG_SET;