blob: b169775456bb6c8ff05f860516be31db9c094953 [file] [log] [blame]
Zheng Bao1ad9f292010-04-23 17:37:41 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 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
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
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>
26#if CONFIG_LOGICAL_CPUS==1
27#include <cpu/amd/multicore.h>
28#endif
29
30#include <cpu/amd/amdfam10_sysconf.h>
31
32/* Global variables for MB layouts and these will be shared by irqtable mptable
33* and acpi_tables busnum is default.
34*/
Zheng Bao1ad9f292010-04-23 17:37:41 +000035u8 bus_rs780[11];
36u8 bus_sb700[2];
37u32 apicid_sb700;
38
39/*
40* Here you only need to set value in pci1234 for HT-IO that could be installed or not
41* You may need to preset pci1234 for HTIO board,
42* please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
43*/
44u32 pci1234x[] = {
45 0x0000ff0,
46};
47
48/*
49* HT Chain device num, actually it is unit id base of every ht device in chain,
50* assume every chain only have 4 ht device at most
51*/
52u32 hcdnx[] = {
53 0x20202020,
54};
55
Zheng Bao1ad9f292010-04-23 17:37:41 +000056u32 sbdn_rs780;
57u32 sbdn_sb700;
58
59extern void get_pci1234(void);
60
61static u32 get_bus_conf_done = 0;
62
63void get_bus_conf(void)
64{
65 u32 apicid_base;
66 device_t dev;
Patrick Georgi8cda9692010-11-21 14:40:09 +000067 int i;
Zheng Bao1ad9f292010-04-23 17:37:41 +000068
69 if (get_bus_conf_done == 1)
70 return; /* do it only once */
71 get_bus_conf_done = 1;
72
73 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
74 for (i = 0; i < sysconf.hc_possible_num; i++) {
75 sysconf.pci1234[i] = pci1234x[i];
76 sysconf.hcdn[i] = hcdnx[i];
77 }
78
79 get_pci1234();
80
81 sysconf.sbdn = (sysconf.hcdn[0] & 0xff);
82 sbdn_rs780 = sysconf.sbdn;
83 sbdn_sb700 = 0;
84
85 for (i = 0; i < 2; i++) {
86 bus_sb700[i] = 0;
87 }
88 for (i = 0; i < ARRAY_SIZE(bus_rs780); i++) {
89 bus_rs780[i] = 0;
90 }
91
Zheng Bao1ad9f292010-04-23 17:37:41 +000092 bus_rs780[0] = (sysconf.pci1234[0] >> 16) & 0xff;
93 bus_sb700[0] = bus_rs780[0];
94
Zheng Bao1ad9f292010-04-23 17:37:41 +000095 /* sb700 */
96 dev = dev_find_slot(bus_sb700[0], PCI_DEVFN(sbdn_sb700 + 0x14, 4));
97 if (dev) {
98 bus_sb700[1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
Zheng Bao1ad9f292010-04-23 17:37:41 +000099 }
100
101 /* rs780 */
102 for (i = 1; i < ARRAY_SIZE(bus_rs780); i++) {
103 dev = dev_find_slot(bus_rs780[0], PCI_DEVFN(sbdn_rs780 + i, 0));
104 if (dev) {
105 bus_rs780[i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
Zheng Bao1ad9f292010-04-23 17:37:41 +0000106 }
107 }
108
109 /* I/O APICs: APIC ID Version State Address */
Zheng Bao1ad9f292010-04-23 17:37:41 +0000110#if CONFIG_LOGICAL_CPUS==1
111 apicid_base = get_apicid_base(1);
112#else
113 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
114#endif
115 apicid_sb700 = apicid_base + 0;
116}