blob: 08f35bcf289bc8ae3b5804117cc96beb6133ce4f [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)
32 Field (PSCR, AnyAcc, NoLock, Preserve)
33 {
34 , 25,
35 UPCE, 1,
36 UPDE, 1,
37 }
38 Store (One, UPCE)
39 Store (One, UPDE)
40}
41
42/*
43 * USB Wake Enable Setup (UWES)
44 * Arg0 - Port enable bitmap
45 * Arg1 - Port 1 Status and control offset
46 * Arg2 - xHCI Memory-mapped address
47 */
48Method (UWES, 3, Serialized)
49{
50 Store (Arg0, Local0)
51
52 While (One) {
53 FindSetRightBit (Local0, Local1)
54 If (LEqual (Local1, Zero)) {
55 Break
56 }
57 UPWE (Local1, Arg1, Arg2)
58 /*
59 * Clear the lowest set bit in Local0 since it was
60 * processed.
61 * Local0 = Local0 & (Local0 - 1)
62 */
63 And (Local0, Subtract (Local0, 1), Local0)
64 }
65}
66
Lee Leahy1d14b3e2015-05-12 18:23:27 -070067/* XHCI Controller 0:14.0 */
Lee Leahyb0005132015-05-12 18:19:47 -070068
69Device (XHCI)
70{
71 Name (_ADR, 0x00140000)
72
Duncan Lauriee32da952015-08-27 17:09:02 -070073 Name (_PRW, Package () { GPE0_PME_B0, 3 })
74
75 Method (_DSW, 3)
76 {
77 Store (Arg0, PMEE)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070078 UWES (And (\U2WE, 0x3FF), 0x480, XMEM)
79 UWES (And (\U3WE, 0x3F), 0x540, XMEM)
Duncan Lauriee32da952015-08-27 17:09:02 -070080 }
81
82 Name (_S3D, 3) /* D3 supported in S3 */
83 Name (_S4D, 3) /* D3 supported in S4 */
84 Name (_S0W, 3) /* D3 can wake device in S0 */
85 Name (_S3W, 3) /* D3 can wake system from S3 */
86 Name (_S4W, 3) /* D3 can wake system from S4 */
Lee Leahyb0005132015-05-12 18:19:47 -070087
88 OperationRegion (XPRT, PCI_Config, 0x00, 0x100)
89 Field (XPRT, AnyAcc, NoLock, Preserve)
90 {
91 Offset (0x0),
Duncan Lauriee32da952015-08-27 17:09:02 -070092 DVID, 16, /* VENDORID */
Lee Leahyb0005132015-05-12 18:19:47 -070093 Offset (0x10),
94 , 16,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070095 XMEM, 16, /* MEM_BASE */
Naresh G Solankifb793792017-03-16 15:30:25 +053096 Offset (0x50), /* XHCLKGTEN */
97 , 2,
98 STGE, 1, /* SS Link Trunk clock gating enable */
Lee Leahyb0005132015-05-12 18:19:47 -070099 Offset (0x74),
Duncan Lauriee32da952015-08-27 17:09:02 -0700100 D0D3, 2, /* POWERSTATE */
Lee Leahyb0005132015-05-12 18:19:47 -0700101 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700102 PMEE, 1, /* PME_EN */
Lee Leahyb0005132015-05-12 18:19:47 -0700103 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700104 PMES, 1, /* PME_STS */
Naresh G Solankifb793792017-03-16 15:30:25 +0530105 Offset (0xA2),
106 , 2,
107 D3HE, 1, /* D3_hot_en */
Lee Leahyb0005132015-05-12 18:19:47 -0700108 }
109
Duncan Lauriee32da952015-08-27 17:09:02 -0700110 OperationRegion (XREG, SystemMemory,
111 Add (ShiftLeft (XMEM, 16), 0x8000), 0x200)
112 Field (XREG, DWordAcc, Lock, Preserve)
Lee Leahyb0005132015-05-12 18:19:47 -0700113 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700114 Offset (0x1c4), /* USB2PMCTRL */
115 , 2,
116 UPSW, 2, /* U2PSUSPGP */
Lee Leahyb0005132015-05-12 18:19:47 -0700117 }
118
Duncan Lauriee32da952015-08-27 17:09:02 -0700119 Method (_PSC, 0, Serialized)
Lee Leahyb0005132015-05-12 18:19:47 -0700120 {
121 Return (^D0D3)
122 }
123
124 Method (_PS0, 0, Serialized)
125 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700126 If (LEqual (^DVID, 0xFFFF)) {
127 Return
128 }
129 If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
130 Return
131 }
132
Naresh G Solankifb793792017-03-16 15:30:25 +0530133 /* Disable d3hot and SS link trunk clock gating */
134 Store(Zero, ^D3HE)
135 Store(Zero, ^STGE)
136
Duncan Lauriee32da952015-08-27 17:09:02 -0700137 /* If device is in D3, set back to D0 */
138 If (LEqual (^D0D3, 3)) {
Duncan Laurieaa1b6b02015-09-23 18:01:45 -0700139 Store (Zero, Local0)
140 Store (Local0, ^D0D3)
Duncan Lauriee32da952015-08-27 17:09:02 -0700141 Store (^D0D3, Local0)
142 }
143
144 /* Disable USB2 PHY SUS Well Power Gating */
145 Store (Zero, ^UPSW)
146
147 /*
148 * Apply USB2 PHPY Power Gating workaround if needed.
149 */
150 If (^^PMC.UWAB) {
151 /* Write to MTPMC to have PMC disable power gating */
152 Store (1, ^^PMC.MPMC)
153
154 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
155 Store (10, Local0)
156 While (^^PMC.PMFS) {
157 If (LNot (Local0)) {
158 Break
159 }
160 Decrement (Local0)
161 Sleep (10)
162 }
163 }
Lee Leahyb0005132015-05-12 18:19:47 -0700164 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700165
Lee Leahyb0005132015-05-12 18:19:47 -0700166 Method (_PS3, 0, Serialized)
167 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700168 If (LEqual (^DVID, 0xFFFF)) {
169 Return
170 }
171 If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
172 Return
173 }
174
175 /* Clear PME Status */
176 Store (1, ^PMES)
177
178 /* Enable PME */
179 Store (1, ^PMEE)
180
181 /* If device is in D3, set back to D0 */
182 If (LEqual (^D0D3, 3)) {
Duncan Laurieaa1b6b02015-09-23 18:01:45 -0700183 Store (Zero, Local0)
184 Store (Local0, ^D0D3)
Duncan Lauriee32da952015-08-27 17:09:02 -0700185 Store (^D0D3, Local0)
186 }
187
188 /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */
189 Store (3, ^UPSW)
190
Naresh G Solankifb793792017-03-16 15:30:25 +0530191 /* Enable d3hot and SS link trunk clock gating */
192 Store(One, ^D3HE)
193 Store(One, ^STGE)
194
Duncan Lauriee32da952015-08-27 17:09:02 -0700195 /* Now put device in D3 */
Duncan Laurieaa1b6b02015-09-23 18:01:45 -0700196 Store (3, Local0)
197 Store (Local0, ^D0D3)
Duncan Lauriee32da952015-08-27 17:09:02 -0700198 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 }
Lee Leahyb0005132015-05-12 18:19:47 -0700219 }
220
Duncan Lauriee32da952015-08-27 17:09:02 -0700221 /* Root Hub for Skylake-LP PCH */
222 Device (RHUB)
223 {
224 Name (_ADR, Zero)
Lee Leahyb0005132015-05-12 18:19:47 -0700225
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500226 // GPLD: Generate Port Location Data (PLD)
227 Method (GPLD, 1, Serialized)
228 {
229
230 Name (PCKG, Package (0x01)
231 {
232 Buffer (0x10) {}
233 })
234
235 // REV: Revision 0x02 for ACPI 5.0
236 CreateField (DerefOf (Index (PCKG, Zero)), Zero, 0x07, REV)
237 Store (0x02, REV)
238
239 // VISI: Port visibility to user per port
240 CreateField (DerefOf (Index (PCKG, Zero)), 0x40, One, VISI)
241 Store (Arg0, VISI)
242
243 Return (PCKG)
244 }
245
Duncan Lauriee32da952015-08-27 17:09:02 -0700246 /* USB2 */
247 Device (HS01) { Name (_ADR, 1) }
248 Device (HS02) { Name (_ADR, 2) }
249 Device (HS03) { Name (_ADR, 3) }
250 Device (HS04) { Name (_ADR, 4) }
251 Device (HS05) { Name (_ADR, 5) }
252 Device (HS06) { Name (_ADR, 6) }
253 Device (HS07) { Name (_ADR, 7) }
254 Device (HS08) { Name (_ADR, 8) }
255 Device (HS09) { Name (_ADR, 9) }
256 Device (HS10) { Name (_ADR, 10) }
Lee Leahyb0005132015-05-12 18:19:47 -0700257
Duncan Lauriee32da952015-08-27 17:09:02 -0700258 /* USBr */
259 Device (USR1) { Name (_ADR, 11) }
260 Device (USR2) { Name (_ADR, 12) }
Lee Leahyb0005132015-05-12 18:19:47 -0700261
Duncan Lauriee32da952015-08-27 17:09:02 -0700262 /* USB3 */
263 Device (SS01) { Name (_ADR, 13) }
264 Device (SS02) { Name (_ADR, 14) }
265 Device (SS03) { Name (_ADR, 15) }
266 Device (SS04) { Name (_ADR, 16) }
267 Device (SS05) { Name (_ADR, 17) }
268 Device (SS06) { Name (_ADR, 18) }
Lee Leahyb0005132015-05-12 18:19:47 -0700269 }
270}