blob: 2f5d8b220022e1f4befd5944c0260938a1b5d82c [file] [log] [blame]
Angel Pons3bd1e3d2020-04-05 15:47:17 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahyb0005132015-05-12 18:19:47 -07002
Edward O'Callaghaned310242020-06-30 13:39:01 +10003#define PORTSCN_OFFSET 0x480
4#define PORTSCXUSB3_OFFSET 0x540
5
6#define WAKE_ON_CONNECT_DISCONNECT_ENABLE 0x6000000
7#define RO_BITS_OFF_MASK ~0x80FE0012
8
Furquan Shaikh3bfe3402016-10-18 14:25:25 -07009/*
10 * USB Port Wake Enable (UPWE) on usb attach/detach
11 * Arg0 - Port Number
12 * Arg1 - Port 1 Status and control offset
13 * Arg2 - xHCI Memory-mapped address
14 */
15Method (UPWE, 3, Serialized)
16{
Edward O'Callaghaned310242020-06-30 13:39:01 +100017 Local0 = Arg1 + ((Arg0 - 1) * 0x10)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070018
19 /* Map ((XMEM << 16) + Local0 in PSCR */
20 OperationRegion (PSCR, SystemMemory,
21 Add (ShiftLeft (Arg2, 16), Local0), 0x10)
Kane Chenc3892c82018-02-23 10:11:27 +080022 Field (PSCR, DWordAcc, NoLock, Preserve)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070023 {
Kane Chenc3892c82018-02-23 10:11:27 +080024 PSCT, 32,
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070025 }
Edward O'Callaghaned310242020-06-30 13:39:01 +100026 Local0 = PSCT
Kane Chenc3892c82018-02-23 10:11:27 +080027 /*
28 * And port status/control reg with RO and RWS bits
29 * RO bits: 0, 2:3, 10:13, 24, 28:30
30 * RWS bits: 5:9, 14:16, 25:27
31 */
Edward O'Callaghaned310242020-06-30 13:39:01 +100032 Local0 = Local0 & RO_BITS_OFF_MASK
Kane Chenc3892c82018-02-23 10:11:27 +080033 /* Set WCE and WDE bits */
Edward O'Callaghaned310242020-06-30 13:39:01 +100034 Local0 = Local0 | WAKE_ON_CONNECT_DISCONNECT_ENABLE
35 PSCT = Local0
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070036}
37
38/*
39 * USB Wake Enable Setup (UWES)
40 * Arg0 - Port enable bitmap
41 * Arg1 - Port 1 Status and control offset
42 * Arg2 - xHCI Memory-mapped address
43 */
44Method (UWES, 3, Serialized)
45{
Edward O'Callaghaned310242020-06-30 13:39:01 +100046 Local0 = Arg0
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070047
48 While (One) {
49 FindSetRightBit (Local0, Local1)
Edward O'Callaghaned310242020-06-30 13:39:01 +100050 If (Local1 == Zero) {
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070051 Break
52 }
53 UPWE (Local1, Arg1, Arg2)
54 /*
55 * Clear the lowest set bit in Local0 since it was
56 * processed.
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070057 */
Edward O'Callaghaned310242020-06-30 13:39:01 +100058 Local0 = Local0 & (Local0 - 1)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070059 }
60}
61
Lee Leahy1d14b3e2015-05-12 18:23:27 -070062/* XHCI Controller 0:14.0 */
Lee Leahyb0005132015-05-12 18:19:47 -070063
64Device (XHCI)
65{
66 Name (_ADR, 0x00140000)
67
Duncan Lauriee32da952015-08-27 17:09:02 -070068 Name (_PRW, Package () { GPE0_PME_B0, 3 })
69
70 Method (_DSW, 3)
71 {
Edward O'Callaghaned310242020-06-30 13:39:01 +100072 PMEE = Arg0
73 UWES ((\U2WE & 0x3FF), PORTSCN_OFFSET, XMEM)
74 UWES ((\U3WE & 0x3F ), PORTSCXUSB3_OFFSET, XMEM)
Duncan Lauriee32da952015-08-27 17:09:02 -070075 }
76
77 Name (_S3D, 3) /* D3 supported in S3 */
78 Name (_S4D, 3) /* D3 supported in S4 */
79 Name (_S0W, 3) /* D3 can wake device in S0 */
80 Name (_S3W, 3) /* D3 can wake system from S3 */
81 Name (_S4W, 3) /* D3 can wake system from S4 */
Lee Leahyb0005132015-05-12 18:19:47 -070082
83 OperationRegion (XPRT, PCI_Config, 0x00, 0x100)
84 Field (XPRT, AnyAcc, NoLock, Preserve)
85 {
86 Offset (0x0),
Duncan Lauriee32da952015-08-27 17:09:02 -070087 DVID, 16, /* VENDORID */
Lee Leahyb0005132015-05-12 18:19:47 -070088 Offset (0x10),
89 , 16,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070090 XMEM, 16, /* MEM_BASE */
Naresh G Solankifb793792017-03-16 15:30:25 +053091 Offset (0x50), /* XHCLKGTEN */
92 , 2,
93 STGE, 1, /* SS Link Trunk clock gating enable */
Lee Leahyb0005132015-05-12 18:19:47 -070094 Offset (0x74),
Duncan Lauriee32da952015-08-27 17:09:02 -070095 D0D3, 2, /* POWERSTATE */
Lee Leahyb0005132015-05-12 18:19:47 -070096 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070097 PMEE, 1, /* PME_EN */
Lee Leahyb0005132015-05-12 18:19:47 -070098 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070099 PMES, 1, /* PME_STS */
Naresh G Solankifb793792017-03-16 15:30:25 +0530100 Offset (0xA2),
101 , 2,
102 D3HE, 1, /* D3_hot_en */
Lee Leahyb0005132015-05-12 18:19:47 -0700103 }
104
Duncan Lauriee32da952015-08-27 17:09:02 -0700105 OperationRegion (XREG, SystemMemory,
106 Add (ShiftLeft (XMEM, 16), 0x8000), 0x200)
107 Field (XREG, DWordAcc, Lock, Preserve)
Lee Leahyb0005132015-05-12 18:19:47 -0700108 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700109 Offset (0x1c4), /* USB2PMCTRL */
110 , 2,
111 UPSW, 2, /* U2PSUSPGP */
Lee Leahyb0005132015-05-12 18:19:47 -0700112 }
113
Duncan Lauriee32da952015-08-27 17:09:02 -0700114 Method (_PSC, 0, Serialized)
Lee Leahyb0005132015-05-12 18:19:47 -0700115 {
116 Return (^D0D3)
117 }
118
119 Method (_PS0, 0, Serialized)
120 {
Christian Walter343e1342019-06-07 10:36:24 +0200121 If (!LEqual (^DVID, 0xFFFF)) {
122 If (!LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700123
Christian Walter343e1342019-06-07 10:36:24 +0200124 /* Disable d3hot and SS link trunk clock gating */
125 Store(Zero, ^D3HE)
126 Store(Zero, ^STGE)
Naresh G Solankifb793792017-03-16 15:30:25 +0530127
Christian Walter343e1342019-06-07 10:36:24 +0200128 /* If device is in D3, set back to D0 */
129 If (LEqual (^D0D3, 3)) {
130 Store (Zero, Local0)
131 Store (Local0, ^D0D3)
132 Store (^D0D3, Local0)
Duncan Lauriee32da952015-08-27 17:09:02 -0700133 }
Christian Walter343e1342019-06-07 10:36:24 +0200134
135 /* Disable USB2 PHY SUS Well Power Gating */
136 Store (Zero, ^UPSW)
137
138 /*
139 * Apply USB2 PHPY Power Gating workaround if needed.
140 */
141 If (^^PMC.UWAB) {
142 /* Write to MTPMC to have PMC disable power gating */
143 Store (1, ^^PMC.MPMC)
144
145 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
146 Store (10, Local0)
147 While (^^PMC.PMFS) {
148 If (LNot (Local0)) {
149 Break
150 }
151 Decrement (Local0)
152 Sleep (10)
153 }
154 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700155 }
156 }
Lee Leahyb0005132015-05-12 18:19:47 -0700157 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700158
Lee Leahyb0005132015-05-12 18:19:47 -0700159 Method (_PS3, 0, Serialized)
160 {
Christian Walter343e1342019-06-07 10:36:24 +0200161 If (!LEqual (^DVID, 0xFFFF)) {
162 If (!LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700163
Christian Walter343e1342019-06-07 10:36:24 +0200164 /* Clear PME Status */
165 Store (1, ^PMES)
Duncan Lauriee32da952015-08-27 17:09:02 -0700166
Christian Walter343e1342019-06-07 10:36:24 +0200167 /* Enable PME */
168 Store (1, ^PMEE)
Duncan Lauriee32da952015-08-27 17:09:02 -0700169
Christian Walter343e1342019-06-07 10:36:24 +0200170 /* If device is in D3, set back to D0 */
171 If (LEqual (^D0D3, 3)) {
172 Store (Zero, Local0)
173 Store (Local0, ^D0D3)
174 Store (^D0D3, Local0)
Duncan Lauriee32da952015-08-27 17:09:02 -0700175 }
Christian Walter343e1342019-06-07 10:36:24 +0200176
177 /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */
178 Store (3, ^UPSW)
179
180 /* Enable d3hot and SS link trunk clock gating */
181 Store(One, ^D3HE)
182 Store(One, ^STGE)
183
184 /* Now put device in D3 */
185 Store (3, Local0)
186 Store (Local0, ^D0D3)
187 Store (^D0D3, Local0)
188
189 /*
190 * Apply USB2 PHPY Power Gating workaround if needed.
191 * This code assumes XDCI is disabled, if it is enabled
192 * then this must also check if it is in D3 state too.
193 */
194 If (^^PMC.UWAB) {
195 /* Write to MTPMC to have PMC enable power gating */
196 Store (3, ^^PMC.MPMC)
197
198 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
199 Store (10, Local0)
200 While (^^PMC.PMFS) {
201 If (LNot (Local0)) {
202 Break
203 }
204 Decrement (Local0)
205 Sleep (10)
206 }
207 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700208 }
209 }
Lee Leahyb0005132015-05-12 18:19:47 -0700210 }
211
Duncan Lauriee32da952015-08-27 17:09:02 -0700212 /* Root Hub for Skylake-LP PCH */
213 Device (RHUB)
214 {
215 Name (_ADR, Zero)
Lee Leahyb0005132015-05-12 18:19:47 -0700216
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500217 // GPLD: Generate Port Location Data (PLD)
218 Method (GPLD, 1, Serialized)
219 {
220
221 Name (PCKG, Package (0x01)
222 {
223 Buffer (0x10) {}
224 })
225
226 // REV: Revision 0x02 for ACPI 5.0
227 CreateField (DerefOf (Index (PCKG, Zero)), Zero, 0x07, REV)
Edward O'Callaghaned310242020-06-30 13:39:01 +1000228 REV = 0x02
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500229
230 // VISI: Port visibility to user per port
231 CreateField (DerefOf (Index (PCKG, Zero)), 0x40, One, VISI)
Edward O'Callaghaned310242020-06-30 13:39:01 +1000232 VISI = Arg0
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500233
234 Return (PCKG)
235 }
236
Duncan Lauriee32da952015-08-27 17:09:02 -0700237 /* USB2 */
238 Device (HS01) { Name (_ADR, 1) }
239 Device (HS02) { Name (_ADR, 2) }
240 Device (HS03) { Name (_ADR, 3) }
241 Device (HS04) { Name (_ADR, 4) }
242 Device (HS05) { Name (_ADR, 5) }
243 Device (HS06) { Name (_ADR, 6) }
244 Device (HS07) { Name (_ADR, 7) }
245 Device (HS08) { Name (_ADR, 8) }
246 Device (HS09) { Name (_ADR, 9) }
247 Device (HS10) { Name (_ADR, 10) }
Lee Leahyb0005132015-05-12 18:19:47 -0700248
Duncan Lauriee32da952015-08-27 17:09:02 -0700249 /* USBr */
250 Device (USR1) { Name (_ADR, 11) }
251 Device (USR2) { Name (_ADR, 12) }
Lee Leahyb0005132015-05-12 18:19:47 -0700252
Duncan Lauriee32da952015-08-27 17:09:02 -0700253 /* USB3 */
254 Device (SS01) { Name (_ADR, 13) }
255 Device (SS02) { Name (_ADR, 14) }
256 Device (SS03) { Name (_ADR, 15) }
257 Device (SS04) { Name (_ADR, 16) }
258 Device (SS05) { Name (_ADR, 17) }
259 Device (SS06) { Name (_ADR, 18) }
Lee Leahyb0005132015-05-12 18:19:47 -0700260 }
261}