coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pcie.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <assert.h>
4 #include <commonlib/helpers.h>
5 #include <console/console.h>
6 #include <device/device.h>
7 #include <device/pci.h>
8 #include <device/pci_def.h>
9 #include <device/pciexp.h>
10 #include <device/pci_ids.h>
11 #include <device/pci_ops.h>
12 #include "iobp.h"
13 #include "pch.h"
15 #include <stdint.h>
16 #include "chip.h"
17 
18 #define MAX_NUM_ROOT_PORTS 8
19 
20 struct root_port_config {
21  /* RPFN is a write-once register so keep a copy until it is written */
22  u32 orig_rpfn;
23  u32 new_rpfn;
31  bool coalesce;
32  int gbe_port;
33  int num_ports;
35 };
36 
37 static struct root_port_config rpc;
38 
39 static inline int max_root_ports(void)
40 {
42  return 6;
43 
44  return 8;
45 }
46 
47 static inline int root_port_is_first(struct device *dev)
48 {
49  return PCI_FUNC(dev->path.pci.devfn) == 0;
50 }
51 
52 static inline int root_port_is_last(struct device *dev)
53 {
54  return PCI_FUNC(dev->path.pci.devfn) == (rpc.num_ports - 1);
55 }
56 
57 /* Root ports are numbered 1..N in the documentation. */
58 static inline int root_port_number(struct device *dev)
59 {
60  return PCI_FUNC(dev->path.pci.devfn) + 1;
61 }
62 
63 static bool is_rp_enabled(int rp)
64 {
65  ASSERT(rp > 0 && rp <= ARRAY_SIZE(rpc.ports));
66 
67  if (rpc.ports[rp - 1] == NULL)
68  return false;
69 
70  return rpc.ports[rp - 1]->enabled;
71 }
72 
74 {
75  /* Is the Gbe Port enabled? */
76  if (!((rpc.strpfusecfg1 >> 19) & 1))
77  return;
78 
79  if (pch_is_lp()) {
80  switch ((rpc.strpfusecfg1 >> 16) & 0x7) {
81  case 0:
82  rpc.gbe_port = 3;
83  break;
84  case 1:
85  rpc.gbe_port = 4;
86  break;
87  case 2:
88  case 3:
89  case 4:
90  case 5:
91  /* Lanes 0-4 of Root Port 5. */
92  rpc.gbe_port = 5;
93  break;
94  default:
95  printk(BIOS_DEBUG, "Invalid GbE Port Selection.\n");
96  }
97  } else {
98  /* Non-LP has 1:1 mapping with root ports. */
99  rpc.gbe_port = ((rpc.strpfusecfg1 >> 16) & 0x7) + 1;
100  }
101 }
102 
103 static void update_num_ports(void)
104 {
105  /*
106  * According to existing code in 'root_port_check_disable()', which does
107  * not agree with the confusing information on the datasheets, the last
108  * visible function depends on the strapped root port width as follows:
109  *
110  * +-----+----+----+----+----+
111  * | RPC | #5 | #6 | #7 | #8 |
112  * +-----+----+----+----+----+
113  * | 0 | x1 | x1 | x1 | x1 |
114  * | 1 | x2 | | x1 | x1 |
115  * | 2 | x2 | | x2 | |
116  * | 3 | x4 | | | |
117  * +-----+----+----+----+----+
118  */
119  switch ((rpc.strpfusecfg2 >> 14) & 0x3) {
120  case 0:
121  case 1:
122  break;
123  case 2:
124  rpc.num_ports = MIN(rpc.num_ports, 7);
125  break;
126  case 3:
127  rpc.num_ports = MIN(rpc.num_ports, 5);
128  break;
129  }
130 
131  printk(BIOS_DEBUG, "Adjusted number of PCIe root ports to %d as per strpfusecfg2\n",
132  rpc.num_ports);
133 }
134 
135 static void root_port_init_config(struct device *dev)
136 {
137  int rp;
138 
139  if (root_port_is_first(dev)) {
143  rpc.gbe_port = -1;
144 
145  rpc.pin_ownership = pci_read_config32(dev, 0x410);
147 
148  if (dev->chip_info != NULL) {
150 
151  config = dev->chip_info;
152  rpc.coalesce = config->pcie_port_coalesce;
153  }
154  }
155 
156  rp = root_port_number(dev);
157  if (rp > rpc.num_ports) {
158  printk(BIOS_ERR, "Found Root Port %d, expecting %d\n",
159  rp, rpc.num_ports);
160  return;
161  }
162 
163  /* Read the fuse configuration and pin ownership. */
164  switch (rp) {
165  case 1:
166  rpc.strpfusecfg1 = pci_read_config32(dev, 0xfc);
167  rpc.b0d28f0_32c = pci_read_config32(dev, 0x32c);
168  break;
169  case 5:
170  rpc.strpfusecfg2 = pci_read_config32(dev, 0xfc);
171  rpc.b0d28f4_32c = pci_read_config32(dev, 0x32c);
172 
173  if (!pch_is_lp())
175 
176  break;
177  case 6:
178  rpc.b0d28f5_32c = pci_read_config32(dev, 0x32c);
179  rpc.strpfusecfg3 = pci_read_config32(dev, 0xfc);
180  break;
181  default:
182  break;
183  }
184 
185  /* Cache pci device. */
186  rpc.ports[rp - 1] = dev;
187 }
188 
189 /* Update devicetree with new Root Port function number assignment */
190 static void pch_pcie_device_set_func(int index, int pci_func)
191 {
192  struct device *dev;
193  unsigned int new_devfn;
194 
195  dev = rpc.ports[index];
196 
197  /* Set the new PCI function field for this Root Port. */
198  rpc.new_rpfn &= ~RPFN_FNMASK(index);
199  rpc.new_rpfn |= RPFN_FNSET(index, pci_func);
200 
201  /* Determine the new devfn for this port */
202  new_devfn = PCI_DEVFN(PCH_PCIE_DEV_SLOT, pci_func);
203 
204  if (dev && dev->path.pci.devfn != new_devfn) {
206  "PCH: PCIe map %02x.%1x -> %02x.%1x\n",
207  PCI_SLOT(dev->path.pci.devfn),
208  PCI_FUNC(dev->path.pci.devfn),
209  PCI_SLOT(new_devfn), PCI_FUNC(new_devfn));
210 
211  dev->path.pci.devfn = new_devfn;
212  }
213 }
214 
215 static void pcie_enable_clock_gating(void)
216 {
217  int i;
218  int is_lp;
219  int enabled_ports;
220 
221  is_lp = pch_is_lp();
222  enabled_ports = 0;
223 
224  for (i = 0; i < rpc.num_ports; i++) {
225  struct device *dev;
226  int rp;
227 
228  dev = rpc.ports[i];
229  if (!dev)
230  continue;
231 
232  rp = root_port_number(dev);
233 
234  if (!is_rp_enabled(rp)) {
235 
236  /* Configure shared resource clock gating. */
237  if (rp == 1 || rp == 5 || (rp == 6 && is_lp))
238  pci_or_config8(dev, 0xe1, 0x3c);
239 
240  if (!is_lp) {
241  if (rp == 1 && !is_rp_enabled(2) &&
242  !is_rp_enabled(3) && !is_rp_enabled(4)) {
243  pci_or_config8(dev, 0xe2, 1);
244  pci_or_config8(dev, 0xe1, 1 << 7);
245  }
246  if (rp == 5 && !is_rp_enabled(6) &&
247  !is_rp_enabled(7) && !is_rp_enabled(8)) {
248  pci_or_config8(dev, 0xe2, 1);
249  pci_or_config8(dev, 0xe1, 1 << 7);
250  }
251  continue;
252  }
253 
254  pci_or_config8(dev, 0xe2, 3 << 4);
255  pci_or_config32(dev, 0x420, 1 << 31);
256 
257  /* Per-Port CLKREQ# handling. */
258  if (is_lp && gpio_is_native(18 + rp - 1))
259  pci_or_config32(dev, 0x420, 3 << 29);
260 
261  /* Enable static clock gating. */
262  if (rp == 1 && !is_rp_enabled(2) &&
263  !is_rp_enabled(3) && !is_rp_enabled(4)) {
264  pci_or_config8(dev, 0xe2, 1);
265  pci_or_config8(dev, 0xe1, 1 << 7);
266  } else if (rp == 5 || rp == 6) {
267  pci_or_config8(dev, 0xe2, 1);
268  pci_or_config8(dev, 0xe1, 1 << 7);
269  }
270  continue;
271  }
272 
273  enabled_ports++;
274 
275  /* Enable dynamic clock gating. */
276  pci_or_config8(dev, 0xe1, 0x03);
277 
278  if (is_lp) {
279  pci_or_config8(dev, 0xe2, 1 << 6);
280  pci_update_config8(dev, 0xe8, ~(3 << 2), (2 << 2));
281  }
282 
283  /* Update PECR1 register. */
284  pci_or_config8(dev, 0xe8, 1);
285 
286  pci_or_config8(dev, 0x324, 1 << 5);
287 
288  /* Per-Port CLKREQ# handling. */
289  if (is_lp && gpio_is_native(18 + rp - 1))
290  pci_or_config32(dev, 0x420, 3 << 29);
291 
292  /* Configure shared resource clock gating. */
293  if (rp == 1 || rp == 5 || (rp == 6 && is_lp))
294  pci_or_config8(dev, 0xe1, 0x3c);
295  }
296 
297  if (!enabled_ports && is_lp && rpc.ports[0])
298  pci_or_config8(rpc.ports[0], 0xe1, 1 << 6);
299 }
300 
301 static void root_port_commit_config(void)
302 {
303  int i;
304 
305  /* If the first root port is disabled the coalesce ports. */
306  if (!is_rp_enabled(1))
307  rpc.coalesce = true;
308 
309  /* Perform clock gating configuration. */
311 
312  for (i = 0; i < rpc.num_ports; i++) {
313  struct device *dev;
314 
315  dev = rpc.ports[i];
316 
317  if (dev == NULL) {
318  printk(BIOS_ERR, "Root Port %d device is NULL?\n", i+1);
319  continue;
320  }
321 
322  if (dev->enabled)
323  continue;
324 
325  printk(BIOS_DEBUG, "%s: Disabling device\n", dev_path(dev));
326 
327  /* Ensure memory, io, and bus master are all disabled */
330 
331  /* Disable this device if possible */
332  pch_disable_devfn(dev);
333  }
334 
335  if (rpc.coalesce) {
336  int current_func;
337 
338  /* For all Root Ports N enabled ports get assigned the lower
339  * PCI function number. The disabled ones get upper PCI
340  * function numbers. */
341  current_func = 0;
342  for (i = 0; i < rpc.num_ports; i++) {
343  if (!is_rp_enabled(i + 1))
344  continue;
345  pch_pcie_device_set_func(i, current_func);
346  current_func++;
347  }
348 
349  /* Allocate the disabled devices' PCI function number. */
350  for (i = 0; i < rpc.num_ports; i++) {
351  if (is_rp_enabled(i + 1))
352  continue;
353  pch_pcie_device_set_func(i, current_func);
354  current_func++;
355  }
356  }
357 
358  printk(BIOS_SPEW, "PCH: RPFN 0x%08x -> 0x%08x\n",
360  RCBA32(RPFN) = rpc.new_rpfn;
361 }
362 
363 static void root_port_mark_disable(struct device *dev)
364 {
365  /* Mark device as disabled. */
366  dev->enabled = 0;
367  /* Mark device to be hidden. */
369 }
370 
371 static void root_port_check_disable(struct device *dev)
372 {
373  int rp;
374  int is_lp;
375 
376  /* Device already disabled. */
377  if (!dev->enabled) {
379  return;
380  }
381 
382  rp = root_port_number(dev);
383 
384  /* Is the GbE port mapped to this Root Port? */
385  if (rp == rpc.gbe_port) {
387  return;
388  }
389 
390  is_lp = pch_is_lp();
391 
392  /* Check Root Port Configuration. */
393  switch (rp) {
394  case 2:
395  /* Root Port 2 is disabled for all lane configurations
396  * but config 00b (4x1 links). */
397  if ((rpc.strpfusecfg1 >> 14) & 0x3) {
399  return;
400  }
401  break;
402  case 3:
403  /* Root Port 3 is disabled in config 11b (1x4 links). */
404  if (((rpc.strpfusecfg1 >> 14) & 0x3) == 0x3) {
406  return;
407  }
408  break;
409  case 4:
410  /* Root Port 4 is disabled in configs 11b (1x4 links)
411  * and 10b (2x2 links). */
412  if ((rpc.strpfusecfg1 >> 14) & 0x2) {
414  return;
415  }
416  break;
417  case 6:
418  if (is_lp)
419  break;
420  /* Root Port 6 is disabled for all lane configurations
421  * but config 00b (4x1 links). */
422  if ((rpc.strpfusecfg2 >> 14) & 0x3) {
424  return;
425  }
426  break;
427  case 7:
428  if (is_lp)
429  break;
430  /* Root Port 7 is disabled in config 11b (1x4 links). */
431  if (((rpc.strpfusecfg2 >> 14) & 0x3) == 0x3) {
433  return;
434  }
435  break;
436  case 8:
437  if (is_lp)
438  break;
439  /* Root Port 8 is disabled in configs 11b (1x4 links)
440  * and 10b (2x2 links). */
441  if ((rpc.strpfusecfg2 >> 14) & 0x2) {
443  return;
444  }
445  break;
446  }
447 
448  /* Check Pin Ownership. */
449  if (is_lp) {
450  switch (rp) {
451  case 1:
452  /* Bit 0 is Root Port 1 ownership. */
453  if ((rpc.pin_ownership & 0x1) == 0) {
455  return;
456  }
457  break;
458  case 2:
459  /* Bit 2 is Root Port 2 ownership. */
460  if ((rpc.pin_ownership & 0x4) == 0) {
462  return;
463  }
464  break;
465  case 6:
466  /* Bits 7:4 are Root Port 6 pin-lane ownership. */
467  if ((rpc.pin_ownership & 0xf0) == 0) {
469  return;
470  }
471  break;
472  }
473  } else {
474  switch (rp) {
475  case 1:
476  /* Bits 4 and 0 are Root Port 1 ownership. */
477  if ((rpc.pin_ownership & 0x11) == 0) {
479  return;
480  }
481  break;
482  case 2:
483  /* Bits 5 and 2 are Root Port 2 ownership. */
484  if ((rpc.pin_ownership & 0x24) == 0) {
486  return;
487  }
488  break;
489  }
490  }
491 }
492 
493 static void pcie_add_0x0202000_iobp(u32 reg)
494 {
495  u32 reg32;
496 
497  reg32 = pch_iobp_read(reg);
498  reg32 += (0x2 << 16) | (0x2 << 8);
499  pch_iobp_write(reg, reg32);
500 }
501 
502 static void pch_pcie_early(struct device *dev)
503 {
505  int do_aspm = 0;
506  int rp = root_port_number(dev);
507  int is_lp = pch_is_lp();
508 
509  if (is_lp) {
510  switch (rp) {
511  case 1:
512  case 2:
513  case 3:
514  case 4:
515  /*
516  * Bits 31:28 of b0d28f0 0x32c register correspond to
517  * Root Ports 4:1.
518  */
519  do_aspm = !!(rpc.b0d28f0_32c & (1 << (28 + rp - 1)));
520  break;
521  case 5:
522  /*
523  * Bit 28 of b0d28f4 0x32c register correspond to
524  * Root Ports 4:1.
525  */
526  do_aspm = !!(rpc.b0d28f4_32c & (1 << 28));
527  break;
528  case 6:
529  /*
530  * Bit 28 of b0d28f5 0x32c register correspond to
531  * Root Ports 4:1.
532  */
533  do_aspm = !!(rpc.b0d28f5_32c & (1 << 28));
534  break;
535  }
536  } else {
537  switch (rp) {
538  case 1:
539  case 2:
540  case 3:
541  case 4:
542  /*
543  * Bits 31:28 of b0d28f0 0x32c register correspond to
544  * Root Ports 4:1.
545  */
546  do_aspm = !!(rpc.b0d28f0_32c & (1 << (28 + rp - 1)));
547  break;
548  case 5:
549  case 6:
550  case 7:
551  case 8:
552  /*
553  * Bits 31:28 of b0d28f4 0x32c register correspond to
554  * Root Ports 8:5.
555  */
556  do_aspm = !!(rpc.b0d28f4_32c & (1 << (28 + rp - 5)));
557  break;
558  }
559  }
560 
561  /* Allow ASPM to be forced on in devicetree */
562  if (config && (config->pcie_port_force_aspm & (1 << (rp - 1))))
563  do_aspm = 1;
564 
565  printk(BIOS_DEBUG, "PCIe Root Port %d ASPM is %sabled\n",
566  rp, do_aspm ? "en" : "dis");
567 
568  if (do_aspm) {
569  /* Set ASPM bits in MPC2 register. */
570  pci_update_config32(dev, 0xd4, ~(0x3 << 2), (1 << 4) | (0x2 << 2));
571 
572  /* Set unique clock exit latency in MPC register. */
573  pci_update_config32(dev, 0xd8, ~(0x7 << 18), (0x7 << 18));
574 
575  /* Set L1 exit latency in LCAP register. */
576  pci_update_config32(dev, 0x4c, ~(0x7 << 15), (0x4 << 15));
577 
578  if (is_lp) {
579  switch (rp) {
580  case 1:
581  pcie_add_0x0202000_iobp(0xe9002440);
582  break;
583  case 2:
584  pcie_add_0x0202000_iobp(0xe9002640);
585  break;
586  case 3:
587  pcie_add_0x0202000_iobp(0xe9000840);
588  break;
589  case 4:
590  pcie_add_0x0202000_iobp(0xe9000a40);
591  break;
592  case 5:
593  pcie_add_0x0202000_iobp(0xe9000c40);
594  pcie_add_0x0202000_iobp(0xe9000e40);
595  pcie_add_0x0202000_iobp(0xe9001040);
596  pcie_add_0x0202000_iobp(0xe9001240);
597  break;
598  case 6:
599  /* Update IOBP based on lane ownership. */
600  if (rpc.pin_ownership & (1 << 4))
601  pcie_add_0x0202000_iobp(0xea002040);
602  if (rpc.pin_ownership & (1 << 5))
603  pcie_add_0x0202000_iobp(0xea002240);
604  if (rpc.pin_ownership & (1 << 6))
605  pcie_add_0x0202000_iobp(0xea002440);
606  if (rpc.pin_ownership & (1 << 7))
607  pcie_add_0x0202000_iobp(0xea002640);
608  break;
609  }
610  } else {
611  switch (rp) {
612  case 1:
613  if ((rpc.pin_ownership & 0x3) == 1)
614  pcie_add_0x0202000_iobp(0xe9002e40);
615  else
616  pcie_add_0x0202000_iobp(0xea002040);
617  break;
618  case 2:
619  if ((rpc.pin_ownership & 0xc) == 0x4)
620  pcie_add_0x0202000_iobp(0xe9002c40);
621  else
622  pcie_add_0x0202000_iobp(0xea002240);
623  break;
624  case 3:
625  pcie_add_0x0202000_iobp(0xe9002a40);
626  break;
627  case 4:
628  pcie_add_0x0202000_iobp(0xe9002840);
629  break;
630  case 5:
631  pcie_add_0x0202000_iobp(0xe9002640);
632  break;
633  case 6:
634  pcie_add_0x0202000_iobp(0xe9002440);
635  break;
636  case 7:
637  pcie_add_0x0202000_iobp(0xe9002240);
638  break;
639  case 8:
640  pcie_add_0x0202000_iobp(0xe9002040);
641  break;
642  }
643  }
644 
645  pci_and_config32(dev, 0x338, ~(1 << 26));
646  }
647 
648  /* Enable LTR in Root Port. Disable OBFF. */
649  pci_update_config32(dev, 0x64, ~(3 << 18), 1 << 11);
650  pci_update_config16(dev, 0x68, ~(3 << 13), 1 << 10);
651 
652  pci_update_config32(dev, 0x318, ~(0xffff << 16), (0x1414 << 16));
653 
654  /* Set L1 exit latency in LCAP register. */
655  if (!do_aspm && (pci_read_config8(dev, 0xf5) & 0x1))
656  pci_update_config32(dev, 0x4c, ~(0x7 << 15), (0x4 << 15));
657  else
658  pci_update_config32(dev, 0x4c, ~(0x7 << 15), (0x2 << 15));
659 
660  pci_update_config32(dev, 0x314, 0, 0x743a361b);
661 
662  /* Set Common Clock Exit Latency in MPC register. */
663  pci_update_config32(dev, 0xd8, ~(0x7 << 15), (0x3 << 15));
664 
665  pci_update_config32(dev, 0x33c, ~0x00ffffff, 0x854c74);
666 
667  /* Set Invalid Receive Range Check Enable in MPC register. */
668  pci_or_config32(dev, 0xd8, 1 << 25);
669 
670  pci_and_config8(dev, 0xf5, 0x3f);
671 
672  if (rp == 1 || rp == 5 || (is_lp && rp == 6))
673  pci_and_config8(dev, 0xf7, ~0x0c);
674 
675  /* Set EOI forwarding disable. */
676  pci_or_config32(dev, 0xd4, 1 << 1);
677 
678  /* Set AER Extended Cap ID to 01h and Next Cap Pointer to 200h. */
679  if (CONFIG(PCIEXP_AER))
680  pci_update_config32(dev, 0x100, ~0xfffff, (1 << 29) | 0x10001);
681  else
682  pci_update_config32(dev, 0x100, ~0xfffff, (1 << 29));
683 
684  /* Set L1 Sub-State Cap ID to 1Eh and Next Cap Pointer to None. */
685  if (CONFIG(PCIEXP_L1_SUB_STATE))
686  pci_update_config32(dev, 0x200, ~0xfffff, 0x001e);
687  else
688  pci_update_config32(dev, 0x200, ~0xfffff, 0);
689 
690  if (is_lp)
691  pci_or_config32(dev, 0x100, 1 << 29);
692 
693  /* Read and write back write-once capability registers. */
694  pci_update_config32(dev, 0x34, ~0, 0);
695  pci_update_config32(dev, 0x40, ~0, 0);
696  pci_update_config32(dev, 0x80, ~0, 0);
697  pci_update_config32(dev, 0x90, ~0, 0);
698 }
699 
700 static void pch_pcie_init(struct device *dev)
701 {
702  printk(BIOS_DEBUG, "Initializing PCH PCIe bridge.\n");
703 
704  /* Enable SERR */
706 
707  /* Enable Bus Master */
709 
710  /* Set Cache Line Size to 0x10 */
711  // This has no effect but the OS might expect it
712  pci_write_config8(dev, 0x0c, 0x10);
713 
715 
716  /* Clear errors in status registers */
717  pci_update_config16(dev, 0x06, ~0, 0);
718  pci_update_config16(dev, 0x1e, ~0, 0);
719 }
720 
721 static void pch_pcie_enable(struct device *dev)
722 {
723  /* Add this device to the root port config structure. */
725 
726  /* Check to see if this Root Port should be disabled. */
728 
729  /* Power Management init before enumeration */
730  if (dev->enabled)
731  pch_pcie_early(dev);
732 
733  /*
734  * When processing the last PCIe root port we can now
735  * update the Root Port Function Number and Hide register.
736  */
737  if (root_port_is_last(dev))
739 }
740 
741 static struct device_operations device_ops = {
743  .set_resources = pci_dev_set_resources,
744  .enable_resources = pci_bus_enable_resources,
745  .init = pch_pcie_init,
746  .enable = pch_pcie_enable,
747  .scan_bus = pciexp_scan_bridge,
748  .ops_pci = &pci_dev_ops_pci,
749 };
750 
751 static const unsigned short pci_device_ids[] = {
766  0
767 };
768 
769 static const struct pci_driver pch_pcie __pci_driver = {
770  .ops = &device_ops,
771  .vendor = PCI_VID_INTEL,
772  .devices = pci_device_ids,
773 };
#define ASSERT(x)
Definition: assert.h:44
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define MIN(a, b)
Definition: helpers.h:37
#define printk(level,...)
Definition: stdlib.h:16
const char * dev_path(const struct device *dev)
Definition: device_util.c:149
@ CONFIG
Definition: dsi_common.h:201
static __always_inline void pci_or_config32(const struct device *dev, u16 reg, u32 ormask)
Definition: pci_ops.h:191
static __always_inline void pci_and_config16(const struct device *dev, u16 reg, u16 andmask)
Definition: pci_ops.h:147
static __always_inline void pci_and_config8(const struct device *dev, u16 reg, u8 andmask)
Definition: pci_ops.h:136
static __always_inline void pci_update_config32(const struct device *dev, u16 reg, u32 mask, u32 or)
Definition: pci_ops.h:120
static __always_inline void pci_update_config8(const struct device *dev, u16 reg, u8 mask, u8 or)
Definition: pci_ops.h:88
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
static __always_inline void pci_or_config8(const struct device *dev, u16 reg, u8 ormask)
Definition: pci_ops.h:169
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
static __always_inline void pci_update_config16(const struct device *dev, u16 reg, u16 mask, u16 or)
Definition: pci_ops.h:104
static __always_inline void pci_and_config32(const struct device *dev, u16 reg, u32 andmask)
Definition: pci_ops.h:158
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
void pch_iobp_write(u32 address, u32 data)
Definition: iobp.c:63
u32 pch_iobp_read(u32 address)
Definition: iobp.c:25
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define BIOS_SPEW
BIOS_SPEW - Excessively verbose output.
Definition: loglevel.h:142
enum board_config config
Definition: memory.c:448
#define PCI_BRIDGE_CTL_PARITY
Definition: pci_def.h:136
#define PCI_COMMAND_SERR
Definition: pci_def.h:19
#define PCI_DEVFN(slot, func)
Definition: pci_def.h:548
#define PCI_BRIDGE_CONTROL
Definition: pci_def.h:134
#define PCI_COMMAND_IO
Definition: pci_def.h:11
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_COMMAND_MEMORY
Definition: pci_def.h:12
#define PCI_FUNC(devfn)
Definition: pci_def.h:550
#define PCI_COMMAND
Definition: pci_def.h:10
#define PCI_SLOT(devfn)
Definition: pci_def.h:549
void pci_bus_enable_resources(struct device *dev)
Definition: pci_device.c:758
void pci_bus_read_resources(struct device *dev)
Definition: pci_device.c:540
struct pci_operations pci_dev_ops_pci
Default device operation for PCI devices.
Definition: pci_device.c:911
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define PCI_DID_INTEL_LPT_H_PCIE_RP8
Definition: pci_ids.h:3096
#define PCI_DID_INTEL_LPT_H81
Definition: pci_ids.h:2835
#define PCI_DID_INTEL_LPT_H_PCIE_RP2
Definition: pci_ids.h:3090
#define PCI_DID_INTEL_LPT_LP_PCIE_RP2
Definition: pci_ids.h:3098
#define PCI_DID_INTEL_LPT_LP_PCIE_RP4
Definition: pci_ids.h:3100
#define PCI_DID_INTEL_LPT_H_PCIE_RP5
Definition: pci_ids.h:3093
#define PCI_DID_INTEL_LPT_H_PCIE_RP1
Definition: pci_ids.h:3089
#define PCI_DID_INTEL_LPT_H_PCIE_RP7
Definition: pci_ids.h:3095
#define PCI_DID_INTEL_LPT_H_PCIE_RP6
Definition: pci_ids.h:3094
#define PCI_DID_INTEL_LPT_H_PCIE_RP4
Definition: pci_ids.h:3092
#define PCI_DID_INTEL_LPT_H_PCIE_RP3
Definition: pci_ids.h:3091
#define PCI_DID_INTEL_LPT_LP_PCIE_RP3
Definition: pci_ids.h:3099
#define PCI_DID_INTEL_LPT_LP_PCIE_RP1
Definition: pci_ids.h:3097
#define PCI_DID_INTEL_LPT_LP_PCIE_RP5
Definition: pci_ids.h:3101
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
#define PCI_DID_INTEL_LPT_LP_PCIE_RP6
Definition: pci_ids.h:3102
void pciexp_scan_bridge(struct device *dev)
void pch_disable_devfn(struct device *dev)
Definition: pch.c:77
#define RPFN_FNSET(port, func)
Definition: rcba.h:16
#define RPFN_HIDE(port)
Definition: rcba.h:12
#define RPFN
Definition: rcba.h:9
#define RPFN_FNMASK(port)
Definition: rcba.h:18
#define PCH_PCIE_DEV_SLOT
Definition: pch.h:81
int gpio_is_native(int gpio_num)
Definition: gpio.c:147
#define RCBA32(x)
Definition: rcba.h:14
int pch_silicon_id(void)
Definition: pch.c:33
static int pch_is_lp(void)
Definition: pch.h:104
static bool is_rp_enabled(int rp)
Definition: pcie.c:63
static struct device_operations device_ops
Definition: pcie.c:741
#define MAX_NUM_ROOT_PORTS
Definition: pcie.c:18
static struct root_port_config rpc
Definition: pcie.c:37
static int max_root_ports(void)
Definition: pcie.c:39
static void root_port_config_update_gbe_port(void)
Definition: pcie.c:73
static void update_num_ports(void)
Definition: pcie.c:103
static void pch_pcie_early(struct device *dev)
Definition: pcie.c:502
static void root_port_init_config(struct device *dev)
Definition: pcie.c:135
static void pch_pcie_enable(struct device *dev)
Definition: pcie.c:721
static int root_port_is_first(struct device *dev)
Definition: pcie.c:47
static void pch_pcie_device_set_func(int index, int pci_func)
Definition: pcie.c:190
static void root_port_check_disable(struct device *dev)
Definition: pcie.c:371
static void pch_pcie_init(struct device *dev)
Definition: pcie.c:700
static const unsigned short pci_device_ids[]
Definition: pcie.c:751
static void pcie_add_0x0202000_iobp(u32 reg)
Definition: pcie.c:493
static void root_port_mark_disable(struct device *dev)
Definition: pcie.c:363
static void pcie_enable_clock_gating(void)
Definition: pcie.c:215
static const struct pci_driver pch_pcie __pci_driver
Definition: pcie.c:769
static void root_port_commit_config(void)
Definition: pcie.c:301
static int root_port_number(struct device *dev)
Definition: pcie.c:58
static int root_port_is_last(struct device *dev)
Definition: pcie.c:52
#define NULL
Definition: stddef.h:19
uint32_t u32
Definition: stdint.h:51
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct pci_path pci
Definition: path.h:116
Definition: device.h:107
struct device_path path
Definition: device.h:115
DEVTREE_CONST void * chip_info
Definition: device.h:164
unsigned int enabled
Definition: device.h:122
unsigned int devfn
Definition: path.h:54
u32 orig_rpfn
Definition: pcie.c:26
u32 new_rpfn
Definition: pcie.c:27
u32 strpfusecfg3
Definition: pcie.c:31
bool coalesce
Definition: pcie.c:35
u32 b0d28f0_32c
Definition: pcie.c:32
struct device * ports[MAX_NUM_ROOT_PORTS]
Definition: pcie.c:38
u32 b0d28f4_32c
Definition: pcie.c:33
u32 strpfusecfg2
Definition: pcie.c:30
int num_ports
Definition: pcie.c:37
u32 pin_ownership
Definition: pcie.c:28
u32 b0d28f5_32c
Definition: pcie.c:34
u32 strpfusecfg1
Definition: pcie.c:29
int gbe_port
Definition: pcie.c:36