blob: 992f3066775bf414b883aefe0bfd0952484a96c4 [file] [log] [blame]
Josef Kellermannbfa7ee52011-05-11 07:47:43 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010017 * Foundation, Inc.
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000018 */
19
20#include <console/console.h>
21#include <device/pci.h>
22#include <device/pci_ids.h>
23#include <string.h>
24#include <stdint.h>
25#include <stdlib.h>
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000026#include <cpu/amd/multicore.h>
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000027
28#include <cpu/amd/amdk8_sysconf.h>
29
30/* Global variables for MB layouts and these will be shared by irqtable mptable
31* and acpi_tables busnum is default.
32*/
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000033u8 bus_rs690[8];
34u8 bus_sb600[2];
35u32 apicid_sb600;
36
37/*
38* Here you only need to set value in pci1234 for HT-IO that could be installed or not
39* You may need to preset pci1234 for HTIO board,
40* please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
41*/
42u32 pci1234x[] = {
43 0x0000ff0,
44};
45
46/*
47* HT Chain device num, actually it is unit id base of every ht device in chain,
48* assume every chain only have 4 ht device at most
49*/
50u32 hcdnx[] = {
51 0x20202020,
52};
53
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000054u32 sbdn_rs690;
55u32 sbdn_sb600;
56
57
58
59static u32 get_bus_conf_done = 0;
60
61void get_bus_conf(void)
62{
63 u32 apicid_base;
64 device_t dev;
Patrick Georgic5ae3062011-10-06 14:34:22 +020065 int i;
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000066
67 if (get_bus_conf_done == 1)
68 return; /* do it only once */
69 get_bus_conf_done = 1;
70
71 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
72 for (i = 0; i < sysconf.hc_possible_num; i++) {
73 sysconf.pci1234[i] = pci1234x[i];
74 sysconf.hcdn[i] = hcdnx[i];
75 }
76
77 get_sblk_pci1234();
78
79 sysconf.sbdn = (sysconf.hcdn[0] & 0xff);
80 sbdn_rs690 = sysconf.sbdn;
81 sbdn_sb600 = 0;
82
83 for (i = 0; i < 2; i++) {
84 bus_sb600[i] = 0;
85 }
86 for (i = 0; i < 8; i++) {
87 bus_rs690[i] = 0;
88 }
89
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000090 bus_rs690[0] = (sysconf.pci1234[0] >> 16) & 0xff;
91 bus_sb600[0] = bus_rs690[0];
92
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000093 /* sb600 */
94 dev = dev_find_slot(bus_sb600[0], PCI_DEVFN(sbdn_sb600 + 0x14, 4));
95 if (dev) {
96 bus_sb600[1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000097 }
98
99 /* rs690 */
100 for (i = 1; i < 8; i++) {
101 dev = dev_find_slot(bus_rs690[0], PCI_DEVFN(sbdn_rs690 + i, 0));
102 if (dev) {
103 bus_rs690[i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000104 }
105 }
106
107 /* I/O APICs: APIC ID Version State Address */
Timothy Pearsond4bbfe82015-10-27 16:48:36 -0500108 if (IS_ENABLED(CONFIG_LOGICAL_CPUS))
109 apicid_base = get_apicid_base(1);
110 else
111 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000112 apicid_sb600 = apicid_base + 0;
113}