blob: 96f3b6a6e5b09aed5193a16ced804a207b4d4d87 [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
Duncan Lauriee32da952015-08-27 17:09:02 -07005 * Copyright (C) 2015 Google Inc.
Lee Leahy1d14b3e2015-05-12 18:23:27 -07006 * Copyright (C) 2015 Intel Corporation.
Lee Leahyb0005132015-05-12 18:19:47 -07007 *
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 Leahyb0005132015-05-12 18:19:47 -070016 */
17
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070018/*
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 */
24Method (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)
32 Field (PSCR, AnyAcc, NoLock, Preserve)
33 {
34 , 25,
35 UPCE, 1,
36 UPDE, 1,
37 }
38 Store (One, UPCE)
39 Store (One, UPDE)
40}
41
42/*
43 * USB Wake Enable Setup (UWES)
44 * Arg0 - Port enable bitmap
45 * Arg1 - Port 1 Status and control offset
46 * Arg2 - xHCI Memory-mapped address
47 */
48Method (UWES, 3, Serialized)
49{
50 Store (Arg0, Local0)
51
52 While (One) {
53 FindSetRightBit (Local0, Local1)
54 If (LEqual (Local1, Zero)) {
55 Break
56 }
57 UPWE (Local1, Arg1, Arg2)
58 /*
59 * Clear the lowest set bit in Local0 since it was
60 * processed.
61 * Local0 = Local0 & (Local0 - 1)
62 */
63 And (Local0, Subtract (Local0, 1), Local0)
64 }
65}
66
Lee Leahy1d14b3e2015-05-12 18:23:27 -070067/* XHCI Controller 0:14.0 */
Lee Leahyb0005132015-05-12 18:19:47 -070068
69Device (XHCI)
70{
71 Name (_ADR, 0x00140000)
72
Duncan Lauriee32da952015-08-27 17:09:02 -070073 Name (_PRW, Package () { GPE0_PME_B0, 3 })
74
75 Method (_DSW, 3)
76 {
77 Store (Arg0, PMEE)
Furquan Shaikh3bfe3402016-10-18 14:25:25 -070078 UWES (And (\U2WE, 0x3FF), 0x480, XMEM)
79 UWES (And (\U3WE, 0x3F), 0x540, XMEM)
Duncan Lauriee32da952015-08-27 17:09:02 -070080 }
81
82 Name (_S3D, 3) /* D3 supported in S3 */
83 Name (_S4D, 3) /* D3 supported in S4 */
84 Name (_S0W, 3) /* D3 can wake device in S0 */
85 Name (_S3W, 3) /* D3 can wake system from S3 */
86 Name (_S4W, 3) /* D3 can wake system from S4 */
Lee Leahyb0005132015-05-12 18:19:47 -070087
88 OperationRegion (XPRT, PCI_Config, 0x00, 0x100)
89 Field (XPRT, AnyAcc, NoLock, Preserve)
90 {
91 Offset (0x0),
Duncan Lauriee32da952015-08-27 17:09:02 -070092 DVID, 16, /* VENDORID */
Lee Leahyb0005132015-05-12 18:19:47 -070093 Offset (0x10),
94 , 16,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070095 XMEM, 16, /* MEM_BASE */
Lee Leahyb0005132015-05-12 18:19:47 -070096 Offset (0x74),
Duncan Lauriee32da952015-08-27 17:09:02 -070097 D0D3, 2, /* POWERSTATE */
Lee Leahyb0005132015-05-12 18:19:47 -070098 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -070099 PMEE, 1, /* PME_EN */
Lee Leahyb0005132015-05-12 18:19:47 -0700100 , 6,
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700101 PMES, 1, /* PME_STS */
Lee Leahyb0005132015-05-12 18:19:47 -0700102 }
103
Duncan Lauriee32da952015-08-27 17:09:02 -0700104 OperationRegion (XREG, SystemMemory,
105 Add (ShiftLeft (XMEM, 16), 0x8000), 0x200)
106 Field (XREG, DWordAcc, Lock, Preserve)
Lee Leahyb0005132015-05-12 18:19:47 -0700107 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700108 Offset (0x1c4), /* USB2PMCTRL */
109 , 2,
110 UPSW, 2, /* U2PSUSPGP */
Lee Leahyb0005132015-05-12 18:19:47 -0700111 }
112
Duncan Lauriee32da952015-08-27 17:09:02 -0700113 Method (_PSC, 0, Serialized)
Lee Leahyb0005132015-05-12 18:19:47 -0700114 {
115 Return (^D0D3)
116 }
117
118 Method (_PS0, 0, Serialized)
119 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700120 If (LEqual (^DVID, 0xFFFF)) {
121 Return
122 }
123 If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
124 Return
125 }
126
127 /* If device is in D3, set back to D0 */
128 If (LEqual (^D0D3, 3)) {
Duncan Laurieaa1b6b02015-09-23 18:01:45 -0700129 Store (Zero, Local0)
130 Store (Local0, ^D0D3)
Duncan Lauriee32da952015-08-27 17:09:02 -0700131 Store (^D0D3, Local0)
132 }
133
134 /* Disable USB2 PHY SUS Well Power Gating */
135 Store (Zero, ^UPSW)
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 */
142 Store (1, ^^PMC.MPMC)
143
144 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
145 Store (10, Local0)
146 While (^^PMC.PMFS) {
147 If (LNot (Local0)) {
148 Break
149 }
150 Decrement (Local0)
151 Sleep (10)
152 }
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 {
Duncan Lauriee32da952015-08-27 17:09:02 -0700158 If (LEqual (^DVID, 0xFFFF)) {
159 Return
160 }
161 If (LOr (LEqual (^XMEM, 0xFFFF), LEqual (^XMEM, 0x0000))) {
162 Return
163 }
164
165 /* Clear PME Status */
166 Store (1, ^PMES)
167
168 /* Enable PME */
169 Store (1, ^PMEE)
170
171 /* If device is in D3, set back to D0 */
172 If (LEqual (^D0D3, 3)) {
Duncan Laurieaa1b6b02015-09-23 18:01:45 -0700173 Store (Zero, Local0)
174 Store (Local0, ^D0D3)
Duncan Lauriee32da952015-08-27 17:09:02 -0700175 Store (^D0D3, Local0)
176 }
177
178 /* Enable USB2 PHY SUS Well Power Gating in D0/D0i2/D0i3/D3 */
179 Store (3, ^UPSW)
180
181 /* Now put device in D3 */
Duncan Laurieaa1b6b02015-09-23 18:01:45 -0700182 Store (3, Local0)
183 Store (Local0, ^D0D3)
Duncan Lauriee32da952015-08-27 17:09:02 -0700184 Store (^D0D3, Local0)
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 */
193 Store (3, ^^PMC.MPMC)
194
195 /* Wait for PCH_PM_STS.MSG_FULL_STS to be 0 */
196 Store (10, Local0)
197 While (^^PMC.PMFS) {
198 If (LNot (Local0)) {
199 Break
200 }
201 Decrement (Local0)
202 Sleep (10)
203 }
204 }
Lee Leahyb0005132015-05-12 18:19:47 -0700205 }
206
Duncan Lauriee32da952015-08-27 17:09:02 -0700207 /* Root Hub for Skylake-LP PCH */
208 Device (RHUB)
209 {
210 Name (_ADR, Zero)
Lee Leahyb0005132015-05-12 18:19:47 -0700211
Duncan Lauriee32da952015-08-27 17:09:02 -0700212 /* USB2 */
213 Device (HS01) { Name (_ADR, 1) }
214 Device (HS02) { Name (_ADR, 2) }
215 Device (HS03) { Name (_ADR, 3) }
216 Device (HS04) { Name (_ADR, 4) }
217 Device (HS05) { Name (_ADR, 5) }
218 Device (HS06) { Name (_ADR, 6) }
219 Device (HS07) { Name (_ADR, 7) }
220 Device (HS08) { Name (_ADR, 8) }
221 Device (HS09) { Name (_ADR, 9) }
222 Device (HS10) { Name (_ADR, 10) }
Lee Leahyb0005132015-05-12 18:19:47 -0700223
Duncan Lauriee32da952015-08-27 17:09:02 -0700224 /* USBr */
225 Device (USR1) { Name (_ADR, 11) }
226 Device (USR2) { Name (_ADR, 12) }
Lee Leahyb0005132015-05-12 18:19:47 -0700227
Duncan Lauriee32da952015-08-27 17:09:02 -0700228 /* USB3 */
229 Device (SS01) { Name (_ADR, 13) }
230 Device (SS02) { Name (_ADR, 14) }
231 Device (SS03) { Name (_ADR, 15) }
232 Device (SS04) { Name (_ADR, 16) }
233 Device (SS05) { Name (_ADR, 17) }
234 Device (SS06) { Name (_ADR, 18) }
Lee Leahyb0005132015-05-12 18:19:47 -0700235 }
236}