blob: 1cefda9285ba6c379b1d457cc3d18ab2a92437a3 [file] [log] [blame]
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +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.
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000016 */
17
18#include <console/console.h>
19#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020020#include <device/pci_ops.h>
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000021#include <string.h>
22#include <stdint.h>
Stefan Reinauer9a16e3e2010-03-29 14:45:36 +000023#include <cpu/amd/multicore.h>
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000024
25#include <cpu/amd/amdfam10_sysconf.h>
26
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000027#include <stdlib.h>
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000028#include "mb_sysconf.h"
29
30// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
31struct mb_sysconf_t mb_sysconf;
32
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000033void get_bus_conf(void)
34{
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000035 unsigned apicid_base;
36 struct mb_sysconf_t *m;
37
Elyes HAOUAS4b73fa92018-06-08 19:00:44 +020038 struct device *dev;
Patrick Georgi5244e1b2010-11-21 14:41:07 +000039 int i;
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000040
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000041 sysconf.mb = &mb_sysconf;
Myles Watsona643ea32008-10-06 21:00:46 +000042
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000043 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);
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000047
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000048 sysconf.sbdn = (sysconf.hcdn[0] & 0xff); // first byte of first chain
49 m->bus_mcp55[0] = (sysconf.pci1234[0] >> 12) & 0xff;
50
Myles Watsona643ea32008-10-06 21:00:46 +000051 /* 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);
Myles Watsona643ea32008-10-06 21:00:46 +000058 }
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000059
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -060060 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));
Myles Watsona643ea32008-10-06 21:00:46 +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);
Myles Watsona643ea32008-10-06 21:00:46 +000067 }
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000068 }
69
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +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);
73 else
74 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000075 m->apicid_mcp55 = apicid_base+0;
Arne Georg Gleditsch33e6d5d2008-08-19 17:59:34 +000076}