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__
47 #include <contrib/dev/acpica/include/acpi.h>
48 #include <contrib/dev/acpica/include/accommon.h>
49 #include <contrib/dev/acpica/include/actables.h>
51 #define _COMPONENT ACPI_EVENTS
52 ACPI_MODULE_NAME ("evxfevnt")
55 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
56 /*******************************************************************************
58 * FUNCTION: AcpiEnable
64 * DESCRIPTION: Transfers the system into ACPI mode.
66 ******************************************************************************/
72 ACPI_STATUS Status = AE_OK;
75 ACPI_FUNCTION_TRACE (AcpiEnable);
78 /* ACPI tables must be present */
80 if (!AcpiTbTablesLoaded ())
82 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
85 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
87 if (AcpiGbl_ReducedHardware)
89 return_ACPI_STATUS (AE_OK);
92 /* Check current mode */
94 if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
96 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
100 /* Transition to ACPI mode */
102 Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
103 if (ACPI_FAILURE (Status))
105 ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
106 return_ACPI_STATUS (Status);
109 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
110 "Transition to ACPI mode successful\n"));
113 return_ACPI_STATUS (Status);
116 ACPI_EXPORT_SYMBOL (AcpiEnable)
119 /*******************************************************************************
121 * FUNCTION: AcpiDisable
127 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
129 ******************************************************************************/
135 ACPI_STATUS Status = AE_OK;
138 ACPI_FUNCTION_TRACE (AcpiDisable);
141 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
143 if (AcpiGbl_ReducedHardware)
145 return_ACPI_STATUS (AE_OK);
148 if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
150 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
151 "System is already in legacy (non-ACPI) mode\n"));
155 /* Transition to LEGACY mode */
157 Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
159 if (ACPI_FAILURE (Status))
161 ACPI_ERROR ((AE_INFO,
162 "Could not exit ACPI mode to legacy mode"));
163 return_ACPI_STATUS (Status);
166 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
169 return_ACPI_STATUS (Status);
172 ACPI_EXPORT_SYMBOL (AcpiDisable)
175 /*******************************************************************************
177 * FUNCTION: AcpiEnableEvent
179 * PARAMETERS: Event - The fixed eventto be enabled
184 * DESCRIPTION: Enable an ACPI event (fixed)
186 ******************************************************************************/
193 ACPI_STATUS Status = AE_OK;
197 ACPI_FUNCTION_TRACE (AcpiEnableEvent);
200 /* Decode the Fixed Event */
202 if (Event > ACPI_EVENT_MAX)
204 return_ACPI_STATUS (AE_BAD_PARAMETER);
208 * Enable the requested fixed event (by writing a one to the enable
211 Status = AcpiWriteBitRegister (
212 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
214 if (ACPI_FAILURE (Status))
216 return_ACPI_STATUS (Status);
219 /* Make sure that the hardware responded */
221 Status = AcpiReadBitRegister (
222 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
223 if (ACPI_FAILURE (Status))
225 return_ACPI_STATUS (Status);
230 ACPI_ERROR ((AE_INFO,
231 "Could not enable %s event", AcpiUtGetEventName (Event)));
232 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
235 return_ACPI_STATUS (Status);
238 ACPI_EXPORT_SYMBOL (AcpiEnableEvent)
241 /*******************************************************************************
243 * FUNCTION: AcpiDisableEvent
245 * PARAMETERS: Event - The fixed event to be disabled
250 * DESCRIPTION: Disable an ACPI event (fixed)
252 ******************************************************************************/
259 ACPI_STATUS Status = AE_OK;
263 ACPI_FUNCTION_TRACE (AcpiDisableEvent);
266 /* Decode the Fixed Event */
268 if (Event > ACPI_EVENT_MAX)
270 return_ACPI_STATUS (AE_BAD_PARAMETER);
274 * Disable the requested fixed event (by writing a zero to the enable
277 Status = AcpiWriteBitRegister (
278 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
280 if (ACPI_FAILURE (Status))
282 return_ACPI_STATUS (Status);
285 Status = AcpiReadBitRegister (
286 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
287 if (ACPI_FAILURE (Status))
289 return_ACPI_STATUS (Status);
294 ACPI_ERROR ((AE_INFO,
295 "Could not disable %s events", AcpiUtGetEventName (Event)));
296 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
299 return_ACPI_STATUS (Status);
302 ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
305 /*******************************************************************************
307 * FUNCTION: AcpiClearEvent
309 * PARAMETERS: Event - The fixed event to be cleared
313 * DESCRIPTION: Clear an ACPI event (fixed)
315 ******************************************************************************/
321 ACPI_STATUS Status = AE_OK;
324 ACPI_FUNCTION_TRACE (AcpiClearEvent);
327 /* Decode the Fixed Event */
329 if (Event > ACPI_EVENT_MAX)
331 return_ACPI_STATUS (AE_BAD_PARAMETER);
335 * Clear the requested fixed event (By writing a one to the status
338 Status = AcpiWriteBitRegister (
339 AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
342 return_ACPI_STATUS (Status);
345 ACPI_EXPORT_SYMBOL (AcpiClearEvent)
348 /*******************************************************************************
350 * FUNCTION: AcpiGetEventStatus
352 * PARAMETERS: Event - The fixed event
353 * EventStatus - Where the current status of the event will
358 * DESCRIPTION: Obtains and returns the current status of the event
360 ******************************************************************************/
365 ACPI_EVENT_STATUS *EventStatus)
367 ACPI_STATUS Status = AE_OK;
370 ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
375 return_ACPI_STATUS (AE_BAD_PARAMETER);
378 /* Decode the Fixed Event */
380 if (Event > ACPI_EVENT_MAX)
382 return_ACPI_STATUS (AE_BAD_PARAMETER);
385 /* Get the status of the requested fixed event */
387 Status = AcpiReadBitRegister (
388 AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus);
390 return_ACPI_STATUS (Status);
393 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
395 #endif /* !ACPI_REDUCED_HARDWARE */