Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 5 | * Copyright (C) 2015 Google Inc. |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 6 | * Copyright (C) 2015 Intel Corporation. |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 18 | /* |
| 19 | * USB Port Wake Enable (UPWE) on usb attach/detach |
| 20 | * Arg0 - Port Number |
| 21 | * Arg1 - Port 1 Status and control offset |
| 22 | * Arg2 - xHCI Memory-mapped address |
| 23 | */ |
| 24 | Method (UPWE, 3, Serialized) |
| 25 | { |
| 26 | /* Local0 = Arg1 + ((Arg0 - 1) * 0x10) */ |
| 27 | Add (Arg1, Multiply (Subtract (Arg0, 1), 0x10), Local0) |
| 28 | |
| 29 | /* Map ((XMEM << 16) + Local0 in PSCR */ |
| 30 | OperationRegion (PSCR, SystemMemory, |
| 31 | Add (ShiftLeft (Arg2, 16), Local0), 0x10) |
Kane Chen | c3892c8 | 2018-02-23 10:11:27 +0800 | [diff] [blame^] | 32 | Field (PSCR, DWordAcc, NoLock, Preserve) |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 33 | { |
Kane Chen | c3892c8 | 2018-02-23 10:11:27 +0800 | [diff] [blame^] | 34 | PSCT, 32, |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 35 | } |
Kane Chen | c3892c8 | 2018-02-23 10:11:27 +0800 | [diff] [blame^] | 36 | Store(PSCT, Local0) |
| 37 | /* |
| 38 | * And port status/control reg with RO and RWS bits |
| 39 | * RO bits: 0, 2:3, 10:13, 24, 28:30 |
| 40 | * RWS bits: 5:9, 14:16, 25:27 |
| 41 | */ |
| 42 | And (Local0, ~0x80FE0012, Local0) |
| 43 | /* Set WCE and WDE bits */ |
| 44 | Or (Local0, 0x6000000, Local0) |
| 45 | Store(Local0, PSCT) |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | /* |
| 49 | * USB Wake Enable Setup (UWES) |
| 50 | * Arg0 - Port enable bitmap |
| 51 | * Arg1 - Port 1 Status and control offset |
| 52 | * Arg2 - xHCI Memory-mapped address |
| 53 | */ |
| 54 | Method (UWES, 3, Serialized) |
| 55 | { |
| 56 | Store (Arg0, Local0) |
| 57 | |
| 58 | While (One) { |
| 59 | FindSetRightBit (Local0, Local1) |
| 60 | If (LEqual (Local1, Zero)) { |
| 61 | Break |
| 62 | } |
| 63 | UPWE (Local1, Arg1, Arg2) |
| 64 | /* |
| 65 | * Clear the lowest set bit in Local0 since it was |
| 66 | * processed. |
| 67 | * Local0 = Local0 & (Local0 - 1) |
| 68 | */ |
| 69 | And (Local0, Subtract (Local0, 1), Local0) |
| 70 | } |
| 71 | } |
| 72 | |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 73 | /* XHCI Controller 0:14.0 */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 74 | |
| 75 | Device (XHCI) |
| 76 | { |
| 77 | Name (_ADR, 0x00140000) |
| 78 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 79 | Name (_PRW, Package () { GPE0_PME_B0, 3 }) |
| 80 | |
| 81 | Method (_DSW, 3) |
| 82 | { |
| 83 | Store (Arg0, PMEE) |
Furquan Shaikh | 3bfe340 | 2016-10-18 14:25:25 -0700 | [diff] [blame] | 84 | UWES (And (\U2WE, 0x3FF), 0x480, XMEM) |
| 85 | UWES (And (\U3WE, 0x3F), 0x540, XMEM) |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | Name (_S3D, 3) /* D3 supported in S3 */ |
| 89 | Name (_S4D, 3) /* D3 supported in S4 */ |
| 90 | Name (_S0W, 3) /* D3 can wake device in S0 */ |
| 91 | Name (_S3W, 3) /* D3 can wake system from S3 */ |
| 92 | Name (_S4W, 3) /* D3 can wake system from S4 */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 93 | |
| 94 | OperationRegion (XPRT, PCI_Config, 0x00, 0x100) |
| 95 | Field (XPRT, AnyAcc, NoLock, Preserve) |
| 96 | { |
| 97 | Offset (0x0), |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 98 | DVID, 16, /* VENDORID */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 99 | Offset (0x10), |
| 100 | , 16, |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 101 | XMEM, 16, /* MEM_BASE */ |
Naresh G Solanki | fb79379 | 2017-03-16 15:30:25 +0530 | [diff] [blame] | 102 | Offset (0x50), /* XHCLKGTEN */ |
| 103 | , 2, |
| 104 | STGE, 1, /* SS Link Trunk clock gating enable */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 105 | Offset (0x74), |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 106 | D0D3, 2, /* POWERSTATE */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 107 | , 6, |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 108 | PMEE, 1, /* PME_EN */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 109 | , 6, |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 110 | PMES, 1, /* PME_STS */ |
Naresh G Solanki | fb79379 | 2017-03-16 15:30:25 +0530 | [diff] [blame] | 111 | Offset (0xA2), |
| 112 | , 2, |
| 113 | D3HE, 1, /* D3_hot_en */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 116 | OperationRegion (XREG, SystemMemory, |
| 117 | Add (ShiftLeft (XMEM, 16), 0x8000), 0x200) |
| 118 | Field (XREG, DWordAcc, Lock, Preserve) |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 119 | { |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 120 | Offset (0x1c4), /* USB2PMCTRL */ |
| 121 | , 2, |
| 122 | UPSW, 2, /* U2PSUSPGP */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 125 | Method (_PSC, 0, Serialized) |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 126 | { |
| 127 | Return (^D0D3) |
| 128 | } |
| 129 | |
| 130 | Method (_PS0, 0, Serialized) |
| 131 | { |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 132 | If (LEqual (^DVID, 0xFFFF)) { |
| 133 | Return |
| 134 | } |
| 135 | If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) { |
| 136 | Return |
| 137 | } |
| 138 | |
Naresh G Solanki | fb79379 | 2017-03-16 15:30:25 +0530 | [diff] [blame] | 139 | /* Disable d3hot and SS link trunk clock gating */ |
| 140 | Store(Zero, ^D3HE) |
| 141 | Store(Zero, ^STGE) |
| 142 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 143 | /* If device is in D3, set back to D0 */ |
| 144 | If (LEqual (^D0D3, 3)) { |
Duncan Laurie | aa1b6b0 | 2015-09-23 18:01:45 -0700 | [diff] [blame] | 145 | Store (Zero, Local0) |
| 146 | Store (Local0, ^D0D3) |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 147 | Store (^D0D3, Local0) |
| 148 | } |
| 149 | |
| 150 | /* Disable USB2 PHY SUS Well Power Gating */ |
| 151 | Store (Zero, ^UPSW) |
| 152 | |
| 153 | /* |
| 154 | * Apply USB2 PHPY Power Gating workaround if needed. |
| 155 | */ |
| 156 | If (^^PMC.UWAB) { |
| 157 | /* Write to MTPMC to have PMC disable power gating */ |
| 158 | Store (1, ^^PMC.MPMC) |
| 159 | |
| 160 | /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */ |
| 161 | Store (10, Local0) |
| 162 | While (^^PMC.PMFS) { |
| 163 | If (LNot (Local0)) { |
| 164 | Break |
| 165 | } |
| 166 | Decrement (Local0) |
| 167 | Sleep (10) |
| 168 | } |
| 169 | } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 170 | } |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 171 | |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 172 | Method (_PS3, 0, Serialized) |
| 173 | { |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 174 | If (LEqual (^DVID, 0xFFFF)) { |
| 175 | Return |
| 176 | } |
| 177 | If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) { |
| 178 | Return |
| 179 | } |
| 180 | |
| 181 | /* Clear PME Status */ |
| 182 | Store (1, ^PMES) |
| 183 | |
| 184 | /* Enable PME */ |
| 185 | Store (1, ^PMEE) |
| 186 | |
| 187 | /* If device is in D3, set back to D0 */ |
| 188 | If (LEqual (^D0D3, 3)) { |
Duncan Laurie | aa1b6b0 | 2015-09-23 18:01:45 -0700 | [diff] [blame] | 189 | Store (Zero, Local0) |
| 190 | Store (Local0, ^D0D3) |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 191 | Store (^D0D3, Local0) |
| 192 | } |
| 193 | |
| 194 | /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */ |
| 195 | Store (3, ^UPSW) |
| 196 | |
Naresh G Solanki | fb79379 | 2017-03-16 15:30:25 +0530 | [diff] [blame] | 197 | /* Enable d3hot and SS link trunk clock gating */ |
| 198 | Store(One, ^D3HE) |
| 199 | Store(One, ^STGE) |
| 200 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 201 | /* Now put device in D3 */ |
Duncan Laurie | aa1b6b0 | 2015-09-23 18:01:45 -0700 | [diff] [blame] | 202 | Store (3, Local0) |
| 203 | Store (Local0, ^D0D3) |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 204 | Store (^D0D3, Local0) |
| 205 | |
| 206 | /* |
| 207 | * Apply USB2 PHPY Power Gating workaround if needed. |
| 208 | * This code assumes XDCI is disabled, if it is enabled |
| 209 | * then this must also check if it is in D3 state too. |
| 210 | */ |
| 211 | If (^^PMC.UWAB) { |
| 212 | /* Write to MTPMC to have PMC enable power gating */ |
| 213 | Store (3, ^^PMC.MPMC) |
| 214 | |
| 215 | /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */ |
| 216 | Store (10, Local0) |
| 217 | While (^^PMC.PMFS) { |
| 218 | If (LNot (Local0)) { |
| 219 | Break |
| 220 | } |
| 221 | Decrement (Local0) |
| 222 | Sleep (10) |
| 223 | } |
| 224 | } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 225 | } |
| 226 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 227 | /* Root Hub for Skylake-LP PCH */ |
| 228 | Device (RHUB) |
| 229 | { |
| 230 | Name (_ADR, Zero) |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 231 | |
Matt DeVillier | dc1b781 | 2017-04-22 16:36:10 -0500 | [diff] [blame] | 232 | // GPLD: Generate Port Location Data (PLD) |
| 233 | Method (GPLD, 1, Serialized) |
| 234 | { |
| 235 | |
| 236 | Name (PCKG, Package (0x01) |
| 237 | { |
| 238 | Buffer (0x10) {} |
| 239 | }) |
| 240 | |
| 241 | // REV: Revision 0x02 for ACPI 5.0 |
| 242 | CreateField (DerefOf (Index (PCKG, Zero)), Zero, 0x07, REV) |
| 243 | Store (0x02, REV) |
| 244 | |
| 245 | // VISI: Port visibility to user per port |
| 246 | CreateField (DerefOf (Index (PCKG, Zero)), 0x40, One, VISI) |
| 247 | Store (Arg0, VISI) |
| 248 | |
| 249 | Return (PCKG) |
| 250 | } |
| 251 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 252 | /* USB2 */ |
| 253 | Device (HS01) { Name (_ADR, 1) } |
| 254 | Device (HS02) { Name (_ADR, 2) } |
| 255 | Device (HS03) { Name (_ADR, 3) } |
| 256 | Device (HS04) { Name (_ADR, 4) } |
| 257 | Device (HS05) { Name (_ADR, 5) } |
| 258 | Device (HS06) { Name (_ADR, 6) } |
| 259 | Device (HS07) { Name (_ADR, 7) } |
| 260 | Device (HS08) { Name (_ADR, 8) } |
| 261 | Device (HS09) { Name (_ADR, 9) } |
| 262 | Device (HS10) { Name (_ADR, 10) } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 263 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 264 | /* USBr */ |
| 265 | Device (USR1) { Name (_ADR, 11) } |
| 266 | Device (USR2) { Name (_ADR, 12) } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 267 | |
Duncan Laurie | e32da95 | 2015-08-27 17:09:02 -0700 | [diff] [blame] | 268 | /* USB3 */ |
| 269 | Device (SS01) { Name (_ADR, 13) } |
| 270 | Device (SS02) { Name (_ADR, 14) } |
| 271 | Device (SS03) { Name (_ADR, 15) } |
| 272 | Device (SS04) { Name (_ADR, 16) } |
| 273 | Device (SS05) { Name (_ADR, 17) } |
| 274 | Device (SS06) { Name (_ADR, 18) } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 275 | } |
| 276 | } |