Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / northbridge / intel / e7520 / pciexp_porta.c
1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/pci.h>
4 #include <device/pci_ids.h>
5 #include <device/pci_ops.h>
6 #include <device/pciexp.h>
7 #include <arch/io.h>
8 #include "chip.h"
9 #include <reset.h>
10
11 typedef struct northbridge_intel_e7520_config config_t;
12
13 static void pcie_init(struct device *dev)
14 {
15         config_t *config;
16
17         /* Get the chip configuration */
18         config = dev->chip_info;
19
20         if(config->intrline) {
21                 pci_write_config32(dev, 0x3c, config->intrline);
22         }
23
24 }
25
26 static unsigned int pcie_scan_bridge(struct device *dev, unsigned int max)
27 {
28         uint16_t val;
29         uint16_t ctl;
30         int flag = 0;
31         do {
32                 val = pci_read_config16(dev, 0x76);
33                 printk(BIOS_DEBUG, "pcie porta 0x76: %02x\n", val);
34                 if((val & (1<<10) )&&(!flag)) { /* training error */
35                         ctl = pci_read_config16(dev, 0x74);
36                         pci_write_config16(dev, 0x74, (ctl | (1<<5)));
37                         val = pci_read_config16(dev, 0x76);
38                         printk(BIOS_DEBUG, "pcie porta reset 0x76: %02x\n", val);
39                         flag=1;
40                         hard_reset();
41                 }
42         } while ( val & (3<<10) );
43         return pciexp_scan_bridge(dev, max);
44 }
45
46 static struct device_operations pcie_ops  = {
47         .read_resources   = pci_bus_read_resources,
48         .set_resources    = pci_dev_set_resources,
49         .enable_resources = pci_bus_enable_resources,
50         .init             = pcie_init,
51         .scan_bus         = pcie_scan_bridge,
52         .reset_bus        = pci_bus_reset,
53         .ops_pci          = 0,
54 };
55
56 static const struct pci_driver pci_driver __pci_driver = {
57         .ops    = &pcie_ops,
58         .vendor = PCI_VENDOR_ID_INTEL,
59         .device = PCI_DEVICE_ID_INTEL_PCIE_PA,
60 };
61
62