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