More Makefile cleanups, otherwise mainly noticeable are the netfilter fix
[davej-history.git] / drivers / acpi / events / evsci.c
blob02320e93c34e75e4c3ca1612fc8c3a5d7d65b4e1
1 /*******************************************************************************
3 * Module Name: evsci - System Control Interrupt configuration and
4 * legacy to ACPI mode state transition functions
5 * $Revision: 67 $
7 ******************************************************************************/
9 /*
10 * Copyright (C) 2000 R. Byron Moore
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "acpi.h"
28 #include "acnamesp.h"
29 #include "achware.h"
30 #include "acevents.h"
33 #define _COMPONENT EVENT_HANDLING
34 MODULE_NAME ("evsci")
38 * Elements correspond to counts for TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC,
39 * and GENERAL respectively. These counts are modified by the ACPI interrupt
40 * handler.
42 * TBD: [Investigate] Note that GENERAL should probably be split out into
43 * one element for each bit in the GPE registers
47 /*******************************************************************************
49 * FUNCTION: Acpi_ev_sci_handler
51 * PARAMETERS: Context - Calling Context
53 * RETURN: Status code indicates whether interrupt was handled.
55 * DESCRIPTION: Interrupt handler that will figure out what function or
56 * control method to call to deal with a SCI. Installed
57 * using BU interrupt support.
59 ******************************************************************************/
61 static u32
62 acpi_ev_sci_handler (void *context)
64 u32 interrupt_handled = INTERRUPT_NOT_HANDLED;
68 * Make sure that ACPI is enabled by checking SCI_EN. Note that we are
69 * required to treat the SCI interrupt as sharable, level, active low.
71 if (!acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, SCI_EN)) {
72 /* ACPI is not enabled; this interrupt cannot be for us */
74 return (INTERRUPT_NOT_HANDLED);
78 * Fixed Acpi_events:
79 * -------------
80 * Check for and dispatch any Fixed Acpi_events that have occurred
82 interrupt_handled |= acpi_ev_fixed_event_detect ();
85 * GPEs:
86 * -----
87 * Check for and dispatch any GPEs that have occurred
89 interrupt_handled |= acpi_ev_gpe_detect ();
91 return (interrupt_handled);
95 /******************************************************************************
97 * FUNCTION: Acpi_ev_install_sci_handler
99 * PARAMETERS: none
101 * RETURN: Status
103 * DESCRIPTION: Installs SCI handler.
105 ******************************************************************************/
108 acpi_ev_install_sci_handler (void)
110 u32 except = AE_OK;
113 except = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
114 acpi_ev_sci_handler,
115 NULL);
117 return (except);
121 /******************************************************************************
124 * FUNCTION: Acpi_ev_remove_sci_handler
126 * PARAMETERS: none
128 * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not
129 * installed to begin with
131 * DESCRIPTION: Restores original status of all fixed event enable bits and
132 * removes SCI handler.
134 ******************************************************************************/
136 ACPI_STATUS
137 acpi_ev_remove_sci_handler (void)
139 #if 0
140 /* TBD:[Investigate] Figure this out!! Disable all events first ??? */
142 if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (TMR_FIXED_EVENT)) {
143 acpi_event_disable_event (TMR_FIXED_EVENT);
146 if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (GBL_FIXED_EVENT)) {
147 acpi_event_disable_event (GBL_FIXED_EVENT);
150 if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (PWR_BTN_FIXED_EVENT)) {
151 acpi_event_disable_event (PWR_BTN_FIXED_EVENT);
154 if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (SLP_BTN_FIXED_EVENT)) {
155 acpi_event_disable_event (SLP_BTN_FIXED_EVENT);
158 if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (RTC_FIXED_EVENT)) {
159 acpi_event_disable_event (RTC_FIXED_EVENT);
162 original_fixed_enable_bit_status = 0;
164 #endif
166 acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
167 acpi_ev_sci_handler);
169 return (AE_OK);
173 /*******************************************************************************
175 * FUNCTION: Acpi_ev_sci_count
177 * PARAMETERS: Event Event that generated an SCI.
179 * RETURN: Number of SCI's for requested event since last time
180 * Sci_occured() was called for this event.
182 * DESCRIPTION: Checks to see if SCI has been generated from requested source
183 * since the last time this function was called.
185 ******************************************************************************/
188 /*******************************************************************************
190 * FUNCTION: Acpi_ev_restore_acpi_state
192 * PARAMETERS: none
194 * RETURN: none
196 * DESCRIPTION: Restore the original ACPI state of the machine
198 ******************************************************************************/
200 void
201 acpi_ev_restore_acpi_state (void)
203 u32 index;
206 /* Restore the state of the chipset enable bits. */
208 if (acpi_gbl_restore_acpi_chipset == TRUE) {
209 /* Restore the fixed events */
211 if (acpi_hw_register_read (ACPI_MTX_LOCK, PM1_EN) !=
212 acpi_gbl_pm1_enable_register_save)
214 acpi_hw_register_write (ACPI_MTX_LOCK, PM1_EN,
215 acpi_gbl_pm1_enable_register_save);
219 /* Ensure that all status bits are clear */
221 acpi_hw_clear_acpi_status ();
224 /* Now restore the GPEs */
226 for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) {
227 if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index) !=
228 acpi_gbl_gpe0enable_register_save[index])
230 acpi_hw_register_write (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index,
231 acpi_gbl_gpe0enable_register_save[index]);
235 /* GPE 1 present? */
237 if (acpi_gbl_FADT->gpe1_blk_len) {
238 for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) {
239 if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index) !=
240 acpi_gbl_gpe1_enable_register_save[index])
242 acpi_hw_register_write (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index,
243 acpi_gbl_gpe1_enable_register_save[index]);
248 if (acpi_hw_get_mode() != acpi_gbl_original_mode) {
249 acpi_hw_set_mode (acpi_gbl_original_mode);
253 return;
257 /******************************************************************************
259 * FUNCTION: Acpi_ev_terminate
261 * PARAMETERS: none
263 * RETURN: none
265 * DESCRIPTION: free memory allocated for table storage.
267 ******************************************************************************/
269 void
270 acpi_ev_terminate (void)
275 * Free global tables, etc.
278 if (acpi_gbl_gpe_registers) {
279 acpi_cm_free (acpi_gbl_gpe_registers);
282 if (acpi_gbl_gpe_info) {
283 acpi_cm_free (acpi_gbl_gpe_info);
286 return;