4027f48e7c0a9b16106b49e15f6ce7a516357bcc
[coreboot.git] / src / southbridge / broadcom / bcm21000 / bcm21000_pcie.c
1 /*
2  * This file is part of the coreboot project.
3  *
4 * Copyright (C) 2009 University of Heidelberg
5  * Written by Mondrian Nuessle <nuessle@uni-heidelberg.de> for University of Heidelberg
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20  */
21
22
23 #include <console/console.h>
24 #include <device/device.h>
25 #include <device/pci.h>
26 #include <device/pci_ids.h>
27 #include <device/pci_ops.h>
28
29 static void pcie_init(struct device *dev)
30 {
31
32         /* Enable pci error detecting */
33         uint32_t dword;
34         uint32_t msicap;
35
36         printk(BIOS_DEBUG, "PCIE enable.... dev= %s\n",dev_path(dev));
37
38         /* System error enable */
39         dword = pci_read_config32(dev, 0x04);
40         dword |= (1<<8); /* System error enable */
41         dword |= (1<<30); /* Clear possible errors */
42         pci_write_config32(dev, 0x04, dword);
43
44         /* enable MSI on PCIE: */
45         msicap = pci_read_config32(dev, 0xa0);
46         msicap |= (1<<16); /* enable MSI*/
47         pci_write_config32(dev, 0xa0, msicap);
48 }
49
50 static struct pci_operations lops_pci = {
51         .set_subsystem = 0,
52 };
53
54 static struct device_operations pcie_ops  = {
55         .read_resources   = pci_bus_read_resources,
56         .set_resources    = pci_dev_set_resources,
57         .enable_resources = pci_bus_enable_resources,
58         .init             = pcie_init,
59         .scan_bus         = pci_scan_bridge,
60         .reset_bus        = pci_bus_reset,
61         .ops_pci          = &lops_pci,
62 };
63
64
65 static const struct pci_driver pcie_driver1 __pci_driver = {
66         .ops    = &pcie_ops,
67         .vendor = PCI_VENDOR_ID_SERVERWORKS,
68         .device = PCI_DEVICE_ID_SERVERWORKS_BCM21000_EXB0,
69 };
70
71 static const struct pci_driver pcie_driver2 __pci_driver = {
72         .ops    = &pcie_ops,
73         .vendor = PCI_VENDOR_ID_SERVERWORKS,
74         .device = PCI_DEVICE_ID_SERVERWORKS_BCM21000_EXB1,
75 };
76
77 static const struct pci_driver pcie_driver3 __pci_driver = {
78         .ops    = &pcie_ops,
79         .vendor = PCI_VENDOR_ID_SERVERWORKS,
80         .device = PCI_DEVICE_ID_SERVERWORKS_BCM21000_EXB2,
81 };
82