1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
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
34 #define _COMPONENT EVENT_HANDLING
35 MODULE_NAME ("evxfevnt")
38 /**************************************************************************
40 * FUNCTION: Acpi_enable
46 * DESCRIPTION: Transfers the system into ACPI mode.
48 *************************************************************************/
56 /* Make sure we've got ACPI tables */
59 return (AE_NO_ACPI_TABLES
);
62 /* Make sure the BIOS supports ACPI mode */
64 if (SYS_MODE_LEGACY
== acpi_hw_get_mode_capabilities()) {
68 /* Transition to ACPI mode */
70 status
= acpi_hw_set_mode (SYS_MODE_ACPI
);
71 if (ACPI_FAILURE (status
)) {
79 /**************************************************************************
81 * FUNCTION: Acpi_disable
87 * DESCRIPTION: Returns the system to original ACPI/legacy mode, and
88 * uninstalls the SCI interrupt handler.
90 *************************************************************************/
98 /* Restore original mode */
100 status
= acpi_hw_set_mode (acpi_gbl_original_mode
);
101 if (ACPI_FAILURE (status
)) {
105 /* Unload the SCI interrupt handler */
107 acpi_ev_remove_sci_handler ();
108 acpi_ev_restore_acpi_state ();
114 /******************************************************************************
116 * FUNCTION: Acpi_enable_event
118 * PARAMETERS: Event - The fixed event or GPE to be enabled
119 * Type - The type of event
123 * DESCRIPTION: Enable an ACPI event (fixed and general purpose)
125 ******************************************************************************/
132 ACPI_STATUS status
= AE_OK
;
136 /* The Type must be either Fixed Acpi_event or GPE */
141 case ACPI_EVENT_FIXED
:
143 /* Decode the Fixed Acpi_event */
147 case ACPI_EVENT_PMTIMER
:
148 register_id
= TMR_EN
;
151 case ACPI_EVENT_GLOBAL
:
152 register_id
= GBL_EN
;
155 case ACPI_EVENT_POWER_BUTTON
:
156 register_id
= PWRBTN_EN
;
159 case ACPI_EVENT_SLEEP_BUTTON
:
160 register_id
= SLPBTN_EN
;
164 register_id
= RTC_EN
;
168 return (AE_BAD_PARAMETER
);
173 * Enable the requested fixed event (by writing a one to the
174 * enable register bit)
177 acpi_hw_register_bit_access (ACPI_WRITE
, ACPI_MTX_LOCK
, register_id
, 1);
179 if (1 != acpi_hw_register_bit_access(ACPI_READ
, ACPI_MTX_LOCK
, register_id
)) {
188 /* Ensure that we have a valid GPE number */
190 if ((event
>= NUM_GPE
) ||
191 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
))
193 return (AE_BAD_PARAMETER
);
197 /* Enable the requested GPE number */
199 acpi_hw_enable_gpe (event
);
205 status
= AE_BAD_PARAMETER
;
213 /******************************************************************************
215 * FUNCTION: Acpi_disable_event
217 * PARAMETERS: Event - The fixed event or GPE to be enabled
218 * Type - The type of event
222 * DESCRIPTION: Disable an ACPI event (fixed and general purpose)
224 ******************************************************************************/
231 ACPI_STATUS status
= AE_OK
;
235 /* The Type must be either Fixed Acpi_event or GPE */
240 case ACPI_EVENT_FIXED
:
242 /* Decode the Fixed Acpi_event */
246 case ACPI_EVENT_PMTIMER
:
247 register_id
= TMR_EN
;
250 case ACPI_EVENT_GLOBAL
:
251 register_id
= GBL_EN
;
254 case ACPI_EVENT_POWER_BUTTON
:
255 register_id
= PWRBTN_EN
;
258 case ACPI_EVENT_SLEEP_BUTTON
:
259 register_id
= SLPBTN_EN
;
263 register_id
= RTC_EN
;
267 return (AE_BAD_PARAMETER
);
272 * Disable the requested fixed event (by writing a zero to the
273 * enable register bit)
276 acpi_hw_register_bit_access (ACPI_WRITE
, ACPI_MTX_LOCK
, register_id
, 0);
278 if (0 != acpi_hw_register_bit_access(ACPI_READ
, ACPI_MTX_LOCK
, register_id
)) {
287 /* Ensure that we have a valid GPE number */
289 if ((event
>= NUM_GPE
) ||
290 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
))
292 return (AE_BAD_PARAMETER
);
295 /* Disable the requested GPE number */
297 acpi_hw_disable_gpe (event
);
302 status
= AE_BAD_PARAMETER
;
309 /******************************************************************************
311 * FUNCTION: Acpi_clear_event
313 * PARAMETERS: Event - The fixed event or GPE to be cleared
314 * Type - The type of event
318 * DESCRIPTION: Clear an ACPI event (fixed and general purpose)
320 ******************************************************************************/
327 ACPI_STATUS status
= AE_OK
;
331 /* The Type must be either Fixed Acpi_event or GPE */
336 case ACPI_EVENT_FIXED
:
338 /* Decode the Fixed Acpi_event */
342 case ACPI_EVENT_PMTIMER
:
343 register_id
= TMR_STS
;
346 case ACPI_EVENT_GLOBAL
:
347 register_id
= GBL_STS
;
350 case ACPI_EVENT_POWER_BUTTON
:
351 register_id
= PWRBTN_STS
;
354 case ACPI_EVENT_SLEEP_BUTTON
:
355 register_id
= SLPBTN_STS
;
359 register_id
= RTC_STS
;
363 return (AE_BAD_PARAMETER
);
368 * Clear the requested fixed event (By writing a one to the
369 * status register bit)
372 acpi_hw_register_bit_access (ACPI_WRITE
, ACPI_MTX_LOCK
, register_id
, 1);
378 /* Ensure that we have a valid GPE number */
380 if ((event
>= NUM_GPE
) ||
381 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
))
383 return (AE_BAD_PARAMETER
);
387 acpi_hw_clear_gpe (event
);
393 status
= AE_BAD_PARAMETER
;
400 /******************************************************************************
402 * FUNCTION: Acpi_get_event_status
404 * PARAMETERS: Event - The fixed event or GPE
405 * Type - The type of event
406 * Status - Where the current status of the event will
411 * DESCRIPTION: Obtains and returns the current status of the event
413 ******************************************************************************/
417 acpi_get_event_status (
420 ACPI_EVENT_STATUS
*event_status
)
422 ACPI_STATUS status
= AE_OK
;
427 return (AE_BAD_PARAMETER
);
431 /* The Type must be either Fixed Acpi_event or GPE */
436 case ACPI_EVENT_FIXED
:
438 /* Decode the Fixed Acpi_event */
442 case ACPI_EVENT_PMTIMER
:
443 register_id
= TMR_STS
;
446 case ACPI_EVENT_GLOBAL
:
447 register_id
= GBL_STS
;
450 case ACPI_EVENT_POWER_BUTTON
:
451 register_id
= PWRBTN_STS
;
454 case ACPI_EVENT_SLEEP_BUTTON
:
455 register_id
= SLPBTN_STS
;
459 register_id
= RTC_STS
;
463 return (AE_BAD_PARAMETER
);
467 /* Get the status of the requested fixed event */
469 *event_status
= acpi_hw_register_bit_access (ACPI_READ
, ACPI_MTX_LOCK
, register_id
);
475 /* Ensure that we have a valid GPE number */
477 if ((event
>= NUM_GPE
) ||
478 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
))
480 return (AE_BAD_PARAMETER
);
484 /* Obtain status on the requested GPE number */
486 acpi_hw_get_gpe_status (event
, event_status
);
491 status
= AE_BAD_PARAMETER
;