Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 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 |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 8 | * published by the Free Software Foundation; version 2 of the License. |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 9 | * |
| 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 Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 14 | */ |
| 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 Serbinenko | e6e5b5e | 2014-08-31 02:21:43 +0200 | [diff] [blame] | 24 | #include <cbmem.h> |
| 25 | #include <arch/acpigen.h> |
| 26 | #include <cpu/cpu.h> |
| 27 | #include "sch.h" |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 28 | |
| 29 | unsigned 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 Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 40 | pciexbar_reg = pci_read_config32(dev, 0x48); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 41 | |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 42 | /* MMCFG not supported or not enabled. */ |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 43 | if (!(pciexbar_reg & (1 << 0))) |
| 44 | return current; |
| 45 | |
| 46 | switch ((pciexbar_reg >> 1) & 3) { |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 47 | case 0: /* 256MB */ |
| 48 | pciexbar = pciexbar_reg & ((1 << 31) | (1 << 30) | (1 << 29) | |
| 49 | (1 << 28)); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 50 | max_buses = 256; |
| 51 | break; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 52 | case 1: /* 128M */ |
| 53 | pciexbar = pciexbar_reg & ((1 << 31) | (1 << 30) | (1 << 29) | |
| 54 | (1 << 28) | (1 << 27)); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 55 | max_buses = 128; |
| 56 | break; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 57 | case 2: /* 64M */ |
| 58 | pciexbar = pciexbar_reg & ((1 << 31) | (1 << 30) | (1 << 29) | |
| 59 | (1 << 28) | (1 << 27) | (1 << 26)); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 60 | max_buses = 64; |
| 61 | break; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 62 | default: /* RSVD */ |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 63 | return current; |
| 64 | } |
| 65 | |
| 66 | if (!pciexbar) |
| 67 | return current; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 68 | |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 69 | current += acpi_create_mcfg_mmconfig((acpi_mcfg_mmconfig_t *) current, |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 70 | pciexbar, 0x0, 0x0, max_buses - 1); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 71 | return current; |
| 72 | } |