1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #define __EVXFEVNT_C__
46 #define EXPORT_ACPI_INTERFACES
52 #define _COMPONENT ACPI_EVENTS
53 ACPI_MODULE_NAME ("evxfevnt")
56 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
57 /*******************************************************************************
59 * FUNCTION: AcpiEnable
65 * DESCRIPTION: Transfers the system into ACPI mode.
67 ******************************************************************************/
73 ACPI_STATUS Status
= AE_OK
;
76 ACPI_FUNCTION_TRACE (AcpiEnable
);
79 /* ACPI tables must be present */
81 if (!AcpiTbTablesLoaded ())
83 return_ACPI_STATUS (AE_NO_ACPI_TABLES
);
86 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
88 if (AcpiGbl_ReducedHardware
)
90 return_ACPI_STATUS (AE_OK
);
93 /* Check current mode */
95 if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI
)
97 ACPI_DEBUG_PRINT ((ACPI_DB_INIT
, "System is already in ACPI mode\n"));
101 /* Transition to ACPI mode */
103 Status
= AcpiHwSetMode (ACPI_SYS_MODE_ACPI
);
104 if (ACPI_FAILURE (Status
))
106 ACPI_ERROR ((AE_INFO
, "Could not transition to ACPI mode"));
107 return_ACPI_STATUS (Status
);
110 ACPI_DEBUG_PRINT ((ACPI_DB_INIT
,
111 "Transition to ACPI mode successful\n"));
114 return_ACPI_STATUS (Status
);
117 ACPI_EXPORT_SYMBOL (AcpiEnable
)
120 /*******************************************************************************
122 * FUNCTION: AcpiDisable
128 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
130 ******************************************************************************/
136 ACPI_STATUS Status
= AE_OK
;
139 ACPI_FUNCTION_TRACE (AcpiDisable
);
142 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
144 if (AcpiGbl_ReducedHardware
)
146 return_ACPI_STATUS (AE_OK
);
149 if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY
)
151 ACPI_DEBUG_PRINT ((ACPI_DB_INIT
,
152 "System is already in legacy (non-ACPI) mode\n"));
156 /* Transition to LEGACY mode */
158 Status
= AcpiHwSetMode (ACPI_SYS_MODE_LEGACY
);
160 if (ACPI_FAILURE (Status
))
162 ACPI_ERROR ((AE_INFO
,
163 "Could not exit ACPI mode to legacy mode"));
164 return_ACPI_STATUS (Status
);
167 ACPI_DEBUG_PRINT ((ACPI_DB_INIT
, "ACPI mode disabled\n"));
170 return_ACPI_STATUS (Status
);
173 ACPI_EXPORT_SYMBOL (AcpiDisable
)
176 /*******************************************************************************
178 * FUNCTION: AcpiEnableEvent
180 * PARAMETERS: Event - The fixed eventto be enabled
185 * DESCRIPTION: Enable an ACPI event (fixed)
187 ******************************************************************************/
194 ACPI_STATUS Status
= AE_OK
;
198 ACPI_FUNCTION_TRACE (AcpiEnableEvent
);
201 /* Decode the Fixed Event */
203 if (Event
> ACPI_EVENT_MAX
)
205 return_ACPI_STATUS (AE_BAD_PARAMETER
);
209 * Enable the requested fixed event (by writing a one to the enable
212 Status
= AcpiWriteBitRegister (
213 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
,
215 if (ACPI_FAILURE (Status
))
217 return_ACPI_STATUS (Status
);
220 /* Make sure that the hardware responded */
222 Status
= AcpiReadBitRegister (
223 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
, &Value
);
224 if (ACPI_FAILURE (Status
))
226 return_ACPI_STATUS (Status
);
231 ACPI_ERROR ((AE_INFO
,
232 "Could not enable %s event", AcpiUtGetEventName (Event
)));
233 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE
);
236 return_ACPI_STATUS (Status
);
239 ACPI_EXPORT_SYMBOL (AcpiEnableEvent
)
242 /*******************************************************************************
244 * FUNCTION: AcpiDisableEvent
246 * PARAMETERS: Event - The fixed event to be disabled
251 * DESCRIPTION: Disable an ACPI event (fixed)
253 ******************************************************************************/
260 ACPI_STATUS Status
= AE_OK
;
264 ACPI_FUNCTION_TRACE (AcpiDisableEvent
);
267 /* Decode the Fixed Event */
269 if (Event
> ACPI_EVENT_MAX
)
271 return_ACPI_STATUS (AE_BAD_PARAMETER
);
275 * Disable the requested fixed event (by writing a zero to the enable
278 Status
= AcpiWriteBitRegister (
279 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
,
281 if (ACPI_FAILURE (Status
))
283 return_ACPI_STATUS (Status
);
286 Status
= AcpiReadBitRegister (
287 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
, &Value
);
288 if (ACPI_FAILURE (Status
))
290 return_ACPI_STATUS (Status
);
295 ACPI_ERROR ((AE_INFO
,
296 "Could not disable %s events", AcpiUtGetEventName (Event
)));
297 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE
);
300 return_ACPI_STATUS (Status
);
303 ACPI_EXPORT_SYMBOL (AcpiDisableEvent
)
306 /*******************************************************************************
308 * FUNCTION: AcpiClearEvent
310 * PARAMETERS: Event - The fixed event to be cleared
314 * DESCRIPTION: Clear an ACPI event (fixed)
316 ******************************************************************************/
322 ACPI_STATUS Status
= AE_OK
;
325 ACPI_FUNCTION_TRACE (AcpiClearEvent
);
328 /* Decode the Fixed Event */
330 if (Event
> ACPI_EVENT_MAX
)
332 return_ACPI_STATUS (AE_BAD_PARAMETER
);
336 * Clear the requested fixed event (By writing a one to the status
339 Status
= AcpiWriteBitRegister (
340 AcpiGbl_FixedEventInfo
[Event
].StatusRegisterId
,
343 return_ACPI_STATUS (Status
);
346 ACPI_EXPORT_SYMBOL (AcpiClearEvent
)
349 /*******************************************************************************
351 * FUNCTION: AcpiGetEventStatus
353 * PARAMETERS: Event - The fixed event
354 * EventStatus - Where the current status of the event will
359 * DESCRIPTION: Obtains and returns the current status of the event
361 ******************************************************************************/
366 ACPI_EVENT_STATUS
*EventStatus
)
368 ACPI_STATUS Status
= AE_OK
;
371 ACPI_FUNCTION_TRACE (AcpiGetEventStatus
);
376 return_ACPI_STATUS (AE_BAD_PARAMETER
);
379 /* Decode the Fixed Event */
381 if (Event
> ACPI_EVENT_MAX
)
383 return_ACPI_STATUS (AE_BAD_PARAMETER
);
386 /* Get the status of the requested fixed event */
388 Status
= AcpiReadBitRegister (
389 AcpiGbl_FixedEventInfo
[Event
].StatusRegisterId
, EventStatus
);
391 return_ACPI_STATUS (Status
);
394 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus
)
396 #endif /* !ACPI_REDUCED_HARDWARE */