blob: bfe6c6df7737cd8e98592ba9ed375cafc7396c77 [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
Subrata Banik36ca7b32023-03-23 14:48:53 +05303#include <intelblocks/xhci.h>
Edward O'Callaghaned310242020-06-30 13:39:01 +10004
Reka Normana5215c42023-09-22 15:26:54 +10005/* Include UWES method for enabling USB wake */
6#include <soc/intel/common/acpi/xhci_wake.asl>
Furquan Shaikh3bfe3402016-10-18 14:25:25 -07007
Lee Leahy1d14b3e2015-05-12 18:23:27 -07008/* XHCI Controller 0:14.0 */
Lee Leahyb0005132015-05-12 18:19:47 -07009
10Device (XHCI)
11{
12 Name (_ADR, 0x00140000)
13
Duncan Lauriee32da952015-08-27 17:09:02 -070014 Name (_PRW, Package () { GPE0_PME_B0, 3 })
15
16 Method (_DSW, 3)
17 {
Edward O'Callaghaned310242020-06-30 13:39:01 +100018 PMEE = Arg0
19 UWES ((\U2WE & 0x3FF), PORTSCN_OFFSET, XMEM)
20 UWES ((\U3WE & 0x3F ), PORTSCXUSB3_OFFSET, XMEM)
Duncan Lauriee32da952015-08-27 17:09:02 -070021 }
22
23 Name (_S3D, 3) /* D3 supported in S3 */
24 Name (_S4D, 3) /* D3 supported in S4 */
25 Name (_S0W, 3) /* D3 can wake device in S0 */
26 Name (_S3W, 3) /* D3 can wake system from S3 */
27 Name (_S4W, 3) /* D3 can wake system from S4 */
Lee Leahyb0005132015-05-12 18:19:47 -070028
29 OperationRegion (XPRT, PCI_Config, 0x00, 0x100)
30 Field (XPRT, AnyAcc, NoLock, Preserve)
31 {
Duncan Lauriee32da952015-08-27 17:09:02 -070032 DVID, 16, /* VENDORID */
Lee Leahyb0005132015-05-12 18:19:47 -070033 Offset (0x10),
34 , 16,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070035 XMEM, 16, /* MEM_BASE */
Naresh G Solankifb793792017-03-16 15:30:25 +053036 Offset (0x50), /* XHCLKGTEN */
37 , 2,
38 STGE, 1, /* SS Link Trunk clock gating enable */
Lee Leahyb0005132015-05-12 18:19:47 -070039 Offset (0x74),
Duncan Lauriee32da952015-08-27 17:09:02 -070040 D0D3, 2, /* POWERSTATE */
Lee Leahyb0005132015-05-12 18:19:47 -070041 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070042 PMEE, 1, /* PME_EN */
Lee Leahyb0005132015-05-12 18:19:47 -070043 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070044 PMES, 1, /* PME_STS */
Naresh G Solankifb793792017-03-16 15:30:25 +053045 Offset (0xA2),
46 , 2,
47 D3HE, 1, /* D3_hot_en */
Lee Leahyb0005132015-05-12 18:19:47 -070048 }
49
Felix Singer372573e2022-12-16 03:49:55 +010050 OperationRegion (XREG, SystemMemory, (XMEM << 16) + 0x8000, 0x200)
Duncan Lauriee32da952015-08-27 17:09:02 -070051 Field (XREG, DWordAcc, Lock, Preserve)
Lee Leahyb0005132015-05-12 18:19:47 -070052 {
Duncan Lauriee32da952015-08-27 17:09:02 -070053 Offset (0x1c4), /* USB2PMCTRL */
54 , 2,
55 UPSW, 2, /* U2PSUSPGP */
Lee Leahyb0005132015-05-12 18:19:47 -070056 }
57
Duncan Lauriee32da952015-08-27 17:09:02 -070058 Method (_PSC, 0, Serialized)
Lee Leahyb0005132015-05-12 18:19:47 -070059 {
60 Return (^D0D3)
61 }
62
63 Method (_PS0, 0, Serialized)
64 {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +020065 If (^DVID != 0xFFFF) {
66 If (!((^XMEM == 0xFFFF) || (^XMEM == 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -070067
Christian Walter343e1342019-06-07 10:36:24 +020068 /* Disable d3hot and SS link trunk clock gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +020069 ^D3HE = 0
70 ^STGE = 0
Naresh G Solankifb793792017-03-16 15:30:25 +053071
Christian Walter343e1342019-06-07 10:36:24 +020072 /* If device is in D3, set back to D0 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +020073 If (^D0D3 == 3) {
74 Local0 = 0
75 ^D0D3 = Local0
76 Local0 = ^D0D3
Duncan Lauriee32da952015-08-27 17:09:02 -070077 }
Christian Walter343e1342019-06-07 10:36:24 +020078
79 /* Disable USB2 PHY SUS Well Power Gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +020080 ^UPSW = 0
Christian Walter343e1342019-06-07 10:36:24 +020081
82 /*
83 * Apply USB2 PHPY Power Gating workaround if needed.
84 */
85 If (^^PMC.UWAB) {
86 /* Write to MTPMC to have PMC disable power gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +020087 ^^PMC.MPMC = 1
Christian Walter343e1342019-06-07 10:36:24 +020088
89 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +020090 Local0 = 10
Christian Walter343e1342019-06-07 10:36:24 +020091 While (^^PMC.PMFS) {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +020092 If (!Local0) {
Christian Walter343e1342019-06-07 10:36:24 +020093 Break
94 }
Elyes HAOUASfc29afb2020-10-09 15:05:28 +020095 Local0--
Christian Walter343e1342019-06-07 10:36:24 +020096 Sleep (10)
97 }
98 }
Duncan Lauriee32da952015-08-27 17:09:02 -070099 }
100 }
Lee Leahyb0005132015-05-12 18:19:47 -0700101 }
Duncan Lauriee32da952015-08-27 17:09:02 -0700102
Lee Leahyb0005132015-05-12 18:19:47 -0700103 Method (_PS3, 0, Serialized)
104 {
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200105 If (^DVID != 0xFFFF) {
106 If (!((^XMEM == 0xFFFF) || (^XMEM == 0x0000))) {
Duncan Lauriee32da952015-08-27 17:09:02 -0700107
Christian Walter343e1342019-06-07 10:36:24 +0200108 /* Clear PME Status */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200109 ^PMES = 1
Duncan Lauriee32da952015-08-27 17:09:02 -0700110
Christian Walter343e1342019-06-07 10:36:24 +0200111 /* Enable PME */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200112 ^PMEE= 1
Duncan Lauriee32da952015-08-27 17:09:02 -0700113
Christian Walter343e1342019-06-07 10:36:24 +0200114 /* If device is in D3, set back to D0 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200115 If (^D0D3 == 3) {
116 Local0 = 0
117 ^D0D3 = Local0
118 Local0 = ^D0D3
Duncan Lauriee32da952015-08-27 17:09:02 -0700119 }
Christian Walter343e1342019-06-07 10:36:24 +0200120
121 /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200122 ^UPSW = 3
Christian Walter343e1342019-06-07 10:36:24 +0200123
124 /* Enable d3hot and SS link trunk clock gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200125 ^D3HE = 1
126 ^STGE = 1
Christian Walter343e1342019-06-07 10:36:24 +0200127
128 /* Now put device in D3 */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200129 Local0 = 3
130 ^D0D3 = Local0
131 Local0 = ^D0D3
Christian Walter343e1342019-06-07 10:36:24 +0200132
133 /*
134 * Apply USB2 PHPY Power Gating workaround if needed.
135 * This code assumes XDCI is disabled, if it is enabled
136 * then this must also check if it is in D3 state too.
137 */
138 If (^^PMC.UWAB) {
139 /* Write to MTPMC to have PMC enable power gating */
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200140 ^^PMC.MPMC = 3
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 }
155
Duncan Lauriee32da952015-08-27 17:09:02 -0700156 /* Root Hub for Skylake-LP PCH */
157 Device (RHUB)
158 {
Felix Singer9df60d32022-12-26 09:43:07 +0100159 Name (_ADR, 0)
Lee Leahyb0005132015-05-12 18:19:47 -0700160
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500161 // GPLD: Generate Port Location Data (PLD)
162 Method (GPLD, 1, Serialized)
163 {
164
165 Name (PCKG, Package (0x01)
166 {
167 Buffer (0x10) {}
168 })
169
170 // REV: Revision 0x02 for ACPI 5.0
Felix Singer9df60d32022-12-26 09:43:07 +0100171 CreateField (DerefOf (PCKG[0]), 0, 0x07, REV)
Edward O'Callaghaned310242020-06-30 13:39:01 +1000172 REV = 0x02
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500173
174 // VISI: Port visibility to user per port
Felix Singer7b8ac002022-12-26 08:45:56 +0100175 CreateField (DerefOf (PCKG[0]), 0x40, 1, VISI)
Edward O'Callaghaned310242020-06-30 13:39:01 +1000176 VISI = Arg0
Matt DeVillierdc1b7812017-04-22 16:36:10 -0500177
178 Return (PCKG)
179 }
180
Duncan Lauriee32da952015-08-27 17:09:02 -0700181 /* USB2 */
182 Device (HS01) { Name (_ADR, 1) }
183 Device (HS02) { Name (_ADR, 2) }
184 Device (HS03) { Name (_ADR, 3) }
185 Device (HS04) { Name (_ADR, 4) }
186 Device (HS05) { Name (_ADR, 5) }
187 Device (HS06) { Name (_ADR, 6) }
188 Device (HS07) { Name (_ADR, 7) }
189 Device (HS08) { Name (_ADR, 8) }
190 Device (HS09) { Name (_ADR, 9) }
191 Device (HS10) { Name (_ADR, 10) }
Lee Leahyb0005132015-05-12 18:19:47 -0700192
Duncan Lauriee32da952015-08-27 17:09:02 -0700193 /* USBr */
194 Device (USR1) { Name (_ADR, 11) }
195 Device (USR2) { Name (_ADR, 12) }
Lee Leahyb0005132015-05-12 18:19:47 -0700196
Duncan Lauriee32da952015-08-27 17:09:02 -0700197 /* USB3 */
198 Device (SS01) { Name (_ADR, 13) }
199 Device (SS02) { Name (_ADR, 14) }
200 Device (SS03) { Name (_ADR, 15) }
201 Device (SS04) { Name (_ADR, 16) }
202 Device (SS05) { Name (_ADR, 17) }
203 Device (SS06) { Name (_ADR, 18) }
Lee Leahyb0005132015-05-12 18:19:47 -0700204 }
205}