tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / soc / intel / broadwell / acpi / xhci.asl
bloba70ded917664fcbdb92c4823e0d55eb52beac76b
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2009 coresystems GmbH
5  * Copyright (C) 2014 Google Inc.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  */
17 // XHCI Controller 0:14.0
19 Device (XHCI)
21         Name (_ADR, 0x00140000)
23         Name (PLSD, 5) // Port Link State - RxDetect
24         Name (PLSP, 7) // Port Link State - Polling
26         OperationRegion (XPRT, PCI_Config, 0x00, 0x100)
27         Field (XPRT, AnyAcc, NoLock, Preserve)
28         {
29                 Offset (0x0),
30                 DVID, 16,
31                 Offset (0x10),
32                 , 16,
33                 XMEM, 16, // MEM_BASE
34                 Offset (0x40),
35                 , 11,
36                 SWAI, 1,
37                 , 20,
38                 Offset (0x44),
39                 , 12,
40                 SAIP, 2,
41                 , 18,
42                 Offset (0x74),
43                 D0D3, 2,
44                 , 6,
45                 PMEE, 1,  // PME_EN
46                 , 6,
47                 PMES, 1,  // PME_STS
48                 Offset (0xb0),
49                 , 13,
50                 MB13, 1,
51                 MB14, 1,
52                 Offset (0xd0),
53                 PR2R, 32,  // USB2PR
54                 PR2M, 32,  // USB2PRM
55                 PR3R, 32,  // USB3PR
56                 PR3M, 32,  // USB3PRM
57         }
59         // Clear status bits
60         Method (LPCL, 0, Serialized)
61         {
62                 OperationRegion (XREG, SystemMemory,
63                                  ShiftLeft (^XMEM, 16), 0x600)
64                 Field (XREG, DWordAcc, Lock, Preserve)
65                 {
66                         Offset (0x510), // PORTSCNUSB3[0]
67                         PSC0, 32,
68                         Offset (0x520), // PORTSCNUSB3[1]
69                         PSC1, 32,
70                         Offset (0x530), // PORTSCNUSB3[2]
71                         PSC2, 32,
72                         Offset (0x540), // PORTSCNUSB3[3]
73                         PSC3, 32,
74                 }
76                 // Port Enabled/Disabled (Bit 1)
77                 Name (PEDB, ShiftLeft (1, 1))
79                 // Change Status (Bits 23:17)
80                 Name (CHST, ShiftLeft (0x7f, 17))
82                 // Port 0
83                 And (PSC0, Not (PEDB), Local0)
84                 Or (Local0, CHST, PSC0)
86                 // Port 1
87                 And (PSC1, Not (PEDB), Local0)
88                 Or (Local0, CHST, PSC1)
90                 // Port 2
91                 And (PSC2, Not (PEDB), Local0)
92                 Or (Local0, CHST, PSC2)
94                 // Port 3
95                 And (PSC3, Not (PEDB), Local0)
96                 Or (Local0, CHST, PSC3)
97         }
99         Method (LPS0, 0, Serialized)
100         {
101                 OperationRegion (XREG, SystemMemory,
102                                  ShiftLeft (^XMEM, 16), 0x600)
103                 Field (XREG, DWordAcc, Lock, Preserve)
104                 {
105                         Offset (0x510), // PORTSCNUSB3
106                         , 5,
107                         PLS1, 4,        // [8:5] Port Link State
108                         PPR1, 1,        // [9] Port Power
109                         , 7,
110                         CSC1, 1,        // [17] Connect Status Change
111                         , 1,
112                         WRC1, 1,        // [19] Warm Port Reset Change
113                         , 11,
114                         WPR1, 1,        // [31] Warm Port Reset
115                         Offset (0x520), // PORTSCNUSB3
116                         , 5,
117                         PLS2, 4,        // [8:5] Port Link State
118                         PPR2, 1,        // [9] Port Power
119                         , 7,
120                         CSC2, 1,        // [17] Connect Status Change
121                         , 1,
122                         WRC2, 1,        // [19] Warm Port Reset Change
123                         , 11,
124                         WPR2, 1,        // [31] Warm Port Reset
125                         Offset (0x530), // PORTSCNUSB3
126                         , 5,
127                         PLS3, 4,        // [8:5] Port Link State
128                         PPR3, 1,        // [9] Port Power
129                         , 7,
130                         CSC3, 1,        // [17] Connect Status Change
131                         , 1,
132                         WRC3, 1,        // [19] Warm Port Reset Change
133                         , 11,
134                         WPR3, 1,        // [31] Warm Port Reset
135                         Offset (0x540), // PORTSCNUSB3
136                         , 5,
137                         PLS4, 4,        // [8:5] Port Link State
138                         PPR4, 1,        // [9] Port Power
139                         , 7,
140                         CSC4, 1,        // [17] Connect Status Change
141                         , 1,
142                         WRC4, 1,        // [19] Warm Port Reset Change
143                         , 11,
144                         WPR4, 1,        // [31] Warm Port Reset
145                 }
147                 // Wait for all powered ports to finish polling
148                 Store (10, Local0)
149                 While (LOr (LOr (LAnd (LEqual (PPR1, 1), LEqual (PLS1, PLSP)),
150                                  LAnd (LEqual (PPR2, 1), LEqual (PLS2, PLSP))),
151                             LOr (LAnd (LEqual (PPR3, 1), LEqual (PLS3, PLSP)),
152                                  LAnd (LEqual (PPR4, 1), LEqual (PLS4, PLSP)))))
153                 {
154                         If (LEqual (Local0, 0)) {
155                                 Break
156                         }
157                         Decrement (Local0)
158                         Stall (10)
159                 }
161                 // For each USB3 Port:
162                 //   If port is disconnected (PLS=5 PP=1 CSC=0)
163                 //     1) Issue warm reset (WPR=1)
164                 //     2) Poll for warm reset complete (WRC=0)
165                 //     3) Write 1 to port status to clear
167                 // Local# indicate if port is reset
168                 Store (0, Local1)
169                 Store (0, Local2)
170                 Store (0, Local3)
171                 Store (0, Local4)
173                 If (LAnd (LEqual (PLS1, PLSD),
174                           LAnd (LEqual (CSC1, 0), LEqual (PPR1, 1)))) {
175                         Store (1, WPR1)       // Issue warm reset
176                         Store (1, Local1)
177                 }
178                 If (LAnd (LEqual (PLS2, PLSD),
179                           LAnd (LEqual (CSC2, 0), LEqual (PPR2, 1)))) {
180                         Store (1, WPR2)       // Issue warm reset
181                         Store (1, Local2)
182                 }
183                 If (LAnd (LEqual (PLS3, PLSD),
184                           LAnd (LEqual (CSC3, 0), LEqual (PPR3, 1)))) {
185                         Store (1, WPR3)       // Issue warm reset
186                         Store (1, Local3)
187                 }
188                 If (LAnd (LEqual (PLS4, PLSD),
189                           LAnd (LEqual (CSC4, 0), LEqual (PPR4, 1)))) {
190                         Store (1, WPR4)       // Issue warm reset
191                         Store (1, Local4)
192                 }
194                 // Poll for warm reset complete on all ports that were reset
195                 Store (10, Local0)
196                 While (LOr (LOr (LAnd (LEqual (Local1, 1), LEqual (WRC1, 0)),
197                                  LAnd (LEqual (Local2, 1), LEqual (WRC2, 0))),
198                             LOr (LAnd (LEqual (Local3, 1), LEqual (WRC3, 0)),
199                                  LAnd (LEqual (Local4, 1), LEqual (WRC4, 0)))))
200                 {
201                         If (LEqual (Local0, 0)) {
202                                 Break
203                         }
204                         Decrement (Local0)
205                         Stall (10)
206                 }
208                 // Clear status bits in all ports
209                 LPCL ()
210         }
212         Method (_PSC, 0, NotSerialized)
213         {
214                 Return (^D0D3)
215         }
217         Method (_PS0, 0, Serialized)
218         {
219                 If (LEqual (^DVID, 0xFFFF)) {
220                         Return ()
221                 }
222                 If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
223                         Return ()
224                 }
226                 OperationRegion (XREG, SystemMemory,
227                                  Add (ShiftLeft (^XMEM, 16), 0x8000), 0x200)
228                 Field (XREG, DWordAcc, Lock, Preserve)
229                 {
230                         Offset (0x0e0), // AUX Reset Control 1
231                         , 15,
232                         AX15, 1,
233                         Offset (0x154), // AUX Domain PM Control Register 2
234                         , 31,
235                         CLK2, 1,
236                         Offset (0x16c), // AUX Clock Control
237                         , 2,
238                         CLK0, 1,
239                         , 11,
240                         CLK1, 1, // USB3 Port Aux/Core Clock Gating Enable
241                 }
243                 // If device is in D3, set back to D0
244                 Store (^D0D3, Local0)
245                 if (LEqual (Local0, 3)) {
246                         Store (0, ^D0D3)
247                 }
249                 if (LNot (\ISWP())) {
250                         // Clear PCI 0xB0[14:13]
251                         Store (0, ^MB13)
252                         Store (0, ^MB14)
254                         // Clear MMIO 0x816C[14,2]
255                         Store (0, CLK0)
256                         Store (0, CLK1)
258                         // Set MMIO 0x8154[31]
259                         Store (1, CLK2)
261                         // Handle per-port reset if needed
262                         LPS0 ()
264                         // Set MMIO 0x80e0[15]
265                         Store (1, AX15)
267                         // Clear PCI CFG offset 0x40[11]
268                         Store (0, ^SWAI)
270                         // Clear PCI CFG offset 0x44[13:12]
271                         Store (0, ^SAIP)
272                 }
274                 Return ()
275         }
277         Method (_PS3, 0, Serialized)
278         {
279                 If (LEqual (^DVID, 0xFFFF)) {
280                         Return ()
281                 }
282                 If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
283                         Return ()
284                 }
286                 OperationRegion (XREG, SystemMemory,
287                                  Add (ShiftLeft (^XMEM, 16), 0x8000), 0x200)
288                 Field (XREG, DWordAcc, Lock, Preserve)
289                 {
290                         Offset (0x0e0), // AUX Reset Control 1
291                         , 15,
292                         AX15, 1,
293                         Offset (0x154), // AUX Domain PM Control Register 2
294                         , 31,
295                         CLK2, 1,
296                         Offset (0x16c), // AUX Clock Control
297                         , 2,
298                         CLK0, 1,
299                         , 11,
300                         CLK1, 1, // USB3 Port Aux/Core Clock Gating Enable
301                 }
303                 Store (1, ^PMES) // Clear PME Status
304                 Store (1, ^PMEE) // Enable PME
306                 // If device is in D3, set back to D0
307                 Store (^D0D3, Local0)
308                 if (LEqual (Local0, 3)) {
309                         Store (0, ^D0D3)
310                 }
312                 if (LNot (\ISWP())) {
313                         // Set PCI 0xB0[14:13]
314                         Store (1, ^MB13)
315                         Store (1, ^MB14)
317                         // Set MMIO 0x816C[14,2]
318                         Store (1, CLK0)
319                         Store (1, CLK1)
321                         // Clear MMIO 0x8154[31]
322                         Store (0, CLK2)
324                         // Clear MMIO 0x80e0[15]
325                         Store (0, AX15)
327                         // Set PCI CFG offset 0x40[11]
328                         Store (1, ^SWAI)
330                         // Set PCI CFG offset 0x44[13:12]
331                         Store (1, ^SAIP)
332                 }
334                 // Put device in D3
335                 Store (3, ^D0D3)
337                 Return ()
338         }
340         Name (_PRW, Package(){ 0x6d, 3 })
342         // Leave USB ports on for to allow Wake from USB
344         Method(_S3D,0)  // Highest D State in S3 State
345         {
346                 Return (3)
347         }
349         Method(_S4D,0)  // Highest D State in S4 State
350         {
351                 Return (3)
352         }
354         Device (HUB7)
355         {
356                 Name (_ADR, 0x00000000)
358                 // How many are there?
359                 Device (PRT1) { Name (_ADR, 1) } // USB Port 0
360                 Device (PRT2) { Name (_ADR, 2) } // USB Port 1
361                 Device (PRT3) { Name (_ADR, 3) } // USB Port 2
362                 Device (PRT4) { Name (_ADR, 4) } // USB Port 3
363                 Device (PRT5) { Name (_ADR, 5) } // USB Port 4
364                 Device (PRT6) { Name (_ADR, 6) } // USB Port 5
365         }