| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <cpu/intel/haswell/haswell.h> |
| 5 |
#include <delay.h> |
| 6 |
#include <device/device.h> |
| 7 |
#include <device/pci.h> |
| 8 |
#include <device/pciexp.h> |
| 9 |
#include <device/pci_ids.h> |
| 10 |
#include <device/pci_ops.h> |
| 11 |
#include <soc/lpc.h> |
| 12 |
#include <soc/pch.h> |
| 13 |
#include <soc/pci_devs.h> |
| 14 |
#include <soc/rcba.h> |
| 15 |
#include <soc/intel/broadwell/pch/chip.h> |
| 16 |
#include <southbridge/intel/lynxpoint/iobp.h> |
| 17 |
#include <southbridge/intel/lynxpoint/lp_gpio.h> |
| 18 |
#include <types.h> |
| 19 |
|
| 20 |
|
| 21 |
#define MAX_NUM_ROOT_PORTS 6 |
| 22 |
|
| 23 |
struct root_port_config { |
| 24 |
|
| 25 |
u32 orig_rpfn; |
| 26 |
u32 new_rpfn; |
| 27 |
u32 pin_ownership; |
| 28 |
u32 strpfusecfg1; |
| 29 |
u32 strpfusecfg2; |
| 30 |
u32 strpfusecfg3; |
| 31 |
u32 b0d28f0_32c; |
| 32 |
u32 b0d28f4_32c; |
| 33 |
u32 b0d28f5_32c; |
| 34 |
bool coalesce; |
| 35 |
int gbe_port; |
| 36 |
int num_ports; |
| 37 |
struct device *ports[MAX_NUM_ROOT_PORTS]; |
| 38 |
}; |
| 39 |
|
| 40 |
static struct root_port_config rpc; |
| 41 |
|
| 42 |
static inline int root_port_is_first(struct device *dev) |
| 43 |
{ |
| 44 |
return PCI_FUNC(dev->path.pci.devfn) == 0; |
| 45 |
} |
| 46 |
|
| 47 |
static inline int root_port_is_last(struct device *dev) |
| 48 |
{ |
| 49 |
return PCI_FUNC(dev->path.pci.devfn) == (rpc.num_ports - 1); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
static inline int root_port_number(struct device *dev) |
| 54 |
{ |
| 55 |
return PCI_FUNC(dev->path.pci.devfn) + 1; |
| 56 |
} |
| 57 |
|
| 58 |
static void root_port_config_update_gbe_port(void) |
| 59 |
{ |
| 60 |
|
| 61 |
if (!((rpc.strpfusecfg1 >> 19) & 1)) |
| 62 |
return; |
| 63 |
|
| 64 |
switch ((rpc.strpfusecfg1 >> 16) & 0x7) { |
| 65 |
case 0: |
| 66 |
rpc.gbe_port = 3; |
| 67 |
break; |
| 68 |
case 1: |
| 69 |
rpc.gbe_port = 4; |
| 70 |
break; |
| 71 |
case 2: |
| 72 |
case 3: |
| 73 |
case 4: |
| 74 |
case 5: |
| 75 |
|
| 76 |
rpc.gbe_port = 5; |
| 77 |
break; |
| 78 |
default: |
| 79 |
printk(BIOS_DEBUG, "Invalid GbE Port Selection.\n"); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
static void pcie_iosf_port_grant_count(struct device *dev) |
| 84 |
{ |
| 85 |
u8 update_val; |
| 86 |
u32 rpcd = (pci_read_config32(dev, 0xfc) >> 14) & 0x3; |
| 87 |
|
| 88 |
switch (rpcd) { |
| 89 |
case 1: |
| 90 |
case 3: |
| 91 |
update_val = 0x02; |
| 92 |
break; |
| 93 |
case 2: |
| 94 |
update_val = 0x22; |
| 95 |
break; |
| 96 |
default: |
| 97 |
update_val = 0x00; |
| 98 |
break; |
| 99 |
} |
| 100 |
|
| 101 |
RCBA32(0x103C) = (RCBA32(0x103C) & (~0xff)) | update_val; |
| 102 |
} |
| 103 |
|
| 104 |
static void root_port_init_config(struct device *dev) |
| 105 |
{ |
| 106 |
int rp; |
| 107 |
u32 data = 0; |
| 108 |
u8 resp, id; |
| 109 |
|
| 110 |
if (root_port_is_first(dev)) { |
| 111 |
rpc.orig_rpfn = RCBA32(RPFN); |
| 112 |
rpc.new_rpfn = rpc.orig_rpfn; |
| 113 |
rpc.num_ports = MAX_NUM_ROOT_PORTS; |
| 114 |
rpc.gbe_port = -1; |
| 115 |
|
| 116 |
pci_update_config8(dev, 0xf5, ~0xa, 0x5); |
| 117 |
|
| 118 |
pcie_iosf_port_grant_count(dev); |
| 119 |
|
| 120 |
rpc.pin_ownership = pci_read_config32(dev, 0x410); |
| 121 |
root_port_config_update_gbe_port(); |
| 122 |
|
| 123 |
pci_or_config8(dev, 0xe2, 3 << 4); |
| 124 |
const struct soc_intel_broadwell_pch_config *config = config_of(dev); |
| 125 |
rpc.coalesce = config->pcie_port_coalesce; |
| 126 |
} |
| 127 |
|
| 128 |
rp = root_port_number(dev); |
| 129 |
if (rp > rpc.num_ports) { |
| 130 |
printk(BIOS_ERR, "Found Root Port %d, expecting %d\n", |
| 131 |
rp, rpc.num_ports); |
| 132 |
return; |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
switch (rp) { |
| 137 |
case 1: |
| 138 |
rpc.strpfusecfg1 = pci_read_config32(dev, 0xfc); |
| 139 |
rpc.b0d28f0_32c = pci_read_config32(dev, 0x32c); |
| 140 |
break; |
| 141 |
case 5: |
| 142 |
rpc.strpfusecfg2 = pci_read_config32(dev, 0xfc); |
| 143 |
rpc.b0d28f4_32c = pci_read_config32(dev, 0x32c); |
| 144 |
break; |
| 145 |
case 6: |
| 146 |
rpc.b0d28f5_32c = pci_read_config32(dev, 0x32c); |
| 147 |
rpc.strpfusecfg3 = pci_read_config32(dev, 0xfc); |
| 148 |
break; |
| 149 |
default: |
| 150 |
break; |
| 151 |
} |
| 152 |
|
| 153 |
pci_write_config32(dev, 0x418, 0x02000430); |
| 154 |
|
| 155 |
if (root_port_is_first(dev)) { |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
id = 0xe0 + (u8)(RCBA32(RPFN) & 0x07); |
| 161 |
pch_iobp_exec(0xE00000E0, IOBP_PCICFG_READ, id, &data, &resp); |
| 162 |
data |= ((0x30 << 16) | (0x40 << 8)); |
| 163 |
pch_iobp_exec(0xE00000E0, IOBP_PCICFG_WRITE, id, &data, &resp); |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
rpc.ports[rp - 1] = dev; |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
static void pch_pcie_device_set_func(int index, int pci_func) |
| 172 |
{ |
| 173 |
struct device *dev; |
| 174 |
unsigned int new_devfn; |
| 175 |
|
| 176 |
dev = rpc.ports[index]; |
| 177 |
|
| 178 |
|
| 179 |
rpc.new_rpfn &= ~RPFN_FNMASK(index); |
| 180 |
rpc.new_rpfn |= RPFN_FNSET(index, pci_func); |
| 181 |
|
| 182 |
|
| 183 |
new_devfn = PCI_DEVFN(PCH_DEV_SLOT_PCIE, pci_func); |
| 184 |
|
| 185 |
if (dev && dev->path.pci.devfn != new_devfn) { |
| 186 |
printk(BIOS_DEBUG, |
| 187 |
"PCH: PCIe map %02x.%1x -> %02x.%1x\n", |
| 188 |
PCI_SLOT(dev->path.pci.devfn), |
| 189 |
PCI_FUNC(dev->path.pci.devfn), |
| 190 |
PCI_SLOT(new_devfn), PCI_FUNC(new_devfn)); |
| 191 |
|
| 192 |
dev->path.pci.devfn = new_devfn; |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
static void pcie_enable_clock_gating(void) |
| 197 |
{ |
| 198 |
int i; |
| 199 |
int enabled_ports = 0; |
| 200 |
int is_broadwell = !!(cpu_family_model() == BROADWELL_FAMILY_ULT); |
| 201 |
|
| 202 |
for (i = 0; i < rpc.num_ports; i++) { |
| 203 |
struct device *dev; |
| 204 |
int rp; |
| 205 |
|
| 206 |
dev = rpc.ports[i]; |
| 207 |
if (!dev) |
| 208 |
continue; |
| 209 |
|
| 210 |
rp = root_port_number(dev); |
| 211 |
|
| 212 |
if (!dev->enabled) { |
| 213 |
|
| 214 |
if (rp == 1 || rp == 5 || rp == 6) |
| 215 |
pci_or_config8(dev, 0xe1, 0x3c); |
| 216 |
|
| 217 |
pci_or_config8(dev, 0xe2, 3 << 4); |
| 218 |
pci_or_config32(dev, 0x420, 1 << 31); |
| 219 |
|
| 220 |
|
| 221 |
if (gpio_is_native(18 + rp - 1)) |
| 222 |
pci_or_config32(dev, 0x420, 3 << 29); |
| 223 |
|
| 224 |
|
| 225 |
if (rp == 1 && !rpc.ports[1]->enabled && |
| 226 |
!rpc.ports[2]->enabled && !rpc.ports[3]->enabled) { |
| 227 |
pci_or_config8(dev, 0xe2, 1); |
| 228 |
pci_or_config8(dev, 0xe1, 1 << 7); |
| 229 |
} else if (rp == 5 || rp == 6) { |
| 230 |
pci_or_config8(dev, 0xe2, 1); |
| 231 |
pci_or_config8(dev, 0xe1, 1 << 7); |
| 232 |
} |
| 233 |
continue; |
| 234 |
} |
| 235 |
|
| 236 |
enabled_ports++; |
| 237 |
|
| 238 |
|
| 239 |
pci_or_config8(dev, 0xe1, 0x03); |
| 240 |
pci_or_config8(dev, 0xe2, 1 << 6); |
| 241 |
pci_update_config8(dev, 0xe8, ~(3 << 2), (2 << 2)); |
| 242 |
|
| 243 |
|
| 244 |
pci_or_config8(dev, 0xe8, 3); |
| 245 |
|
| 246 |
if (is_broadwell) { |
| 247 |
pci_or_config32(dev, 0x324, (1 << 5) | (1 << 14)); |
| 248 |
} else { |
| 249 |
pci_or_config32(dev, 0x324, 1 << 5); |
| 250 |
} |
| 251 |
|
| 252 |
if (gpio_is_native(18 + rp - 1)) |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
pci_update_config32(dev, 0x420, ~(1 << 17), (3 << 29) | 1); |
| 258 |
|
| 259 |
|
| 260 |
if (rp == 1 || rp == 5 || rp == 6) |
| 261 |
pci_or_config8(dev, 0xe1, 0x3c); |
| 262 |
|
| 263 |
|
| 264 |
RCBA32_OR(0x2b1c, (1 << (16 + i))); |
| 265 |
} |
| 266 |
|
| 267 |
if (!enabled_ports) |
| 268 |
pci_or_config8(rpc.ports[0], 0xe1, 1 << 6); |
| 269 |
} |
| 270 |
|
| 271 |
static void root_port_commit_config(void) |
| 272 |
{ |
| 273 |
int i; |
| 274 |
|
| 275 |
|
| 276 |
if (!rpc.ports[0]->enabled) |
| 277 |
rpc.coalesce = true; |
| 278 |
|
| 279 |
|
| 280 |
pcie_enable_clock_gating(); |
| 281 |
|
| 282 |
for (i = 0; i < rpc.num_ports; i++) { |
| 283 |
struct device *dev; |
| 284 |
u32 reg32; |
| 285 |
int n = 0; |
| 286 |
|
| 287 |
dev = rpc.ports[i]; |
| 288 |
|
| 289 |
if (dev == NULL) { |
| 290 |
printk(BIOS_ERR, "Root Port %d device is NULL?\n", i+1); |
| 291 |
continue; |
| 292 |
} |
| 293 |
|
| 294 |
if (dev->enabled) |
| 295 |
continue; |
| 296 |
|
| 297 |
printk(BIOS_DEBUG, "%s: Disabling device\n", dev_path(dev)); |
| 298 |
|
| 299 |
|
| 300 |
pci_or_config32(dev, 0x338, 1 << 26); |
| 301 |
|
| 302 |
do { |
| 303 |
reg32 = pci_read_config32(dev, 0x328); |
| 304 |
n++; |
| 305 |
if (((reg32 & 0xff000000) == 0x01000000) || (n > 50)) |
| 306 |
break; |
| 307 |
udelay(100); |
| 308 |
} while (1); |
| 309 |
|
| 310 |
if (n > 50) |
| 311 |
printk(BIOS_DEBUG, "%s: Timeout waiting for 328h\n", |
| 312 |
dev_path(dev)); |
| 313 |
|
| 314 |
pci_or_config32(dev, 0x408, 1 << 27); |
| 315 |
|
| 316 |
|
| 317 |
pch_disable_devfn(dev); |
| 318 |
} |
| 319 |
|
| 320 |
if (rpc.coalesce) { |
| 321 |
int current_func; |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
current_func = 0; |
| 327 |
for (i = 0; i < rpc.num_ports; i++) { |
| 328 |
if (!rpc.ports[i]->enabled) |
| 329 |
continue; |
| 330 |
pch_pcie_device_set_func(i, current_func); |
| 331 |
current_func++; |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
for (i = 0; i < rpc.num_ports; i++) { |
| 336 |
if (rpc.ports[i]->enabled) |
| 337 |
continue; |
| 338 |
pch_pcie_device_set_func(i, current_func); |
| 339 |
current_func++; |
| 340 |
} |
| 341 |
} |
| 342 |
|
| 343 |
printk(BIOS_SPEW, "PCH: RPFN 0x%08x -> 0x%08x\n", |
| 344 |
rpc.orig_rpfn, rpc.new_rpfn); |
| 345 |
RCBA32(RPFN) = rpc.new_rpfn; |
| 346 |
} |
| 347 |
|
| 348 |
static void root_port_mark_disable(struct device *dev) |
| 349 |
{ |
| 350 |
|
| 351 |
dev->enabled = 0; |
| 352 |
|
| 353 |
rpc.new_rpfn |= RPFN_HIDE(PCI_FUNC(dev->path.pci.devfn)); |
| 354 |
} |
| 355 |
|
| 356 |
static void root_port_check_disable(struct device *dev) |
| 357 |
{ |
| 358 |
int rp; |
| 359 |
|
| 360 |
|
| 361 |
if (!dev->enabled) { |
| 362 |
root_port_mark_disable(dev); |
| 363 |
return; |
| 364 |
} |
| 365 |
|
| 366 |
rp = root_port_number(dev); |
| 367 |
|
| 368 |
|
| 369 |
if (rp == rpc.gbe_port) { |
| 370 |
root_port_mark_disable(dev); |
| 371 |
return; |
| 372 |
} |
| 373 |
|
| 374 |
|
| 375 |
switch (rp) { |
| 376 |
case 2: |
| 377 |
|
| 378 |
|
| 379 |
if ((rpc.strpfusecfg1 >> 14) & 0x3) { |
| 380 |
root_port_mark_disable(dev); |
| 381 |
return; |
| 382 |
} |
| 383 |
break; |
| 384 |
case 3: |
| 385 |
|
| 386 |
if (((rpc.strpfusecfg1 >> 14) & 0x3) == 0x3) { |
| 387 |
root_port_mark_disable(dev); |
| 388 |
return; |
| 389 |
} |
| 390 |
break; |
| 391 |
case 4: |
| 392 |
|
| 393 |
|
| 394 |
if ((rpc.strpfusecfg1 >> 14) & 0x2) { |
| 395 |
root_port_mark_disable(dev); |
| 396 |
return; |
| 397 |
} |
| 398 |
break; |
| 399 |
} |
| 400 |
|
| 401 |
|
| 402 |
switch (rp) { |
| 403 |
case 1: |
| 404 |
|
| 405 |
if ((rpc.pin_ownership & 0x1) == 0) { |
| 406 |
root_port_mark_disable(dev); |
| 407 |
return; |
| 408 |
} |
| 409 |
break; |
| 410 |
case 2: |
| 411 |
|
| 412 |
if ((rpc.pin_ownership & 0x4) == 0) { |
| 413 |
root_port_mark_disable(dev); |
| 414 |
return; |
| 415 |
} |
| 416 |
break; |
| 417 |
case 6: |
| 418 |
|
| 419 |
if ((rpc.pin_ownership & 0xf0) == 0) { |
| 420 |
root_port_mark_disable(dev); |
| 421 |
return; |
| 422 |
} |
| 423 |
break; |
| 424 |
} |
| 425 |
} |
| 426 |
|
| 427 |
static void pcie_add_0x0202000_iobp(u32 reg) |
| 428 |
{ |
| 429 |
u32 reg32; |
| 430 |
|
| 431 |
reg32 = pch_iobp_read(reg); |
| 432 |
reg32 += (0x2 << 16) | (0x2 << 8); |
| 433 |
pch_iobp_write(reg, reg32); |
| 434 |
} |
| 435 |
|
| 436 |
static void pch_pcie_early(struct device *dev) |
| 437 |
{ |
| 438 |
const struct soc_intel_broadwell_pch_config *config = config_of(dev); |
| 439 |
int do_aspm = 0; |
| 440 |
int rp = root_port_number(dev); |
| 441 |
|
| 442 |
switch (rp) { |
| 443 |
case 1: |
| 444 |
case 2: |
| 445 |
case 3: |
| 446 |
case 4: |
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
do_aspm = !!(rpc.b0d28f0_32c & (1 << (28 + rp - 1))); |
| 452 |
break; |
| 453 |
case 5: |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
do_aspm = !!(rpc.b0d28f4_32c & (1 << 28)); |
| 459 |
break; |
| 460 |
case 6: |
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
do_aspm = !!(rpc.b0d28f5_32c & (1 << 29)); |
| 466 |
break; |
| 467 |
} |
| 468 |
|
| 469 |
|
| 470 |
if ((config->pcie_port_force_aspm & (1 << (rp - 1)))) |
| 471 |
do_aspm = 1; |
| 472 |
|
| 473 |
printk(BIOS_DEBUG, "PCIe Root Port %d ASPM is %sabled\n", |
| 474 |
rp, do_aspm ? "en" : "dis"); |
| 475 |
|
| 476 |
if (do_aspm) { |
| 477 |
|
| 478 |
pci_update_config32(dev, 0xd4, ~(0x3 << 2), (1 << 4) | (0x2 << 2)); |
| 479 |
|
| 480 |
|
| 481 |
pci_update_config32(dev, 0xd8, ~(0x7 << 18), (0x7 << 18)); |
| 482 |
|
| 483 |
switch (rp) { |
| 484 |
case 1: |
| 485 |
pcie_add_0x0202000_iobp(0xe9002440); |
| 486 |
break; |
| 487 |
case 2: |
| 488 |
pcie_add_0x0202000_iobp(0xe9002640); |
| 489 |
break; |
| 490 |
case 3: |
| 491 |
pcie_add_0x0202000_iobp(0xe9000840); |
| 492 |
break; |
| 493 |
case 4: |
| 494 |
pcie_add_0x0202000_iobp(0xe9000a40); |
| 495 |
break; |
| 496 |
case 5: |
| 497 |
pcie_add_0x0202000_iobp(0xe9000c40); |
| 498 |
pcie_add_0x0202000_iobp(0xe9000e40); |
| 499 |
pcie_add_0x0202000_iobp(0xe9001040); |
| 500 |
pcie_add_0x0202000_iobp(0xe9001240); |
| 501 |
break; |
| 502 |
case 6: |
| 503 |
|
| 504 |
if (rpc.pin_ownership & (1 << 4)) |
| 505 |
pcie_add_0x0202000_iobp(0xea002040); |
| 506 |
if (rpc.pin_ownership & (1 << 5)) |
| 507 |
pcie_add_0x0202000_iobp(0xea002240); |
| 508 |
if (rpc.pin_ownership & (1 << 6)) |
| 509 |
pcie_add_0x0202000_iobp(0xea002440); |
| 510 |
if (rpc.pin_ownership & (1 << 7)) |
| 511 |
pcie_add_0x0202000_iobp(0xea002640); |
| 512 |
break; |
| 513 |
} |
| 514 |
|
| 515 |
pci_update_config32(dev, 0x338, ~(1 << 26), 0); |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
pci_update_config32(dev, 0x64, ~(3 << 18), (1 << 11)); |
| 520 |
pci_or_config32(dev, 0x68, 1 << 10); |
| 521 |
|
| 522 |
pci_update_config32(dev, 0x318, ~(0xffff << 16), (0x1414 << 16)); |
| 523 |
|
| 524 |
|
| 525 |
if ((pci_read_config8(dev, 0xf5) & 0x1) || do_aspm) |
| 526 |
pci_update_config32(dev, 0x4c, ~(0x7 << 15), (0x4 << 15)); |
| 527 |
else |
| 528 |
pci_update_config32(dev, 0x4c, ~(0x7 << 15), (0x2 << 15)); |
| 529 |
|
| 530 |
pci_update_config32(dev, 0x314, 0, 0x743a361b); |
| 531 |
|
| 532 |
|
| 533 |
pci_update_config32(dev, 0xd8, ~(0x7 << 15), (0x3 << 15)); |
| 534 |
|
| 535 |
pci_update_config32(dev, 0x33c, ~0x00ffffff, 0x854d74); |
| 536 |
|
| 537 |
|
| 538 |
pci_or_config32(dev, 0xd8, 1 << 25); |
| 539 |
|
| 540 |
pci_and_config8(dev, 0xf5, 0x0f); |
| 541 |
|
| 542 |
|
| 543 |
if (CONFIG(PCIEXP_AER)) |
| 544 |
pci_update_config32(dev, 0x100, ~0xfffff, (1 << 29) | 0x10001); |
| 545 |
else |
| 546 |
pci_update_config32(dev, 0x100, ~0xfffff, (1 << 29)); |
| 547 |
|
| 548 |
|
| 549 |
if (CONFIG(PCIEXP_L1_SUB_STATE)) |
| 550 |
pci_update_config32(dev, 0x200, ~0xfffff, 0x001e); |
| 551 |
else |
| 552 |
pci_update_config32(dev, 0x200, ~0xfffff, 0); |
| 553 |
|
| 554 |
pci_update_config32(dev, 0x320, ~(3 << 20) & ~(7 << 6), (1 << 20) | (3 << 6)); |
| 555 |
|
| 556 |
|
| 557 |
pci_or_config32(dev, 0x320, 3 << 23); |
| 558 |
|
| 559 |
if (rp == 1 || rp == 5 || rp == 6) |
| 560 |
pci_update_config8(dev, 0xf7, ~0xc, 0); |
| 561 |
|
| 562 |
|
| 563 |
pci_update_config32(dev, 0xd4, ~0, (1 << 1)); |
| 564 |
|
| 565 |
|
| 566 |
pci_update_config32(dev, 0x34, ~0, 0); |
| 567 |
pci_update_config32(dev, 0x40, ~0, 0); |
| 568 |
pci_update_config32(dev, 0x80, ~0, 0); |
| 569 |
pci_update_config32(dev, 0x90, ~0, 0); |
| 570 |
} |
| 571 |
|
| 572 |
static void pch_pcie_init(struct device *dev) |
| 573 |
{ |
| 574 |
printk(BIOS_DEBUG, "Initializing PCH PCIe bridge.\n"); |
| 575 |
|
| 576 |
|
| 577 |
pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_SERR); |
| 578 |
|
| 579 |
|
| 580 |
pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
| 581 |
|
| 582 |
|
| 583 |
pci_write_config8(dev, 0x0c, 0x10); |
| 584 |
|
| 585 |
pci_and_config16(dev, PCI_BRIDGE_CONTROL, ~PCI_BRIDGE_CTL_PARITY); |
| 586 |
|
| 587 |
|
| 588 |
pci_update_config16(dev, 0x06, ~0, 0); |
| 589 |
pci_update_config16(dev, 0x1e, ~0, 0); |
| 590 |
} |
| 591 |
|
| 592 |
static void pch_pcie_enable(struct device *dev) |
| 593 |
{ |
| 594 |
|
| 595 |
root_port_init_config(dev); |
| 596 |
|
| 597 |
|
| 598 |
root_port_check_disable(dev); |
| 599 |
|
| 600 |
|
| 601 |
if (dev->enabled) |
| 602 |
pch_pcie_early(dev); |
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
if (root_port_is_last(dev)) |
| 609 |
root_port_commit_config(); |
| 610 |
} |
| 611 |
|
| 612 |
static void pcie_get_ltr_max_latencies(u16 *max_snoop, u16 *max_nosnoop) |
| 613 |
{ |
| 614 |
*max_snoop = PCIE_LTR_MAX_SNOOP_LATENCY_3146US; |
| 615 |
*max_nosnoop = PCIE_LTR_MAX_NO_SNOOP_LATENCY_3146US; |
| 616 |
} |
| 617 |
|
| 618 |
static struct pci_operations pcie_ops = { |
| 619 |
.set_subsystem = pci_dev_set_subsystem, |
| 620 |
.get_ltr_max_latencies = pcie_get_ltr_max_latencies, |
| 621 |
}; |
| 622 |
|
| 623 |
static struct device_operations device_ops = { |
| 624 |
.read_resources = pci_bus_read_resources, |
| 625 |
.set_resources = pci_dev_set_resources, |
| 626 |
.enable_resources = pci_bus_enable_resources, |
| 627 |
.init = pch_pcie_init, |
| 628 |
.enable = pch_pcie_enable, |
| 629 |
.scan_bus = pciexp_scan_bridge, |
| 630 |
.ops_pci = &pcie_ops, |
| 631 |
}; |
| 632 |
|
| 633 |
static const unsigned short pcie_device_ids[] = { |
| 634 |
|
| 635 |
0x9c10, 0x9c12, 0x9c14, 0x9c16, 0x9c18, 0x9c1a, |
| 636 |
|
| 637 |
0x9c90, 0x9c92, 0x9c94, 0x9c96, 0x9c98, 0x9c9a, 0x2448, |
| 638 |
0 |
| 639 |
}; |
| 640 |
|
| 641 |
static const struct pci_driver pch_pcie __pci_driver = { |
| 642 |
.ops = &device_ops, |
| 643 |
.vendor = PCI_VID_INTEL, |
| 644 |
.devices = pcie_device_ids, |
| 645 |
}; |