blob: 226d57de91c6b73bdf220e505ed4153eef177a65 [file] [log] [blame]
WANG Siyuanf77f7342013-08-13 17:09:51 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 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#include <cpu/amd/amdfam14.h>
27#include "agesawrapper.h"
28
29/* Global variables for MB layouts and these will be shared by irqtable mptable
30 * and acpi_tables busnum is default.
31 */
32u8 bus_isa;
Kyösti Mälkki4f9bf7e2013-09-09 09:23:19 +030033u8 bus_yangtze[6];
WANG Siyuanf77f7342013-08-13 17:09:51 +080034u32 apicid_yangtze;
35
36/*
37 * Here you only need to set value in pci1234 for HT-IO that could be installed or not
38 * You may need to preset pci1234 for HTIO board,
39 * please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
40 */
41u32 pci1234x[] = {
42 0x0000ff0,
43};
44
45u32 bus_type[256];
46u32 sbdn_yangtze;
47
48static u32 get_bus_conf_done = 0;
49
WANG Siyuanf77f7342013-08-13 17:09:51 +080050void get_bus_conf(void)
51{
52 u32 apicid_base;
WANG Siyuan2c86fc42013-09-23 15:12:56 +080053 u32 value;
WANG Siyuanf77f7342013-08-13 17:09:51 +080054
55 device_t dev;
56 int i, j;
57
58 if (get_bus_conf_done == 1)
59 return; /* do it only once */
60
61 get_bus_conf_done = 1;
62
WANG Siyuanf77f7342013-08-13 17:09:51 +080063 dev = dev_find_slot(0, PCI_DEVFN(0, 0)); /* clear IoapicSbFeatureEn */
64 pci_write_config32(dev, 0xF8, 0);
65 pci_write_config32(dev, 0xFC, 5); /* TODO: move it to dsdt.asl */
66
WANG Siyuan2c86fc42013-09-23 15:12:56 +080067 /* disable No Snoop */
68 dev = dev_find_slot(0, PCI_DEVFN(1, 1));
69 value = pci_read_config32(dev, 0x60);
70 value &= ~(1 << 11);
71 pci_write_config32(dev, 0x60, value);
72
WANG Siyuanf77f7342013-08-13 17:09:51 +080073 sbdn_yangtze = 0;
74
Kyösti Mälkki4f9bf7e2013-09-09 09:23:19 +030075 memset(bus_yangtze, 0, sizeof(bus_yangtze));
WANG Siyuanf77f7342013-08-13 17:09:51 +080076
77 for (i = 0; i < 256; i++) {
78 bus_type[i] = 0; /* default ISA bus. */
79 }
80
81 bus_type[0] = 1; /* pci */
82
83 // bus_yangtze[0] = (sysconf.pci1234[0] >> 16) & 0xff;
84 bus_yangtze[0] = (pci1234x[0] >> 16) & 0xff;
85
86 /* yangtze */
87 dev = dev_find_slot(bus_yangtze[0], PCI_DEVFN(sbdn_yangtze + 0x14, 4));
88
89 if (dev) {
90 bus_yangtze[1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
91
92 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
93 bus_isa++;
94 for (j = bus_yangtze[1]; j < bus_isa; j++)
95 bus_type[j] = 1;
96 }
97
98 for (i = 0; i < 4; i++) {
99 dev = dev_find_slot(bus_yangtze[0], PCI_DEVFN(sbdn_yangtze + 0x14, i));
100 if (dev) {
101 bus_yangtze[2 + i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
102 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
103 bus_isa++;
104 }
105 }
106 for (j = bus_yangtze[2]; j < bus_isa; j++)
107 bus_type[j] = 1;
108
109 /* I/O APICs: APIC ID Version State Address */
110 bus_isa = 10;
111 apicid_base = CONFIG_MAX_CPUS;
112 apicid_yangtze = apicid_base;
113}