1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2017, 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.
44 #define EXPORT_ACPI_INTERFACES
50 #define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME ("evxfevnt")
54 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
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 (AcpiGbl_FadtIndex
== ACPI_INVALID_TABLE_INDEX
)
81 return_ACPI_STATUS (AE_NO_ACPI_TABLES
);
84 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
86 if (AcpiGbl_ReducedHardware
)
88 return_ACPI_STATUS (AE_OK
);
91 /* Check current mode */
93 if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI
)
95 ACPI_DEBUG_PRINT ((ACPI_DB_INIT
,
96 "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
,
167 "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 /* If Hardware Reduced flag is set, there are no fixed events */
203 if (AcpiGbl_ReducedHardware
)
205 return_ACPI_STATUS (AE_OK
);
208 /* Decode the Fixed Event */
210 if (Event
> ACPI_EVENT_MAX
)
212 return_ACPI_STATUS (AE_BAD_PARAMETER
);
216 * Enable the requested fixed event (by writing a one to the enable
219 Status
= AcpiWriteBitRegister (
220 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
,
222 if (ACPI_FAILURE (Status
))
224 return_ACPI_STATUS (Status
);
227 /* Make sure that the hardware responded */
229 Status
= AcpiReadBitRegister (
230 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
, &Value
);
231 if (ACPI_FAILURE (Status
))
233 return_ACPI_STATUS (Status
);
238 ACPI_ERROR ((AE_INFO
,
239 "Could not enable %s event", AcpiUtGetEventName (Event
)));
240 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE
);
243 return_ACPI_STATUS (Status
);
246 ACPI_EXPORT_SYMBOL (AcpiEnableEvent
)
249 /*******************************************************************************
251 * FUNCTION: AcpiDisableEvent
253 * PARAMETERS: Event - The fixed event to be disabled
258 * DESCRIPTION: Disable an ACPI event (fixed)
260 ******************************************************************************/
267 ACPI_STATUS Status
= AE_OK
;
271 ACPI_FUNCTION_TRACE (AcpiDisableEvent
);
274 /* If Hardware Reduced flag is set, there are no fixed events */
276 if (AcpiGbl_ReducedHardware
)
278 return_ACPI_STATUS (AE_OK
);
281 /* Decode the Fixed Event */
283 if (Event
> ACPI_EVENT_MAX
)
285 return_ACPI_STATUS (AE_BAD_PARAMETER
);
289 * Disable the requested fixed event (by writing a zero to the enable
292 Status
= AcpiWriteBitRegister (
293 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
,
295 if (ACPI_FAILURE (Status
))
297 return_ACPI_STATUS (Status
);
300 Status
= AcpiReadBitRegister (
301 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
, &Value
);
302 if (ACPI_FAILURE (Status
))
304 return_ACPI_STATUS (Status
);
309 ACPI_ERROR ((AE_INFO
,
310 "Could not disable %s events", AcpiUtGetEventName (Event
)));
311 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE
);
314 return_ACPI_STATUS (Status
);
317 ACPI_EXPORT_SYMBOL (AcpiDisableEvent
)
320 /*******************************************************************************
322 * FUNCTION: AcpiClearEvent
324 * PARAMETERS: Event - The fixed event to be cleared
328 * DESCRIPTION: Clear an ACPI event (fixed)
330 ******************************************************************************/
336 ACPI_STATUS Status
= AE_OK
;
339 ACPI_FUNCTION_TRACE (AcpiClearEvent
);
342 /* If Hardware Reduced flag is set, there are no fixed events */
344 if (AcpiGbl_ReducedHardware
)
346 return_ACPI_STATUS (AE_OK
);
349 /* Decode the Fixed Event */
351 if (Event
> ACPI_EVENT_MAX
)
353 return_ACPI_STATUS (AE_BAD_PARAMETER
);
357 * Clear the requested fixed event (By writing a one to the status
360 Status
= AcpiWriteBitRegister (
361 AcpiGbl_FixedEventInfo
[Event
].StatusRegisterId
,
364 return_ACPI_STATUS (Status
);
367 ACPI_EXPORT_SYMBOL (AcpiClearEvent
)
370 /*******************************************************************************
372 * FUNCTION: AcpiGetEventStatus
374 * PARAMETERS: Event - The fixed event
375 * EventStatus - Where the current status of the event will
380 * DESCRIPTION: Obtains and returns the current status of the event
382 ******************************************************************************/
387 ACPI_EVENT_STATUS
*EventStatus
)
390 ACPI_EVENT_STATUS LocalEventStatus
= 0;
394 ACPI_FUNCTION_TRACE (AcpiGetEventStatus
);
399 return_ACPI_STATUS (AE_BAD_PARAMETER
);
402 /* Decode the Fixed Event */
404 if (Event
> ACPI_EVENT_MAX
)
406 return_ACPI_STATUS (AE_BAD_PARAMETER
);
409 /* Fixed event currently can be dispatched? */
411 if (AcpiGbl_FixedEventHandlers
[Event
].Handler
)
413 LocalEventStatus
|= ACPI_EVENT_FLAG_HAS_HANDLER
;
416 /* Fixed event currently enabled? */
418 Status
= AcpiReadBitRegister (
419 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
, &InByte
);
420 if (ACPI_FAILURE (Status
))
422 return_ACPI_STATUS (Status
);
428 (ACPI_EVENT_FLAG_ENABLED
| ACPI_EVENT_FLAG_ENABLE_SET
);
431 /* Fixed event currently active? */
433 Status
= AcpiReadBitRegister (
434 AcpiGbl_FixedEventInfo
[Event
].StatusRegisterId
, &InByte
);
435 if (ACPI_FAILURE (Status
))
437 return_ACPI_STATUS (Status
);
442 LocalEventStatus
|= ACPI_EVENT_FLAG_STATUS_SET
;
445 (*EventStatus
) = LocalEventStatus
;
446 return_ACPI_STATUS (AE_OK
);
449 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus
)
451 #endif /* !ACPI_REDUCED_HARDWARE */