1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 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
29 #define _COMPONENT ACPI_EVENTS
30 MODULE_NAME ("evxfevnt")
33 /**************************************************************************
35 * FUNCTION: Acpi_enable
41 * DESCRIPTION: Transfers the system into ACPI mode.
43 *************************************************************************/
51 /* Make sure we've got ACPI tables */
54 return (AE_NO_ACPI_TABLES
);
57 /* Make sure the BIOS supports ACPI mode */
59 if (SYS_MODE_LEGACY
== acpi_hw_get_mode_capabilities()) {
63 /* Transition to ACPI mode */
65 status
= acpi_hw_set_mode (SYS_MODE_ACPI
);
66 if (ACPI_FAILURE (status
)) {
74 /**************************************************************************
76 * FUNCTION: Acpi_disable
82 * DESCRIPTION: Returns the system to original ACPI/legacy mode, and
83 * uninstalls the SCI interrupt handler.
85 *************************************************************************/
93 /* Restore original mode */
95 status
= acpi_hw_set_mode (acpi_gbl_original_mode
);
96 if (ACPI_FAILURE (status
)) {
100 /* Unload the SCI interrupt handler */
102 acpi_ev_remove_sci_handler ();
103 acpi_ev_restore_acpi_state ();
109 /******************************************************************************
111 * FUNCTION: Acpi_enable_event
113 * PARAMETERS: Event - The fixed event or GPE to be enabled
114 * Type - The type of event
118 * DESCRIPTION: Enable an ACPI event (fixed and general purpose)
120 ******************************************************************************/
127 ACPI_STATUS status
= AE_OK
;
131 /* The Type must be either Fixed Acpi_event or GPE */
135 case ACPI_EVENT_FIXED
:
137 /* Decode the Fixed Acpi_event */
140 case ACPI_EVENT_PMTIMER
:
141 register_id
= TMR_EN
;
144 case ACPI_EVENT_GLOBAL
:
145 register_id
= GBL_EN
;
148 case ACPI_EVENT_POWER_BUTTON
:
149 register_id
= PWRBTN_EN
;
152 case ACPI_EVENT_SLEEP_BUTTON
:
153 register_id
= SLPBTN_EN
;
157 register_id
= RTC_EN
;
161 return (AE_BAD_PARAMETER
);
166 * Enable the requested fixed event (by writing a one to the
167 * enable register bit)
170 acpi_hw_register_bit_access (ACPI_WRITE
, ACPI_MTX_LOCK
, register_id
, 1);
172 if (1 != acpi_hw_register_bit_access(ACPI_READ
, ACPI_MTX_LOCK
, register_id
)) {
173 return (AE_NO_HARDWARE_RESPONSE
);
181 /* Ensure that we have a valid GPE number */
183 if ((event
>= NUM_GPE
) ||
184 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
)) {
185 return (AE_BAD_PARAMETER
);
189 /* Enable the requested GPE number */
191 acpi_hw_enable_gpe (event
);
197 status
= AE_BAD_PARAMETER
;
205 /******************************************************************************
207 * FUNCTION: Acpi_disable_event
209 * PARAMETERS: Event - The fixed event or GPE to be enabled
210 * Type - The type of event
214 * DESCRIPTION: Disable an ACPI event (fixed and general purpose)
216 ******************************************************************************/
223 ACPI_STATUS status
= AE_OK
;
227 /* The Type must be either Fixed Acpi_event or GPE */
231 case ACPI_EVENT_FIXED
:
233 /* Decode the Fixed Acpi_event */
236 case ACPI_EVENT_PMTIMER
:
237 register_id
= TMR_EN
;
240 case ACPI_EVENT_GLOBAL
:
241 register_id
= GBL_EN
;
244 case ACPI_EVENT_POWER_BUTTON
:
245 register_id
= PWRBTN_EN
;
248 case ACPI_EVENT_SLEEP_BUTTON
:
249 register_id
= SLPBTN_EN
;
253 register_id
= RTC_EN
;
257 return (AE_BAD_PARAMETER
);
262 * Disable the requested fixed event (by writing a zero to the
263 * enable register bit)
266 acpi_hw_register_bit_access (ACPI_WRITE
, ACPI_MTX_LOCK
, register_id
, 0);
268 if (0 != acpi_hw_register_bit_access(ACPI_READ
, ACPI_MTX_LOCK
, register_id
)) {
269 return (AE_NO_HARDWARE_RESPONSE
);
277 /* Ensure that we have a valid GPE number */
279 if ((event
>= NUM_GPE
) ||
280 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
)) {
281 return (AE_BAD_PARAMETER
);
284 /* Disable the requested GPE number */
286 acpi_hw_disable_gpe (event
);
291 status
= AE_BAD_PARAMETER
;
298 /******************************************************************************
300 * FUNCTION: Acpi_clear_event
302 * PARAMETERS: Event - The fixed event or GPE to be cleared
303 * Type - The type of event
307 * DESCRIPTION: Clear an ACPI event (fixed and general purpose)
309 ******************************************************************************/
316 ACPI_STATUS status
= AE_OK
;
320 /* The Type must be either Fixed Acpi_event or GPE */
324 case ACPI_EVENT_FIXED
:
326 /* Decode the Fixed Acpi_event */
329 case ACPI_EVENT_PMTIMER
:
330 register_id
= TMR_STS
;
333 case ACPI_EVENT_GLOBAL
:
334 register_id
= GBL_STS
;
337 case ACPI_EVENT_POWER_BUTTON
:
338 register_id
= PWRBTN_STS
;
341 case ACPI_EVENT_SLEEP_BUTTON
:
342 register_id
= SLPBTN_STS
;
346 register_id
= RTC_STS
;
350 return (AE_BAD_PARAMETER
);
355 * Clear the requested fixed event (By writing a one to the
356 * status register bit)
359 acpi_hw_register_bit_access (ACPI_WRITE
, ACPI_MTX_LOCK
, register_id
, 1);
365 /* Ensure that we have a valid GPE number */
367 if ((event
>= NUM_GPE
) ||
368 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
)) {
369 return (AE_BAD_PARAMETER
);
373 acpi_hw_clear_gpe (event
);
379 status
= AE_BAD_PARAMETER
;
386 /******************************************************************************
388 * FUNCTION: Acpi_get_event_status
390 * PARAMETERS: Event - The fixed event or GPE
391 * Type - The type of event
392 * Status - Where the current status of the event will
397 * DESCRIPTION: Obtains and returns the current status of the event
399 ******************************************************************************/
403 acpi_get_event_status (
406 ACPI_EVENT_STATUS
*event_status
)
408 ACPI_STATUS status
= AE_OK
;
413 return (AE_BAD_PARAMETER
);
417 /* The Type must be either Fixed Acpi_event or GPE */
421 case ACPI_EVENT_FIXED
:
423 /* Decode the Fixed Acpi_event */
426 case ACPI_EVENT_PMTIMER
:
427 register_id
= TMR_STS
;
430 case ACPI_EVENT_GLOBAL
:
431 register_id
= GBL_STS
;
434 case ACPI_EVENT_POWER_BUTTON
:
435 register_id
= PWRBTN_STS
;
438 case ACPI_EVENT_SLEEP_BUTTON
:
439 register_id
= SLPBTN_STS
;
443 register_id
= RTC_STS
;
447 return (AE_BAD_PARAMETER
);
451 /* Get the status of the requested fixed event */
453 *event_status
= acpi_hw_register_bit_access (ACPI_READ
, ACPI_MTX_LOCK
, register_id
);
459 /* Ensure that we have a valid GPE number */
461 if ((event
>= NUM_GPE
) ||
462 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
)) {
463 return (AE_BAD_PARAMETER
);
467 /* Obtain status on the requested GPE number */
469 acpi_hw_get_gpe_status (event
, event_status
);
474 status
= AE_BAD_PARAMETER
;