blob: fbeb56200a0573481adbe21acd38647fde5b13ac [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin76c37002012-10-30 09:03:43 -05002
Duncan Laurie7fab00c2013-05-22 09:51:11 -07003// XHCI Controller 0:14.0
Aaron Durbin76c37002012-10-30 09:03:43 -05004
Duncan Laurie7fab00c2013-05-22 09:51:11 -07005Device (XHCI)
Aaron Durbin76c37002012-10-30 09:03:43 -05006{
Duncan Laurie80fd5c42013-07-19 08:41:38 -07007 Name (_ADR, 0x00140000)
8
9 Name (PLSD, 5) // Port Link State - RxDetect
10 Name (PLSP, 7) // Port Link State - Polling
11
Angel Ponse53dfe02020-10-25 20:53:29 +010012 OperationRegion (XPRT, PCI_Config, 0, 0x100)
Duncan Laurie80fd5c42013-07-19 08:41:38 -070013 Field (XPRT, AnyAcc, NoLock, Preserve)
14 {
15 Offset (0x0),
16 DVID, 16,
17 Offset (0x10),
18 , 16,
19 XMEM, 16, // MEM_BASE
20 Offset (0x74),
21 D0D3, 2,
22 , 6,
23 PMEE, 1, // PME_EN
24 , 6,
25 PMES, 1, // PME_STS
26 Offset (0xb0),
27 , 13,
28 MB13, 1,
29 MB14, 1,
30 Offset (0xd0),
31 PR2R, 32, // USB2PR
32 PR2M, 32, // USB2PRM
33 PR3R, 32, // USB3PR
34 PR3M, 32, // USB3PRM
35 }
36
37 // Clear status bits
38 Method (LPCL, 0, Serialized)
39 {
Angel Ponse53dfe02020-10-25 20:53:29 +010040 OperationRegion (XREG, SystemMemory, ^XMEM << 16, 0x600)
Duncan Laurie80fd5c42013-07-19 08:41:38 -070041 Field (XREG, DWordAcc, Lock, Preserve)
42 {
43 Offset (0x510), // PORTSCNUSB3[0]
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070044 PSC0, 32,
Duncan Laurie80fd5c42013-07-19 08:41:38 -070045 Offset (0x520), // PORTSCNUSB3[1]
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070046 PSC1, 32,
Duncan Laurie80fd5c42013-07-19 08:41:38 -070047 Offset (0x530), // PORTSCNUSB3[2]
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070048 PSC2, 32,
Duncan Laurie80fd5c42013-07-19 08:41:38 -070049 Offset (0x540), // PORTSCNUSB3[3]
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070050 PSC3, 32,
Duncan Laurie80fd5c42013-07-19 08:41:38 -070051 }
52
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070053 // Port Enabled/Disabled (Bit 1)
Angel Ponse53dfe02020-10-25 20:53:29 +010054 Name (PEDB, 1 << 1)
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070055
56 // Change Status (Bits 23:17)
Angel Ponse53dfe02020-10-25 20:53:29 +010057 Name (CHST, 0x7f << 17)
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070058
59 // Port 0
Angel Ponse53dfe02020-10-25 20:53:29 +010060 Local0 = PSC0 & ~PEDB
61 PSC0 = Local0 | CHST
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070062
63 // Port 1
Angel Ponse53dfe02020-10-25 20:53:29 +010064 Local0 = PSC1 & ~PEDB
65 PSC1 = Local0 | CHST
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070066
67 // Port 2
Angel Ponse53dfe02020-10-25 20:53:29 +010068 Local0 = PSC2 & ~PEDB
69 PSC2 = Local0 | CHST
Duncan Laurie0bf1dea2013-08-13 13:32:28 -070070
71 // Port 3
Angel Ponse53dfe02020-10-25 20:53:29 +010072 Local0 = PSC3 & ~PEDB
73 PSC3 = Local0 | CHST
Duncan Laurie80fd5c42013-07-19 08:41:38 -070074 }
75
76 Method (LPS0, 0, Serialized)
77 {
Angel Ponse53dfe02020-10-25 20:53:29 +010078 OperationRegion (XREG, SystemMemory, ^XMEM << 16, 0x600)
Duncan Laurie80fd5c42013-07-19 08:41:38 -070079 Field (XREG, DWordAcc, Lock, Preserve)
80 {
81 Offset (0x510), // PORTSCNUSB3
82 , 5,
83 PLS1, 4, // [8:5] Port Link State
84 PPR1, 1, // [9] Port Power
85 , 7,
86 CSC1, 1, // [17] Connect Status Change
87 , 1,
88 WRC1, 1, // [19] Warm Port Reset Change
89 , 11,
90 WPR1, 1, // [31] Warm Port Reset
91 Offset (0x520), // PORTSCNUSB3
92 , 5,
93 PLS2, 4, // [8:5] Port Link State
94 PPR2, 1, // [9] Port Power
95 , 7,
96 CSC2, 1, // [17] Connect Status Change
97 , 1,
98 WRC2, 1, // [19] Warm Port Reset Change
99 , 11,
100 WPR2, 1, // [31] Warm Port Reset
101 Offset (0x530), // PORTSCNUSB3
102 , 5,
103 PLS3, 4, // [8:5] Port Link State
104 PPR3, 1, // [9] Port Power
105 , 7,
106 CSC3, 1, // [17] Connect Status Change
107 , 1,
108 WRC3, 1, // [19] Warm Port Reset Change
109 , 11,
110 WPR3, 1, // [31] Warm Port Reset
111 Offset (0x540), // PORTSCNUSB3
112 , 5,
113 PLS4, 4, // [8:5] Port Link State
114 PPR4, 1, // [9] Port Power
115 , 7,
116 CSC4, 1, // [17] Connect Status Change
117 , 1,
118 WRC4, 1, // [19] Warm Port Reset Change
119 , 11,
120 WPR4, 1, // [31] Warm Port Reset
121 }
122
123 // Wait for all powered ports to finish polling
Angel Ponse53dfe02020-10-25 20:53:29 +0100124 Local0 = 10
125 While ((PPR1 == 1 && PLS1 == PLSP || PPR2 == 1 && PLS2 == PLSP) ||
126 (PPR3 == 1 && PLS3 == PLSP || PPR4 == 1 && PLS4 == PLSP))
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700127 {
Angel Ponse53dfe02020-10-25 20:53:29 +0100128 If (Local0 == 0) {
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700129 Break
130 }
Angel Ponse53dfe02020-10-25 20:53:29 +0100131 Local0--
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700132 Stall (10)
133 }
134
135 // For each USB3 Port:
136 // If port is disconnected (PLS=5 PP=1 CSC=0)
137 // 1) Issue warm reset (WPR=1)
138 // 2) Poll for warm reset complete (WRC=0)
139 // 3) Write 1 to port status to clear
140
141 // Local# indicate if port is reset
Angel Ponse53dfe02020-10-25 20:53:29 +0100142 Local1 = 0
143 Local2 = 0
144 Local3 = 0
145 Local4 = 0
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700146
Angel Ponse53dfe02020-10-25 20:53:29 +0100147 If (PLS1 == PLSD && (CSC1 == 0 && PPR1 == 1)) {
148 WPR1 = 1 // Issue warm reset
149 Local1 = 1
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700150 }
Angel Ponse53dfe02020-10-25 20:53:29 +0100151 If (PLS2 == PLSD && (CSC2 == 0 && PPR2 == 1)) {
152 WPR2 = 1 // Issue warm reset
153 Local2 = 1
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700154 }
Angel Ponse53dfe02020-10-25 20:53:29 +0100155 If (PLS3 == PLSD && (CSC3 == 0 && PPR3 == 1)) {
156 WPR3 = 1 // Issue warm reset
157 Local3 = 1
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700158 }
Angel Ponse53dfe02020-10-25 20:53:29 +0100159 If (PLS4 == PLSD && (CSC4 == 0 && PPR4 == 1)) {
160 WPR4 = 1 // Issue warm reset
161 Local4 = 1
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700162 }
163
164 // Poll for warm reset complete on all ports that were reset
Angel Ponse53dfe02020-10-25 20:53:29 +0100165 Local0 = 10
166 While ((Local1 == 1 && WRC1 == 0 || Local2 == 1 && WRC2 == 0) ||
167 (Local3 == 1 && WRC3 == 0 || Local4 == 1 && WRC4 == 0))
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700168 {
Angel Ponse53dfe02020-10-25 20:53:29 +0100169 If (Local0 == 0) {
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700170 Break
171 }
Angel Ponse53dfe02020-10-25 20:53:29 +0100172 Local0--
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700173 Stall (10)
174 }
175
176 // Clear status bits in all ports
177 LPCL ()
178 }
179
Duncan Laurie568ce5c2013-07-30 16:15:14 -0700180 Method (_PSC, 0, NotSerialized)
181 {
182 Return (^D0D3)
183 }
184
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700185 Method (_PS0, 0, Serialized)
186 {
Angel Ponse53dfe02020-10-25 20:53:29 +0100187 If (^DVID == 0xFFFF) {
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700188 Return ()
189 }
Angel Ponse53dfe02020-10-25 20:53:29 +0100190 If (^XMEM == 0xFFFF || ^XMEM == 0) {
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700191 Return ()
192 }
193
Angel Ponse53dfe02020-10-25 20:53:29 +0100194 OperationRegion (XREG, SystemMemory, (^XMEM << 16) + 0x8000, 0x200)
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700195 Field (XREG, DWordAcc, Lock, Preserve)
196 {
197 Offset (0x0e0), // AUX Reset Control 1
198 , 15,
199 AX15, 1,
200 Offset (0x154), // AUX Domain PM Control Register 2
201 , 31,
202 CLK2, 1,
203 Offset (0x16c), // AUX Clock Control
204 , 2,
205 CLK0, 1,
206 , 11,
207 CLK1, 1, // USB3 Port Aux/Core Clock Gating Enable
208 }
209
210 // If device is in D3, set back to D0
Angel Ponse53dfe02020-10-25 20:53:29 +0100211 Local0 = ^D0D3
212 if (Local0 == 3) {
213 ^D0D3 = 0
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700214 }
215
Angel Ponsfe911922020-10-25 23:08:04 +0100216#if CONFIG(INTEL_LYNXPOINT_LP)
217 // Clear PCI 0xB0[14:13]
218 ^MB13 = 0
219 ^MB14 = 0
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700220
Angel Ponsfe911922020-10-25 23:08:04 +0100221 // Clear MMIO 0x816C[14,2]
222 CLK0 = 0
223 CLK1 = 0
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700224
225 // Set MMIO 0x8154[31]
Angel Ponse53dfe02020-10-25 20:53:29 +0100226 CLK2 = 1
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700227
Angel Ponsfe911922020-10-25 23:08:04 +0100228 // Handle per-port reset if needed
229 LPS0 ()
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700230
Angel Ponsfe911922020-10-25 23:08:04 +0100231 // Set MMIO 0x80e0[15]
232 AX15 = 1
233#else
234 // Set MMIO 0x8154[31]
235 CLK2 = 1
236#endif
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700237
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700238 Return ()
239 }
240
241 Method (_PS3, 0, Serialized)
242 {
Angel Ponse53dfe02020-10-25 20:53:29 +0100243 If (^DVID == 0xFFFF) {
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700244 Return ()
245 }
Angel Ponse53dfe02020-10-25 20:53:29 +0100246 If (^XMEM == 0xFFFF || ^XMEM == 0) {
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700247 Return ()
248 }
249
Angel Ponse53dfe02020-10-25 20:53:29 +0100250 OperationRegion (XREG, SystemMemory, (^XMEM << 16) + 0x8000, 0x200)
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700251 Field (XREG, DWordAcc, Lock, Preserve)
252 {
253 Offset (0x0e0), // AUX Reset Control 1
254 , 15,
255 AX15, 1,
256 Offset (0x154), // AUX Domain PM Control Register 2
257 , 31,
258 CLK2, 1,
259 Offset (0x16c), // AUX Clock Control
260 , 2,
261 CLK0, 1,
262 , 11,
263 CLK1, 1, // USB3 Port Aux/Core Clock Gating Enable
264 }
265
Angel Ponse53dfe02020-10-25 20:53:29 +0100266 ^PMES = 1 // Clear PME Status
267 ^PMEE = 1 // Enable PME
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700268
269 // If device is in D3, set back to D0
Angel Ponse53dfe02020-10-25 20:53:29 +0100270 Local0 = ^D0D3
271 if (Local0 == 3) {
272 ^D0D3 = 0
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700273 }
274
Angel Ponsfe911922020-10-25 23:08:04 +0100275#if CONFIG(INTEL_LYNXPOINT_LP)
276 // Set PCI 0xB0[14:13]
277 ^MB13 = 1
278 ^MB14 = 1
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700279
Angel Ponsfe911922020-10-25 23:08:04 +0100280 // Set MMIO 0x816C[14,2]
281 CLK0 = 1
282 CLK1 = 1
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700283
284 // Clear MMIO 0x8154[31]
Angel Ponse53dfe02020-10-25 20:53:29 +0100285 CLK2 = 0
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700286
Angel Ponsfe911922020-10-25 23:08:04 +0100287 // Clear MMIO 0x80e0[15]
288 AX15 = 0
289#else
290 // Clear MMIO 0x8154[31]
291 CLK2 = 0
292#endif
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700293
294 // Put device in D3
Angel Ponse53dfe02020-10-25 20:53:29 +0100295 ^D0D3 = 3
Duncan Laurie80fd5c42013-07-19 08:41:38 -0700296
297 Return ()
298 }
Aaron Durbin76c37002012-10-30 09:03:43 -0500299
Angel Pons59ea8ef2020-10-25 21:28:09 +0100300 Name (_PRW, Package () { DEFAULT_PRW_VALUE, 3 })
Aaron Durbin76c37002012-10-30 09:03:43 -0500301
302 // Leave USB ports on for to allow Wake from USB
303
Angel Ponse53dfe02020-10-25 20:53:29 +0100304 Method (_S3D, 0) // Highest D State in S3 State
Aaron Durbin76c37002012-10-30 09:03:43 -0500305 {
Duncan Laurie568ce5c2013-07-30 16:15:14 -0700306 Return (3)
Aaron Durbin76c37002012-10-30 09:03:43 -0500307 }
308
Angel Ponse53dfe02020-10-25 20:53:29 +0100309 Method (_S4D, 0) // Highest D State in S4 State
Aaron Durbin76c37002012-10-30 09:03:43 -0500310 {
Duncan Laurie568ce5c2013-07-30 16:15:14 -0700311 Return (3)
Aaron Durbin76c37002012-10-30 09:03:43 -0500312 }
313
314 Device (HUB7)
315 {
Angel Ponse53dfe02020-10-25 20:53:29 +0100316 Name (_ADR, 0)
Aaron Durbin76c37002012-10-30 09:03:43 -0500317
Matt DeVillier8b96fd22017-04-17 18:25:09 -0500318 // GPLD: Generate Port Location Data (PLD)
319 Method (GPLD, 1, Serialized) {
Angel Ponse53dfe02020-10-25 20:53:29 +0100320 Name (PCKG, Package () {
Matt DeVillier8b96fd22017-04-17 18:25:09 -0500321 Buffer (0x10) {}
322 })
323
Angel Ponse53dfe02020-10-25 20:53:29 +0100324 // REV: Revision 2 for ACPI 5.0
325 CreateField (DerefOf (PCKG [0]), 0, 7, REV)
326 REV = 2
Matt DeVillier8b96fd22017-04-17 18:25:09 -0500327
328 // VISI: Port visibility to user per port
Angel Ponse53dfe02020-10-25 20:53:29 +0100329 CreateField (DerefOf (PCKG [0]), 0x40, 1, VISI)
330 VISI = Arg0
Matt DeVillier8b96fd22017-04-17 18:25:09 -0500331 Return (PCKG)
332 }
333
Aaron Durbin76c37002012-10-30 09:03:43 -0500334 Device (PRT1) { Name (_ADR, 1) } // USB Port 0
335 Device (PRT2) { Name (_ADR, 2) } // USB Port 1
336 Device (PRT3) { Name (_ADR, 3) } // USB Port 2
337 Device (PRT4) { Name (_ADR, 4) } // USB Port 3
338 Device (PRT5) { Name (_ADR, 5) } // USB Port 4
339 Device (PRT6) { Name (_ADR, 6) } // USB Port 5
Matt DeVilliera672d152017-04-17 18:26:58 -0500340 Device (PRT7) { Name (_ADR, 7) } // USB Port 6
341 Device (SSP1) { Name (_ADR, 10) } // USB Port 10
342 Device (SSP2) { Name (_ADR, 11) } // USB Port 11
343 Device (SSP3) { Name (_ADR, 12) } // USB Port 12
344 Device (SSP4) { Name (_ADR, 13) } // USB Port 13
Aaron Durbin76c37002012-10-30 09:03:43 -0500345 }
346}