Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/hardware/hwgpe.c
+++ new/usr/src/common/acpica/components/hardware/hwgpe.c
1 -
2 1 /******************************************************************************
3 2 *
4 3 * Module Name: hwgpe - Low level GPE enable/disable/clear functions
5 4 *
6 5 *****************************************************************************/
7 6
8 7 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2014, Intel Corp.
10 9 * All rights reserved.
11 10 *
12 11 * Redistribution and use in source and binary forms, with or without
13 12 * modification, are permitted provided that the following conditions
14 13 * are met:
15 14 * 1. Redistributions of source code must retain the above copyright
16 15 * notice, this list of conditions, and the following disclaimer,
17 16 * without modification.
18 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 18 * substantially similar to the "NO WARRANTY" disclaimer below
20 19 * ("Disclaimer") and any redistribution must be conditioned upon
21 20 * including a substantially similar Disclaimer requirement for further
22 21 * binary redistribution.
23 22 * 3. Neither the names of the above-listed copyright holders nor the names
24 23 * of any contributors may be used to endorse or promote products derived
25 24 * from this software without specific prior written permission.
26 25 *
27 26 * Alternatively, this software may be distributed under the terms of the
28 27 * GNU General Public License ("GPL") version 2 as published by the Free
29 28 * Software Foundation.
30 29 *
31 30 * NO WARRANTY
32 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
42 41 * POSSIBILITY OF SUCH DAMAGES.
43 42 */
44 43
45 44 #include "acpi.h"
46 45 #include "accommon.h"
47 46 #include "acevents.h"
48 47
49 48 #define _COMPONENT ACPI_HARDWARE
50 49 ACPI_MODULE_NAME ("hwgpe")
51 50
51 +#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52 +
52 53 /* Local prototypes */
53 54
54 55 static ACPI_STATUS
55 56 AcpiHwEnableWakeupGpeBlock (
56 57 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
57 58 ACPI_GPE_BLOCK_INFO *GpeBlock,
58 59 void *Context);
59 60
60 61
61 62 /******************************************************************************
62 63 *
63 64 * FUNCTION: AcpiHwGetGpeRegisterBit
64 65 *
65 66 * PARAMETERS: GpeEventInfo - Info block for the GPE
66 - * GpeRegisterInfo - Info block for the GPE register
67 67 *
68 68 * RETURN: Register mask with a one in the GPE bit position
69 69 *
70 70 * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
71 71 * correct position for the input GPE.
72 72 *
73 73 ******************************************************************************/
74 74
75 75 UINT32
76 76 AcpiHwGetGpeRegisterBit (
77 - ACPI_GPE_EVENT_INFO *GpeEventInfo,
78 - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo)
77 + ACPI_GPE_EVENT_INFO *GpeEventInfo)
79 78 {
80 79
81 80 return ((UINT32) 1 <<
82 - (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber));
81 + (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber));
83 82 }
84 83
85 84
86 85 /******************************************************************************
87 86 *
88 87 * FUNCTION: AcpiHwLowSetGpe
89 88 *
90 89 * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled
91 90 * Action - Enable or disable
92 91 *
93 92 * RETURN: Status
94 93 *
95 94 * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
96 95 *
97 96 ******************************************************************************/
98 97
99 98 ACPI_STATUS
100 99 AcpiHwLowSetGpe (
101 100 ACPI_GPE_EVENT_INFO *GpeEventInfo,
102 101 UINT32 Action)
103 102 {
104 103 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
105 104 ACPI_STATUS Status;
106 105 UINT32 EnableMask;
107 106 UINT32 RegisterBit;
108 107
109 108
110 109 ACPI_FUNCTION_ENTRY ();
111 110
112 111
113 112 /* Get the info block for the entire GPE register */
114 113
115 114 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
116 115 if (!GpeRegisterInfo)
117 116 {
118 117 return (AE_NOT_EXIST);
119 118 }
120 119
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
121 120 /* Get current value of the enable register that contains this GPE */
122 121
123 122 Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
124 123 if (ACPI_FAILURE (Status))
125 124 {
126 125 return (Status);
127 126 }
128 127
129 128 /* Set or clear just the bit that corresponds to this GPE */
130 129
131 - RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
130 + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
132 131 switch (Action)
133 132 {
134 133 case ACPI_GPE_CONDITIONAL_ENABLE:
135 134
136 135 /* Only enable if the EnableForRun bit is set */
137 136
138 137 if (!(RegisterBit & GpeRegisterInfo->EnableForRun))
139 138 {
140 139 return (AE_BAD_PARAMETER);
141 140 }
142 141
143 142 /*lint -fallthrough */
144 143
145 144 case ACPI_GPE_ENABLE:
145 +
146 146 ACPI_SET_BIT (EnableMask, RegisterBit);
147 147 break;
148 148
149 149 case ACPI_GPE_DISABLE:
150 +
150 151 ACPI_CLEAR_BIT (EnableMask, RegisterBit);
151 152 break;
152 153
153 154 default:
154 - ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u\n", Action));
155 +
156 + ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u", Action));
155 157 return (AE_BAD_PARAMETER);
156 158 }
157 159
158 160 /* Write the updated enable mask */
159 161
160 162 Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
161 163 return (Status);
162 164 }
163 165
164 166
165 167 /******************************************************************************
166 168 *
167 169 * FUNCTION: AcpiHwClearGpe
168 170 *
169 171 * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared
170 172 *
171 173 * RETURN: Status
172 174 *
173 175 * DESCRIPTION: Clear the status bit for a single GPE.
174 176 *
175 177 ******************************************************************************/
176 178
177 179 ACPI_STATUS
178 180 AcpiHwClearGpe (
179 181 ACPI_GPE_EVENT_INFO *GpeEventInfo)
180 182 {
181 183 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
182 184 ACPI_STATUS Status;
183 185 UINT32 RegisterBit;
184 186
185 187
186 188 ACPI_FUNCTION_ENTRY ();
187 189
188 190 /* Get the info block for the entire GPE register */
189 191
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
190 192 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
191 193 if (!GpeRegisterInfo)
192 194 {
193 195 return (AE_NOT_EXIST);
194 196 }
195 197
196 198 /*
197 199 * Write a one to the appropriate bit in the status register to
198 200 * clear this GPE.
199 201 */
200 - RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
202 + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
201 203
202 204 Status = AcpiHwWrite (RegisterBit,
203 205 &GpeRegisterInfo->StatusAddress);
204 206
205 207 return (Status);
206 208 }
207 209
208 210
209 211 /******************************************************************************
210 212 *
211 213 * FUNCTION: AcpiHwGetGpeStatus
212 214 *
213 215 * PARAMETERS: GpeEventInfo - Info block for the GPE to queried
214 216 * EventStatus - Where the GPE status is returned
215 217 *
216 218 * RETURN: Status
217 219 *
218 220 * DESCRIPTION: Return the status of a single GPE.
219 221 *
220 222 ******************************************************************************/
221 223
222 224 ACPI_STATUS
223 225 AcpiHwGetGpeStatus (
224 226 ACPI_GPE_EVENT_INFO *GpeEventInfo,
225 227 ACPI_EVENT_STATUS *EventStatus)
226 228 {
227 229 UINT32 InByte;
228 230 UINT32 RegisterBit;
229 231 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
230 232 ACPI_EVENT_STATUS LocalEventStatus = 0;
231 233 ACPI_STATUS Status;
232 234
233 235
234 236 ACPI_FUNCTION_ENTRY ();
235 237
236 238
237 239 if (!EventStatus)
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
238 240 {
239 241 return (AE_BAD_PARAMETER);
240 242 }
241 243
242 244 /* Get the info block for the entire GPE register */
243 245
244 246 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
245 247
246 248 /* Get the register bitmask for this GPE */
247 249
248 - RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
250 + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
249 251
250 252 /* GPE currently enabled? (enabled for runtime?) */
251 253
252 254 if (RegisterBit & GpeRegisterInfo->EnableForRun)
253 255 {
254 256 LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
255 257 }
256 258
257 259 /* GPE enabled for wake? */
258 260
259 261 if (RegisterBit & GpeRegisterInfo->EnableForWake)
260 262 {
261 263 LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
262 264 }
263 265
264 266 /* GPE currently active (status bit == 1)? */
265 267
266 268 Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
267 269 if (ACPI_FAILURE (Status))
268 270 {
269 271 return (Status);
270 272 }
271 273
272 274 if (RegisterBit & InByte)
273 275 {
274 276 LocalEventStatus |= ACPI_EVENT_FLAG_SET;
275 277 }
276 278
277 279 /* Set return value */
278 280
279 281 (*EventStatus) = LocalEventStatus;
280 282 return (AE_OK);
281 283 }
282 284
283 285
284 286 /******************************************************************************
285 287 *
286 288 * FUNCTION: AcpiHwDisableGpeBlock
287 289 *
288 290 * PARAMETERS: GpeXruptInfo - GPE Interrupt info
289 291 * GpeBlock - Gpe Block info
290 292 *
291 293 * RETURN: Status
292 294 *
293 295 * DESCRIPTION: Disable all GPEs within a single GPE block
294 296 *
295 297 ******************************************************************************/
296 298
297 299 ACPI_STATUS
298 300 AcpiHwDisableGpeBlock (
299 301 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
300 302 ACPI_GPE_BLOCK_INFO *GpeBlock,
301 303 void *Context)
302 304 {
303 305 UINT32 i;
304 306 ACPI_STATUS Status;
305 307
306 308
307 309 /* Examine each GPE Register within the block */
308 310
309 311 for (i = 0; i < GpeBlock->RegisterCount; i++)
310 312 {
311 313 /* Disable all GPEs in this register */
312 314
313 315 Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress);
314 316 if (ACPI_FAILURE (Status))
315 317 {
316 318 return (Status);
317 319 }
318 320 }
319 321
320 322 return (AE_OK);
321 323 }
322 324
323 325
324 326 /******************************************************************************
325 327 *
326 328 * FUNCTION: AcpiHwClearGpeBlock
327 329 *
328 330 * PARAMETERS: GpeXruptInfo - GPE Interrupt info
329 331 * GpeBlock - Gpe Block info
330 332 *
331 333 * RETURN: Status
332 334 *
333 335 * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
334 336 *
335 337 ******************************************************************************/
336 338
337 339 ACPI_STATUS
338 340 AcpiHwClearGpeBlock (
339 341 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
340 342 ACPI_GPE_BLOCK_INFO *GpeBlock,
341 343 void *Context)
342 344 {
343 345 UINT32 i;
344 346 ACPI_STATUS Status;
345 347
346 348
347 349 /* Examine each GPE Register within the block */
348 350
349 351 for (i = 0; i < GpeBlock->RegisterCount; i++)
350 352 {
351 353 /* Clear status on all GPEs in this register */
352 354
353 355 Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress);
354 356 if (ACPI_FAILURE (Status))
355 357 {
356 358 return (Status);
357 359 }
358 360 }
359 361
360 362 return (AE_OK);
361 363 }
362 364
363 365
364 366 /******************************************************************************
365 367 *
366 368 * FUNCTION: AcpiHwEnableRuntimeGpeBlock
367 369 *
368 370 * PARAMETERS: GpeXruptInfo - GPE Interrupt info
369 371 * GpeBlock - Gpe Block info
370 372 *
371 373 * RETURN: Status
372 374 *
373 375 * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
374 376 * combination wake/run GPEs.
375 377 *
376 378 ******************************************************************************/
377 379
378 380 ACPI_STATUS
379 381 AcpiHwEnableRuntimeGpeBlock (
380 382 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
381 383 ACPI_GPE_BLOCK_INFO *GpeBlock,
382 384 void *Context)
383 385 {
384 386 UINT32 i;
385 387 ACPI_STATUS Status;
386 388
387 389
388 390 /* NOTE: assumes that all GPEs are currently disabled */
389 391
390 392 /* Examine each GPE Register within the block */
391 393
392 394 for (i = 0; i < GpeBlock->RegisterCount; i++)
393 395 {
394 396 if (!GpeBlock->RegisterInfo[i].EnableForRun)
395 397 {
396 398 continue;
397 399 }
398 400
399 401 /* Enable all "runtime" GPEs in this register */
400 402
401 403 Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun,
402 404 &GpeBlock->RegisterInfo[i].EnableAddress);
403 405 if (ACPI_FAILURE (Status))
404 406 {
405 407 return (Status);
406 408 }
407 409 }
408 410
409 411 return (AE_OK);
410 412 }
411 413
412 414
413 415 /******************************************************************************
414 416 *
415 417 * FUNCTION: AcpiHwEnableWakeupGpeBlock
416 418 *
417 419 * PARAMETERS: GpeXruptInfo - GPE Interrupt info
418 420 * GpeBlock - Gpe Block info
419 421 *
420 422 * RETURN: Status
421 423 *
422 424 * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
423 425 * combination wake/run GPEs.
424 426 *
425 427 ******************************************************************************/
426 428
427 429 static ACPI_STATUS
428 430 AcpiHwEnableWakeupGpeBlock (
429 431 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
430 432 ACPI_GPE_BLOCK_INFO *GpeBlock,
431 433 void *Context)
432 434 {
433 435 UINT32 i;
434 436 ACPI_STATUS Status;
435 437
436 438
437 439 /* Examine each GPE Register within the block */
438 440
439 441 for (i = 0; i < GpeBlock->RegisterCount; i++)
440 442 {
441 443 if (!GpeBlock->RegisterInfo[i].EnableForWake)
442 444 {
443 445 continue;
444 446 }
445 447
446 448 /* Enable all "wake" GPEs in this register */
447 449
448 450 Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake,
449 451 &GpeBlock->RegisterInfo[i].EnableAddress);
450 452 if (ACPI_FAILURE (Status))
451 453 {
452 454 return (Status);
453 455 }
454 456 }
455 457
456 458 return (AE_OK);
457 459 }
458 460
459 461
460 462 /******************************************************************************
461 463 *
462 464 * FUNCTION: AcpiHwDisableAllGpes
463 465 *
464 466 * PARAMETERS: None
465 467 *
466 468 * RETURN: Status
467 469 *
468 470 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
469 471 *
470 472 ******************************************************************************/
471 473
472 474 ACPI_STATUS
473 475 AcpiHwDisableAllGpes (
474 476 void)
475 477 {
476 478 ACPI_STATUS Status;
477 479
478 480
479 481 ACPI_FUNCTION_TRACE (HwDisableAllGpes);
480 482
481 483
482 484 Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
483 485 Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
484 486 return_ACPI_STATUS (Status);
485 487 }
486 488
487 489
488 490 /******************************************************************************
489 491 *
490 492 * FUNCTION: AcpiHwEnableAllRuntimeGpes
491 493 *
492 494 * PARAMETERS: None
493 495 *
494 496 * RETURN: Status
495 497 *
496 498 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
497 499 *
498 500 ******************************************************************************/
499 501
500 502 ACPI_STATUS
501 503 AcpiHwEnableAllRuntimeGpes (
502 504 void)
503 505 {
504 506 ACPI_STATUS Status;
505 507
506 508
507 509 ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes);
508 510
509 511
510 512 Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL);
511 513 return_ACPI_STATUS (Status);
512 514 }
513 515
514 516
515 517 /******************************************************************************
516 518 *
517 519 * FUNCTION: AcpiHwEnableAllWakeupGpes
518 520 *
519 521 * PARAMETERS: None
520 522 *
521 523 * RETURN: Status
522 524 *
523 525 * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
524 526 *
525 527 ******************************************************************************/
526 528
527 529 ACPI_STATUS
528 530 AcpiHwEnableAllWakeupGpes (
529 531 void)
530 532 {
↓ open down ↓ |
272 lines elided |
↑ open up ↑ |
531 533 ACPI_STATUS Status;
532 534
533 535
534 536 ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
535 537
536 538
537 539 Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
538 540 return_ACPI_STATUS (Status);
539 541 }
540 542
543 +#endif /* !ACPI_REDUCED_HARDWARE */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX