summaryrefslogtreecommitdiff
path: root/Board/EM/Thunderbolt/TbtDxe/TbtGpe.asl
blob: ad17b9f241f1dbd850b9b0b789fd0ca4a194bce3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2011, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************
//*************************************************************************
// $Header: /Alaska/SOURCE/Modules/Thunderbolt/TbtDxe/TbtGpe.asl 22    5/19/14 7:32a Barretlin $
//
// $Revision: 22 $
//
// $Date: 5/19/14 7:32a $
//*************************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/Thunderbolt/TbtDxe/TbtGpe.asl $
// 
// 22    5/19/14 7:32a Barretlin
// [TAG]  		EIP165410
// [Category]  	New Feature
// [Description]  	Support Thunderbolt AIC at NB PCIE slot
// [Files]  		TbtPei.c TbtDxe.c TbtGpe.asl TbtSmm.c TbtOemBoard.c
// TbtOemLib.c TbtOemLib.h TbtSetup.sdl TbtSetup.sd TbtSetup.uni
// TbtSetupReset.c
// 
// 21    5/19/14 7:13a Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Using setup item choose return value of _RMV method in
// ASL code
// [Files]  		TbtDxe.c TbtGpe.asl TbtOemBoard.c TbtOemBoard.h TbtSetup.sd
// TbtSetup.sdl TbtSetup.uni
// 
// 20    2/22/14 5:50p Barretlin
// [TAG]  		EIP N/A
// [Category]  	Bug Fix
// [Severity]  	Important
// [Symptom]  	For Cactus Ridge host the thunderbolt hotplug event cannot
// be trigger
// [RootCause]  	signal event is not trigger under _INI/TINI method cause
// OS will not set GPE event enable bit
// [Solution]  	Change signal event location of _INI/TINI method
// [Files]  		TbtGpe.asl
// 
// 19    2/18/14 12:07p Barretlin
// 
// 18    2/18/14 6:02a Barretlin
// [TAG]  		EIP152401
// [Category]  	Spec Update
// [Severity]  	Minor
// [Description]  	Update Intel Thunderbolt Sample code rev 1.9
// [Files]  		TbtSmm.c TbtGpe.asl TbtOemPorting.asl
// 
// 17    1/05/14 1:43p Barretlin
// [TAG]  		EIP N/A
// [Category]  	New Feature
// [Description]  	Support Thunderbolt feature Enable/Disable in run time
// Support dynamic Thunderbolt AIC location in run time
// [Files]  		TbtDxe.c TbtGpe.asl
// 
// 16    7/26/13 2:24a Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	remove non Intel RC config
// [Files]  		TbtGpe.asl
// 
// 15    6/21/13 7:41a Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Fix build error with non Intel RC project
// [Files]  		TbtDxe.sdl TbtDxe.c TbtGpe.asl TbtDxeLib.h
// 
// 14    6/19/13 9:24a Barretlin
// [TAG]  		EIP126581
// [Category]  	Spec Update
// [Severity]  	Minor
// [Description]  	Update Intel Thunderbolt sample code to rev. 1.7
// [Files]  		TbtGpe.asl
// 
// 13    5/27/13 8:57a Barretlin
// [TAG]  		EIP124914
// [Category]  	New Feature
// [Description]  	Support Falcon Ridge chip
// [Files]  		TbtGpe.asl
// 
// 12    5/27/13 8:54a Barretlin
// [TAG]  		EIP122882
// [Category]  	Bug Fix
// [Severity]  	Normal
// [Symptom]  	let system entering sleep status continually and waking up
// system via Thunderbolt Lan device, system will auto-wake
// [RootCause]  	PCIE PME status is not cleared by ASL in SB module
// [Solution]  	Clear PCIE PME status againg before system entring sleep
// status
// [Files]  		TbtDxe.sdl TbtGpe.asl
// 
// 11    5/27/13 8:46a Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	add sychronized method to make sure executed sequence
// is one by one
// [Files]  		TbtGpe.asl
// 
// 10    4/12/13 1:18p Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Rollback OSUP method and following Intel sample code
// [Files]  		TbtGpe.asl
// 
// 9     4/10/13 2:31p Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Change reported MMIO address way in ASL code
// [Files]  		TbtDxe.c TbtGpe.asl
// 
// 8     4/10/13 1:37p Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Adding a TPTS method into _PTS method in ASL code
// [Files]  		TbtDxe.sdl TbtGpe.asl
// 
// 7     4/03/13 8:42a Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Fix might hang up when S3 resuming
// [Files]  		TbtGpe.asl
// 
// 6     3/21/13 4:58a Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Use token to decide where location of OS_UP command for
// RR chip is
// [Files]  		TbtDxe.sdl TbtGpe.asl
// 
// 5     2/08/13 1:23a Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Following Intel sample code move _INI method of
// thunderbolt from under PCIE root port to under system bus
// [Files]  		TbtDxe.sdl TbtGpe.asl
// 
// 4     2/06/13 7:49a Barretlin
// [TAG]  		EIP114556
// [Category]  	Spec Update
// [Severity]  	Minor
// [Description]  	Update RR handshake flow for Thunderbolt RR Spec 0.9
// [Files]  		TbtGpe.asl
// 
// 3     1/24/13 1:31a Barretlin
// [TAG]  		EIP N/A
// [Category]  	Bug Fix
// [Severity]  	Minor
// [Symptom]  	TBT debug setup item function fail
// [RootCause]  	ASL updating error
// [Files]  		TbtGpe.asl
// 
// 2     1/18/13 2:26a Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Improve _RMV ASL code  for SharkBay RC
// [Files]  		TbtDxe.sdl TbtDxe.c TbtGpe.asl
// 
// 1     1/10/13 4:56a Barretlin
// Change SS path and update module for Thunderbolt Spec 1.6 for Cactus
// Ridge chip and Thunderbolt Spec 0.5 for Redwood Ridge chip
// 
// 6     12/12/12 3:02a Barretlin
// [TAG]  		EIP108272
// [Category]  	Spec Update
// [Severity]  	Important
// [Description]  	Update to Spec 1.4 to support Redwood Ridge chip
// [Files]  		TbtPei.c TbtSmm.c TbtDxe.c TbtDxe.sdl TbtGpe.asl
// TbtOemBoard.c TbtOemBoard.h TbtOemLib.c TbtOemLib.h
// 
// 5     10/28/12 10:50p Barretlin
// [TAG]  		EIP N/A
// [Category]  	Improvement
// [Description]  	Change GPIO routing for SharkBay ULT platform
// [Files]  		TbtDxe.c TbtGpe.asl TbtDxeLib.c TbtDxeLib.h TbtSmm.c
// 
// 4     5/07/12 6:34a Barretlin
// [TAG]  		None
// [Category]  	Improvement
// [Description]  	Add three setup items for debug
// [Files]  		TbtDxe.c
// TbtGpe.asl
// TbtSmm.c
// TbtSetup.sd
// TbtSetup.uni
// TbtOemBoard.c
// TbtOemBoard.h
// 
// 3     4/16/12 10:17a Barretlin
// [TAG]  		EIP86590
// [Category]  	Bug Fix
// [Symptom]  	Only EP#1 can be detected after resume from S3
// [Solution]  	Adding a TWAK method into _WAK method
// [Files]  		TbtDxe.sdl  TbtGpe.asl
// 
// 2     4/14/12 4:50a Barretlin
// [TAG]  		None
// [Category]  	Improvement
// [Description]  	Improve ASL code, which redefines device name and RMV
// mothod at same address when project supports RMV method, that might
// cause conflict.
// [Files]  		TbtDxe.c  TbtGpe.asl
// 
// 1     12/08/11 4:09a Wesleychen
// Thunderbolt eModule initially releases.
// 
//*************************************************************************
Scope(\)
{
    Mutex(OSUM, 0)  // OS Up mutex
    Event(WFEV)
//    Name(TBTE, 0) // Thunderbolt function enable
    Name(PEMA, ASL_PCIEX_BASE_ADDRESS) // PCIE base address
    Name(TBRP, ASL_TBT_RPNum) // PCIE root port location for Thunderbolt Host
    Name(TBUS, 0xFF) // Thunderbolt Host BUS number
    Name(TBHR, 0xFF) //1:Cactus Ridge 2:Redwood Ridge 3:Falcon Ridge 4:Win Ridge will be updated
    Name(TBMV, 0xFF) // _RMV return value for Thunderbolt
    Name(RPR6, 0)
    Name(RPR7, 0)
    Name(RPR8, 0)
    Name(RPR9, 0)
    Name(RPRA, 0)
    Name(RPRB, 0)
}

