blob: 734539b76287ac0dbd1bfb6641ecac8599437ca0 [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 {
Duncan Lauriee32da952015-08-27 17:09:02 -070086 DVID, 16, /* VENDORID */
Lee Leahyb0005132015-05-12 18:19:47 -070087 Offset (0x10),
88 , 16,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070089 XMEM, 16, /* MEM_BASE */
Naresh G Solankifb793792017-03-16 15:30:25 +053090 Offset (0x50), /* XHCLKGTEN */
91 , 2,
92 STGE, 1, /* SS Link Trunk clock gating enable */
Lee Leahyb0005132015-05-12 18:19:47 -070093 Offset (0x74),
Duncan Lauriee32da952015-08-27 17:09:02 -070094 D0D3, 2, /* POWERSTATE */
Lee Leahyb0005132015-05-12 18:19:47 -070095 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070096 PMEE, 1, /* PME_EN */
Lee Leahyb0005132015-05-12 18:19:47 -070097 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070098 PMES, 1, /* PME_STS */
Naresh G Solankifb793792017-03-16 15:30:25 +053099 Offset (0xA2),
100 , 2,
101 D3HE, 1, /* D3_hot_en */
Lee Leahyb0005132015-05-12 18:19:47 -0700102 }
103
Duncan Lauriee32da952015-08-27 17:09:02 -0700104 OperationRegion (XREG, SystemMemory,
105 Add (ShiftLeft (XMEM, 16), 0x8000), 0x200)
106 Field (XREG, DWordAcc, Lock, Preserve)
Lee Leahyb0005132015-05-12 18:19:47 -0700107 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700108 Offset (0x1c4), /* USB2PMCTRL */
109 , 2,
110 UPSW, 2, /* U2PSUSPGP */
Lee Leahyb0005132015-05-12 18:19:47 -0700111 }
112
Duncan Lauriee32da952015-08-27 17:09:02 -0700113 Method (_PSC, 0, Serialized)
Lee Leahyb0005132015-05-12 18:19:47 -0700114 {
115 Return (^D0D3)
116 }
117
118 Method (_PS0, 0, Serialized)
119 {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200120 If (^DVID != 0xFFFF) {
121 If (!((^XMEM == 0xFFFF) || (^XMEM == 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700122
Christian Walter343e1342019-06-07 10:36:24 +0200123 /* Disable d3hot and SS link trunk clock gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200124 ^D3HE = 0
125 ^STGE = 0
Naresh G Solankifb793792017-03-16 15:30:25 +0530126
Christian Walter343e1342019-06-07 10:36:24 +0200127 /* If device is in D3, set back to D0 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200128 If (^D0D3 == 3) {
129 Local0 = 0
130 ^D0D3 = Local0
131 Local0 = ^D0D3
Duncan Lauriee32da952015-08-27 17:09:02 -0700132 }
Christian Walter343e1342019-06-07 10:36:24 +0200133
134 /* Disable USB2 PHY SUS Well Power Gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200135 ^UPSW = 0
Christian Walter343e1342019-06-07 10:36:24 +0200136
137 /*
138 * Apply USB2 PHPY Power Gating workaround if needed.
139 */
140 If (^^PMC.UWAB) {
141 /* Write to MTPMC to have PMC disable power gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200142 ^^PMC.MPMC = 1
Christian Walter343e1342019-06-07 10:36:24 +0200143
144 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200145 Local0 = 10
Christian Walter343e1342019-06-07 10:36:24 +0200146 While (^^PMC.PMFS) {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200147 If (!Local0) {
Christian Walter343e1342019-06-07 10:36:24 +0200148 Break
149 }
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200150 Local0--
Christian Walter343e1342019-06-07 10:36:24 +0200151 Sleep (10)
152 }
153 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700154 }
155 }
Lee Leahyb0005132015-05-12 18:19:47 -0700156 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700157
Lee Leahyb0005132015-05-12 18:19:47 -0700158 Method (_PS3, 0, Serialized)
159 {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200160 If (^DVID != 0xFFFF) {
161 If (!((^XMEM == 0xFFFF) || (^XMEM == 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700162
Christian Walter343e1342019-06-07 10:36:24 +0200163 /* Clear PME Status */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200164 ^PMES = 1
Duncan Lauriee32da952015-08-27 17:09:02 -0700165
Christian Walter343e1342019-06-07 10:36:24 +0200166 /* Enable PME */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200167 ^PMEE= 1
Duncan Lauriee32da952015-08-27 17:09:02 -0700168
Christian Walter343e1342019-06-07 10:36:24 +0200169 /* If device is in D3, set back to D0 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200170 If (^D0D3 == 3) {
171 Local0 = 0
172 ^D0D3 = Local0
173 Local0 = ^D0D3
Duncan Lauriee32da952015-08-27 17:09:02 -0700174 }
Christian Walter343e1342019-06-07 10:36:24 +0200175
176 /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200177 ^UPSW = 3
Christian Walter343e1342019-06-07 10:36:24 +0200178
179 /* Enable d3hot and SS link trunk clock gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200180 ^D3HE = 1
181 ^STGE = 1
Christian Walter343e1342019-06-07 10:36:24 +0200182
183 /* Now put device in D3 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200184 Local0 = 3
185 ^D0D3 = Local0
186 Local0 = ^D0D3
Christian Walter343e1342019-06-07 10:36:24 +0200187
188 /*
189 * Apply USB2 PHPY Power Gating workaround if needed.
190 * This code assumes XDCI is disabled, if it is enabled
191 * then this must also check if it is in D3 state too.
192 */
193 If (^^PMC.UWAB) {
194 /* Write to MTPMC to have PMC enable power gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200195 ^^PMC.MPMC = 3
Christian Walter343e1342019-06-07 10:36:24 +0200196
197 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200198 Local0 = 10
Christian Walter343e1342019-06-07 10:36:24 +0200199 While (^^PMC.PMFS) {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200200 If (!Local0) {
Christian Walter343e1342019-06-07 10:36:24 +0200201 Break
202 }
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200203 Local0--
Christian Walter343e1342019-06-07 10:36:24 +0200204 Sleep (10)
205 }
206 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700207 }
208 }
Lee Leahyb0005132015-05-12 18:19:47 -0700209 }
210
Duncan Lauriee32da952015-08-27 17:09:02 -0700211 /* Root Hub for Skylake-LP PCH */
212 Device (RHUB)
213 {
214 Name (_ADR, Zero)
Lee Leahyb0005132015-05-12 18:19:47 -0700215
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500216 // GPLD: Generate Port Location Data (PLD)
217 Method (GPLD, 1, Serialized)
218 {
219
220 Name (PCKG, Package (0x01)
221 {
222 Buffer (0x10) {}
223 })
224
225 // REV: Revision 0x02 for ACPI 5.0
226 CreateField (DerefOf (Index (PCKG, Zero)), Zero, 0x07, REV)
Edward O'Callaghaned310242020-06-30 13:39:01 +1000227 REV = 0x02
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500228
229 // VISI: Port visibility to user per port
230 CreateField (DerefOf (Index (PCKG, Zero)), 0x40, One, VISI)
Edward O'Callaghaned310242020-06-30 13:39:01 +1000231 VISI = Arg0
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500232
233 Return (PCKG)
234 }
235
Duncan Lauriee32da952015-08-27 17:09:02 -0700236 /* USB2 */
237 Device (HS01) { Name (_ADR, 1) }
238 Device (HS02) { Name (_ADR, 2) }
239 Device (HS03) { Name (_ADR, 3) }
240 Device (HS04) { Name (_ADR, 4) }
241 Device (HS05) { Name (_ADR, 5) }
242 Device (HS06) { Name (_ADR, 6) }
243 Device (HS07) { Name (_ADR, 7) }
244 Device (HS08) { Name (_ADR, 8) }
245 Device (HS09) { Name (_ADR, 9) }
246 Device (HS10) { Name (_ADR, 10) }
Lee Leahyb0005132015-05-12 18:19:47 -0700247
Duncan Lauriee32da952015-08-27 17:09:02 -0700248 /* USBr */
249 Device (USR1) { Name (_ADR, 11) }
250 Device (USR2) { Name (_ADR, 12) }
Lee Leahyb0005132015-05-12 18:19:47 -0700251
Duncan Lauriee32da952015-08-27 17:09:02 -0700252 /* USB3 */
253 Device (SS01) { Name (_ADR, 13) }
254 Device (SS02) { Name (_ADR, 14) }
255 Device (SS03) { Name (_ADR, 15) }
256 Device (SS04) { Name (_ADR, 16) }
257 Device (SS05) { Name (_ADR, 17) }
258 Device (SS06) { Name (_ADR, 18) }
Lee Leahyb0005132015-05-12 18:19:47 -0700259 }
260}