blob: e8c5ebf27e31849dc627cfd3515a8f29618702ad [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 */
Felix Singer372573e2022-12-16 03:49:55 +010020 OperationRegion (PSCR, SystemMemory, (Arg2 << 16) + Local0, 0x10)
Kane Chenc3892c82018-02-23 10:11:27 +080021 Field (PSCR, DWordAcc, NoLock, Preserve)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070022 {
Kane Chenc3892c82018-02-23 10:11:27 +080023 PSCT, 32,
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070024 }
Edward O'Callaghaned310242020-06-30 13:39:01 +100025 Local0 = PSCT
Kane Chenc3892c82018-02-23 10:11:27 +080026 /*
27 * And port status/control reg with RO and RWS bits
28 * RO bits: 0, 2:3, 10:13, 24, 28:30
29 * RWS bits: 5:9, 14:16, 25:27
30 */
Edward O'Callaghaned310242020-06-30 13:39:01 +100031 Local0 = Local0 & RO_BITS_OFF_MASK
Kane Chenc3892c82018-02-23 10:11:27 +080032 /* Set WCE and WDE bits */
Edward O'Callaghaned310242020-06-30 13:39:01 +100033 Local0 = Local0 | WAKE_ON_CONNECT_DISCONNECT_ENABLE
34 PSCT = Local0
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070035}
36
37/*
38 * USB Wake Enable Setup (UWES)
39 * Arg0 - Port enable bitmap
40 * Arg1 - Port 1 Status and control offset
41 * Arg2 - xHCI Memory-mapped address
42 */
43Method (UWES, 3, Serialized)
44{
Edward O'Callaghaned310242020-06-30 13:39:01 +100045 Local0 = Arg0
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070046
Felix Singer7b8ac002022-12-26 08:45:56 +010047 While (1) {
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070048 FindSetRightBit (Local0, Local1)
Felix Singer9df60d32022-12-26 09:43:07 +010049 If (Local1 == 0) {
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070050 Break
51 }
52 UPWE (Local1, Arg1, Arg2)
53 /*
54 * Clear the lowest set bit in Local0 since it was
55 * processed.
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070056 */
Edward O'Callaghaned310242020-06-30 13:39:01 +100057 Local0 = Local0 & (Local0 - 1)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070058 }
59}
60
Lee Leahy1d14b3e2015-05-12 18:23:27 -070061/* XHCI Controller 0:14.0 */
Lee Leahyb0005132015-05-12 18:19:47 -070062
63Device (XHCI)
64{
65 Name (_ADR, 0x00140000)
66
Duncan Lauriee32da952015-08-27 17:09:02 -070067 Name (_PRW, Package () { GPE0_PME_B0, 3 })
68
69 Method (_DSW, 3)
70 {
Edward O'Callaghaned310242020-06-30 13:39:01 +100071 PMEE = Arg0
72 UWES ((\U2WE & 0x3FF), PORTSCN_OFFSET, XMEM)
73 UWES ((\U3WE & 0x3F ), PORTSCXUSB3_OFFSET, XMEM)
Duncan Lauriee32da952015-08-27 17:09:02 -070074 }
75
76 Name (_S3D, 3) /* D3 supported in S3 */
77 Name (_S4D, 3) /* D3 supported in S4 */
78 Name (_S0W, 3) /* D3 can wake device in S0 */
79 Name (_S3W, 3) /* D3 can wake system from S3 */
80 Name (_S4W, 3) /* D3 can wake system from S4 */
Lee Leahyb0005132015-05-12 18:19:47 -070081
82 OperationRegion (XPRT, PCI_Config, 0x00, 0x100)
83 Field (XPRT, AnyAcc, NoLock, Preserve)
84 {
Duncan Lauriee32da952015-08-27 17:09:02 -070085 DVID, 16, /* VENDORID */
Lee Leahyb0005132015-05-12 18:19:47 -070086 Offset (0x10),
87 , 16,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070088 XMEM, 16, /* MEM_BASE */
Naresh G Solankifb793792017-03-16 15:30:25 +053089 Offset (0x50), /* XHCLKGTEN */
90 , 2,
91 STGE, 1, /* SS Link Trunk clock gating enable */
Lee Leahyb0005132015-05-12 18:19:47 -070092 Offset (0x74),
Duncan Lauriee32da952015-08-27 17:09:02 -070093 D0D3, 2, /* POWERSTATE */
Lee Leahyb0005132015-05-12 18:19:47 -070094 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070095 PMEE, 1, /* PME_EN */
Lee Leahyb0005132015-05-12 18:19:47 -070096 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070097 PMES, 1, /* PME_STS */
Naresh G Solankifb793792017-03-16 15:30:25 +053098 Offset (0xA2),
99 , 2,
100 D3HE, 1, /* D3_hot_en */
Lee Leahyb0005132015-05-12 18:19:47 -0700101 }
102
Felix Singer372573e2022-12-16 03:49:55 +0100103 OperationRegion (XREG, SystemMemory, (XMEM << 16) + 0x8000, 0x200)
Duncan Lauriee32da952015-08-27 17:09:02 -0700104 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 {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200118 If (^DVID != 0xFFFF) {
119 If (!((^XMEM == 0xFFFF) || (^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 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200122 ^D3HE = 0
123 ^STGE = 0
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 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200126 If (^D0D3 == 3) {
127 Local0 = 0
128 ^D0D3 = Local0
129 Local0 = ^D0D3
Duncan Lauriee32da952015-08-27 17:09:02 -0700130 }
Christian Walter343e1342019-06-07 10:36:24 +0200131
132 /* Disable USB2 PHY SUS Well Power Gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200133 ^UPSW = 0
Christian Walter343e1342019-06-07 10:36:24 +0200134
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 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200140 ^^PMC.MPMC = 1
Christian Walter343e1342019-06-07 10:36:24 +0200141
142 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200143 Local0 = 10
Christian Walter343e1342019-06-07 10:36:24 +0200144 While (^^PMC.PMFS) {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200145 If (!Local0) {
Christian Walter343e1342019-06-07 10:36:24 +0200146 Break
147 }
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200148 Local0--
Christian Walter343e1342019-06-07 10:36:24 +0200149 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 {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200158 If (^DVID != 0xFFFF) {
159 If (!((^XMEM == 0xFFFF) || (^XMEM == 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700160
Christian Walter343e1342019-06-07 10:36:24 +0200161 /* Clear PME Status */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200162 ^PMES = 1
Duncan Lauriee32da952015-08-27 17:09:02 -0700163
Christian Walter343e1342019-06-07 10:36:24 +0200164 /* Enable PME */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200165 ^PMEE= 1
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 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200168 If (^D0D3 == 3) {
169 Local0 = 0
170 ^D0D3 = Local0
171 Local0 = ^D0D3
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 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200175 ^UPSW = 3
Christian Walter343e1342019-06-07 10:36:24 +0200176
177 /* Enable d3hot and SS link trunk clock gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200178 ^D3HE = 1
179 ^STGE = 1
Christian Walter343e1342019-06-07 10:36:24 +0200180
181 /* Now put device in D3 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200182 Local0 = 3
183 ^D0D3 = Local0
184 Local0 = ^D0D3
Christian Walter343e1342019-06-07 10:36:24 +0200185
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 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200193 ^^PMC.MPMC = 3
Christian Walter343e1342019-06-07 10:36:24 +0200194
195 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200196 Local0 = 10
Christian Walter343e1342019-06-07 10:36:24 +0200197 While (^^PMC.PMFS) {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200198 If (!Local0) {
Christian Walter343e1342019-06-07 10:36:24 +0200199 Break
200 }
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200201 Local0--
Christian Walter343e1342019-06-07 10:36:24 +0200202 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 {
Felix Singer9df60d32022-12-26 09:43:07 +0100212 Name (_ADR, 0)
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
Felix Singer9df60d32022-12-26 09:43:07 +0100224 CreateField (DerefOf (PCKG[0]), 0, 0x07, REV)
Edward O'Callaghaned310242020-06-30 13:39:01 +1000225 REV = 0x02
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500226
227 // VISI: Port visibility to user per port
Felix Singer7b8ac002022-12-26 08:45:56 +0100228 CreateField (DerefOf (PCKG[0]), 0x40, 1, VISI)
Edward O'Callaghaned310242020-06-30 13:39:01 +1000229 VISI = Arg0
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500230
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}