blob: 2c941d868ebadd336e2fa1d6608b5e8001f8ac7c [file] [log] [blame]
Patrick Georgibe61a172010-12-18 07:48:43 +00001/*
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
Uwe Hermann405721d2010-12-18 13:22:37 +00008 * published by the Free Software Foundation; version 2 of the License.
Patrick Georgibe61a172010-12-18 07:48:43 +00009 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Patrick Georgibe61a172010-12-18 07:48:43 +000014 */
15
16#include <types.h>
17#include <string.h>
18#include <console/console.h>
19#include <arch/acpi.h>
20#include <arch/acpigen.h>
21#include <device/device.h>
22#include <device/pci.h>
23#include <device/pci_ids.h>
Vladimir Serbinenkoe6e5b5e2014-08-31 02:21:43 +020024#include <cbmem.h>
25#include <arch/acpigen.h>
26#include <cpu/cpu.h>
27#include "sch.h"
Patrick Georgibe61a172010-12-18 07:48:43 +000028
29unsigned long acpi_fill_mcfg(unsigned long current)
30{
31 device_t dev;
32 u32 pciexbar = 0;
33 u32 pciexbar_reg;
34 int max_buses;
35
36 dev = dev_find_device(0x8086, 0x27a0, 0);
37 if (!dev)
38 return current;
39
Uwe Hermann405721d2010-12-18 13:22:37 +000040 pciexbar_reg = pci_read_config32(dev, 0x48);
Patrick Georgibe61a172010-12-18 07:48:43 +000041
Uwe Hermann405721d2010-12-18 13:22:37 +000042 /* MMCFG not supported or not enabled. */
Patrick Georgibe61a172010-12-18 07:48:43 +000043 if (!(pciexbar_reg & (1 << 0)))
44 return current;
45
46 switch ((pciexbar_reg >> 1) & 3) {
Uwe Hermann405721d2010-12-18 13:22:37 +000047 case 0: /* 256MB */
48 pciexbar = pciexbar_reg & ((1 << 31) | (1 << 30) | (1 << 29) |
49 (1 << 28));
Patrick Georgibe61a172010-12-18 07:48:43 +000050 max_buses = 256;
51 break;
Uwe Hermann405721d2010-12-18 13:22:37 +000052 case 1: /* 128M */
53 pciexbar = pciexbar_reg & ((1 << 31) | (1 << 30) | (1 << 29) |
54 (1 << 28) | (1 << 27));
Patrick Georgibe61a172010-12-18 07:48:43 +000055 max_buses = 128;
56 break;
Uwe Hermann405721d2010-12-18 13:22:37 +000057 case 2: /* 64M */
58 pciexbar = pciexbar_reg & ((1 << 31) | (1 << 30) | (1 << 29) |
59 (1 << 28) | (1 << 27) | (1 << 26));
Patrick Georgibe61a172010-12-18 07:48:43 +000060 max_buses = 64;
61 break;
Uwe Hermann405721d2010-12-18 13:22:37 +000062 default: /* RSVD */
Patrick Georgibe61a172010-12-18 07:48:43 +000063 return current;
64 }
65
66 if (!pciexbar)
67 return current;
Uwe Hermann405721d2010-12-18 13:22:37 +000068
Patrick Georgibe61a172010-12-18 07:48:43 +000069 current += acpi_create_mcfg_mmconfig((acpi_mcfg_mmconfig_t *) current,
Uwe Hermann405721d2010-12-18 13:22:37 +000070 pciexbar, 0x0, 0x0, max_buses - 1);
Patrick Georgibe61a172010-12-18 07:48:43 +000071 return current;
72}