7eb308c36f811a055b9244571484079bc12b0f5b
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
34 #define _COMPONENT ACPI_EVENTS
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 */
140 case ACPI_EVENT_FIXED
:
142 /* Decode the Fixed Acpi_event */
145 case ACPI_EVENT_PMTIMER
:
146 register_id
= TMR_EN
;
149 case ACPI_EVENT_GLOBAL
:
150 register_id
= GBL_EN
;
153 case ACPI_EVENT_POWER_BUTTON
:
154 register_id
= PWRBTN_EN
;
157 case ACPI_EVENT_SLEEP_BUTTON
:
158 register_id
= SLPBTN_EN
;
162 register_id
= RTC_EN
;
166 return (AE_BAD_PARAMETER
);
171 * Enable the requested fixed event (by writing a one to the
172 * enable register bit)
175 acpi_hw_register_bit_access (ACPI_WRITE
, ACPI_MTX_LOCK
, register_id
, 1);
177 if (1 != acpi_hw_register_bit_access(ACPI_READ
, ACPI_MTX_LOCK
, register_id
)) {
178 return (AE_NO_HARDWARE_RESPONSE
);
186 /* Ensure that we have a valid GPE number */
188 if ((event
>= NUM_GPE
) ||
189 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
)) {
190 return (AE_BAD_PARAMETER
);
194 /* Enable the requested GPE number */
196 acpi_hw_enable_gpe (event
);
202 status
= AE_BAD_PARAMETER
;
210 /******************************************************************************
212 * FUNCTION: Acpi_disable_event
214 * PARAMETERS: Event - The fixed event or GPE to be enabled
215 * Type - The type of event
219 * DESCRIPTION: Disable an ACPI event (fixed and general purpose)
221 ******************************************************************************/
228 ACPI_STATUS status
= AE_OK
;
232 /* The Type must be either Fixed Acpi_event or GPE */
236 case ACPI_EVENT_FIXED
:
238 /* Decode the Fixed Acpi_event */
241 case ACPI_EVENT_PMTIMER
:
242 register_id
= TMR_EN
;
245 case ACPI_EVENT_GLOBAL
:
246 register_id
= GBL_EN
;
249 case ACPI_EVENT_POWER_BUTTON
:
250 register_id
= PWRBTN_EN
;
253 case ACPI_EVENT_SLEEP_BUTTON
:
254 register_id
= SLPBTN_EN
;
258 register_id
= RTC_EN
;
262 return (AE_BAD_PARAMETER
);
267 * Disable the requested fixed event (by writing a zero to the
268 * enable register bit)
271 acpi_hw_register_bit_access (ACPI_WRITE
, ACPI_MTX_LOCK
, register_id
, 0);
273 if (0 != acpi_hw_register_bit_access(ACPI_READ
, ACPI_MTX_LOCK
, register_id
)) {
274 return (AE_NO_HARDWARE_RESPONSE
);
282 /* Ensure that we have a valid GPE number */
284 if ((event
>= NUM_GPE
) ||
285 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
)) {
286 return (AE_BAD_PARAMETER
);
289 /* Disable the requested GPE number */
291 acpi_hw_disable_gpe (event
);
296 status
= AE_BAD_PARAMETER
;
303 /******************************************************************************
305 * FUNCTION: Acpi_clear_event
307 * PARAMETERS: Event - The fixed event or GPE to be cleared
308 * Type - The type of event
312 * DESCRIPTION: Clear an ACPI event (fixed and general purpose)
314 ******************************************************************************/
321 ACPI_STATUS status
= AE_OK
;
325 /* The Type must be either Fixed Acpi_event or GPE */
329 case ACPI_EVENT_FIXED
:
331 /* Decode the Fixed Acpi_event */
334 case ACPI_EVENT_PMTIMER
:
335 register_id
= TMR_STS
;
338 case ACPI_EVENT_GLOBAL
:
339 register_id
= GBL_STS
;
342 case ACPI_EVENT_POWER_BUTTON
:
343 register_id
= PWRBTN_STS
;
346 case ACPI_EVENT_SLEEP_BUTTON
:
347 register_id
= SLPBTN_STS
;
351 register_id
= RTC_STS
;
355 return (AE_BAD_PARAMETER
);
360 * Clear the requested fixed event (By writing a one to the
361 * status register bit)
364 acpi_hw_register_bit_access (ACPI_WRITE
, ACPI_MTX_LOCK
, register_id
, 1);
370 /* Ensure that we have a valid GPE number */
372 if ((event
>= NUM_GPE
) ||
373 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
)) {
374 return (AE_BAD_PARAMETER
);
378 acpi_hw_clear_gpe (event
);
384 status
= AE_BAD_PARAMETER
;
391 /******************************************************************************
393 * FUNCTION: Acpi_get_event_status
395 * PARAMETERS: Event - The fixed event or GPE
396 * Type - The type of event
397 * Status - Where the current status of the event will
402 * DESCRIPTION: Obtains and returns the current status of the event
404 ******************************************************************************/
408 acpi_get_event_status (
411 ACPI_EVENT_STATUS
*event_status
)
413 ACPI_STATUS status
= AE_OK
;
418 return (AE_BAD_PARAMETER
);
422 /* The Type must be either Fixed Acpi_event or GPE */
426 case ACPI_EVENT_FIXED
:
428 /* Decode the Fixed Acpi_event */
431 case ACPI_EVENT_PMTIMER
:
432 register_id
= TMR_STS
;
435 case ACPI_EVENT_GLOBAL
:
436 register_id
= GBL_STS
;
439 case ACPI_EVENT_POWER_BUTTON
:
440 register_id
= PWRBTN_STS
;
443 case ACPI_EVENT_SLEEP_BUTTON
:
444 register_id
= SLPBTN_STS
;
448 register_id
= RTC_STS
;
452 return (AE_BAD_PARAMETER
);
456 /* Get the status of the requested fixed event */
458 *event_status
= acpi_hw_register_bit_access (ACPI_READ
, ACPI_MTX_LOCK
, register_id
);
464 /* Ensure that we have a valid GPE number */
466 if ((event
>= NUM_GPE
) ||
467 (acpi_gbl_gpe_valid
[event
] == ACPI_GPE_INVALID
)) {
468 return (AE_BAD_PARAMETER
);
472 /* Obtain status on the requested GPE number */
474 acpi_hw_get_gpe_status (event
, event_status
);
479 status
= AE_BAD_PARAMETER
;