blob: b8adf0b23bf18318925060d5c7378bc9cd327a45 [file] [log] [blame]
Angel Pons3bd1e3d2020-04-05 15:47:17 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Lee Leahyb0005132015-05-12 18:19:47 -07003
Furquan Shaikh3bfe3402016-10-18 14:25:25 -07004/*
5 * USB Port Wake Enable (UPWE) on usb attach/detach
6 * Arg0 - Port Number
7 * Arg1 - Port 1 Status and control offset
8 * Arg2 - xHCI Memory-mapped address
9 */
10Method (UPWE, 3, Serialized)
11{
12 /* Local0 = Arg1 + ((Arg0 - 1) * 0x10) */
13 Add (Arg1, Multiply (Subtract (Arg0, 1), 0x10), Local0)
14
15 /* Map ((XMEM << 16) + Local0 in PSCR */
16 OperationRegion (PSCR, SystemMemory,
17 Add (ShiftLeft (Arg2, 16), Local0), 0x10)
Kane Chenc3892c82018-02-23 10:11:27 +080018 Field (PSCR, DWordAcc, NoLock, Preserve)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070019 {
Kane Chenc3892c82018-02-23 10:11:27 +080020 PSCT, 32,
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070021 }
Kane Chenc3892c82018-02-23 10:11:27 +080022 Store(PSCT, Local0)
23 /*
24 * And port status/control reg with RO and RWS bits
25 * RO bits: 0, 2:3, 10:13, 24, 28:30
26 * RWS bits: 5:9, 14:16, 25:27
27 */
28 And (Local0, ~0x80FE0012, Local0)
29 /* Set WCE and WDE bits */
30 Or (Local0, 0x6000000, Local0)
31 Store(Local0, PSCT)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070032}
33
34/*
35 * USB Wake Enable Setup (UWES)
36 * Arg0 - Port enable bitmap
37 * Arg1 - Port 1 Status and control offset
38 * Arg2 - xHCI Memory-mapped address
39 */
40Method (UWES, 3, Serialized)
41{
42 Store (Arg0, Local0)
43
44 While (One) {
45 FindSetRightBit (Local0, Local1)
46 If (LEqual (Local1, Zero)) {
47 Break
48 }
49 UPWE (Local1, Arg1, Arg2)
50 /*
51 * Clear the lowest set bit in Local0 since it was
52 * processed.
53 * Local0 = Local0 & (Local0 - 1)
54 */
55 And (Local0, Subtract (Local0, 1), Local0)
56 }
57}
58
Lee Leahy1d14b3e2015-05-12 18:23:27 -070059/* XHCI Controller 0:14.0 */
Lee Leahyb0005132015-05-12 18:19:47 -070060
61Device (XHCI)
62{
63 Name (_ADR, 0x00140000)
64
Duncan Lauriee32da952015-08-27 17:09:02 -070065 Name (_PRW, Package () { GPE0_PME_B0, 3 })
66
67 Method (_DSW, 3)
68 {
69 Store (Arg0, PMEE)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070070 UWES (And (\U2WE, 0x3FF), 0x480, XMEM)
71 UWES (And (\U3WE, 0x3F), 0x540, XMEM)
Duncan Lauriee32da952015-08-27 17:09:02 -070072 }
73
74 Name (_S3D, 3) /* D3 supported in S3 */
75 Name (_S4D, 3) /* D3 supported in S4 */
76 Name (_S0W, 3) /* D3 can wake device in S0 */
77 Name (_S3W, 3) /* D3 can wake system from S3 */
78 Name (_S4W, 3) /* D3 can wake system from S4 */
Lee Leahyb0005132015-05-12 18:19:47 -070079
80 OperationRegion (XPRT, PCI_Config, 0x00, 0x100)
81 Field (XPRT, AnyAcc, NoLock, Preserve)
82 {
83 Offset (0x0),
Duncan Lauriee32da952015-08-27 17:09:02 -070084 DVID, 16, /* VENDORID */
Lee Leahyb0005132015-05-12 18:19:47 -070085 Offset (0x10),
86 , 16,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070087 XMEM, 16, /* MEM_BASE */
Naresh G Solankifb793792017-03-16 15:30:25 +053088 Offset (0x50), /* XHCLKGTEN */
89 , 2,
90 STGE, 1, /* SS Link Trunk clock gating enable */
Lee Leahyb0005132015-05-12 18:19:47 -070091 Offset (0x74),
Duncan Lauriee32da952015-08-27 17:09:02 -070092 D0D3, 2, /* POWERSTATE */
Lee Leahyb0005132015-05-12 18:19:47 -070093 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070094 PMEE, 1, /* PME_EN */
Lee Leahyb0005132015-05-12 18:19:47 -070095 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070096 PMES, 1, /* PME_STS */
Naresh G Solankifb793792017-03-16 15:30:25 +053097 Offset (0xA2),
98 , 2,
99 D3HE, 1, /* D3_hot_en */
Lee Leahyb0005132015-05-12 18:19:47 -0700100 }
101
Duncan Lauriee32da952015-08-27 17:09:02 -0700102 OperationRegion (XREG, SystemMemory,
103 Add (ShiftLeft (XMEM, 16), 0x8000), 0x200)
104 Field (XREG, DWordAcc, Lock, Preserve)
Lee Leahyb0005132015-05-12 18:19:47 -0700105 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700106 Offset (0x1c4), /* USB2PMCTRL */
107 , 2,
108 UPSW, 2, /* U2PSUSPGP */
Lee Leahyb0005132015-05-12 18:19:47 -0700109 }
110
Duncan Lauriee32da952015-08-27 17:09:02 -0700111 Method (_PSC, 0, Serialized)
Lee Leahyb0005132015-05-12 18:19:47 -0700112 {
113 Return (^D0D3)
114 }
115
116 Method (_PS0, 0, Serialized)
117 {
Christian Walter343e1342019-06-07 10:36:24 +0200118 If (!LEqual (^DVID, 0xFFFF)) {
119 If (!LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700120
Christian Walter343e1342019-06-07 10:36:24 +0200121 /* Disable d3hot and SS link trunk clock gating */
122 Store(Zero, ^D3HE)
123 Store(Zero, ^STGE)
Naresh G Solankifb793792017-03-16 15:30:25 +0530124
Christian Walter343e1342019-06-07 10:36:24 +0200125 /* If device is in D3, set back to D0 */
126 If (LEqual (^D0D3, 3)) {
127 Store (Zero, Local0)
128 Store (Local0, ^D0D3)
129 Store (^D0D3, Local0)
Duncan Lauriee32da952015-08-27 17:09:02 -0700130 }
Christian Walter343e1342019-06-07 10:36:24 +0200131
132 /* Disable USB2 PHY SUS Well Power Gating */
133 Store (Zero, ^UPSW)
134
135 /*
136 * Apply USB2 PHPY Power Gating workaround if needed.
137 */
138 If (^^PMC.UWAB) {
139 /* Write to MTPMC to have PMC disable power gating */
140 Store (1, ^^PMC.MPMC)
141
142 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
143 Store (10, Local0)
144 While (^^PMC.PMFS) {
145 If (LNot (Local0)) {
146 Break
147 }
148 Decrement (Local0)
149 Sleep (10)
150 }
151 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700152 }
153 }
Lee Leahyb0005132015-05-12 18:19:47 -0700154 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700155
Lee Leahyb0005132015-05-12 18:19:47 -0700156 Method (_PS3, 0, Serialized)
157 {
Christian Walter343e1342019-06-07 10:36:24 +0200158 If (!LEqual (^DVID, 0xFFFF)) {
159 If (!LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700160
Christian Walter343e1342019-06-07 10:36:24 +0200161 /* Clear PME Status */
162 Store (1, ^PMES)
Duncan Lauriee32da952015-08-27 17:09:02 -0700163
Christian Walter343e1342019-06-07 10:36:24 +0200164 /* Enable PME */
165 Store (1, ^PMEE)
Duncan Lauriee32da952015-08-27 17:09:02 -0700166
Christian Walter343e1342019-06-07 10:36:24 +0200167 /* If device is in D3, set back to D0 */
168 If (LEqual (^D0D3, 3)) {
169 Store (Zero, Local0)
170 Store (Local0, ^D0D3)
171 Store (^D0D3, Local0)
Duncan Lauriee32da952015-08-27 17:09:02 -0700172 }
Christian Walter343e1342019-06-07 10:36:24 +0200173
174 /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */
175 Store (3, ^UPSW)
176
177 /* Enable d3hot and SS link trunk clock gating */
178 Store(One, ^D3HE)
179 Store(One, ^STGE)
180
181 /* Now put device in D3 */
182 Store (3, Local0)
183 Store (Local0, ^D0D3)
184 Store (^D0D3, Local0)
185
186 /*
187 * Apply USB2 PHPY Power Gating workaround if needed.
188 * This code assumes XDCI is disabled, if it is enabled
189 * then this must also check if it is in D3 state too.
190 */
191 If (^^PMC.UWAB) {
192 /* Write to MTPMC to have PMC enable power gating */
193 Store (3, ^^PMC.MPMC)
194
195 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
196 Store (10, Local0)
197 While (^^PMC.PMFS) {
198 If (LNot (Local0)) {
199 Break
200 }
201 Decrement (Local0)
202 Sleep (10)
203 }
204 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700205 }
206 }
Lee Leahyb0005132015-05-12 18:19:47 -0700207 }
208
Duncan Lauriee32da952015-08-27 17:09:02 -0700209 /* Root Hub for Skylake-LP PCH */
210 Device (RHUB)
211 {
212 Name (_ADR, Zero)
Lee Leahyb0005132015-05-12 18:19:47 -0700213
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500214 // GPLD: Generate Port Location Data (PLD)
215 Method (GPLD, 1, Serialized)
216 {
217
218 Name (PCKG, Package (0x01)
219 {
220 Buffer (0x10) {}
221 })
222
223 // REV: Revision 0x02 for ACPI 5.0
224 CreateField (DerefOf (Index (PCKG, Zero)), Zero, 0x07, REV)
225 Store (0x02, REV)
226
227 // VISI: Port visibility to user per port
228 CreateField (DerefOf (Index (PCKG, Zero)), 0x40, One, VISI)
229 Store (Arg0, VISI)
230
231 Return (PCKG)
232 }
233
Duncan Lauriee32da952015-08-27 17:09:02 -0700234 /* USB2 */
235 Device (HS01) { Name (_ADR, 1) }
236 Device (HS02) { Name (_ADR, 2) }
237 Device (HS03) { Name (_ADR, 3) }
238 Device (HS04) { Name (_ADR, 4) }
239 Device (HS05) { Name (_ADR, 5) }
240 Device (HS06) { Name (_ADR, 6) }
241 Device (HS07) { Name (_ADR, 7) }
242 Device (HS08) { Name (_ADR, 8) }
243 Device (HS09) { Name (_ADR, 9) }
244 Device (HS10) { Name (_ADR, 10) }
Lee Leahyb0005132015-05-12 18:19:47 -0700245
Duncan Lauriee32da952015-08-27 17:09:02 -0700246 /* USBr */
247 Device (USR1) { Name (_ADR, 11) }
248 Device (USR2) { Name (_ADR, 12) }
Lee Leahyb0005132015-05-12 18:19:47 -0700249
Duncan Lauriee32da952015-08-27 17:09:02 -0700250 /* USB3 */
251 Device (SS01) { Name (_ADR, 13) }
252 Device (SS02) { Name (_ADR, 14) }
253 Device (SS03) { Name (_ADR, 15) }
254 Device (SS04) { Name (_ADR, 16) }
255 Device (SS05) { Name (_ADR, 17) }
256 Device (SS06) { Name (_ADR, 18) }
Lee Leahyb0005132015-05-12 18:19:47 -0700257 }
258}