Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | /******************************************************************************* * * Module Name: evsci - System Control Interrupt configuration and * legacy to ACPI mode state transition functions * $Revision: 74 $ * ******************************************************************************/ /* * Copyright (C) 2000, 2001 R. Byron Moore * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "acpi.h" #include "acnamesp.h" #include "achware.h" #include "acevents.h" #define _COMPONENT ACPI_EVENTS MODULE_NAME ("evsci") /* * Elements correspond to counts for TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC, * and GENERAL respectively. These counts are modified by the ACPI interrupt * handler. * * TBD: [Investigate] Note that GENERAL should probably be split out into * one element for each bit in the GPE registers */ /******************************************************************************* * * FUNCTION: Acpi_ev_sci_handler * * PARAMETERS: Context - Calling Context * * RETURN: Status code indicates whether interrupt was handled. * * DESCRIPTION: Interrupt handler that will figure out what function or * control method to call to deal with a SCI. Installed * using BU interrupt support. * ******************************************************************************/ static u32 acpi_ev_sci_handler (void *context) { u32 interrupt_handled = INTERRUPT_NOT_HANDLED; FUNCTION_TRACE("Ev_sci_handler"); /* * Make sure that ACPI is enabled by checking SCI_EN. Note that we are * required to treat the SCI interrupt as sharable, level, active low. */ if (!acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, SCI_EN)) { /* ACPI is not enabled; this interrupt cannot be for us */ return_VALUE (INTERRUPT_NOT_HANDLED); } /* * Fixed Acpi_events: * ------------- * Check for and dispatch any Fixed Acpi_events that have occurred */ interrupt_handled |= acpi_ev_fixed_event_detect (); /* * GPEs: * ----- * Check for and dispatch any GPEs that have occurred */ interrupt_handled |= acpi_ev_gpe_detect (); return_VALUE (interrupt_handled); } /****************************************************************************** * * FUNCTION: Acpi_ev_install_sci_handler * * PARAMETERS: none * * RETURN: Status * * DESCRIPTION: Installs SCI handler. * ******************************************************************************/ u32 acpi_ev_install_sci_handler (void) { u32 status = AE_OK; FUNCTION_TRACE ("Ev_install_sci_handler"); status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, acpi_ev_sci_handler, NULL); return_ACPI_STATUS (status); } /****************************************************************************** * * FUNCTION: Acpi_ev_remove_sci_handler * * PARAMETERS: none * * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not * installed to begin with * * DESCRIPTION: Restores original status of all fixed event enable bits and * removes SCI handler. * ******************************************************************************/ acpi_status acpi_ev_remove_sci_handler (void) { FUNCTION_TRACE ("Ev_remove_sci_handler"); #if 0 /* TBD:[Investigate] Figure this out!! Disable all events first ??? */ if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (TMR_FIXED_EVENT)) { acpi_event_disable_event (TMR_FIXED_EVENT); } if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (GBL_FIXED_EVENT)) { acpi_event_disable_event (GBL_FIXED_EVENT); } if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (PWR_BTN_FIXED_EVENT)) { acpi_event_disable_event (PWR_BTN_FIXED_EVENT); } if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (SLP_BTN_FIXED_EVENT)) { acpi_event_disable_event (SLP_BTN_FIXED_EVENT); } if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (RTC_FIXED_EVENT)) { acpi_event_disable_event (RTC_FIXED_EVENT); } original_fixed_enable_bit_status = 0; #endif acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, acpi_ev_sci_handler); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ev_restore_acpi_state * * PARAMETERS: none * * RETURN: none * * DESCRIPTION: Restore the original ACPI state of the machine * ******************************************************************************/ void acpi_ev_restore_acpi_state (void) { u32 index; FUNCTION_TRACE ("Ev_restore_acpi_state"); /* Restore the state of the chipset enable bits. */ if (acpi_gbl_restore_acpi_chipset == TRUE) { /* Restore the fixed events */ if (acpi_hw_register_read (ACPI_MTX_LOCK, PM1_EN) != acpi_gbl_pm1_enable_register_save) { acpi_hw_register_write (ACPI_MTX_LOCK, PM1_EN, acpi_gbl_pm1_enable_register_save); } /* Ensure that all status bits are clear */ acpi_hw_clear_acpi_status (); /* Now restore the GPEs */ for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) { if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index) != acpi_gbl_gpe0enable_register_save[index]) { acpi_hw_register_write (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index, acpi_gbl_gpe0enable_register_save[index]); } } /* GPE 1 present? */ if (acpi_gbl_FADT->gpe1_blk_len) { for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) { if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index) != acpi_gbl_gpe1_enable_register_save[index]) { acpi_hw_register_write (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index, acpi_gbl_gpe1_enable_register_save[index]); } } } if (acpi_hw_get_mode() != acpi_gbl_original_mode) { acpi_hw_set_mode (acpi_gbl_original_mode); } } return_VOID; } /****************************************************************************** * * FUNCTION: Acpi_ev_terminate * * PARAMETERS: none * * RETURN: none * * DESCRIPTION: free memory allocated for table storage. * ******************************************************************************/ void acpi_ev_terminate (void) { FUNCTION_TRACE ("Ev_terminate"); /* * Free global tables, etc. */ if (acpi_gbl_gpe_registers) { ACPI_MEM_FREE (acpi_gbl_gpe_registers); } if (acpi_gbl_gpe_info) { ACPI_MEM_FREE (acpi_gbl_gpe_info); } return_VOID; } |