blob: 9de3bc2eaebac7f9c1a80aa423bc090b8d8568c9 [file] [log] [blame]
Sean Rhodes296994b2021-10-14 20:58:15 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include "ubtc.asl"
4
5Scope (\_SB.PCI0.LPCB)
6{
7 #include "cmos.asl"
8
9 Device (EC)
10 {
11 Name (_HID, EisaId ("PNP0C09"))
12 Name (_UID, 0x01)
Sean Rhodes58f6a5d2021-12-19 21:22:15 +000013 Name (_GPE, CONFIG_EC_GPE_SCI)
Sean Rhodes296994b2021-10-14 20:58:15 +010014 Name (ECAV, 0x00)
15 Name (ECTK, 0x01)
16 Name (B2ST, 0x00)
17 Name (CFAN, 0x00)
18 Name (CMDR, 0x00)
19 Name (DOCK, 0x00)
20 Name (PLMX, 0x00)
21 Name (PECH, 0x00)
22 Name (PECL, 0x00)
23 Name (PENV, 0x00)
24 Name (PINV, 0x00)
25 Name (PPSH, 0x00)
26 Name (PPSL, 0x00)
27 Name (PSTP, 0x00)
28 Name (RPWR, 0x00)
29 Name (VPWR, 0x00)
30 Name (WTMS, 0x00)
31 Name (AWT2, 0x00)
32 Name (AWT1, 0x00)
33 Name (AWT0, 0x00)
34 Name (DLED, 0x00)
35 Name (SPT2, 0x00)
36 Name (PB10, 0x00)
37 Name (IWCW, 0x00)
38 Name (IWCR, 0x00)
39 Name (PVOL, 0x00)
40 Mutex (ECMT, 0x00)
41
Sean Rhodesf6ea89d2022-02-24 10:40:57 +000042 Name (BFFR, ResourceTemplate()
Sean Rhodes296994b2021-10-14 20:58:15 +010043 {
44 IO(Decode16, 0x0062, 0x0062, 0x00, 0x01)
45 IO(Decode16, 0x0066, 0x0066, 0x00, 0x01)
46 })
47
48 Method (_CRS, 0, Serialized)
49 {
Sean Rhodesf6ea89d2022-02-24 10:40:57 +000050 Return (BFFR)
Sean Rhodes296994b2021-10-14 20:58:15 +010051 }
52
53 Method (_STA, 0, NotSerialized)
54 {
55 \LIDS = 0x03
56 Return (0x0F)
57 }
58
59 OperationRegion (SIPR, SystemIO, 0xB2, 0x1)
60 Field (SIPR, ByteAcc, Lock, Preserve) {
61 SMB2, 8
62 }
63
64 #include "emem.asl"
65
66 // ECRD (Embedded Controller Read Method)
67 //
68 // Handle all commands sent to EC by BIOS
69 //
70 // Arguments:
71 // Arg0 = Object to Read
72 //
73 // Return Value:
74 // Read Value
75 //
76 Method (ECRD, 1, Serialized, 0, IntObj, FieldUnitObj)
77 {
78 //
Felix Singerca4b5872022-12-26 08:17:06 +010079 // Check for ECDT support, set ECAV to 1 if ECDT is supported by OS
Sean Rhodes296994b2021-10-14 20:58:15 +010080 // Only check once at beginning since ECAV might be clear later in certain conditions
81 //
82 If (ECTK) {
83 If (_REV >= 0x02) {
84 ECAV = 0x01
85 }
86 ECTK = 0x00 // Clear flag for checking once only
87 }
88
89 Local0 = Acquire (ECMT, 1000) // Save Acquired Result
90 If (Local0 == 0x00) // Check for Mutex Acquisition
91 {
92 If (ECAV) {
93 Local1 = DerefOf (Arg0) // Execute Read from EC
94 Release (ECMT)
95 Return (Local1)
96 } Else {
97 Release (ECMT)
98 }
99 }
Sean Rhodesf6ea89d2022-02-24 10:40:57 +0000100 Return (0) // Return in case Arg0 doesn't exist
Sean Rhodes296994b2021-10-14 20:58:15 +0100101 }
102
103 // ECWR (Embedded Controller Write Method)
104 //
105 // Handle all commands sent to EC by BIOS
106 //
107 // Arguments:
108 // Arg0 = Value to Write
109 // Arg1 = Object to Write to
110 //
111 // Return Value:
112 // None
113 //
114 Method (ECWR, 2, Serialized,,,{IntObj, FieldUnitObj})
115 {
116 Local0 = Acquire (ECMT, 1000) // Save Acquired Result
117 If (Local0 == 0x00) // Check for Mutex Acquisition
118 {
119 If (ECAV) {
120 Arg1 = Arg0 // Execute Write to EC
121 Local1 = 0x00
122 While (1) {
123 If (Arg0 == DerefOf (Arg1)) {
124 Break
125 }
126 Sleep (1)
127 Arg1 = Arg0
Felix Singer26fbcc92021-12-30 01:48:51 +0100128 Local1 += 1
Sean Rhodes296994b2021-10-14 20:58:15 +0100129 If (Local1 == 0x03) {
130 Break
131 }
132 }
133 }
134 Release (ECMT)
135 }
136 }
137
138 #include "ac.asl"
139 #include "battery.asl"
140 #include "events.asl"
141 #include "lid.asl"
142 #include "typec.asl"
143
144 Method (_REG, 2, NotSerialized)
145 {
146 If ((Arg0 == 0x03) && (Arg1 == 0x01))
147 {
148 // Load EC Driver
149 ECAV = 0x01
150
151 // Initialise the Lid State
152 \LIDS = LSTE
153
154 // Initialise the OS State
155 OSFG = 0x01
156
157 // Initialise the Power State
158 PWRS = (ECRD (RefOf(ECPS)) & 0x01)
159
160 // Inform the platform code
161 PNOT()
162 }
163 }
164 }
165}