i2c-eg20t: change timeout value 50msec to 1000msec
[zen-stable.git] / drivers / acpi / acpica / evxfevnt.c
blob1768bbec10023613fdce37d84f400907a69c8f8b
1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
30 * NO WARRANTY
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>
46 #include "accommon.h"
47 #include "actables.h"
49 #define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME("evxfevnt")
52 /*******************************************************************************
54 * FUNCTION: acpi_enable
56 * PARAMETERS: None
58 * RETURN: Status
60 * DESCRIPTION: Transfers the system into ACPI mode.
62 ******************************************************************************/
64 acpi_status acpi_enable(void)
66 acpi_status status;
67 int retry;
69 ACPI_FUNCTION_TRACE(acpi_enable);
71 /* ACPI tables must be present */
73 if (!acpi_tb_tables_loaded()) {
74 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
77 /* Check current mode */
79 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
80 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
81 "System is already in ACPI mode\n"));
82 return_ACPI_STATUS(AE_OK);
85 /* Transition to ACPI mode */
87 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
88 if (ACPI_FAILURE(status)) {
89 ACPI_ERROR((AE_INFO,
90 "Could not transition to ACPI mode"));
91 return_ACPI_STATUS(status);
94 /* Sanity check that transition succeeded */
96 for (retry = 0; retry < 30000; ++retry) {
97 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
98 if (retry != 0)
99 ACPI_WARNING((AE_INFO,
100 "Platform took > %d00 usec to enter ACPI mode", retry));
101 return_ACPI_STATUS(AE_OK);
103 acpi_os_stall(100); /* 100 usec */
106 ACPI_ERROR((AE_INFO, "Hardware did not enter ACPI mode"));
107 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
110 ACPI_EXPORT_SYMBOL(acpi_enable)
112 /*******************************************************************************
114 * FUNCTION: acpi_disable
116 * PARAMETERS: None
118 * RETURN: Status
120 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
122 ******************************************************************************/
123 acpi_status acpi_disable(void)
125 acpi_status status = AE_OK;
127 ACPI_FUNCTION_TRACE(acpi_disable);
129 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
130 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
131 "System is already in legacy (non-ACPI) mode\n"));
132 } else {
133 /* Transition to LEGACY mode */
135 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
137 if (ACPI_FAILURE(status)) {
138 ACPI_ERROR((AE_INFO,
139 "Could not exit ACPI mode to legacy mode"));
140 return_ACPI_STATUS(status);
143 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
146 return_ACPI_STATUS(status);
149 ACPI_EXPORT_SYMBOL(acpi_disable)
151 /*******************************************************************************
153 * FUNCTION: acpi_enable_event
155 * PARAMETERS: Event - The fixed eventto be enabled
156 * Flags - Reserved
158 * RETURN: Status
160 * DESCRIPTION: Enable an ACPI event (fixed)
162 ******************************************************************************/
163 acpi_status acpi_enable_event(u32 event, u32 flags)
165 acpi_status status = AE_OK;
166 u32 value;
168 ACPI_FUNCTION_TRACE(acpi_enable_event);
170 /* Decode the Fixed Event */
172 if (event > ACPI_EVENT_MAX) {
173 return_ACPI_STATUS(AE_BAD_PARAMETER);
177 * Enable the requested fixed event (by writing a one to the enable
178 * register bit)
180 status =
181 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
182 enable_register_id, ACPI_ENABLE_EVENT);
183 if (ACPI_FAILURE(status)) {
184 return_ACPI_STATUS(status);
187 /* Make sure that the hardware responded */
189 status =
190 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
191 enable_register_id, &value);
192 if (ACPI_FAILURE(status)) {
193 return_ACPI_STATUS(status);
196 if (value != 1) {
197 ACPI_ERROR((AE_INFO,
198 "Could not enable %s event",
199 acpi_ut_get_event_name(event)));
200 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
203 return_ACPI_STATUS(status);
206 ACPI_EXPORT_SYMBOL(acpi_enable_event)
208 /*******************************************************************************
210 * FUNCTION: acpi_disable_event
212 * PARAMETERS: Event - The fixed eventto be enabled
213 * Flags - Reserved
215 * RETURN: Status
217 * DESCRIPTION: Disable an ACPI event (fixed)
219 ******************************************************************************/
220 acpi_status acpi_disable_event(u32 event, u32 flags)
222 acpi_status status = AE_OK;
223 u32 value;
225 ACPI_FUNCTION_TRACE(acpi_disable_event);
227 /* Decode the Fixed Event */
229 if (event > ACPI_EVENT_MAX) {
230 return_ACPI_STATUS(AE_BAD_PARAMETER);
234 * Disable the requested fixed event (by writing a zero to the enable
235 * register bit)
237 status =
238 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
239 enable_register_id, ACPI_DISABLE_EVENT);
240 if (ACPI_FAILURE(status)) {
241 return_ACPI_STATUS(status);
244 status =
245 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
246 enable_register_id, &value);
247 if (ACPI_FAILURE(status)) {
248 return_ACPI_STATUS(status);
251 if (value != 0) {
252 ACPI_ERROR((AE_INFO,
253 "Could not disable %s events",
254 acpi_ut_get_event_name(event)));
255 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
258 return_ACPI_STATUS(status);
261 ACPI_EXPORT_SYMBOL(acpi_disable_event)
263 /*******************************************************************************
265 * FUNCTION: acpi_clear_event
267 * PARAMETERS: Event - The fixed event to be cleared
269 * RETURN: Status
271 * DESCRIPTION: Clear an ACPI event (fixed)
273 ******************************************************************************/
274 acpi_status acpi_clear_event(u32 event)
276 acpi_status status = AE_OK;
278 ACPI_FUNCTION_TRACE(acpi_clear_event);
280 /* Decode the Fixed Event */
282 if (event > ACPI_EVENT_MAX) {
283 return_ACPI_STATUS(AE_BAD_PARAMETER);
287 * Clear the requested fixed event (By writing a one to the status
288 * register bit)
290 status =
291 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
292 status_register_id, ACPI_CLEAR_STATUS);
294 return_ACPI_STATUS(status);
297 ACPI_EXPORT_SYMBOL(acpi_clear_event)
299 /*******************************************************************************
301 * FUNCTION: acpi_get_event_status
303 * PARAMETERS: Event - The fixed event
304 * event_status - Where the current status of the event will
305 * be returned
307 * RETURN: Status
309 * DESCRIPTION: Obtains and returns the current status of the event
311 ******************************************************************************/
312 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
314 acpi_status status = AE_OK;
315 u32 value;
317 ACPI_FUNCTION_TRACE(acpi_get_event_status);
319 if (!event_status) {
320 return_ACPI_STATUS(AE_BAD_PARAMETER);
323 /* Decode the Fixed Event */
325 if (event > ACPI_EVENT_MAX) {
326 return_ACPI_STATUS(AE_BAD_PARAMETER);
329 /* Get the status of the requested fixed event */
331 status =
332 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
333 enable_register_id, &value);
334 if (ACPI_FAILURE(status))
335 return_ACPI_STATUS(status);
337 *event_status = value;
339 status =
340 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
341 status_register_id, &value);
342 if (ACPI_FAILURE(status))
343 return_ACPI_STATUS(status);
345 if (value)
346 *event_status |= ACPI_EVENT_FLAG_SET;
348 if (acpi_gbl_fixed_event_handlers[event].handler)
349 *event_status |= ACPI_EVENT_FLAG_HANDLE;
351 return_ACPI_STATUS(status);
354 ACPI_EXPORT_SYMBOL(acpi_get_event_status)