1 /*******************************************************************************
3 * Module Name: evsci - System Control Interrupt configuration and
4 * legacy to ACPI mode state transition functions
7 ******************************************************************************/
10 * Copyright (C) 2000, 2001 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
33 #define _COMPONENT ACPI_EVENTS
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
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 ******************************************************************************/
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
);
80 * Check for and dispatch any Fixed Acpi_events that have occurred
82 interrupt_handled
|= acpi_ev_fixed_event_detect ();
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
103 * DESCRIPTION: Installs SCI handler.
105 ******************************************************************************/
108 acpi_ev_install_sci_handler (void)
113 except
= acpi_os_install_interrupt_handler ((u32
) acpi_gbl_FADT
->sci_int
,
121 /******************************************************************************
124 * FUNCTION: Acpi_ev_remove_sci_handler
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 ******************************************************************************/
137 acpi_ev_remove_sci_handler (void)
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;
166 acpi_os_remove_interrupt_handler ((u32
) acpi_gbl_FADT
->sci_int
,
167 acpi_ev_sci_handler
);
173 /*******************************************************************************
175 * FUNCTION: Acpi_ev_restore_acpi_state
181 * DESCRIPTION: Restore the original ACPI state of the machine
183 ******************************************************************************/
186 acpi_ev_restore_acpi_state (void)
191 /* Restore the state of the chipset enable bits. */
193 if (acpi_gbl_restore_acpi_chipset
== TRUE
) {
194 /* Restore the fixed events */
196 if (acpi_hw_register_read (ACPI_MTX_LOCK
, PM1_EN
) !=
197 acpi_gbl_pm1_enable_register_save
) {
198 acpi_hw_register_write (ACPI_MTX_LOCK
, PM1_EN
,
199 acpi_gbl_pm1_enable_register_save
);
203 /* Ensure that all status bits are clear */
205 acpi_hw_clear_acpi_status ();
208 /* Now restore the GPEs */
210 for (index
= 0; index
< DIV_2 (acpi_gbl_FADT
->gpe0blk_len
); index
++) {
211 if (acpi_hw_register_read (ACPI_MTX_LOCK
, GPE0_EN_BLOCK
| index
) !=
212 acpi_gbl_gpe0enable_register_save
[index
]) {
213 acpi_hw_register_write (ACPI_MTX_LOCK
, GPE0_EN_BLOCK
| index
,
214 acpi_gbl_gpe0enable_register_save
[index
]);
220 if (acpi_gbl_FADT
->gpe1_blk_len
) {
221 for (index
= 0; index
< DIV_2 (acpi_gbl_FADT
->gpe1_blk_len
); index
++) {
222 if (acpi_hw_register_read (ACPI_MTX_LOCK
, GPE1_EN_BLOCK
| index
) !=
223 acpi_gbl_gpe1_enable_register_save
[index
]) {
224 acpi_hw_register_write (ACPI_MTX_LOCK
, GPE1_EN_BLOCK
| index
,
225 acpi_gbl_gpe1_enable_register_save
[index
]);
230 if (acpi_hw_get_mode() != acpi_gbl_original_mode
) {
231 acpi_hw_set_mode (acpi_gbl_original_mode
);
239 /******************************************************************************
241 * FUNCTION: Acpi_ev_terminate
247 * DESCRIPTION: free memory allocated for table storage.
249 ******************************************************************************/
252 acpi_ev_terminate (void)
257 * Free global tables, etc.
260 if (acpi_gbl_gpe_registers
) {
261 acpi_cm_free (acpi_gbl_gpe_registers
);
264 if (acpi_gbl_gpe_info
) {
265 acpi_cm_free (acpi_gbl_gpe_info
);