Add support for Intel Sandybridge CPU (northbridge part)
[coreboot.git] / src / northbridge / intel / sandybridge / acpi.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21
22 #include <types.h>
23 #include <string.h>
24 #include <console/console.h>
25 #include <arch/acpi.h>
26 #include <arch/acpigen.h>
27 #include <device/device.h>
28 #include <device/pci.h>
29 #include <device/pci_ids.h>
30 #include "sandybridge.h"
31
32 unsigned long acpi_fill_mcfg(unsigned long current)
33 {
34         device_t dev;
35         u32 pciexbar = 0;
36         u32 pciexbar_reg;
37         int max_buses;
38
39         dev = dev_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_NB, 0);
40         if (!dev)
41                 return current;
42
43         pciexbar_reg=pci_read_config32(dev, PCIEXBAR);
44
45         // MMCFG not supported or not enabled.
46         if (!(pciexbar_reg & (1 << 0)))
47                 return current;
48
49         switch ((pciexbar_reg >> 1) & 3) {
50         case 0: // 256MB
51                 pciexbar = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28));
52                 max_buses = 256;
53                 break;
54         case 1: // 128M
55                 pciexbar = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27));
56                 max_buses = 128;
57                 break;
58         case 2: // 64M
59                 pciexbar = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27)|(1 << 26));
60                 max_buses = 64;
61                 break;
62         default: // RSVD
63                 return current;
64         }
65
66         if (!pciexbar)
67                 return current;
68
69         current += acpi_create_mcfg_mmconfig((acpi_mcfg_mmconfig_t *) current,
70                         pciexbar, 0x0, 0x0, max_buses - 1);
71
72         return current;
73 }
74
75