Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 1 | /* |
| 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 Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <console/console.h> |
| 19 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 20 | #include <device/pci_ops.h> |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 21 | #include <string.h> |
| 22 | #include <stdint.h> |
Stefan Reinauer | 9a16e3e | 2010-03-29 14:45:36 +0000 | [diff] [blame] | 23 | #include <cpu/amd/multicore.h> |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 24 | |
| 25 | #include <cpu/amd/amdfam10_sysconf.h> |
| 26 | |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 27 | #include <stdlib.h> |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 28 | #include "mb_sysconf.h" |
| 29 | |
| 30 | // Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables |
| 31 | struct mb_sysconf_t mb_sysconf; |
| 32 | |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 33 | void get_bus_conf(void) |
| 34 | { |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 35 | unsigned apicid_base; |
| 36 | struct mb_sysconf_t *m; |
| 37 | |
Elyes HAOUAS | 4b73fa9 | 2018-06-08 19:00:44 +0200 | [diff] [blame] | 38 | struct device *dev; |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 39 | int i; |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 40 | |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 41 | sysconf.mb = &mb_sysconf; |
Myles Watson | a643ea3 | 2008-10-06 21:00:46 +0000 | [diff] [blame] | 42 | |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 43 | m = sysconf.mb; |
| 44 | memset(m, 0, sizeof(struct mb_sysconf_t)); |
| 45 | |
Kyösti Mälkki | f112f9f | 2019-01-03 11:39:05 +0200 | [diff] [blame] | 46 | get_default_pci1234(32); |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 47 | |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 48 | sysconf.sbdn = (sysconf.hcdn[0] & 0xff); // first byte of first chain |
| 49 | m->bus_mcp55[0] = (sysconf.pci1234[0] >> 12) & 0xff; |
| 50 | |
Myles Watson | a643ea3 | 2008-10-06 21:00:46 +0000 | [diff] [blame] | 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 Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 57 | printk(BIOS_DEBUG, "ERROR - could not find PCI 1:%02x.0, using defaults\n", sysconf.sbdn + 0x06); |
Myles Watson | a643ea3 | 2008-10-06 21:00:46 +0000 | [diff] [blame] | 58 | } |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 59 | |
Elyes HAOUAS | a5aad2e | 2016-09-19 09:47:16 -0600 | [diff] [blame] | 60 | for(i = 2; i < 8; i++) { |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 61 | dev = dev_find_slot(m->bus_mcp55[0], PCI_DEVFN(sysconf.sbdn + 0x0a + i - 2, 0)); |
Myles Watson | a643ea3 | 2008-10-06 21:00:46 +0000 | [diff] [blame] | 62 | if (dev) { |
| 63 | m->bus_mcp55[i] = pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 64 | } |
| 65 | else { |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 66 | printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_mcp55[0], sysconf.sbdn + 0x0a + i - 2); |
Myles Watson | a643ea3 | 2008-10-06 21:00:46 +0000 | [diff] [blame] | 67 | } |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 70 | /*I/O APICs: APIC ID Version State Address*/ |
Timothy Pearson | d4bbfe8 | 2015-10-27 16:48:36 -0500 | [diff] [blame] | 71 | if (IS_ENABLED(CONFIG_LOGICAL_CPUS)) |
| 72 | apicid_base = get_apicid_base(1); |
| 73 | else |
| 74 | apicid_base = CONFIG_MAX_PHYSICAL_CPUS; |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 75 | m->apicid_mcp55 = apicid_base+0; |
Arne Georg Gleditsch | 33e6d5d | 2008-08-19 17:59:34 +0000 | [diff] [blame] | 76 | } |