Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 2 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 3 | #include <delay.h> |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 4 | #include <device/device.h> |
| 5 | #include <device/pci.h> |
| 6 | #include <device/pci_ids.h> |
| 7 | #include <arch/io.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 8 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 9 | #include <device/pci_ops.h> |
Kyösti Mälkki | 12b121c | 2019-08-18 16:33:39 +0300 | [diff] [blame] | 10 | #include "chip.h" |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 11 | #include "pch.h" |
| 12 | |
Stefan Reinauer | 6dbbe2e | 2013-10-17 17:00:26 -0700 | [diff] [blame] | 13 | typedef struct southbridge_intel_lynxpoint_config config_t; |
| 14 | |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 15 | #ifdef __SIMPLE_DEVICE__ |
| 16 | static u8 *usb_xhci_mem_base(pci_devfn_t dev) |
| 17 | #else |
| 18 | static u8 *usb_xhci_mem_base(struct device *dev) |
| 19 | #endif |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 20 | { |
| 21 | u32 mem_base = pci_read_config32(dev, PCI_BASE_ADDRESS_0); |
| 22 | |
| 23 | /* Check if the controller is disabled or not present */ |
| 24 | if (mem_base == 0 || mem_base == 0xffffffff) |
| 25 | return 0; |
| 26 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 27 | return (u8 *)(mem_base & ~0xf); |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 30 | #ifdef __SIMPLE_DEVICE__ |
| 31 | static int usb_xhci_port_count_usb3(pci_devfn_t dev) |
| 32 | #else |
| 33 | static int usb_xhci_port_count_usb3(struct device *dev) |
| 34 | #endif |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 35 | { |
| 36 | if (pch_is_lp()) { |
| 37 | /* LynxPoint-LP has 4 SS ports */ |
| 38 | return 4; |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 39 | } |
Elyes HAOUAS | 54f9424 | 2018-10-25 10:57:39 +0200 | [diff] [blame] | 40 | /* LynxPoint-H can have 0, 2, 4, or 6 SS ports */ |
| 41 | u8 *mem_base = usb_xhci_mem_base(dev); |
| 42 | u32 fus = read32(mem_base + XHCI_USB3FUS); |
| 43 | fus >>= XHCI_USB3FUS_SS_SHIFT; |
| 44 | fus &= XHCI_USB3FUS_SS_MASK; |
| 45 | switch (fus) { |
| 46 | case 3: return 0; |
| 47 | case 2: return 2; |
| 48 | case 1: return 4; |
| 49 | case 0: |
| 50 | default: return 6; |
| 51 | } |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 54 | static void usb_xhci_reset_status_usb3(u8 *mem_base, int port) |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 55 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 56 | u8 *portsc = mem_base + XHCI_USB3_PORTSC(port); |
Duncan Laurie | 0bf1dea | 2013-08-13 13:32:28 -0700 | [diff] [blame] | 57 | u32 status = read32(portsc); |
| 58 | /* Do not set Port Enabled/Disabled field */ |
| 59 | status &= ~XHCI_USB3_PORTSC_PED; |
| 60 | /* Clear all change status bits */ |
| 61 | status |= XHCI_USB3_PORTSC_CHST; |
| 62 | write32(portsc, status); |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 65 | static void usb_xhci_reset_port_usb3(u8 *mem_base, int port) |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 66 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 67 | u8 *portsc = mem_base + XHCI_USB3_PORTSC(port); |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 68 | write32(portsc, read32(portsc) | XHCI_USB3_PORTSC_WPR); |
| 69 | } |
| 70 | |
| 71 | #define XHCI_RESET_DELAY_US 1000 /* 1ms */ |
| 72 | #define XHCI_RESET_TIMEOUT 100 /* 100ms */ |
| 73 | |
| 74 | /* |
| 75 | * 1) Wait until port is done polling |
| 76 | * 2) If port is disconnected |
| 77 | * a) Issue warm port reset |
| 78 | * b) Poll for warm reset complete |
| 79 | * c) Write 1 to port change status bits |
| 80 | */ |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 81 | #ifdef __SIMPLE_DEVICE__ |
| 82 | static void usb_xhci_reset_usb3(pci_devfn_t dev, int all) |
| 83 | #else |
| 84 | static void usb_xhci_reset_usb3(struct device *dev, int all) |
| 85 | #endif |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 86 | { |
| 87 | u32 status, port_disabled; |
| 88 | int timeout, port; |
| 89 | int port_count = usb_xhci_port_count_usb3(dev); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 90 | u8 *mem_base = usb_xhci_mem_base(dev); |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 91 | |
| 92 | if (!mem_base || !port_count) |
| 93 | return; |
| 94 | |
| 95 | /* Get mask of disabled ports */ |
| 96 | port_disabled = pci_read_config32(dev, XHCI_USB3PDO); |
| 97 | |
| 98 | /* Wait until all enabled ports are done polling */ |
| 99 | for (timeout = XHCI_RESET_TIMEOUT; timeout; timeout--) { |
| 100 | int complete = 1; |
| 101 | for (port = 0; port < port_count; port++) { |
| 102 | /* Skip disabled ports */ |
| 103 | if (port_disabled & (1 << port)) |
| 104 | continue; |
| 105 | /* Read port link status field */ |
| 106 | status = read32(mem_base + XHCI_USB3_PORTSC(port)); |
| 107 | status &= XHCI_USB3_PORTSC_PLS; |
| 108 | if (status == XHCI_PLSR_POLLING) |
| 109 | complete = 0; |
| 110 | } |
| 111 | /* Exit if all ports not polling */ |
| 112 | if (complete) |
| 113 | break; |
| 114 | udelay(XHCI_RESET_DELAY_US); |
| 115 | } |
| 116 | |
| 117 | /* Reset all requested ports */ |
| 118 | for (port = 0; port < port_count; port++) { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 119 | u8 *portsc = mem_base + XHCI_USB3_PORTSC(port); |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 120 | /* Skip disabled ports */ |
| 121 | if (port_disabled & (1 << port)) |
| 122 | continue; |
| 123 | status = read32(portsc) & XHCI_USB3_PORTSC_PLS; |
| 124 | /* Reset all or only disconnected ports */ |
Duncan Laurie | 32d2e2b | 2013-09-25 14:08:32 -0700 | [diff] [blame] | 125 | if (all || (status == XHCI_PLSR_RXDETECT || |
| 126 | status == XHCI_PLSR_POLLING)) |
Duncan Laurie | 16a0f5c | 2013-09-25 14:08:16 -0700 | [diff] [blame] | 127 | usb_xhci_reset_port_usb3(mem_base, port); |
| 128 | else |
| 129 | port_disabled |= 1 << port; |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | /* Wait for warm reset complete on all reset ports */ |
| 133 | for (timeout = XHCI_RESET_TIMEOUT; timeout; timeout--) { |
| 134 | int complete = 1; |
| 135 | for (port = 0; port < port_count; port++) { |
| 136 | /* Only check ports that were reset */ |
| 137 | if (port_disabled & (1 << port)) |
| 138 | continue; |
| 139 | /* Check if warm reset is complete */ |
| 140 | status = read32(mem_base + XHCI_USB3_PORTSC(port)); |
| 141 | if (!(status & XHCI_USB3_PORTSC_WRC)) |
| 142 | complete = 0; |
| 143 | } |
| 144 | /* Check for warm reset complete in any port */ |
| 145 | if (complete) |
| 146 | break; |
| 147 | udelay(XHCI_RESET_DELAY_US); |
| 148 | } |
| 149 | |
| 150 | /* Clear port change status bits */ |
| 151 | for (port = 0; port < port_count; port++) |
| 152 | usb_xhci_reset_status_usb3(mem_base, port); |
| 153 | } |
| 154 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 155 | #ifdef __SIMPLE_DEVICE__ |
Duncan Laurie | 32d2e2b | 2013-09-25 14:08:32 -0700 | [diff] [blame] | 156 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 157 | /* Handler for XHCI controller on entry to S3/S4/S5 */ |
Elyes HAOUAS | ab72fc2 | 2018-11-29 16:13:14 +0100 | [diff] [blame] | 158 | void usb_xhci_sleep_prepare(pci_devfn_t dev, u8 slp_typ) |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 159 | { |
| 160 | u16 reg16; |
| 161 | u32 reg32; |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 162 | u8 *mem_base = usb_xhci_mem_base(dev); |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 163 | |
Aaron Durbin | da5f509 | 2016-07-13 23:23:16 -0500 | [diff] [blame] | 164 | if (!mem_base || slp_typ < ACPI_S3) |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 165 | return; |
| 166 | |
| 167 | if (pch_is_lp()) { |
| 168 | /* Set D0 state */ |
| 169 | reg16 = pci_read_config16(dev, XHCI_PWR_CTL_STS); |
| 170 | reg16 &= ~PWR_CTL_SET_MASK; |
| 171 | reg16 |= PWR_CTL_SET_D0; |
| 172 | pci_write_config16(dev, XHCI_PWR_CTL_STS, reg16); |
| 173 | |
| 174 | /* Clear PCI 0xB0[14:13] */ |
| 175 | reg32 = pci_read_config32(dev, 0xb0); |
| 176 | reg32 &= ~((1 << 14) | (1 << 13)); |
| 177 | pci_write_config32(dev, 0xb0, reg32); |
| 178 | |
| 179 | /* Clear MMIO 0x816c[14,2] */ |
| 180 | reg32 = read32(mem_base + 0x816c); |
| 181 | reg32 &= ~((1 << 14) | (1 << 2)); |
| 182 | write32(mem_base + 0x816c, reg32); |
| 183 | |
Duncan Laurie | 0bf1dea | 2013-08-13 13:32:28 -0700 | [diff] [blame] | 184 | /* Reset disconnected USB3 ports */ |
Duncan Laurie | 16a0f5c | 2013-09-25 14:08:16 -0700 | [diff] [blame] | 185 | usb_xhci_reset_usb3(dev, 0); |
Duncan Laurie | 0bf1dea | 2013-08-13 13:32:28 -0700 | [diff] [blame] | 186 | |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 187 | /* Set MMIO 0x80e0[15] */ |
| 188 | reg32 = read32(mem_base + 0x80e0); |
| 189 | reg32 |= (1 << 15); |
| 190 | write32(mem_base + 0x80e0, reg32); |
| 191 | } |
| 192 | |
| 193 | /* Set D3Hot state and enable PME */ |
| 194 | pci_or_config16(dev, XHCI_PWR_CTL_STS, PWR_CTL_SET_D3); |
Duncan Laurie | 0bf1dea | 2013-08-13 13:32:28 -0700 | [diff] [blame] | 195 | pci_or_config16(dev, XHCI_PWR_CTL_STS, PWR_CTL_STATUS_PME); |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 196 | pci_or_config16(dev, XHCI_PWR_CTL_STS, PWR_CTL_ENABLE_PME); |
| 197 | } |
| 198 | |
Duncan Laurie | 911cedf | 2013-07-30 16:05:55 -0700 | [diff] [blame] | 199 | /* Route all ports to XHCI controller */ |
| 200 | void usb_xhci_route_all(void) |
| 201 | { |
| 202 | u32 port_mask, route; |
| 203 | u16 reg16; |
| 204 | |
| 205 | /* Skip if EHCI is already disabled */ |
| 206 | if (RCBA32(FD) & PCH_DISABLE_EHCI1) |
| 207 | return; |
| 208 | |
| 209 | /* Set D0 state */ |
| 210 | reg16 = pci_read_config16(PCH_XHCI_DEV, XHCI_PWR_CTL_STS); |
| 211 | reg16 &= ~PWR_CTL_SET_MASK; |
| 212 | reg16 |= PWR_CTL_SET_D0; |
| 213 | pci_write_config16(PCH_XHCI_DEV, XHCI_PWR_CTL_STS, reg16); |
| 214 | |
| 215 | /* Set USB3 superspeed enable */ |
| 216 | port_mask = pci_read_config32(PCH_XHCI_DEV, XHCI_USB3PRM); |
| 217 | route = pci_read_config32(PCH_XHCI_DEV, XHCI_USB3PR); |
| 218 | route &= ~XHCI_USB3PR_SSEN; |
| 219 | route |= XHCI_USB3PR_SSEN & port_mask; |
| 220 | pci_write_config32(PCH_XHCI_DEV, XHCI_USB3PR, route); |
| 221 | |
| 222 | /* Route USB2 ports to XHCI controller */ |
| 223 | port_mask = pci_read_config32(PCH_XHCI_DEV, XHCI_USB2PRM); |
| 224 | route = pci_read_config32(PCH_XHCI_DEV, XHCI_USB2PR); |
| 225 | route &= ~XHCI_USB2PR_HCSEL; |
| 226 | route |= XHCI_USB2PR_HCSEL & port_mask; |
| 227 | pci_write_config32(PCH_XHCI_DEV, XHCI_USB2PR, route); |
| 228 | |
| 229 | /* Disable EHCI controller */ |
| 230 | usb_ehci_disable(PCH_EHCI1_DEV); |
| 231 | |
| 232 | /* LynxPoint-H has a second EHCI controller */ |
| 233 | if (!pch_is_lp()) |
| 234 | usb_ehci_disable(PCH_EHCI2_DEV); |
| 235 | |
| 236 | /* Reset and clear port change status */ |
Duncan Laurie | 16a0f5c | 2013-09-25 14:08:16 -0700 | [diff] [blame] | 237 | usb_xhci_reset_usb3(PCH_XHCI_DEV, 1); |
Duncan Laurie | 911cedf | 2013-07-30 16:05:55 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 240 | #else /* !__SIMPLE_DEVICE__ */ |
Duncan Laurie | 1f52908 | 2013-07-30 15:53:45 -0700 | [diff] [blame] | 241 | |
Elyes HAOUAS | ab72fc2 | 2018-11-29 16:13:14 +0100 | [diff] [blame] | 242 | static void usb_xhci_clock_gating(struct device *dev) |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 243 | { |
| 244 | u32 reg32; |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 245 | u16 reg16; |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 246 | |
| 247 | /* IOBP 0xE5004001[7:6] = 11b */ |
| 248 | pch_iobp_update(0xe5004001, ~0, (1 << 7)|(1 << 6)); |
| 249 | |
| 250 | reg32 = pci_read_config32(dev, 0x40); |
| 251 | reg32 &= ~(1 << 23); /* unsupported request */ |
| 252 | |
| 253 | if (pch_is_lp()) { |
| 254 | /* D20:F0:40h[18,17,8] = 111b */ |
| 255 | reg32 |= (1 << 18) | (1 << 17) | (1 << 8); |
| 256 | /* D20:F0:40h[21,20,19] = 110b to enable XHCI Idle L1 */ |
| 257 | reg32 &= ~(1 << 19); |
| 258 | reg32 |= (1 << 21) | (1 << 20); |
| 259 | } else { |
| 260 | /* D20:F0:40h[21,20,18,17,8] = 11111b */ |
| 261 | reg32 |= (1 << 21)|(1 << 20)|(1 << 18)|(1 << 17)|(1 << 8); |
| 262 | } |
| 263 | |
| 264 | /* Avoid writing upper byte as it is write-once */ |
| 265 | pci_write_config16(dev, 0x40, (u16)(reg32 & 0xffff)); |
| 266 | pci_write_config8(dev, 0x40 + 2, (u8)((reg32 >> 16) & 0xff)); |
| 267 | |
| 268 | /* D20:F0:44h[9,7,3] = 111b */ |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 269 | reg16 = pci_read_config16(dev, 0x44); |
| 270 | reg16 |= (1 << 9) | (1 << 7) | (1 << 3); |
| 271 | pci_write_config16(dev, 0x44, reg16); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 272 | |
| 273 | reg32 = pci_read_config32(dev, 0xa0); |
| 274 | if (pch_is_lp()) { |
| 275 | /* D20:F0:A0h[18] = 1 */ |
| 276 | reg32 |= (1 << 18); |
| 277 | } else { |
| 278 | /* D20:F0:A0h[6] = 1 */ |
| 279 | reg32 |= (1 << 6); |
| 280 | } |
| 281 | pci_write_config32(dev, 0xa0, reg32); |
| 282 | |
| 283 | /* D20:F0:A4h[13] = 0 */ |
| 284 | reg32 = pci_read_config32(dev, 0xa4); |
| 285 | reg32 &= ~(1 << 13); |
| 286 | pci_write_config32(dev, 0xa4, reg32); |
| 287 | } |
| 288 | |
Elyes HAOUAS | ab72fc2 | 2018-11-29 16:13:14 +0100 | [diff] [blame] | 289 | static void usb_xhci_init(struct device *dev) |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 290 | { |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 291 | u32 reg32; |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 292 | u16 reg16; |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 293 | u8 *mem_base = usb_xhci_mem_base(dev); |
Stefan Reinauer | 6dbbe2e | 2013-10-17 17:00:26 -0700 | [diff] [blame] | 294 | config_t *config = dev->chip_info; |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 295 | |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 296 | /* D20:F0:74h[1:0] = 00b (set D0 state) */ |
| 297 | reg16 = pci_read_config16(dev, XHCI_PWR_CTL_STS); |
| 298 | reg16 &= ~PWR_CTL_SET_MASK; |
| 299 | reg16 |= PWR_CTL_SET_D0; |
| 300 | pci_write_config16(dev, XHCI_PWR_CTL_STS, reg16); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 301 | |
| 302 | /* Enable clock gating first */ |
| 303 | usb_xhci_clock_gating(dev); |
| 304 | |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 305 | reg32 = read32(mem_base + 0x8144); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 306 | if (pch_is_lp()) { |
| 307 | /* XHCIBAR + 8144h[8,7,6] = 111b */ |
| 308 | reg32 |= (1 << 8) | (1 << 7) | (1 << 6); |
| 309 | } else { |
| 310 | /* XHCIBAR + 8144h[8,7,6] = 100b */ |
| 311 | reg32 &= ~((1 << 7) | (1 << 6)); |
| 312 | reg32 |= (1 << 8); |
| 313 | } |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 314 | write32(mem_base + 0x8144, reg32); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 315 | |
| 316 | if (pch_is_lp()) { |
Duncan Laurie | 527b03a | 2013-08-28 09:53:50 -0700 | [diff] [blame] | 317 | /* XHCIBAR + 816Ch[19:0] = 000e0038h */ |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 318 | reg32 = read32(mem_base + 0x816c); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 319 | reg32 &= ~0x000fffff; |
Duncan Laurie | 527b03a | 2013-08-28 09:53:50 -0700 | [diff] [blame] | 320 | reg32 |= 0x000e0038; |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 321 | write32(mem_base + 0x816c, reg32); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 322 | |
| 323 | /* D20:F0:B0h[17,14,13] = 100b */ |
| 324 | reg32 = pci_read_config32(dev, 0xb0); |
| 325 | reg32 &= ~((1 << 14) | (1 << 13)); |
| 326 | reg32 |= (1 << 17); |
| 327 | pci_write_config32(dev, 0xb0, reg32); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | reg32 = pci_read_config32(dev, 0x50); |
| 331 | if (pch_is_lp()) { |
| 332 | /* D20:F0:50h[28:0] = 0FCE2E5Fh */ |
| 333 | reg32 &= ~0x1fffffff; |
| 334 | reg32 |= 0x0fce2e5f; |
| 335 | } else { |
| 336 | /* D20:F0:50h[26:0] = 07886E9Fh */ |
| 337 | reg32 &= ~0x07ffffff; |
| 338 | reg32 |= 0x07886e9f; |
| 339 | } |
| 340 | pci_write_config32(dev, 0x50, reg32); |
| 341 | |
| 342 | /* D20:F0:44h[31] = 1 (Access Control Bit) */ |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 343 | reg32 = pci_read_config32(dev, 0x44); |
Ryan Salsamendi | 0d9b360 | 2017-06-30 17:15:57 -0700 | [diff] [blame] | 344 | reg32 |= (1UL << 31); |
Duncan Laurie | 0dcb577 | 2013-07-30 15:58:18 -0700 | [diff] [blame] | 345 | pci_write_config32(dev, 0x44, reg32); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 346 | |
| 347 | /* D20:F0:40h[31,23] = 10b (OC Configuration Done) */ |
| 348 | reg32 = pci_read_config32(dev, 0x40); |
| 349 | reg32 &= ~(1 << 23); /* unsupported request */ |
Ryan Salsamendi | 0d9b360 | 2017-06-30 17:15:57 -0700 | [diff] [blame] | 350 | reg32 |= (1UL << 31); |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 351 | pci_write_config32(dev, 0x40, reg32); |
Duncan Laurie | 32d2e2b | 2013-09-25 14:08:32 -0700 | [diff] [blame] | 352 | |
| 353 | if (acpi_is_wakeup_s3()) { |
| 354 | /* Reset ports that are disabled or |
| 355 | * polling before returning to the OS. */ |
| 356 | usb_xhci_reset_usb3(dev, 0); |
Stefan Reinauer | 6dbbe2e | 2013-10-17 17:00:26 -0700 | [diff] [blame] | 357 | } else if (config->xhci_default) { |
| 358 | /* Route all ports to XHCI */ |
| 359 | outb(0xca, 0xb2); |
Duncan Laurie | 32d2e2b | 2013-09-25 14:08:32 -0700 | [diff] [blame] | 360 | } |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 363 | static struct pci_operations lops_pci = { |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 364 | .set_subsystem = &pci_dev_set_subsystem, |
Duncan Laurie | 2d9d39a | 2013-05-29 15:27:55 -0700 | [diff] [blame] | 365 | }; |
| 366 | |
| 367 | static struct device_operations usb_xhci_ops = { |
| 368 | .read_resources = pci_dev_read_resources, |
| 369 | .set_resources = pci_dev_set_resources, |
| 370 | .enable_resources = pci_dev_enable_resources, |
| 371 | .init = usb_xhci_init, |
| 372 | .ops_pci = &lops_pci, |
| 373 | }; |
| 374 | |
| 375 | static const unsigned short pci_device_ids[] = { 0x8c31, /* LynxPoint-H */ |
| 376 | 0x9c31, /* LynxPoint-LP */ |
| 377 | 0 }; |
| 378 | |
| 379 | static const struct pci_driver pch_usb_xhci __pci_driver = { |
| 380 | .ops = &usb_xhci_ops, |
| 381 | .vendor = PCI_VENDOR_ID_INTEL, |
| 382 | .devices = pci_device_ids, |
| 383 | }; |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 384 | #endif /* !__SIMPLE_DEVICE__ */ |