1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2011, 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 /*******************************************************************************
57 * FUNCTION: AcpiEnable
63 * DESCRIPTION: Transfers the system into ACPI mode.
65 ******************************************************************************/
71 ACPI_STATUS Status = AE_OK;
74 ACPI_FUNCTION_TRACE (AcpiEnable);
77 /* ACPI tables must be present */
79 if (!AcpiTbTablesLoaded ())
81 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
84 /* Check current mode */
86 if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
88 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
92 /* Transition to ACPI mode */
94 Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
95 if (ACPI_FAILURE (Status))
97 ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
98 return_ACPI_STATUS (Status);
101 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
102 "Transition to ACPI mode successful\n"));
105 return_ACPI_STATUS (Status);
108 ACPI_EXPORT_SYMBOL (AcpiEnable)
111 /*******************************************************************************
113 * FUNCTION: AcpiDisable
119 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
121 ******************************************************************************/
127 ACPI_STATUS Status = AE_OK;
130 ACPI_FUNCTION_TRACE (AcpiDisable);
133 if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
135 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
136 "System is already in legacy (non-ACPI) mode\n"));
140 /* Transition to LEGACY mode */
142 Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
144 if (ACPI_FAILURE (Status))
146 ACPI_ERROR ((AE_INFO,
147 "Could not exit ACPI mode to legacy mode"));
148 return_ACPI_STATUS (Status);
151 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
154 return_ACPI_STATUS (Status);
157 ACPI_EXPORT_SYMBOL (AcpiDisable)
160 /*******************************************************************************
162 * FUNCTION: AcpiEnableEvent
164 * PARAMETERS: Event - The fixed eventto be enabled
169 * DESCRIPTION: Enable an ACPI event (fixed)
171 ******************************************************************************/
178 ACPI_STATUS Status = AE_OK;
182 ACPI_FUNCTION_TRACE (AcpiEnableEvent);
185 /* Decode the Fixed Event */
187 if (Event > ACPI_EVENT_MAX)
189 return_ACPI_STATUS (AE_BAD_PARAMETER);
193 * Enable the requested fixed event (by writing a one to the enable
196 Status = AcpiWriteBitRegister (
197 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
199 if (ACPI_FAILURE (Status))
201 return_ACPI_STATUS (Status);
204 /* Make sure that the hardware responded */
206 Status = AcpiReadBitRegister (
207 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
208 if (ACPI_FAILURE (Status))
210 return_ACPI_STATUS (Status);
215 ACPI_ERROR ((AE_INFO,
216 "Could not enable %s event", AcpiUtGetEventName (Event)));
217 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
220 return_ACPI_STATUS (Status);
223 ACPI_EXPORT_SYMBOL (AcpiEnableEvent)
226 /*******************************************************************************
228 * FUNCTION: AcpiDisableEvent
230 * PARAMETERS: Event - The fixed event to be disabled
235 * DESCRIPTION: Disable an ACPI event (fixed)
237 ******************************************************************************/
244 ACPI_STATUS Status = AE_OK;
248 ACPI_FUNCTION_TRACE (AcpiDisableEvent);
251 /* Decode the Fixed Event */
253 if (Event > ACPI_EVENT_MAX)
255 return_ACPI_STATUS (AE_BAD_PARAMETER);
259 * Disable the requested fixed event (by writing a zero to the enable
262 Status = AcpiWriteBitRegister (
263 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
265 if (ACPI_FAILURE (Status))
267 return_ACPI_STATUS (Status);
270 Status = AcpiReadBitRegister (
271 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
272 if (ACPI_FAILURE (Status))
274 return_ACPI_STATUS (Status);
279 ACPI_ERROR ((AE_INFO,
280 "Could not disable %s events", AcpiUtGetEventName (Event)));
281 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
284 return_ACPI_STATUS (Status);
287 ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
290 /*******************************************************************************
292 * FUNCTION: AcpiClearEvent
294 * PARAMETERS: Event - The fixed event to be cleared
298 * DESCRIPTION: Clear an ACPI event (fixed)
300 ******************************************************************************/
306 ACPI_STATUS Status = AE_OK;
309 ACPI_FUNCTION_TRACE (AcpiClearEvent);
312 /* Decode the Fixed Event */
314 if (Event > ACPI_EVENT_MAX)
316 return_ACPI_STATUS (AE_BAD_PARAMETER);
320 * Clear the requested fixed event (By writing a one to the status
323 Status = AcpiWriteBitRegister (
324 AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
327 return_ACPI_STATUS (Status);
330 ACPI_EXPORT_SYMBOL (AcpiClearEvent)
333 /*******************************************************************************
335 * FUNCTION: AcpiGetEventStatus
337 * PARAMETERS: Event - The fixed event
338 * EventStatus - Where the current status of the event will
343 * DESCRIPTION: Obtains and returns the current status of the event
345 ******************************************************************************/
350 ACPI_EVENT_STATUS *EventStatus)
352 ACPI_STATUS Status = AE_OK;
355 ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
360 return_ACPI_STATUS (AE_BAD_PARAMETER);
363 /* Decode the Fixed Event */
365 if (Event > ACPI_EVENT_MAX)
367 return_ACPI_STATUS (AE_BAD_PARAMETER);
370 /* Get the status of the requested fixed event */
372 Status = AcpiReadBitRegister (
373 AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus);
375 return_ACPI_STATUS (Status);
378 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)