blob: a56242fa4ec2da25bfa8d0e4dd3764753745ddeb [file] [log] [blame]
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007 AMD
5 * Written by Yinghai Lu <yinghailu@amd.com> for AMD.
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.
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000016 */
17
18#include <console/console.h>
19#include <device/pci.h>
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000020#include <string.h>
21#include <stdint.h>
Stefan Reinauer9a16e3e2010-03-29 14:45:36 +000022#include <cpu/amd/multicore.h>
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000023
24#include <cpu/amd/amdfam10_sysconf.h>
25
26#include <stdlib.h>
27#include "mb_sysconf.h"
28
29// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
30struct mb_sysconf_t mb_sysconf;
31
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000032void get_bus_conf(void)
33{
34 unsigned apicid_base;
35 struct mb_sysconf_t *m;
36
Elyes HAOUAS9740bcb2018-05-04 22:07:08 +020037 struct device *dev;
Patrick Georgi5244e1b2010-11-21 14:41:07 +000038 int i;
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000039
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000040
41 sysconf.mb = &mb_sysconf;
42
43 m = sysconf.mb;
44 memset(m, 0, sizeof(struct mb_sysconf_t));
45
Kyösti Mälkkif112f9f2019-01-03 11:39:05 +020046 get_default_pci1234(32);
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000047
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000048 sysconf.sbdn = (sysconf.hcdn[0] & 0xff); // first byte of first chain
49 m->bus_mcp55[0] = (sysconf.pci1234[0] >> 12) & 0xff;
50
51 /* MCP55 */
52 dev = dev_find_slot(m->bus_mcp55[0], PCI_DEVFN(sysconf.sbdn + 0x06,0));
53 if (dev) {
54 m->bus_mcp55[1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
55 }
56 else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000057 printk(BIOS_DEBUG, "ERROR - could not find PCI 1:%02x.0, using defaults\n", sysconf.sbdn + 0x06);
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000058 }
59
Elyes HAOUAS7533e492018-02-01 09:35:53 +010060 for (i = 2; i < 8; i++) {
Elyes HAOUASa342f392018-10-17 10:56:26 +020061 dev = dev_find_slot(m->bus_mcp55[0], PCI_DEVFN(sysconf.sbdn + 0x0a + i - 2, 0));
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000062 if (dev) {
63 m->bus_mcp55[i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
64 }
65 else {
Elyes HAOUASa342f392018-10-17 10:56:26 +020066 printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_mcp55[0], sysconf.sbdn + 0x0a + i - 2);
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000067 }
68 }
69
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000070/*I/O APICs: APIC ID Version State Address*/
Timothy Pearsond4bbfe82015-10-27 16:48:36 -050071 if (IS_ENABLED(CONFIG_LOGICAL_CPUS)) {
72 apicid_base = get_apicid_base(1);
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -060073 printk(BIOS_SPEW, "CONFIG_LOGICAL_CPUS == 1: apicid_base: %08x\n", apicid_base);
Timothy Pearsond4bbfe82015-10-27 16:48:36 -050074 } else {
75 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -060076 printk(BIOS_SPEW, "CONFIG_LOGICAL_CPUS == 0: apicid_base: %08x\n", apicid_base);
Timothy Pearsond4bbfe82015-10-27 16:48:36 -050077 }
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000078 m->apicid_mcp55 = apicid_base+0;
79}