1 /******************************************************************************
3 * Module Name: hwgpe - Low level GPE enable/disable/clear functions
6 *****************************************************************************/
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
31 #define _COMPONENT HARDWARE
35 /******************************************************************************
37 * FUNCTION: Acpi_hw_enable_gpe
39 * PARAMETERS: Gpe_number - The GPE
43 * DESCRIPTION: Enable a single GPE.
45 ******************************************************************************/
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
83 * DESCRIPTION: Disable a single GPE.
85 ******************************************************************************/
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
123 * DESCRIPTION: Clear a single GPE.
125 ******************************************************************************/
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
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
160 * DESCRIPTION: Return the status of a single GPE.
162 ******************************************************************************/
165 acpi_hw_get_gpe_status (
167 ACPI_EVENT_STATUS
*event_status
)
170 u32 register_index
= 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
)];
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
;
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
;