Angel Pons | 3bd1e3d | 2020-04-05 15:47:17 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 2 | |
Edward O'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 3 | #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 Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 9 | /* |
| 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 | */ |
| 15 | Method (UPWE, 3, Serialized) |
| 16 | { |
Edward O'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 17 | Local0 = Arg1 + ((Arg0 - 1) * 0x10) |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 18 | |
| 19 | /* Map ((XMEM << 16) + Local0 in PSCR */ |
| 20 | OperationRegion (PSCR, SystemMemory, |
| 21 | Add (ShiftLeft (Arg2, 16), Local0), 0x10) |
Kane Chen | c3892c8 | 2018-02-23 10:11:27 +0800 | [diff] [blame] | 22 | Field (PSCR, DWordAcc, NoLock, Preserve) |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 23 | { |
Kane Chen | c3892c8 | 2018-02-23 10:11:27 +0800 | [diff] [blame] | 24 | PSCT, 32, |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 25 | } |
Edward O'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 26 | Local0 = PSCT |
Kane Chen | c3892c8 | 2018-02-23 10:11:27 +0800 | [diff] [blame] | 27 | /* |
| 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'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 32 | Local0 = Local0 & RO_BITS_OFF_MASK |
Kane Chen | c3892c8 | 2018-02-23 10:11:27 +0800 | [diff] [blame] | 33 | /* Set WCE and WDE bits */ |
Edward O'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 34 | Local0 = Local0 | WAKE_ON_CONNECT_DISCONNECT_ENABLE |
| 35 | PSCT = Local0 |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 36 | } |
| 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 | */ |
| 44 | Method (UWES, 3, Serialized) |
| 45 | { |
Edward O'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 46 | Local0 = Arg0 |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 47 | |
| 48 | While (One) { |
| 49 | FindSetRightBit (Local0, Local1) |
Edward O'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 50 | If (Local1 == Zero) { |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 51 | Break |
| 52 | } |
| 53 | UPWE (Local1, Arg1, Arg2) |
| 54 | /* |
| 55 | * Clear the lowest set bit in Local0 since it was |
| 56 | * processed. |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 57 | */ |
Edward O'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 58 | Local0 = Local0 & (Local0 - 1) |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 62 | /* XHCI Controller 0:14.0 */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 63 | |
| 64 | Device (XHCI) |
| 65 | { |
| 66 | Name (_ADR, 0x00140000) |
| 67 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 68 | Name (_PRW, Package () { GPE0_PME_B0, 3 }) |
| 69 | |
| 70 | Method (_DSW, 3) |
| 71 | { |
Edward O'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 72 | PMEE = Arg0 |
| 73 | UWES ((\U2WE & 0x3FF), PORTSCN_OFFSET, XMEM) |
| 74 | UWES ((\U3WE & 0x3F ), PORTSCXUSB3_OFFSET, XMEM) |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 75 | } |
| 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 Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 82 | |
| 83 | OperationRegion (XPRT, PCI_Config, 0x00, 0x100) |
| 84 | Field (XPRT, AnyAcc, NoLock, Preserve) |
| 85 | { |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 86 | DVID, 16, /* VENDORID */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 87 | Offset (0x10), |
| 88 | , 16, |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 89 | XMEM, 16, /* MEM_BASE */ |
Naresh G Solanki | fb79379 | 2017-03-16 15:30:25 +0530 | [diff] [blame] | 90 | Offset (0x50), /* XHCLKGTEN */ |
| 91 | , 2, |
| 92 | STGE, 1, /* SS Link Trunk clock gating enable */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 93 | Offset (0x74), |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 94 | D0D3, 2, /* POWERSTATE */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 95 | , 6, |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 96 | PMEE, 1, /* PME_EN */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 97 | , 6, |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 98 | PMES, 1, /* PME_STS */ |
Naresh G Solanki | fb79379 | 2017-03-16 15:30:25 +0530 | [diff] [blame] | 99 | Offset (0xA2), |
| 100 | , 2, |
| 101 | D3HE, 1, /* D3_hot_en */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 104 | OperationRegion (XREG, SystemMemory, |
| 105 | Add (ShiftLeft (XMEM, 16), 0x8000), 0x200) |
| 106 | Field (XREG, DWordAcc, Lock, Preserve) |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 107 | { |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 108 | Offset (0x1c4), /* USB2PMCTRL */ |
| 109 | , 2, |
| 110 | UPSW, 2, /* U2PSUSPGP */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 113 | Method (_PSC, 0, Serialized) |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 114 | { |
| 115 | Return (^D0D3) |
| 116 | } |
| 117 | |
| 118 | Method (_PS0, 0, Serialized) |
| 119 | { |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 120 | If (^DVID != 0xFFFF) { |
| 121 | If (!((^XMEM == 0xFFFF) || (^XMEM == 0x0000))) { |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 122 | |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 123 | /* Disable d3hot and SS link trunk clock gating */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 124 | ^D3HE = 0 |
| 125 | ^STGE = 0 |
Naresh G Solanki | fb79379 | 2017-03-16 15:30:25 +0530 | [diff] [blame] | 126 | |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 127 | /* If device is in D3, set back to D0 */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 128 | If (^D0D3 == 3) { |
| 129 | Local0 = 0 |
| 130 | ^D0D3 = Local0 |
| 131 | Local0 = ^D0D3 |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 132 | } |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 133 | |
| 134 | /* Disable USB2 PHY SUS Well Power Gating */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 135 | ^UPSW = 0 |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 136 | |
| 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 HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 142 | ^^PMC.MPMC = 1 |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 143 | |
| 144 | /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 145 | Local0 = 10 |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 146 | While (^^PMC.PMFS) { |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 147 | If (!Local0) { |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 148 | Break |
| 149 | } |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 150 | Local0-- |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 151 | Sleep (10) |
| 152 | } |
| 153 | } |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 154 | } |
| 155 | } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 156 | } |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 157 | |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 158 | Method (_PS3, 0, Serialized) |
| 159 | { |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 160 | If (^DVID != 0xFFFF) { |
| 161 | If (!((^XMEM == 0xFFFF) || (^XMEM == 0x0000))) { |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 162 | |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 163 | /* Clear PME Status */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 164 | ^PMES = 1 |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 165 | |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 166 | /* Enable PME */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 167 | ^PMEE= 1 |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 168 | |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 169 | /* If device is in D3, set back to D0 */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 170 | If (^D0D3 == 3) { |
| 171 | Local0 = 0 |
| 172 | ^D0D3 = Local0 |
| 173 | Local0 = ^D0D3 |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 174 | } |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 175 | |
| 176 | /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 177 | ^UPSW = 3 |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 178 | |
| 179 | /* Enable d3hot and SS link trunk clock gating */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 180 | ^D3HE = 1 |
| 181 | ^STGE = 1 |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 182 | |
| 183 | /* Now put device in D3 */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 184 | Local0 = 3 |
| 185 | ^D0D3 = Local0 |
| 186 | Local0 = ^D0D3 |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 187 | |
| 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 HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 195 | ^^PMC.MPMC = 3 |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 196 | |
| 197 | /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */ |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 198 | Local0 = 10 |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 199 | While (^^PMC.PMFS) { |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 200 | If (!Local0) { |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 201 | Break |
| 202 | } |
Elyes HAOUAS | fc29afb | 2020-10-09 15:05:28 +0200 | [diff] [blame^] | 203 | Local0-- |
Christian Walter | 343e134 | 2019-06-07 10:36:24 +0200 | [diff] [blame] | 204 | Sleep (10) |
| 205 | } |
| 206 | } |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 207 | } |
| 208 | } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 211 | /* Root Hub for Skylake-LP PCH */ |
| 212 | Device (RHUB) |
| 213 | { |
| 214 | Name (_ADR, Zero) |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 215 | |
Matt DeVillier | dc1b781 | 2017-04-22 16:36:10 -0500 | [diff] [blame] | 216 | // 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'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 227 | REV = 0x02 |
Matt DeVillier | dc1b781 | 2017-04-22 16:36:10 -0500 | [diff] [blame] | 228 | |
| 229 | // VISI: Port visibility to user per port |
| 230 | CreateField (DerefOf (Index (PCKG, Zero)), 0x40, One, VISI) |
Edward O'Callaghan | ed31024 | 2020-06-30 13:39:01 +1000 | [diff] [blame] | 231 | VISI = Arg0 |
Matt DeVillier | dc1b781 | 2017-04-22 16:36:10 -0500 | [diff] [blame] | 232 | |
| 233 | Return (PCKG) |
| 234 | } |
| 235 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 236 | /* 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 Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 247 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 248 | /* USBr */ |
| 249 | Device (USR1) { Name (_ADR, 11) } |
| 250 | Device (USR2) { Name (_ADR, 12) } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 251 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 252 | /* 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 Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 259 | } |
| 260 | } |