sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / acpi / acpica / evxfevnt.c
blob9179e9abe3db2e4a12f0596450985699c513836c
1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2016, 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 #define EXPORT_ACPI_INTERFACES
46 #include <acpi/acpi.h>
47 #include "accommon.h"
48 #include "actables.h"
50 #define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME("evxfevnt")
53 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
54 /*******************************************************************************
56 * FUNCTION: acpi_enable
58 * PARAMETERS: None
60 * RETURN: Status
62 * DESCRIPTION: Transfers the system into ACPI mode.
64 ******************************************************************************/
65 acpi_status acpi_enable(void)
67 acpi_status status;
68 int retry;
70 ACPI_FUNCTION_TRACE(acpi_enable);
72 /* ACPI tables must be present */
74 if (acpi_gbl_fadt_index == ACPI_INVALID_TABLE_INDEX) {
75 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
78 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
80 if (acpi_gbl_reduced_hardware) {
81 return_ACPI_STATUS(AE_OK);
84 /* Check current mode */
86 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
87 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
88 "System is already in ACPI mode\n"));
89 return_ACPI_STATUS(AE_OK);
92 /* Transition to ACPI mode */
94 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
95 if (ACPI_FAILURE(status)) {
96 ACPI_ERROR((AE_INFO,
97 "Could not transition to ACPI mode"));
98 return_ACPI_STATUS(status);
101 /* Sanity check that transition succeeded */
103 for (retry = 0; retry < 30000; ++retry) {
104 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
105 if (retry != 0)
106 ACPI_WARNING((AE_INFO,
107 "Platform took > %d00 usec to enter ACPI mode", retry));
108 return_ACPI_STATUS(AE_OK);
110 acpi_os_stall(100); /* 100 usec */
113 ACPI_ERROR((AE_INFO, "Hardware did not enter ACPI mode"));
114 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
117 ACPI_EXPORT_SYMBOL(acpi_enable)
119 /*******************************************************************************
121 * FUNCTION: acpi_disable
123 * PARAMETERS: None
125 * RETURN: Status
127 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
129 ******************************************************************************/
130 acpi_status acpi_disable(void)
132 acpi_status status = AE_OK;
134 ACPI_FUNCTION_TRACE(acpi_disable);
136 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
138 if (acpi_gbl_reduced_hardware) {
139 return_ACPI_STATUS(AE_OK);
142 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
143 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
144 "System is already in legacy (non-ACPI) mode\n"));
145 } else {
146 /* Transition to LEGACY mode */
148 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
150 if (ACPI_FAILURE(status)) {
151 ACPI_ERROR((AE_INFO,
152 "Could not exit ACPI mode to legacy mode"));
153 return_ACPI_STATUS(status);
156 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
159 return_ACPI_STATUS(status);
162 ACPI_EXPORT_SYMBOL(acpi_disable)
164 /*******************************************************************************
166 * FUNCTION: acpi_enable_event
168 * PARAMETERS: event - The fixed eventto be enabled
169 * flags - Reserved
171 * RETURN: Status
173 * DESCRIPTION: Enable an ACPI event (fixed)
175 ******************************************************************************/
176 acpi_status acpi_enable_event(u32 event, u32 flags)
178 acpi_status status = AE_OK;
179 u32 value;
181 ACPI_FUNCTION_TRACE(acpi_enable_event);
183 /* Decode the Fixed Event */
185 if (event > ACPI_EVENT_MAX) {
186 return_ACPI_STATUS(AE_BAD_PARAMETER);
190 * Enable the requested fixed event (by writing a one to the enable
191 * register bit)
193 status =
194 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
195 enable_register_id, ACPI_ENABLE_EVENT);
196 if (ACPI_FAILURE(status)) {
197 return_ACPI_STATUS(status);
200 /* Make sure that the hardware responded */
202 status =
203 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
204 enable_register_id, &value);
205 if (ACPI_FAILURE(status)) {
206 return_ACPI_STATUS(status);
209 if (value != 1) {
210 ACPI_ERROR((AE_INFO,
211 "Could not enable %s event",
212 acpi_ut_get_event_name(event)));
213 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
216 return_ACPI_STATUS(status);
219 ACPI_EXPORT_SYMBOL(acpi_enable_event)
221 /*******************************************************************************
223 * FUNCTION: acpi_disable_event
225 * PARAMETERS: event - The fixed event to be disabled
226 * flags - Reserved
228 * RETURN: Status
230 * DESCRIPTION: Disable an ACPI event (fixed)
232 ******************************************************************************/
233 acpi_status acpi_disable_event(u32 event, u32 flags)
235 acpi_status status = AE_OK;
236 u32 value;
238 ACPI_FUNCTION_TRACE(acpi_disable_event);
240 /* Decode the Fixed Event */
242 if (event > ACPI_EVENT_MAX) {
243 return_ACPI_STATUS(AE_BAD_PARAMETER);
247 * Disable the requested fixed event (by writing a zero to the enable
248 * register bit)
250 status =
251 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
252 enable_register_id, ACPI_DISABLE_EVENT);
253 if (ACPI_FAILURE(status)) {
254 return_ACPI_STATUS(status);
257 status =
258 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
259 enable_register_id, &value);
260 if (ACPI_FAILURE(status)) {
261 return_ACPI_STATUS(status);
264 if (value != 0) {
265 ACPI_ERROR((AE_INFO,
266 "Could not disable %s events",
267 acpi_ut_get_event_name(event)));
268 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
271 return_ACPI_STATUS(status);
274 ACPI_EXPORT_SYMBOL(acpi_disable_event)
276 /*******************************************************************************
278 * FUNCTION: acpi_clear_event
280 * PARAMETERS: event - The fixed event to be cleared
282 * RETURN: Status
284 * DESCRIPTION: Clear an ACPI event (fixed)
286 ******************************************************************************/
287 acpi_status acpi_clear_event(u32 event)
289 acpi_status status = AE_OK;
291 ACPI_FUNCTION_TRACE(acpi_clear_event);
293 /* Decode the Fixed Event */
295 if (event > ACPI_EVENT_MAX) {
296 return_ACPI_STATUS(AE_BAD_PARAMETER);
300 * Clear the requested fixed event (By writing a one to the status
301 * register bit)
303 status =
304 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
305 status_register_id, ACPI_CLEAR_STATUS);
307 return_ACPI_STATUS(status);
310 ACPI_EXPORT_SYMBOL(acpi_clear_event)
312 /*******************************************************************************
314 * FUNCTION: acpi_get_event_status
316 * PARAMETERS: event - The fixed event
317 * event_status - Where the current status of the event will
318 * be returned
320 * RETURN: Status
322 * DESCRIPTION: Obtains and returns the current status of the event
324 ******************************************************************************/
325 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
327 acpi_status status;
328 acpi_event_status local_event_status = 0;
329 u32 in_byte;
331 ACPI_FUNCTION_TRACE(acpi_get_event_status);
333 if (!event_status) {
334 return_ACPI_STATUS(AE_BAD_PARAMETER);
337 /* Decode the Fixed Event */
339 if (event > ACPI_EVENT_MAX) {
340 return_ACPI_STATUS(AE_BAD_PARAMETER);
343 /* Fixed event currently can be dispatched? */
345 if (acpi_gbl_fixed_event_handlers[event].handler) {
346 local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER;
349 /* Fixed event currently enabled? */
351 status =
352 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
353 enable_register_id, &in_byte);
354 if (ACPI_FAILURE(status)) {
355 return_ACPI_STATUS(status);
358 if (in_byte) {
359 local_event_status |=
360 (ACPI_EVENT_FLAG_ENABLED | ACPI_EVENT_FLAG_ENABLE_SET);
363 /* Fixed event currently active? */
365 status =
366 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
367 status_register_id, &in_byte);
368 if (ACPI_FAILURE(status)) {
369 return_ACPI_STATUS(status);
372 if (in_byte) {
373 local_event_status |= ACPI_EVENT_FLAG_STATUS_SET;
376 (*event_status) = local_event_status;
377 return_ACPI_STATUS(AE_OK);
380 ACPI_EXPORT_SYMBOL(acpi_get_event_status)
381 #endif /* !ACPI_REDUCED_HARDWARE */