Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 21 | #include <console/console.h> |
| 22 | #include <delay.h> |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 23 | #include <device/device.h> |
| 24 | #include <device/pci.h> |
| 25 | #include <device/pci_ids.h> |
| 26 | #include <arch/io.h> |
| 27 | #include "pch.h" |
| 28 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 29 | static u32 usb_xhci_mem_base(device_t dev) |
| 30 | { |
| 31 | u32 mem_base = pci_read_config32(dev, PCI_BASE_ADDRESS_0); |
| 32 | |
| 33 | /* Check if the controller is disabled or not present */ |
| 34 | if (mem_base == 0 || mem_base == 0xffffffff) |
| 35 | return 0; |
| 36 | |
| 37 | return mem_base & ~0xf; |
| 38 | } |
| 39 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 40 | static int usb_xhci_port_count_usb3(device_t dev) |
| 41 | { |
| 42 | if (pch_is_lp()) { |
| 43 | /* LynxPoint-LP has 4 SS ports */ |
| 44 | return 4; |
| 45 | } else { |
| 46 | /* LynxPoint-H can have 0, 2, 4, or 6 SS ports */ |
| 47 | u32 mem_base = usb_xhci_mem_base(dev); |
| 48 | u32 fus = read32(mem_base + XHCI_USB3FUS); |
| 49 | fus >>= XHCI_USB3FUS_SS_SHIFT; |
| 50 | fus &= XHCI_USB3FUS_SS_MASK; |
| 51 | switch (fus) { |
| 52 | case 3: return 0; |
| 53 | case 2: return 2; |
| 54 | case 1: return 4; |
| 55 | case 0: default: return 6; |
| 56 | } |
| 57 | } |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | static void usb_xhci_reset_status_usb3(u32 mem_base, int port) |
| 62 | { |
| 63 | u32 portsc = mem_base + XHCI_USB3_PORTSC(port); |
Duncan Laurie | 0bf1dea | 2013-08-13 13:32:28 -0700 | [diff] [blame] | 64 | u32 status = read32(portsc); |
| 65 | /* Do not set Port Enabled/Disabled field */ |
| 66 | status &= ~XHCI_USB3_PORTSC_PED; |
| 67 | /* Clear all change status bits */ |
| 68 | status |= XHCI_USB3_PORTSC_CHST; |
| 69 | write32(portsc, status); |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | static void usb_xhci_reset_port_usb3(u32 mem_base, int port) |
| 73 | { |
| 74 | u32 portsc = mem_base + XHCI_USB3_PORTSC(port); |
| 75 | write32(portsc, read32(portsc) | XHCI_USB3_PORTSC_WPR); |
| 76 | } |
| 77 | |
Duncan Laurie | 911cedf | 2013-07-30 16:05:55 -0700 | [diff] [blame] | 78 | #ifdef __SMM__ |
| 79 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 80 | #define XHCI_RESET_DELAY_US 1000 /* 1ms */ |
| 81 | #define XHCI_RESET_TIMEOUT 100 /* 100ms */ |
| 82 | |
| 83 | /* |
| 84 | * 1) Wait until port is done polling |
| 85 | * 2) If port is disconnected |
| 86 | * a) Issue warm port reset |
| 87 | * b) Poll for warm reset complete |
| 88 | * c) Write 1 to port change status bits |
| 89 | */ |
| 90 | static void usb_xhci_reset_usb3(device_t dev, int all) |
| 91 | { |
| 92 | u32 status, port_disabled; |
| 93 | int timeout, port; |
| 94 | int port_count = usb_xhci_port_count_usb3(dev); |
| 95 | u32 mem_base = usb_xhci_mem_base(dev); |
| 96 | |
| 97 | if (!mem_base || !port_count) |
| 98 | return; |
| 99 | |
| 100 | /* Get mask of disabled ports */ |
| 101 | port_disabled = pci_read_config32(dev, XHCI_USB3PDO); |
| 102 | |
| 103 | /* Wait until all enabled ports are done polling */ |
| 104 | for (timeout = XHCI_RESET_TIMEOUT; timeout; timeout--) { |
| 105 | int complete = 1; |
| 106 | for (port = 0; port < port_count; port++) { |
| 107 | /* Skip disabled ports */ |
| 108 | if (port_disabled & (1 << port)) |
| 109 | continue; |
| 110 | /* Read port link status field */ |
| 111 | status = read32(mem_base + XHCI_USB3_PORTSC(port)); |
| 112 | status &= XHCI_USB3_PORTSC_PLS; |
| 113 | if (status == XHCI_PLSR_POLLING) |
| 114 | complete = 0; |
| 115 | } |
| 116 | /* Exit if all ports not polling */ |
| 117 | if (complete) |
| 118 | break; |
| 119 | udelay(XHCI_RESET_DELAY_US); |
| 120 | } |
| 121 | |
| 122 | /* Reset all requested ports */ |
| 123 | for (port = 0; port < port_count; port++) { |
| 124 | u32 portsc = mem_base + XHCI_USB3_PORTSC(port); |
| 125 | /* Skip disabled ports */ |
| 126 | if (port_disabled & (1 << port)) |
| 127 | continue; |
| 128 | status = read32(portsc) & XHCI_USB3_PORTSC_PLS; |
| 129 | /* Reset all or only disconnected ports */ |
| 130 | if (all || status == XHCI_PLSR_RXDETECT) |
| 131 | usb_xhci_reset_port_usb3(mem_base, port); |
| 132 | else |
| 133 | port_disabled |= 1 << port; /* No reset */ |
| 134 | } |
| 135 | |
| 136 | /* Wait for warm reset complete on all reset ports */ |
| 137 | for (timeout = XHCI_RESET_TIMEOUT; timeout; timeout--) { |
| 138 | int complete = 1; |
| 139 | for (port = 0; port < port_count; port++) { |
| 140 | /* Only check ports that were reset */ |
| 141 | if (port_disabled & (1 << port)) |
| 142 | continue; |
| 143 | /* Check if warm reset is complete */ |
| 144 | status = read32(mem_base + XHCI_USB3_PORTSC(port)); |
| 145 | if (!(status & XHCI_USB3_PORTSC_WRC)) |
| 146 | complete = 0; |
| 147 | } |
| 148 | /* Check for warm reset complete in any port */ |
| 149 | if (complete) |
| 150 | break; |
| 151 | udelay(XHCI_RESET_DELAY_US); |
| 152 | } |
| 153 | |
| 154 | /* Clear port change status bits */ |
| 155 | for (port = 0; port < port_count; port++) |
| 156 | usb_xhci_reset_status_usb3(mem_base, port); |
| 157 | } |
| 158 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 159 | /* Handler for XHCI controller on entry to S3/S4/S5 */ |
| 160 | void usb_xhci_sleep_prepare(device_t dev, u8 slp_typ) |
| 161 | { |
| 162 | u16 reg16; |
| 163 | u32 reg32; |
| 164 | u32 mem_base = usb_xhci_mem_base(dev); |
| 165 | |
| 166 | if (!mem_base || slp_typ < 3) |
| 167 | return; |
| 168 | |
| 169 | if (pch_is_lp()) { |
| 170 | /* Set D0 state */ |
| 171 | reg16 = pci_read_config16(dev, XHCI_PWR_CTL_STS); |
| 172 | reg16 &= ~PWR_CTL_SET_MASK; |
| 173 | reg16 |= PWR_CTL_SET_D0; |
| 174 | pci_write_config16(dev, XHCI_PWR_CTL_STS, reg16); |
| 175 | |
| 176 | /* Clear PCI 0xB0[14:13] */ |
| 177 | reg32 = pci_read_config32(dev, 0xb0); |
| 178 | reg32 &= ~((1 << 14) | (1 << 13)); |
| 179 | pci_write_config32(dev, 0xb0, reg32); |
| 180 | |
| 181 | /* Clear MMIO 0x816c[14,2] */ |
| 182 | reg32 = read32(mem_base + 0x816c); |
| 183 | reg32 &= ~((1 << 14) | (1 << 2)); |
| 184 | write32(mem_base + 0x816c, reg32); |
| 185 | |
Duncan Laurie | 0bf1dea | 2013-08-13 13:32:28 -0700 | [diff] [blame] | 186 | /* Reset disconnected USB3 ports */ |
| 187 | usb_xhci_reset_usb3(dev, 0); |
| 188 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 189 | /* Set MMIO 0x80e0[15] */ |
| 190 | reg32 = read32(mem_base + 0x80e0); |
| 191 | reg32 |= (1 << 15); |
| 192 | write32(mem_base + 0x80e0, reg32); |
| 193 | } |
| 194 | |
| 195 | /* Set D3Hot state and enable PME */ |
| 196 | pci_or_config16(dev, XHCI_PWR_CTL_STS, PWR_CTL_SET_D3); |
Duncan Laurie | 0bf1dea | 2013-08-13 13:32:28 -0700 | [diff] [blame] | 197 | pci_or_config16(dev, XHCI_PWR_CTL_STS, PWR_CTL_STATUS_PME); |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 198 | pci_or_config16(dev, XHCI_PWR_CTL_STS, PWR_CTL_ENABLE_PME); |
| 199 | } |
| 200 | |
Duncan Laurie | 911cedf | 2013-07-30 16:05:55 -0700 | [diff] [blame] | 201 | /* Route all ports to XHCI controller */ |
| 202 | void usb_xhci_route_all(void) |
| 203 | { |
| 204 | u32 port_mask, route; |
| 205 | u16 reg16; |
| 206 | |
| 207 | /* Skip if EHCI is already disabled */ |
| 208 | if (RCBA32(FD) & PCH_DISABLE_EHCI1) |
| 209 | return; |
| 210 | |
| 211 | /* Set D0 state */ |
| 212 | reg16 = pci_read_config16(PCH_XHCI_DEV, XHCI_PWR_CTL_STS); |
| 213 | reg16 &= ~PWR_CTL_SET_MASK; |
| 214 | reg16 |= PWR_CTL_SET_D0; |
| 215 | pci_write_config16(PCH_XHCI_DEV, XHCI_PWR_CTL_STS, reg16); |
| 216 | |
| 217 | /* Set USB3 superspeed enable */ |
| 218 | port_mask = pci_read_config32(PCH_XHCI_DEV, XHCI_USB3PRM); |
| 219 | route = pci_read_config32(PCH_XHCI_DEV, XHCI_USB3PR); |
| 220 | route &= ~XHCI_USB3PR_SSEN; |
| 221 | route |= XHCI_USB3PR_SSEN & port_mask; |
| 222 | pci_write_config32(PCH_XHCI_DEV, XHCI_USB3PR, route); |
| 223 | |
| 224 | /* Route USB2 ports to XHCI controller */ |
| 225 | port_mask = pci_read_config32(PCH_XHCI_DEV, XHCI_USB2PRM); |
| 226 | route = pci_read_config32(PCH_XHCI_DEV, XHCI_USB2PR); |
| 227 | route &= ~XHCI_USB2PR_HCSEL; |
| 228 | route |= XHCI_USB2PR_HCSEL & port_mask; |
| 229 | pci_write_config32(PCH_XHCI_DEV, XHCI_USB2PR, route); |
| 230 | |
| 231 | /* Disable EHCI controller */ |
| 232 | usb_ehci_disable(PCH_EHCI1_DEV); |
| 233 | |
| 234 | /* LynxPoint-H has a second EHCI controller */ |
| 235 | if (!pch_is_lp()) |
| 236 | usb_ehci_disable(PCH_EHCI2_DEV); |
| 237 | |
| 238 | /* Reset and clear port change status */ |
| 239 | usb_xhci_reset_usb3(PCH_XHCI_DEV, 1); |
| 240 | } |
| 241 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 242 | #else /* !__SMM__ */ |
| 243 | |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 244 | static void usb_xhci_clock_gating(device_t dev) |
| 245 | { |
| 246 | u32 reg32; |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 247 | u16 reg16; |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 248 | |
| 249 | /* IOBP 0xE5004001[7:6] = 11b */ |
| 250 | pch_iobp_update(0xe5004001, ~0, (1 << 7)|(1 << 6)); |
| 251 | |
| 252 | reg32 = pci_read_config32(dev, 0x40); |
| 253 | reg32 &= ~(1 << 23); /* unsupported request */ |
| 254 | |
| 255 | if (pch_is_lp()) { |
| 256 | /* D20:F0:40h[18,17,8] = 111b */ |
| 257 | reg32 |= (1 << 18) | (1 << 17) | (1 << 8); |
| 258 | /* D20:F0:40h[21,20,19] = 110b to enable XHCI Idle L1 */ |
| 259 | reg32 &= ~(1 << 19); |
| 260 | reg32 |= (1 << 21) | (1 << 20); |
| 261 | } else { |
| 262 | /* D20:F0:40h[21,20,18,17,8] = 11111b */ |
| 263 | reg32 |= (1 << 21)|(1 << 20)|(1 << 18)|(1 << 17)|(1 << 8); |
| 264 | } |
| 265 | |
| 266 | /* Avoid writing upper byte as it is write-once */ |
| 267 | pci_write_config16(dev, 0x40, (u16)(reg32 & 0xffff)); |
| 268 | pci_write_config8(dev, 0x40 + 2, (u8)((reg32 >> 16) & 0xff)); |
| 269 | |
| 270 | /* D20:F0:44h[9,7,3] = 111b */ |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 271 | reg16 = pci_read_config16(dev, 0x44); |
| 272 | reg16 |= (1 << 9) | (1 << 7) | (1 << 3); |
| 273 | pci_write_config16(dev, 0x44, reg16); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 274 | |
| 275 | reg32 = pci_read_config32(dev, 0xa0); |
| 276 | if (pch_is_lp()) { |
| 277 | /* D20:F0:A0h[18] = 1 */ |
| 278 | reg32 |= (1 << 18); |
| 279 | } else { |
| 280 | /* D20:F0:A0h[6] = 1 */ |
| 281 | reg32 |= (1 << 6); |
| 282 | } |
| 283 | pci_write_config32(dev, 0xa0, reg32); |
| 284 | |
| 285 | /* D20:F0:A4h[13] = 0 */ |
| 286 | reg32 = pci_read_config32(dev, 0xa4); |
| 287 | reg32 &= ~(1 << 13); |
| 288 | pci_write_config32(dev, 0xa4, reg32); |
| 289 | } |
| 290 | |
Duncan Laurie | 911cedf | 2013-07-30 16:05:55 -0700 | [diff] [blame] | 291 | /* Re-enable ports that are disabled */ |
| 292 | static void usb_xhci_enable_ports_usb3(device_t dev) |
| 293 | { |
| 294 | #if CONFIG_FINALIZE_USB_ROUTE_XHCI |
| 295 | int port; |
| 296 | u32 portsc, status, disabled; |
| 297 | u32 mem_base = usb_xhci_mem_base(dev); |
| 298 | int port_count = usb_xhci_port_count_usb3(dev); |
| 299 | |
| 300 | if (!mem_base || !port_count) |
| 301 | return; |
| 302 | |
| 303 | /* Get port disable override map */ |
| 304 | disabled = pci_read_config32(dev, XHCI_USB3PDO); |
| 305 | |
| 306 | for (port = 0; port < port_count; port++) { |
| 307 | /* Skip overridden ports */ |
| 308 | if (disabled & (1 << port)) |
| 309 | continue; |
| 310 | portsc = mem_base + XHCI_USB3_PORTSC(port); |
| 311 | status = read32(portsc) & XHCI_USB3_PORTSC_PLS; |
| 312 | |
| 313 | switch (status) { |
| 314 | case XHCI_PLSR_RXDETECT: |
| 315 | /* Clear change status */ |
| 316 | printk(BIOS_DEBUG, "usb_xhci reset port %d\n", port); |
| 317 | usb_xhci_reset_status_usb3(mem_base, port); |
| 318 | break; |
| 319 | case XHCI_PLSR_DISABLED: |
| 320 | default: |
| 321 | /* Transition to enabled */ |
| 322 | printk(BIOS_DEBUG, "usb_xhci enable port %d\n", port); |
| 323 | usb_xhci_reset_port_usb3(mem_base, port); |
| 324 | status = read32(portsc); |
| 325 | status &= ~XHCI_USB3_PORTSC_PLS; |
| 326 | status |= XHCI_PLSW_ENABLE | XHCI_USB3_PORTSC_LWS; |
| 327 | write32(portsc, status); |
| 328 | break; |
| 329 | } |
| 330 | } |
| 331 | #endif |
| 332 | } |
| 333 | |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 334 | static void usb_xhci_init(device_t dev) |
| 335 | { |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 336 | u32 reg32; |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 337 | u16 reg16; |
| 338 | u32 mem_base = usb_xhci_mem_base(dev); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 339 | |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 340 | /* D20:F0:74h[1:0] = 00b (set D0 state) */ |
| 341 | reg16 = pci_read_config16(dev, XHCI_PWR_CTL_STS); |
| 342 | reg16 &= ~PWR_CTL_SET_MASK; |
| 343 | reg16 |= PWR_CTL_SET_D0; |
| 344 | pci_write_config16(dev, XHCI_PWR_CTL_STS, reg16); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 345 | |
| 346 | /* Enable clock gating first */ |
| 347 | usb_xhci_clock_gating(dev); |
| 348 | |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 349 | reg32 = read32(mem_base + 0x8144); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 350 | if (pch_is_lp()) { |
| 351 | /* XHCIBAR + 8144h[8,7,6] = 111b */ |
| 352 | reg32 |= (1 << 8) | (1 << 7) | (1 << 6); |
| 353 | } else { |
| 354 | /* XHCIBAR + 8144h[8,7,6] = 100b */ |
| 355 | reg32 &= ~((1 << 7) | (1 << 6)); |
| 356 | reg32 |= (1 << 8); |
| 357 | } |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 358 | write32(mem_base + 0x8144, reg32); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 359 | |
| 360 | if (pch_is_lp()) { |
Duncan Laurie | 527b03a | 2013-08-28 09:53:50 -0700 | [diff] [blame^] | 361 | /* XHCIBAR + 816Ch[19:0] = 000e0038h */ |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 362 | reg32 = read32(mem_base + 0x816c); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 363 | reg32 &= ~0x000fffff; |
Duncan Laurie | 527b03a | 2013-08-28 09:53:50 -0700 | [diff] [blame^] | 364 | reg32 |= 0x000e0038; |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 365 | write32(mem_base + 0x816c, reg32); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 366 | |
| 367 | /* D20:F0:B0h[17,14,13] = 100b */ |
| 368 | reg32 = pci_read_config32(dev, 0xb0); |
| 369 | reg32 &= ~((1 << 14) | (1 << 13)); |
| 370 | reg32 |= (1 << 17); |
| 371 | pci_write_config32(dev, 0xb0, reg32); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | reg32 = pci_read_config32(dev, 0x50); |
| 375 | if (pch_is_lp()) { |
| 376 | /* D20:F0:50h[28:0] = 0FCE2E5Fh */ |
| 377 | reg32 &= ~0x1fffffff; |
| 378 | reg32 |= 0x0fce2e5f; |
| 379 | } else { |
| 380 | /* D20:F0:50h[26:0] = 07886E9Fh */ |
| 381 | reg32 &= ~0x07ffffff; |
| 382 | reg32 |= 0x07886e9f; |
| 383 | } |
| 384 | pci_write_config32(dev, 0x50, reg32); |
| 385 | |
| 386 | /* D20:F0:44h[31] = 1 (Access Control Bit) */ |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 387 | reg32 = pci_read_config32(dev, 0x44); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 388 | reg32 |= (1 << 31); |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 389 | pci_write_config32(dev, 0x44, reg32); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 390 | |
| 391 | /* D20:F0:40h[31,23] = 10b (OC Configuration Done) */ |
| 392 | reg32 = pci_read_config32(dev, 0x40); |
| 393 | reg32 &= ~(1 << 23); /* unsupported request */ |
| 394 | reg32 |= (1 << 31); |
| 395 | pci_write_config32(dev, 0x40, reg32); |
Duncan Laurie | 911cedf | 2013-07-30 16:05:55 -0700 | [diff] [blame] | 396 | |
Duncan Laurie | 911cedf | 2013-07-30 16:05:55 -0700 | [diff] [blame] | 397 | /* Enable ports that are disabled before returning to OS */ |
Kyösti Mälkki | c3ed886 | 2014-06-19 19:50:51 +0300 | [diff] [blame] | 398 | if (acpi_is_wakeup_s3()) |
Duncan Laurie | 911cedf | 2013-07-30 16:05:55 -0700 | [diff] [blame] | 399 | usb_xhci_enable_ports_usb3(dev); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | static void usb_xhci_set_subsystem(device_t dev, unsigned vendor, |
| 403 | unsigned device) |
| 404 | { |
| 405 | if (!vendor || !device) { |
| 406 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 407 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 408 | } else { |
| 409 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 410 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | static struct pci_operations lops_pci = { |
| 415 | .set_subsystem = &usb_xhci_set_subsystem, |
| 416 | }; |
| 417 | |
| 418 | static struct device_operations usb_xhci_ops = { |
| 419 | .read_resources = pci_dev_read_resources, |
| 420 | .set_resources = pci_dev_set_resources, |
| 421 | .enable_resources = pci_dev_enable_resources, |
| 422 | .init = usb_xhci_init, |
| 423 | .ops_pci = &lops_pci, |
| 424 | }; |
| 425 | |
| 426 | static const unsigned short pci_device_ids[] = { 0x8c31, /* LynxPoint-H */ |
| 427 | 0x9c31, /* LynxPoint-LP */ |
| 428 | 0 }; |
| 429 | |
| 430 | static const struct pci_driver pch_usb_xhci __pci_driver = { |
| 431 | .ops = &usb_xhci_ops, |
| 432 | .vendor = PCI_VENDOR_ID_INTEL, |
| 433 | .devices = pci_device_ids, |
| 434 | }; |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 435 | #endif /* !__SMM__ */ |