evxfevnt.c revision 1.1.1.3 1 /******************************************************************************
2 *
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2013, 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
45 #define __EVXFEVNT_C__
46 #define EXPORT_ACPI_INTERFACES
47
48 #include "acpi.h"
49 #include "accommon.h"
50 #include "actables.h"
51
52 #define _COMPONENT ACPI_EVENTS
53 ACPI_MODULE_NAME ("evxfevnt")
54
55
56 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
57 /*******************************************************************************
58 *
59 * FUNCTION: AcpiEnable
60 *
61 * PARAMETERS: None
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Transfers the system into ACPI mode.
66 *
67 ******************************************************************************/
68
69 ACPI_STATUS
70 AcpiEnable (
71 void)
72 {
73 ACPI_STATUS Status = AE_OK;
74
75
76 ACPI_FUNCTION_TRACE (AcpiEnable);
77
78
79 /* ACPI tables must be present */
80
81 if (!AcpiTbTablesLoaded ())
82 {
83 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
84 }
85
86 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
87
88 if (AcpiGbl_ReducedHardware)
89 {
90 return_ACPI_STATUS (AE_OK);
91 }
92
93 /* Check current mode */
94
95 if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
96 {
97 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
98 }
99 else
100 {
101 /* Transition to ACPI mode */
102
103 Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
104 if (ACPI_FAILURE (Status))
105 {
106 ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
107 return_ACPI_STATUS (Status);
108 }
109
110 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
111 "Transition to ACPI mode successful\n"));
112 }
113
114 return_ACPI_STATUS (Status);
115 }
116
117 ACPI_EXPORT_SYMBOL (AcpiEnable)
118
119
120 /*******************************************************************************
121 *
122 * FUNCTION: AcpiDisable
123 *
124 * PARAMETERS: None
125 *
126 * RETURN: Status
127 *
128 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
129 *
130 ******************************************************************************/
131
132 ACPI_STATUS
133 AcpiDisable (
134 void)
135 {
136 ACPI_STATUS Status = AE_OK;
137
138
139 ACPI_FUNCTION_TRACE (AcpiDisable);
140
141
142 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
143
144 if (AcpiGbl_ReducedHardware)
145 {
146 return_ACPI_STATUS (AE_OK);
147 }
148
149 if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
150 {
151 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
152 "System is already in legacy (non-ACPI) mode\n"));
153 }
154 else
155 {
156 /* Transition to LEGACY mode */
157
158 Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
159
160 if (ACPI_FAILURE (Status))
161 {
162 ACPI_ERROR ((AE_INFO,
163 "Could not exit ACPI mode to legacy mode"));
164 return_ACPI_STATUS (Status);
165 }
166
167 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
168 }
169
170 return_ACPI_STATUS (Status);
171 }
172
173 ACPI_EXPORT_SYMBOL (AcpiDisable)
174
175
176 /*******************************************************************************
177 *
178 * FUNCTION: AcpiEnableEvent
179 *
180 * PARAMETERS: Event - The fixed eventto be enabled
181 * Flags - Reserved
182 *
183 * RETURN: Status
184 *
185 * DESCRIPTION: Enable an ACPI event (fixed)
186 *
187 ******************************************************************************/
188
189 ACPI_STATUS
190 AcpiEnableEvent (
191 UINT32 Event,
192 UINT32 Flags)
193 {
194 ACPI_STATUS Status = AE_OK;
195 UINT32 Value;
196
197
198 ACPI_FUNCTION_TRACE (AcpiEnableEvent);
199
200
201 /* Decode the Fixed Event */
202
203 if (Event > ACPI_EVENT_MAX)
204 {
205 return_ACPI_STATUS (AE_BAD_PARAMETER);
206 }
207
208 /*
209 * Enable the requested fixed event (by writing a one to the enable
210 * register bit)
211 */
212 Status = AcpiWriteBitRegister (
213 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
214 ACPI_ENABLE_EVENT);
215 if (ACPI_FAILURE (Status))
216 {
217 return_ACPI_STATUS (Status);
218 }
219
220 /* Make sure that the hardware responded */
221
222 Status = AcpiReadBitRegister (
223 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
224 if (ACPI_FAILURE (Status))
225 {
226 return_ACPI_STATUS (Status);
227 }
228
229 if (Value != 1)
230 {
231 ACPI_ERROR ((AE_INFO,
232 "Could not enable %s event", AcpiUtGetEventName (Event)));
233 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
234 }
235
236 return_ACPI_STATUS (Status);
237 }
238
239 ACPI_EXPORT_SYMBOL (AcpiEnableEvent)
240
241
242 /*******************************************************************************
243 *
244 * FUNCTION: AcpiDisableEvent
245 *
246 * PARAMETERS: Event - The fixed event to be disabled
247 * Flags - Reserved
248 *
249 * RETURN: Status
250 *
251 * DESCRIPTION: Disable an ACPI event (fixed)
252 *
253 ******************************************************************************/
254
255 ACPI_STATUS
256 AcpiDisableEvent (
257 UINT32 Event,
258 UINT32 Flags)
259 {
260 ACPI_STATUS Status = AE_OK;
261 UINT32 Value;
262
263
264 ACPI_FUNCTION_TRACE (AcpiDisableEvent);
265
266
267 /* Decode the Fixed Event */
268
269 if (Event > ACPI_EVENT_MAX)
270 {
271 return_ACPI_STATUS (AE_BAD_PARAMETER);
272 }
273
274 /*
275 * Disable the requested fixed event (by writing a zero to the enable
276 * register bit)
277 */
278 Status = AcpiWriteBitRegister (
279 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
280 ACPI_DISABLE_EVENT);
281 if (ACPI_FAILURE (Status))
282 {
283 return_ACPI_STATUS (Status);
284 }
285
286 Status = AcpiReadBitRegister (
287 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
288 if (ACPI_FAILURE (Status))
289 {
290 return_ACPI_STATUS (Status);
291 }
292
293 if (Value != 0)
294 {
295 ACPI_ERROR ((AE_INFO,
296 "Could not disable %s events", AcpiUtGetEventName (Event)));
297 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
298 }
299
300 return_ACPI_STATUS (Status);
301 }
302
303 ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
304
305
306 /*******************************************************************************
307 *
308 * FUNCTION: AcpiClearEvent
309 *
310 * PARAMETERS: Event - The fixed event to be cleared
311 *
312 * RETURN: Status
313 *
314 * DESCRIPTION: Clear an ACPI event (fixed)
315 *
316 ******************************************************************************/
317
318 ACPI_STATUS
319 AcpiClearEvent (
320 UINT32 Event)
321 {
322 ACPI_STATUS Status = AE_OK;
323
324
325 ACPI_FUNCTION_TRACE (AcpiClearEvent);
326
327
328 /* Decode the Fixed Event */
329
330 if (Event > ACPI_EVENT_MAX)
331 {
332 return_ACPI_STATUS (AE_BAD_PARAMETER);
333 }
334
335 /*
336 * Clear the requested fixed event (By writing a one to the status
337 * register bit)
338 */
339 Status = AcpiWriteBitRegister (
340 AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
341 ACPI_CLEAR_STATUS);
342
343 return_ACPI_STATUS (Status);
344 }
345
346 ACPI_EXPORT_SYMBOL (AcpiClearEvent)
347
348
349 /*******************************************************************************
350 *
351 * FUNCTION: AcpiGetEventStatus
352 *
353 * PARAMETERS: Event - The fixed event
354 * EventStatus - Where the current status of the event will
355 * be returned
356 *
357 * RETURN: Status
358 *
359 * DESCRIPTION: Obtains and returns the current status of the event
360 *
361 ******************************************************************************/
362
363 ACPI_STATUS
364 AcpiGetEventStatus (
365 UINT32 Event,
366 ACPI_EVENT_STATUS *EventStatus)
367 {
368 ACPI_STATUS Status = AE_OK;
369
370
371 ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
372
373
374 if (!EventStatus)
375 {
376 return_ACPI_STATUS (AE_BAD_PARAMETER);
377 }
378
379 /* Decode the Fixed Event */
380
381 if (Event > ACPI_EVENT_MAX)
382 {
383 return_ACPI_STATUS (AE_BAD_PARAMETER);
384 }
385
386 /* Get the status of the requested fixed event */
387
388 Status = AcpiReadBitRegister (
389 AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus);
390
391 return_ACPI_STATUS (Status);
392 }
393
394 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
395
396 #endif /* !ACPI_REDUCED_HARDWARE */
397