blob: b5aa41292a723f8070da0b8a8e9894b9edf3919f [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
Duncan Lauriee32da952015-08-27 17:09:02 -07005 * Copyright (C) 2015 Google Inc.
Lee Leahy1d14b3e2015-05-12 18:23:27 -07006 * Copyright (C) 2015 Intel Corporation.
Lee Leahyb0005132015-05-12 18:19:47 -07007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Lee Leahyb0005132015-05-12 18:19:47 -070016 */
17
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070018/*
19 * USB Port Wake Enable (UPWE) on usb attach/detach
20 * Arg0 - Port Number
21 * Arg1 - Port 1 Status and control offset
22 * Arg2 - xHCI Memory-mapped address
23 */
24Method (UPWE, 3, Serialized)
25{
26 /* Local0 = Arg1 + ((Arg0 - 1) * 0x10) */
27 Add (Arg1, Multiply (Subtract (Arg0, 1), 0x10), Local0)
28
29 /* Map ((XMEM << 16) + Local0 in PSCR */
30 OperationRegion (PSCR, SystemMemory,
31 Add (ShiftLeft (Arg2, 16), Local0), 0x10)
Kane Chenc3892c82018-02-23 10:11:27 +080032 Field (PSCR, DWordAcc, NoLock, Preserve)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070033 {
Kane Chenc3892c82018-02-23 10:11:27 +080034 PSCT, 32,
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070035 }
Kane Chenc3892c82018-02-23 10:11:27 +080036 Store(PSCT, Local0)
37 /*
38 * And port status/control reg with RO and RWS bits
39 * RO bits: 0, 2:3, 10:13, 24, 28:30
40 * RWS bits: 5:9, 14:16, 25:27
41 */
42 And (Local0, ~0x80FE0012, Local0)
43 /* Set WCE and WDE bits */
44 Or (Local0, 0x6000000, Local0)
45 Store(Local0, PSCT)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070046}
47
48/*
49 * USB Wake Enable Setup (UWES)
50 * Arg0 - Port enable bitmap
51 * Arg1 - Port 1 Status and control offset
52 * Arg2 - xHCI Memory-mapped address
53 */
54Method (UWES, 3, Serialized)
55{
56 Store (Arg0, Local0)
57
58 While (One) {
59 FindSetRightBit (Local0, Local1)
60 If (LEqual (Local1, Zero)) {
61 Break
62 }
63 UPWE (Local1, Arg1, Arg2)
64 /*
65 * Clear the lowest set bit in Local0 since it was
66 * processed.
67 * Local0 = Local0 & (Local0 - 1)
68 */
69 And (Local0, Subtract (Local0, 1), Local0)
70 }
71}
72
Lee Leahy1d14b3e2015-05-12 18:23:27 -070073/* XHCI Controller 0:14.0 */
Lee Leahyb0005132015-05-12 18:19:47 -070074
75Device (XHCI)
76{
77 Name (_ADR, 0x00140000)
78
Duncan Lauriee32da952015-08-27 17:09:02 -070079 Name (_PRW, Package () { GPE0_PME_B0, 3 })
80
81 Method (_DSW, 3)
82 {
83 Store (Arg0, PMEE)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070084 UWES (And (\U2WE, 0x3FF), 0x480, XMEM)
85 UWES (And (\U3WE, 0x3F), 0x540, XMEM)
Duncan Lauriee32da952015-08-27 17:09:02 -070086 }
87
88 Name (_S3D, 3) /* D3 supported in S3 */
89 Name (_S4D, 3) /* D3 supported in S4 */
90 Name (_S0W, 3) /* D3 can wake device in S0 */
91 Name (_S3W, 3) /* D3 can wake system from S3 */
92 Name (_S4W, 3) /* D3 can wake system from S4 */
Lee Leahyb0005132015-05-12 18:19:47 -070093
94 OperationRegion (XPRT, PCI_Config, 0x00, 0x100)
95 Field (XPRT, AnyAcc, NoLock, Preserve)
96 {
97 Offset (0x0),
Duncan Lauriee32da952015-08-27 17:09:02 -070098 DVID, 16, /* VENDORID */
Lee Leahyb0005132015-05-12 18:19:47 -070099 Offset (0x10),
100 , 16,
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700101 XMEM, 16, /* MEM_BASE */
Naresh G Solankifb793792017-03-16 15:30:25 +0530102 Offset (0x50), /* XHCLKGTEN */
103 , 2,
104 STGE, 1, /* SS Link Trunk clock gating enable */
Lee Leahyb0005132015-05-12 18:19:47 -0700105 Offset (0x74),
Duncan Lauriee32da952015-08-27 17:09:02 -0700106 D0D3, 2, /* POWERSTATE */
Lee Leahyb0005132015-05-12 18:19:47 -0700107 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700108 PMEE, 1, /* PME_EN */
Lee Leahyb0005132015-05-12 18:19:47 -0700109 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700110 PMES, 1, /* PME_STS */
Naresh G Solankifb793792017-03-16 15:30:25 +0530111 Offset (0xA2),
112 , 2,
113 D3HE, 1, /* D3_hot_en */
Lee Leahyb0005132015-05-12 18:19:47 -0700114 }
115
Duncan Lauriee32da952015-08-27 17:09:02 -0700116 OperationRegion (XREG, SystemMemory,
117 Add (ShiftLeft (XMEM, 16), 0x8000), 0x200)
118 Field (XREG, DWordAcc, Lock, Preserve)
Lee Leahyb0005132015-05-12 18:19:47 -0700119 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700120 Offset (0x1c4), /* USB2PMCTRL */
121 , 2,
122 UPSW, 2, /* U2PSUSPGP */
Lee Leahyb0005132015-05-12 18:19:47 -0700123 }
124
Duncan Lauriee32da952015-08-27 17:09:02 -0700125 Method (_PSC, 0, Serialized)
Lee Leahyb0005132015-05-12 18:19:47 -0700126 {
127 Return (^D0D3)
128 }
129
130 Method (_PS0, 0, Serialized)
131 {
Christian Walter343e1342019-06-07 10:36:24 +0200132 If (!LEqual (^DVID, 0xFFFF)) {
133 If (!LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700134
Christian Walter343e1342019-06-07 10:36:24 +0200135 /* Disable d3hot and SS link trunk clock gating */
136 Store(Zero, ^D3HE)
137 Store(Zero, ^STGE)
Naresh G Solankifb793792017-03-16 15:30:25 +0530138
Christian Walter343e1342019-06-07 10:36:24 +0200139 /* If device is in D3, set back to D0 */
140 If (LEqual (^D0D3, 3)) {
141 Store (Zero, Local0)
142 Store (Local0, ^D0D3)
143 Store (^D0D3, Local0)
Duncan Lauriee32da952015-08-27 17:09:02 -0700144 }
Christian Walter343e1342019-06-07 10:36:24 +0200145
146 /* Disable USB2 PHY SUS Well Power Gating */
147 Store (Zero, ^UPSW)
148
149 /*
150 * Apply USB2 PHPY Power Gating workaround if needed.
151 */
152 If (^^PMC.UWAB) {
153 /* Write to MTPMC to have PMC disable power gating */
154 Store (1, ^^PMC.MPMC)
155
156 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
157 Store (10, Local0)
158 While (^^PMC.PMFS) {
159 If (LNot (Local0)) {
160 Break
161 }
162 Decrement (Local0)
163 Sleep (10)
164 }
165 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700166 }
167 }
Lee Leahyb0005132015-05-12 18:19:47 -0700168 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700169
Lee Leahyb0005132015-05-12 18:19:47 -0700170 Method (_PS3, 0, Serialized)
171 {
Christian Walter343e1342019-06-07 10:36:24 +0200172 If (!LEqual (^DVID, 0xFFFF)) {
173 If (!LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700174
Christian Walter343e1342019-06-07 10:36:24 +0200175 /* Clear PME Status */
176 Store (1, ^PMES)
Duncan Lauriee32da952015-08-27 17:09:02 -0700177
Christian Walter343e1342019-06-07 10:36:24 +0200178 /* Enable PME */
179 Store (1, ^PMEE)
Duncan Lauriee32da952015-08-27 17:09:02 -0700180
Christian Walter343e1342019-06-07 10:36:24 +0200181 /* If device is in D3, set back to D0 */
182 If (LEqual (^D0D3, 3)) {
183 Store (Zero, Local0)
184 Store (Local0, ^D0D3)
185 Store (^D0D3, Local0)
Duncan Lauriee32da952015-08-27 17:09:02 -0700186 }
Christian Walter343e1342019-06-07 10:36:24 +0200187
188 /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */
189 Store (3, ^UPSW)
190
191 /* Enable d3hot and SS link trunk clock gating */
192 Store(One, ^D3HE)
193 Store(One, ^STGE)
194
195 /* Now put device in D3 */
196 Store (3, Local0)
197 Store (Local0, ^D0D3)
198 Store (^D0D3, Local0)
199
200 /*
201 * Apply USB2 PHPY Power Gating workaround if needed.
202 * This code assumes XDCI is disabled, if it is enabled
203 * then this must also check if it is in D3 state too.
204 */
205 If (^^PMC.UWAB) {
206 /* Write to MTPMC to have PMC enable power gating */
207 Store (3, ^^PMC.MPMC)
208
209 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
210 Store (10, Local0)
211 While (^^PMC.PMFS) {
212 If (LNot (Local0)) {
213 Break
214 }
215 Decrement (Local0)
216 Sleep (10)
217 }
218 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700219 }
220 }
Lee Leahyb0005132015-05-12 18:19:47 -0700221 }
222
Duncan Lauriee32da952015-08-27 17:09:02 -0700223 /* Root Hub for Skylake-LP PCH */
224 Device (RHUB)
225 {
226 Name (_ADR, Zero)
Lee Leahyb0005132015-05-12 18:19:47 -0700227
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500228 // GPLD: Generate Port Location Data (PLD)
229 Method (GPLD, 1, Serialized)
230 {
231
232 Name (PCKG, Package (0x01)
233 {
234 Buffer (0x10) {}
235 })
236
237 // REV: Revision 0x02 for ACPI 5.0
238 CreateField (DerefOf (Index (PCKG, Zero)), Zero, 0x07, REV)
239 Store (0x02, REV)
240
241 // VISI: Port visibility to user per port
242 CreateField (DerefOf (Index (PCKG, Zero)), 0x40, One, VISI)
243 Store (Arg0, VISI)
244
245 Return (PCKG)
246 }
247
Duncan Lauriee32da952015-08-27 17:09:02 -0700248 /* USB2 */
249 Device (HS01) { Name (_ADR, 1) }
250 Device (HS02) { Name (_ADR, 2) }
251 Device (HS03) { Name (_ADR, 3) }
252 Device (HS04) { Name (_ADR, 4) }
253 Device (HS05) { Name (_ADR, 5) }
254 Device (HS06) { Name (_ADR, 6) }
255 Device (HS07) { Name (_ADR, 7) }
256 Device (HS08) { Name (_ADR, 8) }
257 Device (HS09) { Name (_ADR, 9) }
258 Device (HS10) { Name (_ADR, 10) }
Lee Leahyb0005132015-05-12 18:19:47 -0700259
Duncan Lauriee32da952015-08-27 17:09:02 -0700260 /* USBr */
261 Device (USR1) { Name (_ADR, 11) }
262 Device (USR2) { Name (_ADR, 12) }
Lee Leahyb0005132015-05-12 18:19:47 -0700263
Duncan Lauriee32da952015-08-27 17:09:02 -0700264 /* USB3 */
265 Device (SS01) { Name (_ADR, 13) }
266 Device (SS02) { Name (_ADR, 14) }
267 Device (SS03) { Name (_ADR, 15) }
268 Device (SS04) { Name (_ADR, 16) }
269 Device (SS05) { Name (_ADR, 17) }
270 Device (SS06) { Name (_ADR, 18) }
Lee Leahyb0005132015-05-12 18:19:47 -0700271 }
272}