summaryrefslogtreecommitdiff
path: root/ReferenceCode/AcpiTables/Dsdt/EC.ASL
blob: b223a9aa0a3d39f50a82eb93d6b6ce72a2e59dae (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
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
/**************************************************************************;
;*                                                                        *;
;*    Intel Confidential                                                  *;
;*                                                                        *;
;*    Intel Corporation - ACPI Reference Code for the Haswell             *;
;*    Family of Customer Reference Boards.                                *;
;*                                                                        *;
;*                                                                        *;
;*    Copyright (c)  1999 - 2013 Intel Corporation. All rights reserved   *;
;*    This software and associated documentation (if any) is furnished    *;
;*    under a license and may only be used or copied in accordance        *;
;*    with the terms of the license. Except as permitted by such          *;
;*    license, no part of this software or documentation may be           *;
;*    reproduced, stored in a retrieval system, or transmitted in any     *;
;*    form or by any means without the express written consent of         *;
;*    Intel Corporation.                                                  *;
;*                                                                        *;
;*                                                                        *;
;**************************************************************************/
/*++
  This file contains a 'Sample Driver' and is licensed as such  
  under the terms of your license agreement with Intel or your  
  vendor.  This file may be modified by the user, subject to    
  the additional terms of the license agreement                 
--*/


External(\_SB.IETM, DeviceObj)

External(TBAB)
External(RTIP)
External(HGAS, MethodObj)
External(HPFS, MethodObj)
External(HBRT, MethodObj)
External(CHPS, MethodObj)
External(UP1D)
External(UPRW)
External(SVRF, MethodObj)
External(\_SB.PCI0.CTCU, MethodObj)
External(\_SB.PCI0.CTCN, MethodObj)
External(\_SB.PCI0.CTCD, MethodObj)
#if !defined(ASL_Remove_SaSsdt_Data_To_Dsdt) || (ASL_Remove_SaSsdt_Data_To_Dsdt == 0)
External(\_SB.PCI0.GFX0.CLID)
External(\_SB.PCI0.GFX0.IUEH, MethodObj)
External(\_SB.PCI0.GFX0.IUER, DeviceObj)
#endif
#define POWER_BUTTON         0
#define WINDOWS_BUTTON       1
#define VOLUME_UP_BUTTON     2
#define VOLUME_DOWN_BUTTON   3
#define ROTATION_LOCK_BUTTON 4
#define CONVERTIBLE_BUTTON   6
#define DOCK_INDICATOR       7

Device(H_EC)  // Hitachi Embedded Controller
{
  Name(_HID, EISAID("PNP0C09"))

  Name(_UID,1)

  Name(ECAV, Zero)   // OS Bug Checks if EC OpRegion accessed before Embedded Controller Driver loaded

  Method(_CRS,0)
  {
    Name(BFFR, ResourceTemplate()
    {
      IO(Decode16,0x62,0x62,0,1)  // DIN/DOUT
      IO(Decode16,0x66,0x66,0,1)  // CMD/STS
    })

    Return(BFFR)
  }

  Method(_STA)
  {
    If (LEqual(ECON,1)){ 
      Return(0x0F)
    }
    Return(0x00)
  }

  OperationRegion(ECF2,EmbeddedControl,0,0xFF)
  Field(ECF2,ByteAcc,Lock,Preserve)
  {
    Offset(1),
    PLMX, 8,      // 1       Max Platform temprature
    LTMP, 8,      // 2       Sensor Temperature
    RPWR, 1,      // 3.0     Real AC Power (AC Present = 1)
        , 2,      // 3.2:1   Reserved
    CFAN, 1,      // 3.3     CPU Fan (Fan On = 1)
        , 2,      // 3.5:4   Reserved
    LSTE, 1,      // 3.6     Lid State (Lid Open = 1)
        , 1,      // 3.7     Reserved
    SPTR, 8,      // 4       SMBus Protocol Register
    SSTS, 8,      // 5       SMBus Status Register
    SADR, 8,      // 6       SMBus Address Register
    SCMD, 8,      // 7       SMBus Command Register
    SBFR, 256,    // 8       SMBus Block Buffer
    SCNT, 8,      // 40      SMBus Block Count
    Offset(47),
    CTMP, 8,      // 47      EC Critical Temperature
    DOCK, 1,      // 48.0    Docking state (docked = 1)
    EJET, 1,      // 48.1    Eject switch state (Eject (Q-Switch off) = 1)
        , 1,      // 48.2    Reserved
    PBNS, 1,      // 48.3    Power Button State (0 = Pressed)
    VPWR, 1,      // 48.4    Virtual AC Power (AC Present = 1)
        , 3,      // 48.7:5  Reserved
    SCAN, 8,      // 49      Hot-Key Scan Code
    B1ST, 8,      // 50      Battery 1 Status
    B1CR, 8,      // 51      Battery 1 Current Rate
    B1CC, 8,      // 52      Battery 1 Current Capacity
    B1VT, 8,      // 53      Battery 1 Voltage
    B2ST, 8,      // 54      Battery 2 Status
    B2CR, 8,      // 55      Battery 2 Current Rate
    B2CC, 8,      // 56      Battery 2 Current Capacity
    B2VT, 8,      // 57      Battery 2 Voltage
    CMDR, 8,      // 58      KSC command register
    LUXL, 8,      // 59      LUX - Low Byte
    LUXH, 8,      // 60      LUX - High Byte
    ACH0, 8,      // 61      Channel 0 RAW Value
    ACH1, 8,      // 62      Channel 1 RAW Value
    Offset(65),
    PPSL, 8,      // 65      PWM Port Select low byte
    PPSH, 8,      // 66      PWM Port Select high byte
    PINV, 8,      // 67      PWM initial value
    PENV, 8,      // 68      PWM ending value
    PSTP, 8,      // 69      PWM ms delay between steps
    Offset(71),
    CPUP, 16,     // 71      CPU Power mW
    BPWR, 16,     // 73      Brick Power cW(100ths)
    PPWR, 16,     // 75      Platform Power cW(100ths)
    CVRT, 8,      // 77      CPU VR (IMVP) Temp
    FANT, 8,      // 78      Heat exchanger fan temp
    SKNT, 8,      // 79      Skin temp
    AMBT, 8,      // 80      Ambient temp
    Offset(82),   // 82-85   DPTF fields
    TSI,  4,      //         Hysteresis selection is global and meant for all four sensors.
                  //          # 0 = CPU VR (IMVP) temperature sensor
                  //          # 1 = Heat Exchanger temperature sensor
                  //          # 2 = Skin temperature sensor
                  //          # 3 = Ambient temperature sensor
                  //          # 4 = DIMM temperature sensor
                  //          # Above 4 invalid
    HYST, 4,      // 82.4-7  Hysteresis in deg C 
    TSHT, 8,      // 83      Thermal Sensor (N) high trip point
    TSLT, 8,      // 84      Thermal Sensor (N) low trip point
    TSSR, 8,      // 85      TSSR- thermal sensor status register:
                  //         TSSR bits defined:
                  //          BIT0:   CPU VR Temp Sensor Trip Flag 
                  //          BIT1:   Fan Temp Sensor Trip Flag
                  //          BIT2:   Skin Temp Sensor Trip Flag
                  //          BIT3:   Ambient Temp Sensor Trip Flag
                  //          BIT4:   DIMM Trip Point Flag
                  //          BIT[7:5] Reserved
    Offset(86),
    B1CM, 8,      // 86      Battery 1 Command (Place holder for now)
    B1DC, 16,     // 87      Battery 1 Design Capacity (mWh)
    B1RC, 16,     // 89      Battery 1 Remaining Capacity (mWh)
    B1FC, 16,     // 91      Battery 1 Full Charge Capacity (mWh)
    B1FV, 16,     // 93      Battery 1 Full Resolution Voltage (mV)
    B1DI, 16,     // 95      Battery 1 Full Resolution Discharge Current (mA)
    B1CI, 16,     // 97      Battery 1 Full Resolution Charge Current (mA)    
    B2RC, 16,     // 99      Battery 2 Remaining Capacity (mWh)
    B2FC, 16,     // 101     Battery 2 Full Charge Capacity (mWh)
    B2FV, 16,     // 103     Battery 2 Full Resolution Voltage (mV)
    B2DI, 16,     // 105     Battery 2 Full Resolution Discharge Current (mA)
    B2CI, 16,     // 107     Battery 2 Full Resolution Charge Current (mA)
    CPAP, 16,     // 109     CPU average power in mW
    BKAP, 16,     // 111     Brick average power in cW(0.01)
    PLAP, 16,     // 113     Platform average power in cW(0.01)
    CFSP, 16,     // 115     CPU Fan speed in rpm 
    BRTV, 8,      // 117     Brightness value for San Rafael second panel 
       ,  8,      // 118     reserved
    SLPC, 8,      // 119     Select Performance Counters
    DLED, 1,      // 120.0   EC Connected Standby Debug LED (CAPS LOCK)
    PB10, 1,      // 120.1   10 Second Power Button Control 
    Offset(124),
    PTIM, 8,      // 124     CPU,GFX pwr sample timer
    DHPD, 8,      // 125     Digital display hot-plug detect
    DIM0, 8,      // 126     DIMM0 temperature
    DIM1, 8,      // 127     DIMM1 temperature     
    PMAX, 8,      // 128     CPU,MCH & PCH Max temp
    PPDT, 8,      // 129     PCH DTS reading from PCH
    PECL, 8,      // 130     CPU PECI reading fractional value (1/64 Celcius)
    PECH, 8,      // 131     CPU PECI reading integer value (unit Celicus)
    PMDT, 8,      // 132     MCH DTS reading from PCH
    TSD0, 8,      // 133     TS-on-DIMM0 temperature
    TSD1, 8,      // 134     TS-on-DIMM1 temperature
    TSD2, 8,      // 135     TS-on-DIMM2 temperature
    TSD3, 8,      // 136     TS-on-DIMM3 temperature
    PAKN, 8,      // 137     Packet sequence number
    CPUE, 32,     // 138     CPU energy 
    Offset(155),
    PRCL, 8,      // 155     Repeat cycle (LSB)
    PRC0, 8,      // 156     Repeat cycle 
    PRC1, 8,      // 157     Repeat cycle 
    PRCM, 8,      // 158     Repeat cycle (MSB)
    PRIN, 8,      // 159     Repear Intervel
    PSTE, 8,      // 160     Stop on Error 
    PCAD, 8,      // 161     Peci Clinet Addess 
    PEWL, 8,      // 162     Write Length 
    PWRL, 8,      // 163     Read lenght 
    PECD, 8,      // 164     Command Code 
    PEHI, 8,      // 165     Host ID 
    PECI, 8,      // 166     Index 
    PEPL, 8,      // 167     Parameter (LSB)
    PEPM, 8,      // 168     Parameter (MSB)
    PWFC, 8,      // 169     Write FCS 
    PECC, 8,      // 170     Completion code 
    PDT0, 8,      // 171     Data 0 
    PDT1, 8,      // 172     Data 1
    PDT2, 8,      // 173     Data 2 
    PDT3, 8,      // 174     Data 3 
    PRFC, 8,      // 175     Read FCS 
    PRS0, 8,      // 176     Reserved 
    PRS1, 8,      // 177     Reserved 
    PRS2, 8,      // 178     Reserved 
    PRS3, 8,      // 179     Reserved 
    PRS4, 8,      // 180     Reserved
    Offset(187),
    PRCS, 8,      // 187     Peci Repeat Command Status
    PEC0, 8,      // 188     Peci Error Count(LSB)
    PEC1, 8,      // 189     Peci Error Count
    PEC2, 8,      // 190     Peci Error Count
    PEC3, 8,      // 191     Peci Error Count(MSB)
    GTVR, 8,      // 192     CPU GT VR temp
    MCRT, 8,      // 193     Minicard Region Temp
    Offset(194),
    IBT1, 8,      // 194     ISCT Byte 1
                  //          194.0   Enable/Disable ISCT - SAOS bit
                  //          194.1   WLAN powered in S3 
                  //          194.2   WLAN powered in S4
                  //          194.3   WLAN powered in S5
                  //          194.4   WWAN powered in S3
                  //          194.5   WWAN powered in S4
                  //          194.6   WWAN powered in S5
                  //          194.7   Reserved
    IBT2, 8,      // 195     ISCT Byte 2
                  //          195.0   WLAN Wireless Status (0 = Disabled, 1 = Enabled)
                  //          195.1   WWAN Wireless Status (0 = Disabled, 1 = Enabled) 
                  //          195.2:7 Reserved
    WTMS, 8,      // 196     Wake timer Settings       
                  //          196.0   Timer Enabled in S3 
                  //          196.1   Timer Enabled in S4
                  //          196.2   Timer Enabled in S5
                  //          196.3:6 Reserved  
                  //          196.7   Enable/Disable EC Timer
    AWT2, 8,      // 197     ACPIWakeTmrByte2 - Wake timer value (BIT23-16)
    AWT1, 8,      // 198     ACPIWakeTmrByte1 - Wake timer value (BIT15-8)
    AWT0, 8,      // 199     ACPIWakeTmrByte0 - Wake timer value (BIT7-0)
    SPT2, 1,      // 200.0   SATA Por2 - Cable connect power control. 1=ON;0=OFF
    ,7,           // 200.7-1  Reserved
    Offset(211),
    B1DV, 16,     // 211     Battery 1 Design Voltage (mV)
    Offset(215),
    B1ML, 8,      // 215   BattAPmaxL - Battery Pack A maximum low byte
    B1MH, 8,      // 216   BattAPmaxH - Battery Pack A maximum high byte
    B2ML, 8,      // 217   BattBPmaxL - Battery Pack B maximum low byte
    B2MH, 8,      // 218   BattBPmaxH - Battery Pack B maximum high byte
    BTP1, 8,      // 219   Battery 1 Trip Point in %
  }


  // ECRD (Embedded Read Method)
  //
  // Handle all commands sent to EC by BIOS
  //
  //  Arguments: (1)
  //    Arg0 - Object to Read
  //  Return Value:
  //    Read Value
  //    
  Method(ECRD,1,Serialized, 0, IntObj, FieldUnitObj)
  {
    If(LAnd(LEqual(\ECUP,Zero),LEqual(\_SB.RDGP(88),0)))
    {
      \_SB.WTGP(88,1)
      Sleep(16)
    }
    Store(DerefOf (Arg0), Local0)
    Return(Local0)
  }

  // ECWT (Embedded Write Method)
  //
  // Handle all commands sent to EC by BIOS
  //
  //  Arguments: (2)
  //    Arg0 - Value to Write
  //    Arg1 - Object to Write to
  //    
  Method(ECWT,2,Serialized,,,{IntObj, FieldUnitObj})
  {
    If(LAnd(LEqual(\ECUP,Zero),LEqual(\_SB.RDGP(88),0)))
    {
      \_SB.WTGP(88,1)
      Sleep(16)
    }
    Store(Arg0,Arg1)
  }

  // ECMD (Embedded Controller Command)
  //
  // Handle all commands sent to EC by BIOS
  //
  //  Arguments: (1)
  //    Arg0 - EC command
  //  Return Value:
  //    0x00 = Success
  //    0xFF = Failure
  //
  Method(ECMD,1,Serialized)
  {
    While(ECRD(RefOf(\_SB.PCI0.LPCB.H_EC.CMDR))){Stall(20)} // make sure no command is currently being processed so we don't overwrite it
    ECWT(Arg0, RefOf(\_SB.PCI0.LPCB.H_EC.CMDR))
    Return (0x00)
  }

  Include("ALS.ASL")


  // Virtual battery code
  //
  Include("Bat0Virt.asl")

  // Real battery code
  //
  Include("Bat1Real.asl")
  Include("Bat2Real.asl")

  // The _REG Method is needed because communication with the EC
  // before the driver is loaded is prohibited in WIN2000/WINXP.

  Method(_REG,2)
  {
    If(LAnd(LEqual(Arg0,3),LEqual(Arg1,1)))
    {
      // Must be running NT 5.0 OS.
      // Update ECAV Object. ASL should check for this value to be One before accessing EC OpRegion.
      Store(One, ECAV)

      // Turn off the CPU Fan if Active Cooling
      //   is disabled.

      If(LEqual(0,ACTT))
      {
        ECWT(0,RefOf(CFAN))
      }

      // Turn off pwm fan so it starts in a known state
      If(LEqual(1, THOF))
      {
        \_TZ.FN00._OFF() 
      }

      // Update the Ambiant Light Illuminence Values.

      Store(ECRD(RefOf(LUXH)),LHIH)
      Store(ECRD(RefOf(LUXL)),LLOW)

      If(LAnd(LEqual(ALSE,2),IGDS))
      {
        Store(ECRD(RefOf(LUXH)), Local0)     
        Or(ShiftLeft(Local0, 8), ECRD(RefOf(LUXL)), \_SB.PCI0.GFX0.ALSI)   
      }

      // Save the Lid State in global NVS and IGD OpRegion.
      //Store(LSTE,\_SB.PCI0.GFX0.CLID)
      If (LEqual(ECRD(RefOf(LSTE)), 0))
      {
        Store(0,\_SB.PCI0.GFX0.CLID)
      }
      If (LEqual(ECRD(RefOf(LSTE)), 1))
      {
        Store(3,\_SB.PCI0.GFX0.CLID) 
      }
      Store(ECRD(RefOf(LSTE)),LIDS)

      // Update the Dock Status
      Store(\DSTS,\_SB.PCI0.GFX0.CDCK)

      // Unconditionally fix up the Battery and Power State.

      // Initialize the Number of Present Batteries.
      //  1 = Real Battery 1 is present
      //  2 = Real Battery 2 is present
      //  3 = Real Battery 1 and 2 are present

      Store(0,BNUM)
      Or(BNUM,ShiftRight(And(ECRD(RefOf(B1ST)),0x08),3),BNUM)
      Or(BNUM,ShiftRight(And(ECRD(RefOf(B2ST)),0x08),2),BNUM)

      // Save the current Power State for later.

      Store(PWRS,Local0)

      // Initialize the Power State.
      //  BNUM = 0 = Virtual Power State
      //  BNUM > 0 = Real Power State

      If(LEqual(BNUM,0))
      {
        Store(ECRD(RefOf(VPWR)),PWRS)
      }
      Else
      {
        Store(ECRD(RefOf(RPWR)),PWRS)
      }

      // Perform needed ACPI Notifications.

      PNOT()

      //
      // Call Power button init method for 10sec PB OVR
      //
      ^VGBI.PBIN()
    }
  }

  Method(_GPE)
  {
    Store (23,  Local0)   // GPI7 for other boards

    If(LOr(LOr(LEqual(BID,BWT1), LEqual(BID,BW1P)), LOr(LEqual(BID,BW2C), LEqual(BID,BW2P)))) // BoardIdWhiteTipMountain1, BoardIdWhiteTipMountain1Ppv, BoardIdWhiteTipMountain2, BoardIdWhiteTipMountain2Ppv
    {
      Store(10, Local0)   // GPI10
    }

    If(LOr(LOr(LEqual(BID,BSPC), LEqual(BID,BSPP)), LEqual(BID,BRH))) // BoardIdSawToothPeak, BoardIdSawToothPeakPpv, BoardIdReedHarborTdv
    {
      Store(10, Local0)   // GPI10
    }

    return (Local0)
  }
    
  // For the below _Qxx Methods, The Runtime SCI has been asserted,
  // the EC Driver performed it's query, and the value returned from
  // the Query = xx.

  Method(_Q30)    // Real Battery AC Insertion Event.
  {
    P8XH(0,0x30)

    // Set Global Power State = AC Mode.

    Store(1,PWRS)

    // Perform needed ACPI Notifications.

    PNOT()
  }

  Method(_Q31)    // Real Battery AC Removal Event.
  {
    P8XH(0,0x31)

    // Set Global Power State = Battery Mode.

    Store(0,PWRS)

    // Perform needed ACPI Notifications.

    PNOT()
  }

  Method(_Q32)    // Real Battery Capacity Change.
  {
    P8XH(0,0x32)

    // Perform needed ACPI Notifications.

    PNOT()
  }

  Method(_Q33)    // Real Battery Insertion/Removal Event.
  {
    P8XH(0,0x33)

    // Initialize the Number of Present Batteries.
    //  1 = Real Battery 1 is present
    //  2 = Real Battery 2 is present
    //  3 = Real Battery 1 and 2 are present

    Store(0,BNUM)
    Or(BNUM,ShiftRight(And(ECRD(RefOf(B1ST)),0x08),3),BNUM)
    Or(BNUM,ShiftRight(And(ECRD(RefOf(B2ST)),0x08),2),BNUM)

    // Perform needed ACPI Notifications.

    PNOT()
  }
  
  Method(_Q40, 0, Serialized)   // Dock complete Event
  {
    P8XH(0,0x40)   
    If(LEqual(\_SB.PCI0.HDEF.DCKS, 1)) 
    {
      If(LEqual(\_SB.PCI0.HDEF.DCKM, 0))
      {
        Store(1, \_SB.PCI0.HDEF.DCKA)
        Stall(50)
        While(LNotEqual(\_SB.PCI0.HDEF.DCKM, 1))
        {
          Stall(50)
        }
      }
    } 

    Sleep(1000) // Delay 1 second for hot docking stability
    Store(\PDBR, \SSMP)
    Store(1, \DSTS)
    Sleep(1000) // Delay 1 second for hot docking stability
    Notify(\_SB.PCI0.DOCK, 0x00)

    If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
    {
      Or(PB1E, 0x10, PB1E) // Set Dock status
      ^VGBI.UPBT(DOCK_INDICATOR, One)
      ADBG("Notify 0xCA")
      Notify(^VGBI, 0xCA) // Notify Virtual GPIO driver that Docking event happens.
    }

    If(IGDS)
    {
      \_SB.PCI0.GFX0.GDCK(1)
    }
  }

  Method(_Q41)    // Surprise Removal
  {
    P8XH(0,0x41)   
    If(LEqual(\_SB.PCI0.HDEF.DCKS, 1)) 
    {
      If(LEqual(\_SB.PCI0.HDEF.DCKM, 1)) 
      {
        Store(0, \_SB.PCI0.HDEF.DCKA)
      }
    }
    Store(0, \DSTS)
    Notify(\_SB.PCI0.DOCK, 0x01)

    If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
    {
      And(PB1E, Not(0x10), PB1E) // Clear Dock Status
      ^VGBI.UPBT(DOCK_INDICATOR, Zero)
      ADBG("Notify 0xCB")
      Notify(^VGBI, 0xCB) // Notify Virtual GPIO driver that Undocking event happens.
    } Else {
      If(IGDS)
      {
        \_SB.PCI0.GFX0.GDCK(0)
      }
    }           
  }           
  
  Method(_Q42)    // Undocking request Event
  {
    P8XH(0,0x42)
    If(LAnd(\_SB.PCI0.HDEF.DCKS, 1)) 
    {
      Store(0, \_SB.PCI0.HDEF.DCKA)
    }
    Notify(\_SB.PCI0.DOCK, 0x01)

    If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
    {
      And(PB1E, Not(0x10), PB1E) // Clear Dock Status
      ^VGBI.UPBT(DOCK_INDICATOR, Zero)
      If(CondRefOf(\_SB.PCI0.GFX0.IUER))
      {
        Store(\_SB.PCI0.GFX0.IUER, Local0) 
        And(Local0, Not(0x80), \_SB.PCI0.GFX0.IUER)
      }
      ADBG("Notify 0xCB")
      Notify(^VGBI, 0xCB) // Notify Virtual GPIO driver that Undocking event happens.
    } Else {
      If(IGDS)
      {
        \_SB.PCI0.GFX0.GDCK(0)
      }
    }
  }
  
  Method(_Q43)    // Express Card Presence Changed on Saddlestring (Docking)
  {
    P8XH(0,0x43)

    Notify(\_SB.PCI0.RP07, 0x0)
  }
  
  Method(_Q44)  // Virtual Dock Presence Changed
  {
    If(\DSTS)
    {
      Notify(\_SB.PCI0.DOCK, 1) //UnDocked
      Store(0, \DSTS)
    }
    Else
    {
      Notify(\_SB.PCI0.DOCK, 0) //Docked
      Store(1, \DSTS)
    }
  }

  Method(_Q51)    // Lid Switch Event.
  {
    P8XH(0,0x51)

    // Update Lid NVS State.

    Store(ECRD(RefOf(LSTE)),LIDS)

    \_SB.PCI0.GFX0.GLID(LIDS)
    
    // If ETM is not disabled, notify IETM device
    If (LEqual(\_TZ.ETMD, 0))
    {
      If(CondRefOf(\_SB.IETM))
      {
        Notify(\_SB.IETM,0x83)
      }
    }
    Notify(\_SB.LID0,0x80)
  }


  Method(_Q52)    // Hot-Key Event.
  {
    P8XH(0,0x52)

    // This event will be generated whenever a
    // CRTL+ALT+SHIFT+"Next Key" is hit.  This event handler
    // will base code execution on the "Next Key" Scan Code
    // stored in the EC Memory Space.

    Store(ECRD(RefOf(SCAN)),Local2)
    P8XH(1,Local2)


    // "D" Scan Code = 0x20

    If(LEqual(SCAN,0x20))
    {
      ADBG("CAS+D")
      If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
      {
        //
        // CAS+D test emulation mode
        // 1. Windows press notify 0xC2
        // 2. Volume up press notify 0xC4
        // 3. Volume up release notify 0xC5
        // 4. Windows release notify 0xC3
        //

        Sleep(1000) // 1sec delay is needed for Powerbutton and Windows Home button.

        ^VGBI.UPBT(WINDOWS_BUTTON, One) // Update VBDS
        ADBG("Notify 0xC2")
        Notify(^VGBI, 0xC2) // Notify Virtual GPIO driver that Windows Home button is pressed.

        ^VGBI.UPBT(VOLUME_UP_BUTTON, One)
        ADBG("Notify 0xC4")
        Notify(^VGBI, 0xC4) // Notify Virtual GPIO driver that Vol up button is pressed.

        ^VGBI.UPBT(VOLUME_UP_BUTTON, Zero)
        ADBG("Notify 0xC5")
        Notify(^VGBI, 0xC5) // Notify Virtual GPIO driver that Vol up button is released.

        ^VGBI.UPBT(WINDOWS_BUTTON, Zero)
        ADBG("Notify 0xC3")
        Notify(^VGBI, 0xC3) // Notify Virtual GPIO driver that Windows Home button is released.
      }
    }

    // "F" Scan Code = 0x21

    If(LEqual(SCAN,0x21))
    {
      ADBG("CAS+F")
      If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
      {
        //
        // CAS+F test emulation mode
        // 1. Windows press notify 0xC2
        // 2. Volume down press notify 0xC6
        // 3. Volume down release notify 0xC7
        // 4. Windows release notify 0xC3
        //

        Sleep(1000) // 1sec delay is needed for Powerbutton and Windows Home button

        ^VGBI.UPBT(WINDOWS_BUTTON, One) // Update VBDS
        ADBG("Notify 0xC2")
        Notify(^VGBI, 0xC2) // Notify Virtual GPIO driver that Windows Home button is pressed.

        ^VGBI.UPBT(VOLUME_DOWN_BUTTON, One)
        ADBG("Notify 0xC6")
        Notify(^VGBI, 0xC6) // Notify Virtual GPIO driver that Vol down button is pressed.

        ^VGBI.UPBT(VOLUME_DOWN_BUTTON, Zero)
        ADBG("Notify 0xC7")
        Notify(^VGBI, 0xC7) // Notify Virtual GPIO driver that Vol down button is released.

        ^VGBI.UPBT(WINDOWS_BUTTON, Zero) // Update VBDS
        ADBG("Notify 0xC3")
        Notify(^VGBI, 0xC3) // Notify Virtual GPIO driver that Windows Home button is released.
      }
    }

    // Intel Ultrabook Event Handlers.

    // "G" Scan Code = 0x22

    If(LEqual(Local2,0x22))
    {
      ADBG("CAS+G")
      If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
      {
        //
        // CAS+G test emulation mode
        // 1. Windows press notify 0xC2
        // 2. Powerbutton press notify 0xC0
        // 3. Powerbutton release notify 0xC1
        // 4. Windows release notify 0xC3
        //

        Sleep(1000) // 1sec delay is needed for Powerbutton and Windows Home button

        ^VGBI.UPBT(WINDOWS_BUTTON, One)
        ADBG("Notify 0xC2")
        Notify(^VGBI, 0xC2) // Notify Virtual GPIO driver that Windows Home button is pressed.
        If(And(PB1E, 1)) 
        {
          ^VGBI.UPBT(POWER_BUTTON, One)
          ADBG("Notify 0xC0")
          Notify(^VGBI, 0xC0) // Notify Virtual GPIO driver that Power button is pressed.

          ^VGBI.UPBT(POWER_BUTTON, Zero)
          ADBG("Notify 0xC1")
          Notify(^VGBI, 0xC1) // Notify Virtual GPIO driver that Power button is released.
        }

        ^VGBI.UPBT(WINDOWS_BUTTON, Zero)
        ADBG("Notify 0xC3")
        Notify(^VGBI, 0xC3) // Notify Virtual GPIO driver that Windows Home button is released.
      } Else {
        // Power Button.  If HID Event Driver loaded, use it. Otherwise, use GFX Driver.
        If(LEqual(\_SB.HIDD.HRDY, 1))
        {
          \_SB.HIDD.HPEM(9)
        } Else {
          ADBG("IUEH")
          \_SB.PCI0.GFX0.IUEH(0)
        }
      }
    }

    // "H" Scan Code = 0x23

    If(LEqual(Local2,0x23))
    {
      ADBG("CAS+H")
      // Windows Button.  If HID Event Driver loaded, use it.  Otherwise, use GFX Driver.
      Sleep(1000)

      If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
      {
        ^VGBI.UPBT(WINDOWS_BUTTON, One)
        ADBG("Notify 0xC2")
        Notify(^VGBI, 0xC2) // Notify Virtual GPIO driver that Windows Home button is pressed.
        ^VGBI.UPBT(WINDOWS_BUTTON, Zero)
        ADBG("Notify 0xC3")
        Notify(^VGBI, 0xC3) // Notify Virtual GPIO driver that Windows Home button is released.
      } Else {
        If(LEqual(\_SB.HIDD.HRDY, 1))
        {
          \_SB.HIDD.HPEM(1)
        } Else {
          ADBG("IUEH")
          \_SB.PCI0.GFX0.IUEH(1)
        }
      }
    }

    // "J" Scan Code = 0x24
    If(LEqual(Local2,0x24))
    {
      ADBG("CAS+J")
      // Volume Up.  If HID Event Driver loaded, use it.  Otherwise, use GFX Driver.

      If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
      {
        ^VGBI.UPBT(VOLUME_UP_BUTTON, One)
        ADBG("Notify 0xC4")
        Notify(^VGBI, 0xC4) // Notify Virtual GPIO driver that Volume UP button is pressed.

        ^VGBI.UPBT(VOLUME_UP_BUTTON, Zero)
        ADBG("Notify 0xC5")
        Notify(^VGBI, 0xC5) // Notify Virtual GPIO driver that Volume UP button is released.
      } Else {
        If(LEqual(\_SB.HIDD.HRDY, 1))
        {
          \_SB.HIDD.HPEM(17)
        } Else {
          ADBG("IUEH")
           \_SB.PCI0.GFX0.IUEH(2)
        }// End of If(LEqual(\_SB.HIDD.HRDY, 1))
      } // If(LAnd(CondRefOf(^VGBI._STA)),(LEqual(And(^VGBI._STA(),One),One)))
    }

    // "K" Scan Code = 0x25

    If(LEqual(Local2,0x25))
    {
      ADBG("CAS+K")
      // Volume Down.  If HID Event Driver loaded, use it. Otherwise, use GFX Driver.

      If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
      {
        ^VGBI.UPBT(VOLUME_DOWN_BUTTON, One)
        ADBG("Notify 0xC6")
        Notify(^VGBI, 0xC6) // Notify Virtual GPIO driver that Volue Down button is pressed.

        ^VGBI.UPBT(VOLUME_DOWN_BUTTON, Zero)
        ADBG("Notify 0xC7")
        Notify(^VGBI, 0xC7) // Notify Virtual GPIO driver that Volue Down button is released.
      } Else {
        If(LEqual(\_SB.HIDD.HRDY, 1))
        {
          \_SB.HIDD.HPEM(18)
        } Else {
          ADBG("IUEH")
          \_SB.PCI0.GFX0.IUEH(3)
        }
      }
    }

    // "L" Scan Code = 0x26

    If(LEqual(Local2,0x26))
    {
      ADBG("CAS+L")
       // Rotation Lock.  If HID Event Driver loaded, use it. Otherwise, use GFX Driver.
       Sleep(1000)

      If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
      {
        Xor(PB1E, 0x04, PB1E) // Toggle Rotation Lock Status (bit2 of PB1E)
        ^VGBI.UPBT(ROTATION_LOCK_BUTTON, One)
        ADBG("Notify 0xC8")
        Notify(^VGBI, 0xC8) // Notify Virtual GPIO driver that Rotation Lock button is pressed.

        ^VGBI.UPBT(ROTATION_LOCK_BUTTON, Zero)
        ADBG("Notify 0xC9")
        Notify(^VGBI, 0xC9) // Notify Virtual GPIO driver that Rotation Lock button is released.
      } Else {
        If(LEqual(\_SB.HIDD.HRDY, 1))
        {
           \_SB.HIDD.HPEM(2)
        } Else {
          ADBG("IUEH")
          \_SB.PCI0.GFX0.IUEH(4)
        }
      }
    }

    // ";" Scan Code = 0x27
    If(LEqual(Local2,0x27))
    {
       ADBG("CAS+;")

      If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
      {
        Xor(PB1E, 0x08, PB1E) // Toggle Slate/Laptop Lock Status
        If(And(PB1E, 0x08)) // Slave/Laptop Mode changed 0 -> 1 Laptop mode
        {
          ^VGBI.UPBT(CONVERTIBLE_BUTTON, One)
          ADBG("Notify 0xCD")
          Notify(^VGBI, 0xCD) // Notify Virtual GPIO driver that the system is now in Laptop mode.
        } Else { // Slave/Laptop Mode Changed 1 -> 0 Slate/Tablet Mode                              
          ^VGBI.UPBT(CONVERTIBLE_BUTTON, Zero)
          ADBG("Notify 0xCC")
          Notify(^VGBI, 0xCC) // Notify Virtual GPIO driver that the system is now in Slate/Tablet mode.
        }
      } Else {
        \_SB.PCI0.GFX0.IUEH(6) // Convertible Indicator lock
      }
    }

    // "'" Scan Code = 0x28
    If(LEqual(Local2,0x28))
    {
       ADBG("CAS+'")

      If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
      {
        Xor(PB1E, 0x10, PB1E) // Toggle Dock/Undock Status
        If(And(PB1E, 0x10)) // Dock/Undock status changed 0 -> 1 Dock mode
        {
          ^VGBI.UPBT(DOCK_INDICATOR, One)
          ADBG("Notify 0xCA")
          Notify(^VGBI, 0xCA) // Notify Virtual GPIO driver that the system is now in Dock mode.
        } Else { // Dock/Undock status Changed 1 -> 0 Undock mode                              
          ^VGBI.UPBT(DOCK_INDICATOR, Zero)
          ADBG("Notify 0xCB")
          Notify(^VGBI, 0xCB) // Notify Virtual GPIO driver that the system is now in Undock mode.
        }
      } Else {
        \_SB.PCI0.GFX0.IUEH(7) // Docking Indicator lock
      }
    }

    // F1 Scan Code = 0x3B
    If(LEqual(Local2,0x3B)) // EC passes directly to kbd buffer, Windows handles this
    {
      ADBG("FN+F1") // Sleep 
      If(LEqual(BID,BRH)) // BoardIdReedHarborTdv
      {
        ADBG("Sleep")
      } Else {
        If(IGDS)
        {
          \_SB.PCI0.GFX0.GHDS(0) // GMCH SCI hotkey display switch, table index 0       
        }
      }
    }

    // F2 Scan Code = 0x3C
    If(LEqual(Local2,0x3C))
    {
      ADBG("FN+F2")
      If(LEqual(BID,BRH)){ // BoardIdReedHarborTdv
// TODO: Display Sleep for Reed Harbor
        ADBG("Display Sleep")
      } Else {
        If(IGDS) // all other boards
        {
          \_SB.PCI0.GFX0.GHDS(1) // GMCH SCI hotkey display switch, table index 1       
        }
      }
    }

    // F3 Scan Code = 0x3D
    If(LEqual(Local2,0x3D))
    {
      ADBG("FN+F3")
      If(LEqual(BID,BRH)){ // BoardIdReedHarborTdv
// TODO: GPIO_57 RFKILL for WiFi for Reed Harbor
        ADBG("RFKILL")
      } Else {
        If(IGDS) // all other boards
        {
          \_SB.PCI0.GFX0.GHDS(2) // GMCH SCI hotkey display switch, table index 2       
        }
      }
    }

    // F4 Scan Code = 0x3E
    If(LEqual(Local2,0x3E))
    {
      ADBG("FN+F4")
      // BoardIdReedHarborTdv
      If(LEqual(BID,BRH)) // Hot Key decrease brightness.
      {
        If(And(4,DSEN))
        {
          BRTN(0x87)
        } Else {
          Store(BRTL, Local0)
          // Current brightness is a percentage.
          // This must be done if ALS if enabled, as the driver will change the brightness based on ambient light.
          Store(\_SB.PCI0.GFX0.CBLV, BRTL)
          // 1 % will be lost in the conversion so need to make sure we account for it.
          AND(Add(BRTL, 1),0xFE, BRTL)
          If(LGreaterEqual(BRTL, 10))
          {
            Subtract(BRTL, 10, BRTL)
          }
          \_SB.PCI0.GFX0.AINT(1, BRTL)
        }
      } Else { // Hot Key Display Switch for all other boards.
        If(IGDS)
        { 
          \_SB.PCI0.GFX0.GHDS(3) // GMCH SCI hotkey display switch, table index 3       
        }
      }
    }

    If(LEqual(BID,BRH)) // BoardIdReedHarborTdv
    {
      // F5 Scan Code = 0x3F
      If(LEqual(Local2,0x3F))
      {
        ADBG("FN+F5") // brightness up
        If(And(4,DSEN))
        {
          BRTN(0x86)
        } Else {
          Store(BRTL, Local0)
          // Current brightness is a percentage.
          // This must be done if ALS if enabled, as the driver will change the brightness based on ambient light.
          Store(\_SB.PCI0.GFX0.CBLV, BRTL)
          // 1 % will be lost in the conversion so need to make sure we account for it.
          AND(Add(BRTL, 1),0xFE, BRTL)
          If(LLessEqual(BRTL, 90))
          {
            Add(BRTL, 10, BRTL)
          }
          \_SB.PCI0.GFX0.AINT(1, BRTL)
        }
      } // end If(LEqual(Local2,0x3E))
    } Else { // all other boards
      // Virtual Battery Hot Keys(VBHK) - VBHK uses keys 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -, + and F5.
      If(LEqual(BNUM,0))  // Check for Virtual Battery Mode before testing the hot-keys specific to Virtual Battery Support.
      {
        VBHK()  //  remove this call if no virtual battery is needed.
      }
    }

    // F6 Scan Code = 0x40
    If(LEqual(Local2,0x40))
    {
      ADBG("FN+F6")
      If(LEqual(BID,BRH)) // BoardIdReedHarborTdv
      {
        If(IGDS) // toggle display
        {
          \_SB.PCI0.GFX0.GHDS(0) // GMCH SCI hotkey display switch, table index 0       
        }
      } Else {
        If(IGDS) // Cycle Brightness for all other boards
        {
          If(CondRefOf(HGAS))
          {
            HGAS()
          } Else {
            If(And(4,DSEN))
            {
              BRTN(0x85)
            }
          }
        }
      }
    }

    // Disable these Function keys for Reed Harbor.
    If(LEqual(BID,BRH)) // BoardIdReedHarborTdv
    {
      // F7 Scan Code = 0x41
      If(LEqual(Local2,0x41)) // EC passes directly to kbd buffer
      {
        ADBG("FN+F7") // mute
      }
      // F8 Scan Code = 0x42
      If(LEqual(Local2,0x42)) // EC passes directly to kbd buffer
      {
        ADBG("FN+F8") // volume down
      }
      // F9 Scan Code = 0x43
      If(LEqual(Local2,0x43)) // EC passes directly to kbd buffer
      {
        ADBG("FN+F9") // volume up
      }
      // F10 Scan Code = 0x44
      If(LEqual(Local2,0x44)) // blank
      {
        ADBG("FN+10")
      }
    } Else {

      // F7 Scan Code = 0x41
      If(LEqual(Local2,0x41))   // Zero Brightness
      {
        If(IGDS)
        {
          If(CondRefOf(CHPS))
          {
            CHPS()      //Display the current hybrid policy on Port 80 header
          } Else {
            If(And(4,DSEN))
            {
              BRTN(0x88)
            }
          }
        }
      }

      // F8 Scan Code = 0x42
      If(LEqual(Local2,0x42))   // Panel Fitting Hot Key.
      {
        If(IGDS)
        {
          If(CondRefOf(HPFS))
          {
            HPFS()
          } Else {
            \_SB.PCI0.GFX0.AINT(2, 0)
          }
        }
      }
  
      // F9 Scan Code = 0x43
      If(LEqual(Local2,0x43))   // Decrease Brightness Level.
      {
        If(CondRefOf(HBRT))
        {
          HBRT(4)
        }
        If(IGDS)
        {
          If(And(4,DSEN))
          {
            BRTN(0x87)
          } Else {
            Store(BRTL, Local0)
            // Current brightness is a percentage.
            // This must be done if ALS if enabled, as the driver will change the brightness based on ambient light.
            Store(\_SB.PCI0.GFX0.CBLV, BRTL)
            // 1 % will be lost in the conversion so need to make sure we account for it.
            AND(Add(BRTL, 1),0xFE, BRTL)
            If(LGreaterEqual(BRTL, 10))
            {
              Subtract(BRTL, 10, BRTL)
            }
            \_SB.PCI0.GFX0.AINT(1, BRTL)
          }
        }
      }
  
      // F10 Scan Code = 0x44
      If(LEqual(Local2,0x44))   // Increase Brightness Level.
      {
        If(CondRefOf(HBRT))
        {
          HBRT(3)
        }
        If(IGDS)
        {
          If(And(4,DSEN))
          {
            BRTN(0x86)
          } Else {
            Store(BRTL, Local0)
            // Current brightness is a percentage.
            // This must be done if ALS if enabled, as the driver will change the brightness based on ambient light.
            Store(\_SB.PCI0.GFX0.CBLV, BRTL)
            // 1 % will be lost in the conversion so need to make sure we account for it.
            AND(Add(BRTL, 1),0xFE, BRTL)
            If(LLessEqual(BRTL, 90))
            {
              Add(BRTL, 10, BRTL)
            }
            \_SB.PCI0.GFX0.AINT(1, BRTL)
          }
        }
      }
    } // end  If(LEqual(BID,BRH))

    // "F12" Scan Code = 0x58
    If(LEqual(Local2,0x58))
    {
      // Airplane Mode toggle.
      If(\_SB.HIDD.HRDY)
      {
         \_SB.HIDD.HPEM(8)
      }
    }

    // Calculator (-) Key = 0x4A

    If(LEqual(Local2,0x4A))   // ACPI Debug Mode is Off.
    {
      Store(0,DBGS)
    }

    // Calculator (+) Key = 0x4E

    If(LEqual(Local2,0x4E))   // ACPI Debug Mode is On.
    {
      Store(1,DBGS)
    }

    // Calculator (Enter) Key = 0x1C
    If(LEqual(Local2,0x1C))   // Set ACPI Break Point.
    {
      BreakPoint
    }


    // "D" Scan Code = 0x20
    If(LEqual(Local2,0x20))   // Virtual Dock
    {
      \_SB.PCI0.GFX0.GDCK(1)
    }
    
    // "U" Scan Code = 0x16
    If(LEqual(Local2,0x16))   // Virtual Undock
    {
      \_SB.PCI0.GFX0.GDCK(0)
    }

    // "0" Scan Code = 0x01 
    If(LEqual(Local2,0x01))   // Toggle Wireless On/Off state.
    {

    }



    // HK: "O" Scan Code = 0x18
    If(LEqual(Local2,0x18))   // CTDP Up
    {
      If(LAnd(CondRefOf(\_SB.PCI0.CTCU),LEqual(CTDB,1))){ // only allow this feature if it is enabled in SETUP
        \_SB.PCI0.CTCU()
      }
    }

    // HK: "[" Scan Code = 0x1A
    If(LEqual(Local2,0x1A))   // CTDP Nominal
    {
      If(LAnd(CondRefOf(\_SB.PCI0.CTCN),LEqual(CTDB,1))){ // only allow this feature if it is enabled in SETUP
      \_SB.PCI0.CTCN()
      }
    }

    // HK: "]" Scan Code = 0x1B
    If(LEqual(Local2,0x1B))   // CTDP Down
    {
      If(LAnd(CondRefOf(\_SB.PCI0.CTCD),LEqual(CTDB,1))){ // only allow this feature if it is enabled in SETUP
      \_SB.PCI0.CTCD()
      }
    }
  
    // "Fn+F12" Scan Code = 0x62
    If(LEqual(Local2,0x62)) // Web-Cam power control
    {
      P8XH(0, 0x62) 
    }

  } // end Method(_Q52) hot key event

  Method(_Q54)    // Power Button Event for iSCT and Control method Power Button(10sec PB Override without V-GPIO driver)
  {

    P8XH(0,0x54)

    //
    //  iSCT and 10Sec PB Override are now mutual exclusive at least for this event.
    //  Make sure iSCT is enabled before notifying IAOE.
    //
    If(And(ICNF, 1))
    {
      Notify(IAOE,0x80)
    }
    
    //
    // Check if 10sec PB Override and EC 10sec mode.
    // If 10sec PB OVR is enabled but EC 10sec mode is not enabled, then BIOS has to handle
    // Power button event.
    // PB1E Bit0 -> Setup setting for 10sec PB OVR
    // PB10 -> EC setting for 10sec PB OVR
    //
    If(LAnd(And(PB1E, 1), LNot(ECRD(RefOf(PB10))))){

      //
      // Check UAMS(User Absent Mode State) to notify the power button event.
      //
      If(UAMS){ // UAMS has a non-Zero value, means the system is under User Absent Mode. Send Wake up event.
        ADBG("PB Wake up 0x02")
        If(CondRefOf(\_SB.PWRB)){
          Notify(\_SB.PWRB, 0x02)
        }
      } Else { // UAMS is Zero, means the system is ON. Send Sleep event.
        ADBG("PB Sleep 0x80")
        If(CondRefOf(\_SB.PWRB)){
          Notify(\_SB.PWRB, 0x80)
        }
      }
    }
  } // end Method(_Q54) Power button event.

  Method (_Q70)   // ALS "Light Intensity" event
  {
    P8XH(0,0x70)

    // Update the LUX Values.

    Store(ECRD(RefOf(LUXH)),LHIH)
    Store(ECRD(RefOf(LUXL)),LLOW)

    If(LAnd(LEqual(ALSE,2),IGDS))
    {
      // Handle the ALS event via the OpRegion method
      
      Store(ECRD(RefOf(LUXH)), Local0)     
      Or(ShiftLeft(Local0, 8), ECRD(RefOf(LUXL)), Local0)
      \_SB.PCI0.GFX0.AINT(0, Local0)
      Notify(ALSD,0x80) // notify MS driver of change
    }
  }

  Method(_QD5)    // 10 second power button press.
  {
    If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
    {
      ^VGBI.UPBT(POWER_BUTTON, One)
      ADBG("Notify 0xC0")
      ECMD (0x2D) // Wake up EC first. This is needed to get the release event immediately after press event. 
      Notify(^VGBI, 0xC0) // Notify Virtual GPIO driver that the power button is pressed.
    } Else {
      If(CondRefOf(\_SB.PCI0.GFX0.IUER))
      {
        Store(\_SB.PCI0.GFX0.IUER, Local0) 
        And(Local0, 0xC0, \_SB.PCI0.GFX0.IUER)  // Clear 4:0 button events on entry.
        Store(\_SB.PCI0.GFX0.IUER, Local0) 
        Or(Local0, 0x01, \_SB.PCI0.GFX0.IUER)   // Set Power Button Status = pressed.
      }
    } // End IF
  }// End of Method

  Method(_QD6)    // 10 second power button de-press.
  {
    If(LAnd(CondRefOf(^VGBI._STA),LEqual(And(^VGBI._STA(),One),One))) // VirtualButton driver is loaded(means it is Winblue)
    {
      ^VGBI.UPBT(POWER_BUTTON, Zero)
      ADBG("Notify 0xC1")
      Notify(^VGBI, 0xC1)  // Notify Virtual GPIO driver that the power button is released.
    } Else {
      If(CondRefOf(\_SB.PCI0.GFX0.IUER))
      {
        Store(\_SB.PCI0.GFX0.IUER, Local0) 
        And(Local0, 0xC0, \_SB.PCI0.GFX0.IUER)  // Clear 4:0 button events on entry.
      }
    }
  }
//
// Reed Harbor hardware buttons.
//
  Method(_Q80)    // Volume Up
  {
    If(LEqual(BID,BRH)){ // BoardIdReedHarborTdv
ADBG("Volume Up")
      \_SB.PCI0.GFX0.IUEH(2)
    }
  }
  Method(_Q81)    // Volume Down
  {
    If(LEqual(BID,BRH)){ // BoardIdReedHarborTdv
ADBG("Volume Down")
      \_SB.PCI0.GFX0.IUEH(3)
    }
  }
  Method(_Q85)    // Windows Home button
  {
    If(LEqual(BID,BRH)){ // BoardIdReedHarborTdv
ADBG("Windows Home")
      Sleep(1000)
      \_SB.PCI0.GFX0.IUEH(1)
    }
  }

  Method(_QF0)    // Thermal Event.
  {
    If(LEqual(DBGS,0))
    {
      // Only handle the numerous Thermal Events if
      // we are NOT doing ACPI Debugging.
      Notify(\_TZ.TZ00,0x80)
      Notify(\_TZ.TZ01,0x80)
    }
  }

Device(WDT0)  // WDT Device Resource Consumption
{
  Name(_HID,EISAID("PNP0C02"))        

  Name(_UID,3)

  Name(_CRS,ResourceTemplate()
  {
    IO(Decode16,0x6A4,0x6A4,0x1,0x1)  // 1 Byte EC Prv Intfc.
    IO(Decode16,0x6A0,0x6A0,0x1,0x1)  // 1 Byte EC Prv Intfc.
  })
}

/************************************************************************;
;*
;* Name:  CHDK
;*
;* Description: Check DOCK status, returen True if Dock status equal Arg0
;*
;************************************************************************/

  Method(CHDK, 1)
  {
    // If not Mobile Platform then skip the code and return 0
    If(LEqual(ECON,1)){ 
      If(LEqual(ECRD(RefOf(DOCK)), Arg0))
        { // If not docked then it's hot plug
          Return(1)   
        }
    }
    Return(0)
  }

  //
  // Hardware Button Array support
  //

  Device(BIND)  // Button Indicators.
  {
     Name(_HID, "INT33D2")
     Name(_CID, "PNP0C40")

     Method(_STA, 0,Serialized)
     {
       If(LAnd(And(IUBE,1), LGreaterEqual(OSYS, 2012)))
       {
         Return(0x000F)
       }
       Return(0x00)
     }
     //
     // _DSM : Device Specific Method for the Windows Compatible Button Array.
     //
     // Arg0: UUID Unique function identifier
     // Arg1: Integer Revision Level
     // Arg2: Integer Function Index
     // Arg3: Package Parameters
     //
     Method (_DSM, 4, Serialized, 0, UnknownObj, {BuffObj, IntObj, IntObj, PkgObj})
     {
       // Compare passed in UUID to supported UUID.

       If (LEqual(Arg0, ToUUID ("DFBCF3C5-E7A5-44E6-9C1F-29C76F6E059C")))
       {
         If (LEqual(0,ToInteger(Arg1)))        // Revision 0.
         {
           Switch (ToInteger(Arg2))            // Switch to Function Index.
           {
             //
             // Function 0, Query of supported functions.
             //

             Case (0)
             {
               Return (Buffer() {0x03})
             }

             //
             // Function 1, Windows Compatible Button Array Power Button Properties.
             //

             Case (1)
             {
               // Only return support if platform enabled via setup.
               // PB1E's Bit0 is set only when both CS and 10s PB OVR are enabled.
               If(LEqual(And(PB1E, 1), 1))
               {
                 Return (0x07)
               }

               Return(0x00)

             }
           } // End Switch statement
         }  // End Revision check
       }  // End UUID check

       // If the code falls through to this point, just return a buffer of 0.

       Return (Buffer() {0x00})

    }  // End _DSM Method
  }
  
  Device(CIND)  // Convertible Indicators.
  {
     Name(_HID, "INT33D3")
     Name(_CID, "PNP0C60")
    
     Method(_STA, 0,Serialized)
     {
       If(LAnd(And(IUCE,1), LGreaterEqual(OSYS, 2012)))
       {
         Return(0x000F)
       }
       Return(0x00)
     }
  }
  
  Device(DIND)  // Docking Indicators.
  {
     Name(_HID, "INT33D4")
     Name(_CID, "PNP0C70")
     Method(_STA, 0,Serialized)
     {
       If(LAnd(And(IUDE,1), LGreaterEqual(OSYS, 2012)))
       {
         Return(0x000F)
       }
       Return(0x00)
     }
  }

  Device(VGBI)                                  // Virtual GPIO Button "Interface."
  {
  
    Name(_HID, EISAID("INT33D6"))               // HID for Intel Virtual GPIO Button Interface.
    Name(VBDS,0)
    Name(ONTM,0) // Temporary variable to initialise VBDS only once in the boot

    Method(_STA,0,Serialized)
    {
      If(LGreaterEqual(OSYS,2013))              // Virtual Button applicable for Winblue and higher version of WinOS
      {
        ADBG("WinB VGBI STA")
        Return(0x0F)                            // Device present,enabled and should be shown in UI.
      } Else {
        Return(0x00)                            // Device NOT present
      }
    }// End of _STA

    Method(VBDL,0,Serialized) // Virtual Button Driver Load - Refer Bios Arch Spec
    {
      ADBG("VBDL")
      If(LEqual(And(PB1E,One),One)){ // 10 Sec Power Button Enabled in setup?
        ADBG("VBDL EN")

        //
        // Clear PBST so that we can hide the default power button. 
        //
        If(CondRefOf(\_SB.PWRB.PBST))
        {
          Store(0, \_SB.PWRB.PBST)
          Notify(\_SB.PWRB, 1) // Device check
        }

        // First send 0x74 to EC to disable _Q54 event for Power button.
        If(CondRefOf(ECMD)){
          ADBG("Disable _Q54")
          ECMD(0x74)
        }

        // Set EC 10s enable bit.
        ECWT(1, RefOf(PB10))

      } Else {
        // 10s power button disabled, clear EC 10s enable bit.
        ADBG("VBDL DIS")
        ECWT(0, RefOf(PB10))

        //
        // Here we know V-GPIO driver is loaded but 10s PB is disabled.
        // Set PBST so that the default power button can handle the request. 
        //
        If(CondRefOf(\_SB.PWRB.PBST))
        {
          Store(1, \_SB.PWRB.PBST)
          Notify(\_SB.PWRB, 1) // Device check
        }
      }
    }

    Method(VGBS,0,Serialized)  // Virtual GPIO Button Status - Refer Bios Arch Spec
    {
      // Bit[7] : Docking Indicatory Status
      // Bit[6] : Convertible/Slate Indicator Status
      // Bit[5] : Reserved
      // Bit[4] : Rotation Lock Button Status
      // Bit[3] : Volume Down Button Status
      // Bit[2] : Volume Up Button Status
      // Bit[1] : Windows Home Button Status
      // Bit[0] : Power Button Status

      ADBG("VGBS")
      If(LEqual(ONTM,0))
      {
        // Initial setup option on VBDS and thereafter hotkeys should be updating the VBDS
        if(LEqual(And(PB1E,0x04),0x04)) // Rotation Lock
        {
          UPBT(ROTATION_LOCK_BUTTON,One)
        }

        if(LEqual(And(PB1E,0x08),0x08)) // Slate/Laptop
        {
          UPBT(CONVERTIBLE_BUTTON,One)
        }

        if(LEqual(And(PB1E,0x10),0x10))  // Undock/Dock
        {
          UPBT(DOCK_INDICATOR,One)
        }
        Store(One,ONTM) 
      }
      Return(VBDS)
    }// End of Method

    //
    // UPBT Update Button Status
    //
    // Arg0: Bit location of the target button
    //       0: Power Button
    //       1: Windows Button
    //       2: Volume up Button
    //       3: Volume down Button
    //       4: Rotation Lock Button
    //       5: Reserved
    //       6: Convertible state 0 - Slate, 1 - Notebook
    //       7: Dock Indicator 0 - Undock, 1 - Dock
    //       
    // Arg1: On/Off state, 0 - Clear the target bit, 1 - Set the target bit.
    // 
    Method(UPBT,2,Serialized)  // Update Button Status 
    {
      ShiftLeft(One, Arg0, Local0)
      if(Arg1){                // Button Press/ON
        Or(VBDS, Local0, VBDS)
      } Else {                 // Button Press/OFF
        And(VBDS, Not(Local0),VBDS) 
      }
    } // End of UPBT

    Method(PBIN, 0, Serialized)
    {
      ADBG("VGBI PB INIT")
      //
      // Send EC 0x73 command to make 0x54 Power button notification is available.
      // This is needed to support no Virtual GPIO driver case.
      // Once the driver calls VBDL, VBDL sends 0x74(disable PB 0x54) to EC.
      //
      If(LAnd(And(PB1E, 1), LNot(ECRD(RefOf(PB10)))))
      {
        If(CondRefOf(\_SB.PWRB.PBST))
        {
          Store(1, \_SB.PWRB.PBST)
          Notify(\_SB.PWRB, 1) // Device check
        }
        If(CondRefOf(ECMD)){
          ADBG("Enable _Q54")
          ECMD(0x73)  // Enable Power Button 0x54 Notification
        }
      }
    }
  } // End of VGBI

} // End H_EC

  // System Bus

Scope(\_SB)
{

  // Define an AC Device.

  Device(ADP1)
  {
    Name(_HID,"ACPI0003")

    Method(_STA)
    {
      If (LEqual(ECON,1)){ 
        Return(0x0F)
      }
      Return(0x00)
    }
  
    // Return the value that determines if running
    // from AC or not.

    Method(_PSR,0)
    {
      Return(PWRS)
    }

    // Return that everything runs off of AC.

    Method(_PCL,0)
    {
      Return(\_SB)
    }
  }

  // Define a Lid Switch.

  Device(LID0)
  {
    Name(_HID,EISAID("PNP0C0D"))

    Method(_STA)
    {
      If(LEqual(ECON,1)){ 
        Return(0x0F)
      }
      Return(0x00)
    }

    Method(_LID,0)
    {
      // 0 = Closed, 1 = Open.

      Return(\_SB.PCI0.LPCB.H_EC.ECRD(RefOf(\_SB.PCI0.LPCB.H_EC.LSTE)))
    }
  }

  // Define a (Control Method) Power Button.

  Device(PWRB)
  {
    Name(_HID,EISAID("PNP0C0C"))

    // The PRW isn't working when
    // placed in any of the logical locations ( PS2K, PS2M,
    // H_EC ), so a Power Button Device was created specifically
    // for the WAKETIME_SCI PRW.

    //
    // Power button status flag used to communicate H_EC.VBDL
    //
    Name(PBST, 1)

    Method(_PRW, 0) {
      If(LEqual(LANP,1)){
        //
        // When LAN is present, GPIO27 becomes ME GPIO(HSD 4834440).  Remove PBT.
        // 
        Return(Package(){0,0})
      }
      If(LEqual(BID, BWT1))
      {
        Return(Package(){27,4})   // GPI027 = GPE27 for WhiteTipMountain1
      }
      If(LEqual(BID, BW1P))
      {
        Return(Package(){27,4})   // GPI027 = GPE27 for WhiteTipMountain1 PPV
      }
      If(LEqual(BID, BW2C))
      {
        Return(Package(){27,4})   // GPI027 = GPE27 for WhiteTipMountain2
      }
      If(LEqual(BID, BW2P))
      {
        Return(Package(){27,4})   // GPI027 = GPE27 for WhiteTipMountain2 PPV
      }
      If(LEqual(BID, BSPC))
      {
        Return(Package(){27,4})   // GPI027 = GPE27 for SawToothPeak
      }
      If(LEqual(BID, BSPP))
      {
        Return(Package(){27,4})   // GPI027 = GPE27 for SawToothPeak PPV
      }
      
      Return(Package(){30,4})       //GPI14 = GPE30 = Waketime SCI for Haswell Traditional boards
    }
    
    Method(_STA, 0)
    {
      If(LAnd(LEqual(ECON,1), PBST)){ 
        Return(0x0F)
      }
      Return(0x00)
    }

  }//end device PWRB

  Device(HIDD)                                          // HID Device.
  {
     Name(_HID,"INT33D5")                            // Intel Ultrabook HID Platform Event Driver.
     Name(_CID,"PNP0C02")                            // Generic Motherboard Resources.

     Name (HBSY, 0)   // HID Busy
     Name (HIDX, 0)   // HID Index
     Name (HMDE, 0)   // HID Mode
     Name (HRDY, 0)   // HID Ready

     Method(_STA,0,Serialized)                       // Status Method.
     {
        If(LEqual(BID, BHB))                         // Hide device for HarrisBeach
        {
          Return(0x00)
        }
        Else
        {
          Return(0x0F)
        }
     }

    //
    // HID Driver Descriptor Method - Called by HID Driver during initialization
    // to obtain HID Descriptor information.
    //
    // Input: None
    //
    // Output:  Package containing a complete HID Descriptor information.
    //
    Method(HDDM,0,Serialized)
    {
       // Placeholder.
       Name(DPKG, Package(4) {0x11111111, 0x22222222, 0x33333333, 0x44444444})
       Return(DPKG)
    }

    //
    // HID Driver Event Method - Called by HID Driver to get the specific
    // platform event.
    //
    // Input: None
    //
    // Output: Plastform HID Event.
    // Mode 0 = Index of HID Input Report, per pre-defined Table.
    // Mode 1 = Package containing a complete HID Input Report.
    //
    Method(HDEM,0,Serialized)
    {
       Store(0,HBSY)                          // Clear HID Busy.
       // Simple Mode is hardcoded for now.  Return Simple Mode HID Index Value.
       If(LEqual(HMDE,0))
       {
          Return(HIDX)
       }
       Return(HMDE)
    }

    //
    // HID Driver Mode Method - Called by HID Driver during initialization to get
    // the platform mode of operation.
    //
    // Input: None
    //
    // Output:  Mode the platform is running in.
    // 0 = Simple Mode.
    // 1 = Advanced Mode.
    //
    Method(HDMM,0,Serialized)
    {
       Return(HMDE)               // Return Mode of operation.
    }

    //
    // HID Driver Status Method - called by HID Driver to report platform readiness status.
    // Input: Driver Status.
    // 0 = Driver Unloaded.
    // 1 = Driver Loaded and Ready.
    //
    // Output: None
    //
    Method(HDSM,1,Serialized)
    {
      Store(Arg0,HRDY)              // Store HID Ready Status.
      // Eventually code will communicate to platform the Driver status (enabled/disabled).
    }

    //
    // HID Platform Event Method - called by Platform to communicate HID Event to Driver.
    // Input:
    // Mode 0 = Index of HID Event.
    // Mode 1 = Package containing a complete HID Report.
    //
    Method(HPEM,1,Serialized)                        // HID Platform Event Method.
    {
      Store(1,HBSY)                                 // Set HID Busy.
      // Simple Mode is hardcoded for now.  Simply store HID Index value.
      If(LEqual(HMDE,0))
      {
         Store(Arg0,HIDX)
      } Else {
         Store(Arg0,HIDX)
      }
      Notify(\_SB.HIDD,0xC0)                         // Notify Driver to get HID Event.
      Store(0,Local0)                                // Initialize Local0 as a timeout counter.
      While(LAnd(LLess(Local0,250),HBSY))            // Wait <= 1 second for Driver to ACK success.
      {
        Sleep(4)                                     // Delay 4 ms.
        Increment(Local0)                            // Increment Timeout.
      }
      If(LEqual(HBSY,1))                             // Failure?
      {
        Store(0,HBSY)                                // Yes.  Clear HID Busy Flag.
        Store(0,HIDX)                                // Set HID Simple Mode Index = 0 = Undefined.
        Return(1)                                    // Return Failure.
      } Else {
        Return(0)                                    // Return Success.
      }
    }
  }


}//end scope _SB