Scope(\_SB)
{
    // Include OEM porting required ASL
    Include("..\\TbtOemBoard\\TbtOemPorting.asl")

	// WMI ACPI device to control TBT force power
    Device(WMTF)
    {
        // pnp0c14 is pnp id assigned to WMI mapper
        Name(_HID, "PNP0C14")
        Name(_UID, "TBFP")   
        
        Name(_WDG, Buffer() {
            // {86CCFD48-205E-4A77-9C48-2021CBEDE341}
            0x48, 0xFD, 0xCC, 0x86,
            0x5E, 0x20,
            0x77, 0x4A,
            0x9C, 0x48,
            0x20, 0x21, 0xCB, 0xED, 0xE3, 0x41,
            84, 70,    // Object Id (TF)
            1,         // Instance Count
            0x02       // Flags (WMIACPI_REGFLAG_METHOD)
        })
        
        // Set TBT force power
        // Arg2 is force power value
        Method(WMTF, 3)
        {
            CreateByteField(Arg2,0,FP)
            
            If(FP)
            {
                TBFP(1)
            }
            Else
            {
                TBFP(0)
            }						
        }
    }
}

Scope(\_GPE)
{
  // OSUP method apply TB2P<->P2TB handshake procedure 
  // with Command = OS_Up
  // Arg0 - Memory mapped IO address of RR host router upstream port
  Method(OSUP, 1)
  {
      Add(Arg0, 0x548, Local0)
      OperationRegion(PXVD,SystemMemory,Local0,0x08)
      Field(PXVD,DWordAcc, NoLock, Preserve)
      {
        TB2P, 32, 
        P2TB, 32
      }    

      Store(100, Local1)
      Store(0x0D, P2TB) // Write (OS_Up << 1) | 1 to PCIe2TBT
      While(LGreater(Local1, 0))
      {
          Store(Subtract(Local1, 1), Local1)
          Store(TB2P, Local2)
          If(LEqual(Local2, 0xFFFFFFFF))// Device gone
          {
              Return(2)
          }
          If(And(Local2, 1)) // Done
          {
              break
          }
          Sleep(50)
      }
      Store(0x00, P2TB) // Write 0 to PCIe2TBT
      Return(1)
  }

  Method(MMRP)
  {
      // Calculate Memory mapped IO address of RR host router PCIE root port
      // And put it into XXXXX

      Store(\PEMA, Local0)
      If(LLessEqual(ToInteger(TBRP), 0x08))     // SB PCIE root port
      {
          Add(Local0, 0xE0000, Local0) // RP01
          Subtract(ToInteger(\TBRP), 1, Local1)
          Multiply(Local1, 0x1000, Local1)
          Add(Local0, Local1, Local0) //RP0x
      }
      Else                          // NB PCIE root port
      {
          Add(Local0, 0x8000, Local0) //PEG0
          Subtract(ToInteger(\TBRP), 0x20, Local1)
          Multiply(Local1, 0x1000, Local1)
          Add(Local0, Local1, Local0)
      }
      Return(Local0)
  }

  // Calculate Memory mapped IO address of RR host router upstream port
  Method(MMTB)
  {
      // Calculate Memory mapped IO address of RR host router upstream port
      // And put it into XXXXX

      Store(MMRP(), Local0)
      OperationRegion(MMMM, SystemMemory, Local0, 0x1A)
      Field(MMMM, AnyAcc, NoLock, Preserve)
      {
         Offset(0x19),
         SBUS, 8
      }

      Store(SBUS, Local2)
      Store(\PEMA, Local0)
      Multiply(Local2, 0x100000, Local2)
      Add(Local0, Local2, Local0)  //TBT HR US port MMIO address
      Return(Local0)
  }

  Method(GDRP)
  {
    // Put TBT PCIE root port to D0 state

    Store(MMRP(), Local0)
    OperationRegion(RP_X, SystemMemory, Local0, 0x100)
    Field(RP_X, AnyAcc, NoLock, Preserve)
    {
        Offset(0x84),
        NBPS, 2,       // Power State of PEG slot
        Offset(0xA4),
        PSD3, 2        // Power State of SB PCIE slot
    }
    If(LLess(TBRP, 0x20)){
        Store(0, PSD3)
        Return (PSD3)
    }
    If(LGreaterEqual(TBRP, 0x20)){
        Store(0, NBPS)
        Return (NBPS)
    }
  }

  Method(RPDX, 1)
  {
    // Change TBT PCIE root port Power state via Arg0
    // Arg0 - 0: D0 Status
    //        3: D3 Status
    
    Store(MMRP(), Local0)
    OperationRegion(RP_X, SystemMemory, Local0, 0x100)
    Field(RP_X, AnyAcc, NoLock, Preserve)
    {
        Offset(0x84),
        NBPS, 2,       // Power State of PEG slot
        Offset(0xA4),
        PSD3, 2
    }
    If(LLess(TBRP, 0x20)){
        Store(Arg0, PSD3)
        Sleep(100)
    }
    If(LGreaterEqual(TBRP, 0x20)){
        Store(Arg0, NBPS)
        Sleep(100)
    }
  }

  Method(TBAC)
  {
      // Equal Intel BIOS method TSUB and WSUB
      
      Acquire(OSUM, 0xFFFF)
      Store(MMRP(), Local0)
      OperationRegion(RP_X, SystemMemory, Local0, 0x100)
      Field(RP_X, AnyAcc, NoLock, Preserve)
      {
        Offset(0x08),
        RDCC, 32,
        Offset(0x18),
        PBUS, 8,
        SBUS, 8,
        SUBS, 8,
        Offset(0x84),
        NBPS, 2,       // Power State of PEG slot
        Offset(0xA4),
        PSD3, 2
      }
      Store(0, Local1)
      While(1)
      {
        If(LAnd(LNotEqual(RDCC, 0xFFFFFFFF), LNotEqual(SBUS, 0xFF)))
        {
            If(LAnd(LLess(TBRP, 0x20), LEqual(PSD3, 0x0))){
                Break
            }
            If(LAnd(LGreaterEqual(TBRP, 0x20), LEqual(PSD3, 0x0))){
                Break
            }
        }
        Else
        {
            Add(Local1, 0x01, Local1)
            If(LGreater(Local1, 0x03E8))
            {
                P8XH(1,0x7B)
                P8XH(0,0xAC)
                Sleep(0x3E8)
                Break
            }
            Else
            {
                Sleep(0x10)
            }
        }
      }
      Release(OSUM)
  }

  Method(NTFY)
  {
    // Intel Chipset Sample code Notify Method
    Sleep(100)
    Switch(ToInteger(TBRP)) // TBT Selector
    {
        Case (1)
        {
            Notify(\_SB.PCI0.RP01,0)
        }
        Case (2)
        {
            Notify(\_SB.PCI0.RP02,0)
        }
        Case (3)
        {
            Notify(\_SB.PCI0.RP03,0)
        }
        Case (4)
        {
            Notify(\_SB.PCI0.RP04,0)
        }
        Case (5)
        {
            Notify(\_SB.PCI0.RP05,0)
        }
        Case (6)
        {
            Notify(\_SB.PCI0.RP06,0)
        }
        Case (7)
        {
            Notify(\_SB.PCI0.RP07,0)
        }
        Case (8)
        {
            Notify(\_SB.PCI0.RP08,0)
        }
        Case (0x20)
        {
            Notify(\_SB.PCI0.PEG0,0)
        }
        Case (0x21)
        {
            Notify(\_SB.PCI0.PEG1,0)
        }
        Case (0x22)
        {
            Notify(\_SB.PCI0.PEG2,0)
        }
    }
  }

  // Check for 0xFFFFFFFF in TBT Vendor/Device ID
  // And Call OSUP if true
  Method(TBFF)
  {
      // Get mapped IO address of RR host router upstream port
      Store(MMTB(), Local0) 
      OperationRegion(PXVD,SystemMemory,Local0,0x4) 
      Field(PXVD,DWordAcc, NoLock, Preserve)
      {
        VEDI, 32 // Vendor/Device ID
      }    
      
	  //Check Vendor/Device ID for 0xFFFFFFFF
      Store(VEDI, Local1)
      If(LEqual(Local1, 0xFFFFFFFF))
      {
          Return (OSUP(Local0))
      }
      Else
      {
          Return (0)
      }
  } 

  Method(OE1X)
  {
    Name(TSNE, 0xFF) //will be updated by setup menu
    
    If(LLess(OSYS,2009)) { Return() } // only support win7 or above OS

    Wait(WFEV, 0xFFFF)
    Signal(WFEV)
    TBAC()
    Acquire(OSUM, 0xFFFF)    
    If(LNotEqual(\TBHR, 0x01))// For Redwood Ridge/Falcon Ridge
    {
        Store(TBFF(), Local0)
        If(LEqual(Local0, 1))// Only HR
        {
            Sleep(16)
            Release(OSUM)
            Return ()
        }
        If(LEqual(Local0, 2)) // Disconnect
        {
            If(And(TSNE, 0x02)) // If notification is enabled call Notify
            {
                Sleep(16)
                NTFY()
            }
            P8XH(0,0x7D)
            Release(OSUM)
            Return ()
        }
    }

    If(And(TSNE, 0x01))
    {
        Store(TBSW, SSMP)
    }
    If(And(TSNE, 0x02))
    {
        NTFY()
    }
    Sleep(16)
    Release(OSUM)
  }
}

