blob: 29367de6ddf4f24dd66f10be85daf31b515ab905 [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 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700132 If (LEqual (^DVID, 0xFFFF)) {
133 Return
134 }
135 If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
136 Return
137 }
138
Naresh G Solankifb793792017-03-16 15:30:25 +0530139 /* Disable d3hot and SS link trunk clock gating */
140 Store(Zero, ^D3HE)
141 Store(Zero, ^STGE)
142
Duncan Lauriee32da952015-08-27 17:09:02 -0700143 /* If device is in D3, set back to D0 */
144 If (LEqual (^D0D3, 3)) {
Duncan Laurieaa1b6b02015-09-23 18:01:45 -0700145 Store (Zero, Local0)
146 Store (Local0, ^D0D3)
Duncan Lauriee32da952015-08-27 17:09:02 -0700147 Store (^D0D3, Local0)
148 }
149
150 /* Disable USB2 PHY SUS Well Power Gating */
151 Store (Zero, ^UPSW)
152
153 /*
154 * Apply USB2 PHPY Power Gating workaround if needed.
155 */
156 If (^^PMC.UWAB) {
157 /* Write to MTPMC to have PMC disable power gating */
158 Store (1, ^^PMC.MPMC)
159
160 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
161 Store (10, Local0)
162 While (^^PMC.PMFS) {
163 If (LNot (Local0)) {
164 Break
165 }
166 Decrement (Local0)
167 Sleep (10)
168 }
169 }
Lee Leahyb0005132015-05-12 18:19:47 -0700170 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700171
Lee Leahyb0005132015-05-12 18:19:47 -0700172 Method (_PS3, 0, Serialized)
173 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700174 If (LEqual (^DVID, 0xFFFF)) {
175 Return
176 }
177 If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
178 Return
179 }
180
181 /* Clear PME Status */
182 Store (1, ^PMES)
183
184 /* Enable PME */
185 Store (1, ^PMEE)
186
187 /* If device is in D3, set back to D0 */
188 If (LEqual (^D0D3, 3)) {
Duncan Laurieaa1b6b02015-09-23 18:01:45 -0700189 Store (Zero, Local0)
190 Store (Local0, ^D0D3)
Duncan Lauriee32da952015-08-27 17:09:02 -0700191 Store (^D0D3, Local0)
192 }
193
194 /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */
195 Store (3, ^UPSW)
196
Naresh G Solankifb793792017-03-16 15:30:25 +0530197 /* Enable d3hot and SS link trunk clock gating */
198 Store(One, ^D3HE)
199 Store(One, ^STGE)
200
Duncan Lauriee32da952015-08-27 17:09:02 -0700201 /* Now put device in D3 */
Duncan Laurieaa1b6b02015-09-23 18:01:45 -0700202 Store (3, Local0)
203 Store (Local0, ^D0D3)
Duncan Lauriee32da952015-08-27 17:09:02 -0700204 Store (^D0D3, Local0)
205
206 /*
207 * Apply USB2 PHPY Power Gating workaround if needed.
208 * This code assumes XDCI is disabled, if it is enabled
209 * then this must also check if it is in D3 state too.
210 */
211 If (^^PMC.UWAB) {
212 /* Write to MTPMC to have PMC enable power gating */
213 Store (3, ^^PMC.MPMC)
214
215 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
216 Store (10, Local0)
217 While (^^PMC.PMFS) {
218 If (LNot (Local0)) {
219 Break
220 }
221 Decrement (Local0)
222 Sleep (10)
223 }
224 }
Lee Leahyb0005132015-05-12 18:19:47 -0700225 }
226
Duncan Lauriee32da952015-08-27 17:09:02 -0700227 /* Root Hub for Skylake-LP PCH */
228 Device (RHUB)
229 {
230 Name (_ADR, Zero)
Lee Leahyb0005132015-05-12 18:19:47 -0700231
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500232 // GPLD: Generate Port Location Data (PLD)
233 Method (GPLD, 1, Serialized)
234 {
235
236 Name (PCKG, Package (0x01)
237 {
238 Buffer (0x10) {}
239 })
240
241 // REV: Revision 0x02 for ACPI 5.0
242 CreateField (DerefOf (Index (PCKG, Zero)), Zero, 0x07, REV)
243 Store (0x02, REV)
244
245 // VISI: Port visibility to user per port
246 CreateField (DerefOf (Index (PCKG, Zero)), 0x40, One, VISI)
247 Store (Arg0, VISI)
248
249 Return (PCKG)
250 }
251
Duncan Lauriee32da952015-08-27 17:09:02 -0700252 /* USB2 */
253 Device (HS01) { Name (_ADR, 1) }
254 Device (HS02) { Name (_ADR, 2) }
255 Device (HS03) { Name (_ADR, 3) }
256 Device (HS04) { Name (_ADR, 4) }
257 Device (HS05) { Name (_ADR, 5) }
258 Device (HS06) { Name (_ADR, 6) }
259 Device (HS07) { Name (_ADR, 7) }
260 Device (HS08) { Name (_ADR, 8) }
261 Device (HS09) { Name (_ADR, 9) }
262 Device (HS10) { Name (_ADR, 10) }
Lee Leahyb0005132015-05-12 18:19:47 -0700263
Duncan Lauriee32da952015-08-27 17:09:02 -0700264 /* USBr */
265 Device (USR1) { Name (_ADR, 11) }
266 Device (USR2) { Name (_ADR, 12) }
Lee Leahyb0005132015-05-12 18:19:47 -0700267
Duncan Lauriee32da952015-08-27 17:09:02 -0700268 /* USB3 */
269 Device (SS01) { Name (_ADR, 13) }
270 Device (SS02) { Name (_ADR, 14) }
271 Device (SS03) { Name (_ADR, 15) }
272 Device (SS04) { Name (_ADR, 16) }
273 Device (SS05) { Name (_ADR, 17) }
274 Device (SS06) { Name (_ADR, 18) }
Lee Leahyb0005132015-05-12 18:19:47 -0700275 }
276}