blob: 15b19896ae4808af9124f0c68522bfe657f84ad5 [file] [log] [blame]
Frank Vibrans69da1b62011-02-14 19:04:45 +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
Paul Menzela8ae1c62013-02-20 13:21:20 +010012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Frank Vibrans69da1b62011-02-14 19:04:45 +000013 * 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 Menzel7d75fbd2013-02-20 13:40:14 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Frank Vibrans69da1b62011-02-14 19:04:45 +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>
efdesign98d7a696d2011-09-15 15:24:26 -060027#include "agesawrapper.h"
Mike Loptiencbc783f2014-06-06 15:21:28 -060028#include <arch/ioapic.h>
Kerry Shefeed3292011-08-18 18:03:44 +080029#if CONFIG_AMD_SB_CIMX
30#include <sb_cimx.h>
31#endif
Frank Vibrans69da1b62011-02-14 19:04:45 +000032
33
34/* Global variables for MB layouts and these will be shared by irqtable mptable
35* and acpi_tables busnum is default.
36*/
37u8 bus_isa;
Kyösti Mälkki9c7d73c2013-09-09 09:23:19 +030038u8 bus_sb800[6];
Frank Vibrans69da1b62011-02-14 19:04:45 +000039u32 apicid_sb800;
Mike Loptiencbc783f2014-06-06 15:21:28 -060040u32 apicver_sb800;
Frank Vibrans69da1b62011-02-14 19:04:45 +000041
42/*
43* Here you only need to set value in pci1234 for HT-IO that could be installed or not
44* You may need to preset pci1234 for HTIO board,
45* please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
46*/
47u32 pci1234x[] = {
Marc Jones36abff12011-11-07 23:26:14 -070048 0x0000ff0,
Frank Vibrans69da1b62011-02-14 19:04:45 +000049};
50
Frank Vibrans69da1b62011-02-14 19:04:45 +000051u32 bus_type[256];
Frank Vibrans69da1b62011-02-14 19:04:45 +000052u32 sbdn_sb800;
53
Frank Vibrans69da1b62011-02-14 19:04:45 +000054static u32 get_bus_conf_done = 0;
55
Frank Vibrans69da1b62011-02-14 19:04:45 +000056void get_bus_conf(void)
57{
Marc Jones36abff12011-11-07 23:26:14 -070058 u32 apicid_base;
Frank Vibrans69da1b62011-02-14 19:04:45 +000059
Marc Jones36abff12011-11-07 23:26:14 -070060 device_t dev;
61 int i, j;
Frank Vibrans69da1b62011-02-14 19:04:45 +000062
Marc Jones36abff12011-11-07 23:26:14 -070063 if (get_bus_conf_done == 1)
64 return; /* do it only once */
Frank Vibrans69da1b62011-02-14 19:04:45 +000065
Marc Jones36abff12011-11-07 23:26:14 -070066 get_bus_conf_done = 1;
Frank Vibrans69da1b62011-02-14 19:04:45 +000067
Marc Jones36abff12011-11-07 23:26:14 -070068 sbdn_sb800 = 0;
Frank Vibrans69da1b62011-02-14 19:04:45 +000069
Kyösti Mälkki9c7d73c2013-09-09 09:23:19 +030070 memset(bus_sb800, 0, sizeof(bus_sb800));
Frank Vibrans69da1b62011-02-14 19:04:45 +000071
Marc Jones36abff12011-11-07 23:26:14 -070072 for (i = 0; i < 256; i++) {
73 bus_type[i] = 0; /* default ISA bus. */
74 }
Frank Vibrans69da1b62011-02-14 19:04:45 +000075
Marc Jones36abff12011-11-07 23:26:14 -070076 bus_type[0] = 1; /* pci */
Frank Vibrans69da1b62011-02-14 19:04:45 +000077
Marc Jones36abff12011-11-07 23:26:14 -070078// bus_sb800[0] = (sysconf.pci1234[0] >> 16) & 0xff;
79 bus_sb800[0] = (pci1234x[0] >> 16) & 0xff;
Frank Vibrans69da1b62011-02-14 19:04:45 +000080
Marc Jones36abff12011-11-07 23:26:14 -070081 /* sb800 */
82 dev = dev_find_slot(bus_sb800[0], PCI_DEVFN(sbdn_sb800 + 0x14, 4));
Frank Vibrans69da1b62011-02-14 19:04:45 +000083
Marc Jones36abff12011-11-07 23:26:14 -070084 if (dev) {
85 bus_sb800[1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
Frank Vibrans69da1b62011-02-14 19:04:45 +000086
Marc Jones36abff12011-11-07 23:26:14 -070087 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
88 bus_isa++;
89 for (j = bus_sb800[1]; j < bus_isa; j++)
90 bus_type[j] = 1;
91 }
Frank Vibrans69da1b62011-02-14 19:04:45 +000092
Marc Jones36abff12011-11-07 23:26:14 -070093 for (i = 0; i < 4; i++) {
94 dev = dev_find_slot(bus_sb800[0], PCI_DEVFN(sbdn_sb800 + 0x14, i));
95 if (dev) {
96 bus_sb800[2 + i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
97 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
98 bus_isa++;
99 }
100 }
Frank Vibrans69da1b62011-02-14 19:04:45 +0000101
Marc Jones36abff12011-11-07 23:26:14 -0700102 for (j = bus_sb800[2]; j < bus_isa; j++)
103 bus_type[j] = 1;
Frank Vibrans69da1b62011-02-14 19:04:45 +0000104
zbaof543c7b2012-04-13 13:42:46 +0800105
106 /* I/O APICs: APIC ID Version State Address */
Marc Jones36abff12011-11-07 23:26:14 -0700107 bus_isa = 10;
108 apicid_base = CONFIG_MAX_CPUS;
Mike Loptiencbc783f2014-06-06 15:21:28 -0600109
110 /*
111 * By the time this function gets called, the IOAPIC registers
112 * have been written so they can be read to get the correct
113 * APIC ID and Version
114 */
115 apicid_sb800 = (io_apic_read(IO_APIC_ADDR, 0x00) >> 24);
116 apicver_sb800 = (io_apic_read(IO_APIC_ADDR, 0x01) & 0xFF);
Kerry Shefeed3292011-08-18 18:03:44 +0800117
118#if CONFIG_AMD_SB_CIMX
119 sb_Late_Post();
120#endif
Frank Vibrans69da1b62011-02-14 19:04:45 +0000121}