#if defined (ASL_TBT_RMV_REPORT) && (ASL_TBT_RMV_REPORT == 1)
Scope (ASL_TBT_RP_NUM.PXSX)
{
    Method(_RMV)
    {
      Return(TBMV)
    } // end _RMV
}
#endif

Scope (ASL_TBT_RP_NUM)
{
#if defined ASL_TBT_PCI0_INI_SUPPORT && ASL_TBT_PCI0_INI_SUPPORT == 1
  Method(TINI,0)
#else
  Method(_INI,0)
#endif
  {
      If(LLess(OSYS,2009)) { Return() } // only support win7 or above OS

      If(LAnd(LNotEqual(\TBHR, 0xFF), LNotEqual(\TBHR, 0x01)))// For Redwood Ridge/Falcon Ridge
      {
          Acquire(OSUM, 0xFFFF)
          P8XH(0, 0x51)     // for debug
/*
          Store(MMRP(), Local1)
          OperationRegion(RP_X, SystemMemory, Local1, 0x20)
          Field(RP_X, DWordAcc, NoLock, Preserve)
          {
            REG0, 32,
            REG1, 32,
            REG2, 32,
            REG3, 32,
            REG4, 32,
            REG5, 32,
            REG6, 32,
            REG7, 32,
          }
          Store(REG6, Local2)
          Store(0x00F0F000, REG6)
*/
          \_GPE.TBAC()
          // Get memory mapped IO address of RR host router upstream port
          Store(\_GPE.MMTB(), Local3)
          // Call OSUP
          \_GPE.OSUP(Local3)
          Release(OSUM)
      }
      Signal(WFEV)
  }

#if defined(ASL_TBT_WAK_SUPPORT) && (ASL_TBT_WAK_SUPPORT==1)
  Method(TWAK, 1)
  {
      Name(RPL1, 0)
      Name(RPL6, 0)
      Name(RPL7, 0)
      Name(RPL8, 0)
      Name(RPL9, 0)
      Name(RPLA, 0)
      Name(RPLB, 0)
      
      If(LLess(OSYS,2009)) { Return() } // only support win7 or above OS

      If(LAnd(LNotEqual(\TBHR, 0xFF), LNotEqual(\TBHR, 0x01)))// Only for Redwood Ridge/Falcon Ridge
      {
          Acquire(OSUM, 0xFFFF)
          \_GPE.TBAC()
          //Sleep(50)  // fix hang up when S3 resuming
          // Get memory mapped IO address of RR host router upstream port
          Store(\_GPE.MMRP(), Local0)
          OperationRegion(RP_X, SystemMemory, Local0, 0x34)
          Field(RP_X, DWordAcc, NoLock, Preserve)
          {
            REG0, 32,
            REG1, 32,
            REG2, 32,
            REG3, 32,
            REG4, 32,
            REG5, 32,
            REG6, 32,
            REG7, 32,
            REG8, 32,
            REG9, 32,
            REGA, 32,
            REGB, 32,
            REGC, 32,
          }
          Store(REG1, RPL1)
          Store(REG6, RPL6)
          Store(REG7, RPL7)
          Store(REG8, RPL8)
          Store(REG9, RPL9)
          Store(REGA, RPLA)
          Store(REGB, RPLB)
          Store(RPR6, REG6)
          Store(RPR7, REG7)
          Store(RPR8, REG8)
          Store(RPR9, REG9)
          Store(RPRA, REGA)
          Store(RPRB, REGB)
          Store(0x00100007, REG1)
          Store(\_GPE.GDRP(), Local2)
          \_GPE.RPDX(Zero)
          Store(\_GPE.MMTB(), Local3)
          // Call OSUP
          \_GPE.OSUP(Local3)
          // Restore TBT root port resource/bus/cmd/D state registers as before Sx entry
          Store(TBSW, SSMP)
          // Restore original register values as before calling SMI
          Store(RPL1, REG1)
          Store(RPL6, REG6)
          Store(RPL7, REG7)
          Store(RPL8, REG8)
          Store(RPL9, REG9)
          Store(RPLA, REGA)
          Store(RPLB, REGB)
          \_GPE.RPDX(Local2)
          Release(OSUM)

          // For TBT host at NB PCIE slot
          If(LGreaterEqual(ToInteger(TBRP), 0x20))
          {
              Switch(ToInteger(TBRP))
              {
                  Case (0x20)
                  {
                      Notify(\_SB.PCI0.PEG0,0)
                  }
                  Case (0x21)
                  {
                      Notify(\_SB.PCI0.PEG1,0)
                  }
                  Case (0x22)
                  {
                      Notify(\_SB.PCI0.PEG2,0)
                  }
              }
          }
      }

#if defined(ASL_TBT_S3_WAK_SMI) && (ASL_TBT_S3_WAK_SMI == 1) && (ASL_TBT_WAK_SUPPORT == 1)
      Store(Arg0,Local0)
      If(LEqual(Local0, 0x03)){
           If(ASL_TBT_RP_NUM.PDSX){
              Store(TBSW, SSMP)
              NTFY()
           }
      }
#endif
      Signal(WFEV)
  }
#endif

#if defined(ASL_TBT_PTS_SUPPORT) && (ASL_TBT_PTS_SUPPORT==1)
  Method(TPTS, 1)
  {
    If(LLess(OSYS,2009)) { Return() } // only support win7 or above OS

    If(LAnd(LNotEqual(\TBHR, 0xFF), LNotEqual(\TBHR, 0x01)))// Only for Redwood Ridge/Falcon Ridge
    {
        Acquire(OSUM, 0xFFFF)
        Store(\_GPE.MMRP(), Local0)
        OperationRegion(RP_X, SystemMemory, Local0, 0x34)
        Field(RP_X, DWordAcc, NoLock, Preserve)
        {
            REG0, 32,
            REG1, 32,
            REG2, 32,
            REG3, 32,
            REG4, 32,
            REG5, 32,
            REG6, 32,
            REG7, 32,
            REG8, 32,
            REG9, 32,
            REGA, 32,
            REGB, 32,
            REGC, 32,
        }
        Store(REG6, RPR6)
        Store(REG7, RPR7)
        Store(REG8, RPR8)
        Store(REG9, RPR9)
        Store(REGA, RPRA)
        Store(REGB, RPRB)
        Release(OSUM)
    }
#if defined(ASL_TBT_CLEAR_PME_STATUS) && (ASL_TBT_CLEAR_PME_STATUS == 1)
    If(LOr(PSPX, PMEP)){
        Store(PMEX, Local1)
        Store(0, PMEX)
        Sleep(10)
        Store(1, PSPX)
        Sleep(10)
        If(PSPX){
            Store(1, PSPX)
            Sleep(10)
        }
        Store(Local1, PMEX)
	}
#endif
    Reset(WFEV)
  }
#endif
}
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2011, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************