Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
evxfevnt.c
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2012, Intel Corp.
9  * All rights reserved.
10  *
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.
25  *
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.
29  *
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.
42  */
43 
44 #include <linux/export.h>
45 #include <acpi/acpi.h>
46 #include "accommon.h"
47 #include "actables.h"
48 
49 #define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME("evxfevnt")
51 
52 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
53 /*******************************************************************************
54  *
55  * FUNCTION: acpi_enable
56  *
57  * PARAMETERS: None
58  *
59  * RETURN: Status
60  *
61  * DESCRIPTION: Transfers the system into ACPI mode.
62  *
63  ******************************************************************************/
64 
66 {
68  int retry;
69 
71 
72  /* ACPI tables must be present */
73 
74  if (!acpi_tb_tables_loaded()) {
76  }
77 
78  /* Check current mode */
79 
82  "System is already in ACPI mode\n"));
84  }
85 
86  /* Transition to ACPI mode */
87 
89  if (ACPI_FAILURE(status)) {
91  "Could not transition to ACPI mode"));
92  return_ACPI_STATUS(status);
93  }
94 
95  /* Sanity check that transition succeeded */
96 
97  for (retry = 0; retry < 30000; ++retry) {
99  if (retry != 0)
101  "Platform took > %d00 usec to enter ACPI mode", retry));
103  }
104  acpi_os_stall(100); /* 100 usec */
105  }
106 
107  ACPI_ERROR((AE_INFO, "Hardware did not enter ACPI mode"));
109 }
110 
112 
113 /*******************************************************************************
114  *
115  * FUNCTION: acpi_disable
116  *
117  * PARAMETERS: None
118  *
119  * RETURN: Status
120  *
121  * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
122  *
123  ******************************************************************************/
125 {
127 
129 
132  "System is already in legacy (non-ACPI) mode\n"));
133  } else {
134  /* Transition to LEGACY mode */
135 
137 
138  if (ACPI_FAILURE(status)) {
140  "Could not exit ACPI mode to legacy mode"));
141  return_ACPI_STATUS(status);
142  }
143 
144  ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
145  }
146 
147  return_ACPI_STATUS(status);
148 }
149 
151 
152 /*******************************************************************************
153  *
154  * FUNCTION: acpi_enable_event
155  *
156  * PARAMETERS: event - The fixed eventto be enabled
157  * flags - Reserved
158  *
159  * RETURN: Status
160  *
161  * DESCRIPTION: Enable an ACPI event (fixed)
162  *
163  ******************************************************************************/
165 {
167  u32 value;
168 
170 
171  /* Decode the Fixed Event */
172 
173  if (event > ACPI_EVENT_MAX) {
175  }
176 
177  /*
178  * Enable the requested fixed event (by writing a one to the enable
179  * register bit)
180  */
181  status =
183  enable_register_id, ACPI_ENABLE_EVENT);
184  if (ACPI_FAILURE(status)) {
185  return_ACPI_STATUS(status);
186  }
187 
188  /* Make sure that the hardware responded */
189 
190  status =
192  enable_register_id, &value);
193  if (ACPI_FAILURE(status)) {
194  return_ACPI_STATUS(status);
195  }
196 
197  if (value != 1) {
199  "Could not enable %s event",
200  acpi_ut_get_event_name(event)));
202  }
203 
204  return_ACPI_STATUS(status);
205 }
206 
208 
209 /*******************************************************************************
210  *
211  * FUNCTION: acpi_disable_event
212  *
213  * PARAMETERS: Event - The fixed eventto be enabled
214  * Flags - Reserved
215  *
216  * RETURN: Status
217  *
218  * DESCRIPTION: Disable an ACPI event (fixed)
219  *
220  ******************************************************************************/
222 {
224  u32 value;
225 
227 
228  /* Decode the Fixed Event */
229 
230  if (event > ACPI_EVENT_MAX) {
232  }
233 
234  /*
235  * Disable the requested fixed event (by writing a zero to the enable
236  * register bit)
237  */
238  status =
240  enable_register_id, ACPI_DISABLE_EVENT);
241  if (ACPI_FAILURE(status)) {
242  return_ACPI_STATUS(status);
243  }
244 
245  status =
247  enable_register_id, &value);
248  if (ACPI_FAILURE(status)) {
249  return_ACPI_STATUS(status);
250  }
251 
252  if (value != 0) {
254  "Could not disable %s events",
255  acpi_ut_get_event_name(event)));
257  }
258 
259  return_ACPI_STATUS(status);
260 }
261 
263 
264 /*******************************************************************************
265  *
266  * FUNCTION: acpi_clear_event
267  *
268  * PARAMETERS: event - The fixed event to be cleared
269  *
270  * RETURN: Status
271  *
272  * DESCRIPTION: Clear an ACPI event (fixed)
273  *
274  ******************************************************************************/
276 {
278 
280 
281  /* Decode the Fixed Event */
282 
283  if (event > ACPI_EVENT_MAX) {
285  }
286 
287  /*
288  * Clear the requested fixed event (By writing a one to the status
289  * register bit)
290  */
291  status =
293  status_register_id, ACPI_CLEAR_STATUS);
294 
295  return_ACPI_STATUS(status);
296 }
297 
299 
300 /*******************************************************************************
301  *
302  * FUNCTION: acpi_get_event_status
303  *
304  * PARAMETERS: event - The fixed event
305  * event_status - Where the current status of the event will
306  * be returned
307  *
308  * RETURN: Status
309  *
310  * DESCRIPTION: Obtains and returns the current status of the event
311  *
312  ******************************************************************************/
314 {
316  u32 value;
317 
319 
320  if (!event_status) {
322  }
323 
324  /* Decode the Fixed Event */
325 
326  if (event > ACPI_EVENT_MAX) {
328  }
329 
330  /* Get the status of the requested fixed event */
331 
332  status =
334  enable_register_id, &value);
335  if (ACPI_FAILURE(status))
336  return_ACPI_STATUS(status);
337 
338  *event_status = value;
339 
340  status =
342  status_register_id, &value);
343  if (ACPI_FAILURE(status))
344  return_ACPI_STATUS(status);
345 
346  if (value)
347  *event_status |= ACPI_EVENT_FLAG_SET;
348 
350  *event_status |= ACPI_EVENT_FLAG_HANDLE;
351 
352  return_ACPI_STATUS(status);
353 }
354 
356 #endif /* !ACPI_REDUCED_HARDWARE */