1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2012, 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 #include <linux/export.h>
45 #include <acpi/acpi.h>
49 #define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME("evxfevnt")
52 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
53 /*******************************************************************************
55 * FUNCTION: acpi_enable
61 * DESCRIPTION: Transfers the system into ACPI mode.
63 ******************************************************************************/
65 acpi_status
acpi_enable(void)
70 ACPI_FUNCTION_TRACE(acpi_enable
);
72 /* ACPI tables must be present */
74 if (!acpi_tb_tables_loaded()) {
75 return_ACPI_STATUS(AE_NO_ACPI_TABLES
);
78 /* Check current mode */
80 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI
) {
81 ACPI_DEBUG_PRINT((ACPI_DB_INIT
,
82 "System is already in ACPI mode\n"));
83 return_ACPI_STATUS(AE_OK
);
86 /* Transition to ACPI mode */
88 status
= acpi_hw_set_mode(ACPI_SYS_MODE_ACPI
);
89 if (ACPI_FAILURE(status
)) {
91 "Could not transition to ACPI mode"));
92 return_ACPI_STATUS(status
);
95 /* Sanity check that transition succeeded */
97 for (retry
= 0; retry
< 30000; ++retry
) {
98 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI
) {
100 ACPI_WARNING((AE_INFO
,
101 "Platform took > %d00 usec to enter ACPI mode", retry
));
102 return_ACPI_STATUS(AE_OK
);
104 acpi_os_stall(100); /* 100 usec */
107 ACPI_ERROR((AE_INFO
, "Hardware did not enter ACPI mode"));
108 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE
);
111 ACPI_EXPORT_SYMBOL(acpi_enable
)
113 /*******************************************************************************
115 * FUNCTION: acpi_disable
121 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
123 ******************************************************************************/
124 acpi_status
acpi_disable(void)
126 acpi_status status
= AE_OK
;
128 ACPI_FUNCTION_TRACE(acpi_disable
);
130 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY
) {
131 ACPI_DEBUG_PRINT((ACPI_DB_INIT
,
132 "System is already in legacy (non-ACPI) mode\n"));
134 /* Transition to LEGACY mode */
136 status
= acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY
);
138 if (ACPI_FAILURE(status
)) {
140 "Could not exit ACPI mode to legacy mode"));
141 return_ACPI_STATUS(status
);
144 ACPI_DEBUG_PRINT((ACPI_DB_INIT
, "ACPI mode disabled\n"));
147 return_ACPI_STATUS(status
);
150 ACPI_EXPORT_SYMBOL(acpi_disable
)
152 /*******************************************************************************
154 * FUNCTION: acpi_enable_event
156 * PARAMETERS: event - The fixed eventto be enabled
161 * DESCRIPTION: Enable an ACPI event (fixed)
163 ******************************************************************************/
164 acpi_status
acpi_enable_event(u32 event
, u32 flags
)
166 acpi_status status
= AE_OK
;
169 ACPI_FUNCTION_TRACE(acpi_enable_event
);
171 /* Decode the Fixed Event */
173 if (event
> ACPI_EVENT_MAX
) {
174 return_ACPI_STATUS(AE_BAD_PARAMETER
);
178 * Enable the requested fixed event (by writing a one to the enable
182 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
183 enable_register_id
, ACPI_ENABLE_EVENT
);
184 if (ACPI_FAILURE(status
)) {
185 return_ACPI_STATUS(status
);
188 /* Make sure that the hardware responded */
191 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
192 enable_register_id
, &value
);
193 if (ACPI_FAILURE(status
)) {
194 return_ACPI_STATUS(status
);
199 "Could not enable %s event",
200 acpi_ut_get_event_name(event
)));
201 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE
);
204 return_ACPI_STATUS(status
);
207 ACPI_EXPORT_SYMBOL(acpi_enable_event
)
209 /*******************************************************************************
211 * FUNCTION: acpi_disable_event
213 * PARAMETERS: Event - The fixed eventto be enabled
218 * DESCRIPTION: Disable an ACPI event (fixed)
220 ******************************************************************************/
221 acpi_status
acpi_disable_event(u32 event
, u32 flags
)
223 acpi_status status
= AE_OK
;
226 ACPI_FUNCTION_TRACE(acpi_disable_event
);
228 /* Decode the Fixed Event */
230 if (event
> ACPI_EVENT_MAX
) {
231 return_ACPI_STATUS(AE_BAD_PARAMETER
);
235 * Disable the requested fixed event (by writing a zero to the enable
239 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
240 enable_register_id
, ACPI_DISABLE_EVENT
);
241 if (ACPI_FAILURE(status
)) {
242 return_ACPI_STATUS(status
);
246 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
247 enable_register_id
, &value
);
248 if (ACPI_FAILURE(status
)) {
249 return_ACPI_STATUS(status
);
254 "Could not disable %s events",
255 acpi_ut_get_event_name(event
)));
256 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE
);
259 return_ACPI_STATUS(status
);
262 ACPI_EXPORT_SYMBOL(acpi_disable_event
)
264 /*******************************************************************************
266 * FUNCTION: acpi_clear_event
268 * PARAMETERS: event - The fixed event to be cleared
272 * DESCRIPTION: Clear an ACPI event (fixed)
274 ******************************************************************************/
275 acpi_status
acpi_clear_event(u32 event
)
277 acpi_status status
= AE_OK
;
279 ACPI_FUNCTION_TRACE(acpi_clear_event
);
281 /* Decode the Fixed Event */
283 if (event
> ACPI_EVENT_MAX
) {
284 return_ACPI_STATUS(AE_BAD_PARAMETER
);
288 * Clear the requested fixed event (By writing a one to the status
292 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
293 status_register_id
, ACPI_CLEAR_STATUS
);
295 return_ACPI_STATUS(status
);
298 ACPI_EXPORT_SYMBOL(acpi_clear_event
)
300 /*******************************************************************************
302 * FUNCTION: acpi_get_event_status
304 * PARAMETERS: event - The fixed event
305 * event_status - Where the current status of the event will
310 * DESCRIPTION: Obtains and returns the current status of the event
312 ******************************************************************************/
313 acpi_status
acpi_get_event_status(u32 event
, acpi_event_status
* event_status
)
315 acpi_status status
= AE_OK
;
318 ACPI_FUNCTION_TRACE(acpi_get_event_status
);
321 return_ACPI_STATUS(AE_BAD_PARAMETER
);
324 /* Decode the Fixed Event */
326 if (event
> ACPI_EVENT_MAX
) {
327 return_ACPI_STATUS(AE_BAD_PARAMETER
);
330 /* Get the status of the requested fixed event */
333 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
334 enable_register_id
, &value
);
335 if (ACPI_FAILURE(status
))
336 return_ACPI_STATUS(status
);
338 *event_status
= value
;
341 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
342 status_register_id
, &value
);
343 if (ACPI_FAILURE(status
))
344 return_ACPI_STATUS(status
);
347 *event_status
|= ACPI_EVENT_FLAG_SET
;
349 if (acpi_gbl_fixed_event_handlers
[event
].handler
)
350 *event_status
|= ACPI_EVENT_FLAG_HANDLE
;
352 return_ACPI_STATUS(status
);
355 ACPI_EXPORT_SYMBOL(acpi_get_event_status
)
356 #endif /* !ACPI_REDUCED_HARDWARE */