blob: 6a3d23250c7a6436725f14758742656bf2f42119 [file] [log] [blame]
Scott Duplichana649a962011-02-24 05:00:33 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 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
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Scott Duplichana649a962011-02-24 05:00:33 +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>
26#include <cpu/amd/amdfam14.h>
Paul Menzel21204602013-03-29 13:23:31 +010027#include "agesawrapper.h"
Kerry Shefeed3292011-08-18 18:03:44 +080028#if CONFIG_AMD_SB_CIMX
Paul Menzel69743962013-04-19 10:05:57 +020029#include <sb_cimx.h>
Kerry Shefeed3292011-08-18 18:03:44 +080030#endif
Scott Duplichana649a962011-02-24 05:00:33 +000031
32
33/* Global variables for MB layouts and these will be shared by irqtable mptable
34* and acpi_tables busnum is default.
35*/
36u8 bus_isa;
Kyösti Mälkki9c7d73c2013-09-09 09:23:19 +030037u8 bus_sb800[6];
Scott Duplichana649a962011-02-24 05:00:33 +000038u32 apicid_sb800;
39
40/*
41* Here you only need to set value in pci1234 for HT-IO that could be installed or not
42* You may need to preset pci1234 for HTIO board,
43* please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
44*/
45u32 pci1234x[] = {
46 0x0000ff0,
47};
48
Scott Duplichana649a962011-02-24 05:00:33 +000049u32 bus_type[256];
Scott Duplichana649a962011-02-24 05:00:33 +000050u32 sbdn_sb800;
51
Scott Duplichana649a962011-02-24 05:00:33 +000052static u32 get_bus_conf_done = 0;
53
54
Scott Duplichana649a962011-02-24 05:00:33 +000055void get_bus_conf(void)
56{
57 u32 apicid_base;
Scott Duplichana649a962011-02-24 05:00:33 +000058
59 device_t dev;
60 int i, j;
61
62 if (get_bus_conf_done == 1)
63 return; /* do it only once */
64
65 get_bus_conf_done = 1;
66
Scott Duplichana649a962011-02-24 05:00:33 +000067 sbdn_sb800 = 0;
68
Kyösti Mälkki9c7d73c2013-09-09 09:23:19 +030069 memset(bus_sb800, 0, sizeof(bus_sb800));
Scott Duplichana649a962011-02-24 05:00:33 +000070
71 for (i = 0; i < 256; i++) {
72 bus_type[i] = 0; /* default ISA bus. */
73 }
74
75
76 bus_type[0] = 1; /* pci */
77
78// bus_sb800[0] = (sysconf.pci1234[0] >> 16) & 0xff;
79 bus_sb800[0] = (pci1234x[0] >> 16) & 0xff;
80
81 /* sb800 */
82 dev = dev_find_slot(bus_sb800[0], PCI_DEVFN(sbdn_sb800 + 0x14, 4));
83
84
85
86 if (dev) {
87 bus_sb800[1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
88
89 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
90 bus_isa++;
91 for (j = bus_sb800[1]; j < bus_isa; j++)
92 bus_type[j] = 1;
93 }
94
95 for (i = 0; i < 4; i++) {
96 dev = dev_find_slot(bus_sb800[0], PCI_DEVFN(sbdn_sb800 + 0x14, i));
97 if (dev) {
98 bus_sb800[2 + i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
99 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
100 bus_isa++;
101 }
102 }
103 for (j = bus_sb800[2]; j < bus_isa; j++)
104 bus_type[j] = 1;
105
106
107 /* I/O APICs: APIC ID Version State Address */
108 bus_isa = 10;
Marshall Buschman6d5ee2d2011-06-04 15:43:15 +0000109 apicid_base = CONFIG_MAX_CPUS;
Peter Stuged1760c82011-06-04 15:48:14 +0000110 apicid_sb800 = apicid_base;
Kerry Shefeed3292011-08-18 18:03:44 +0800111
112#if CONFIG_AMD_SB_CIMX
113 sb_Late_Post();
114#endif
Scott Duplichana649a962011-02-24 05:00:33 +0000115}