blob: 3a70d838dcf0c5d0b90c882c1cc8e4839e20bbd1 [file] [log] [blame]
bxshifaea4c52006-11-02 16:02:33 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
bxshifaea4c52006-11-02 16:02:33 +00003 *
4 * Copyright (C) 2006 AMD
5 * Written by Yinghai Lu <yinghailu@gmail.com> for AMD.
6 *
7 * Copyright (C) 2006 MSI
8 * Written by bxshi <bingxunshi@gmail.com> for MSI.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010022 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
bxshifaea4c52006-11-02 16:02:33 +000023 */
24#include <console/console.h>
25#include <device/pci.h>
26#include <device/pci_ids.h>
27#include <string.h>
28#include <stdint.h>
Patrick Georgie1667822012-05-05 15:29:32 +020029#if CONFIG_LOGICAL_CPUS
Stefan Reinauer9a16e3e2010-03-29 14:45:36 +000030#include <cpu/amd/multicore.h>
bxshifaea4c52006-11-02 16:02:33 +000031#endif
32
33#include <cpu/amd/amdk8_sysconf.h>
34
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000035#include <stdlib.h>
bxshifaea4c52006-11-02 16:02:33 +000036#include "mb_sysconf.h"
37
38// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
39struct mb_sysconf_t mb_sysconf;
40
Paul Menzel6a4e9b52013-10-18 09:42:55 +020041static unsigned pci1234x[] = { //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, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
43 0x0000ff0,
44 0x0000ff0,
bxshifaea4c52006-11-02 16:02:33 +000045// 0x0000ff0,
46// 0x0000ff0,
47// 0x0000ff0,
48// 0x0000ff0,
49// 0x0000ff0,
50// 0x0000ff0
51};
Paul Menzel6a4e9b52013-10-18 09:42:55 +020052
53static unsigned hcdnx[] = { //HT Chain device num, actually it is unit id base of every ht device in chain, assume every chain only have 4 ht device at most
54 0x20202020,
55 0x20202020,
bxshifaea4c52006-11-02 16:02:33 +000056// 0x20202020,
57// 0x20202020,
58// 0x20202020,
59// 0x20202020,
60// 0x20202020,
61// 0x20202020,
62};
63
bxshifaea4c52006-11-02 16:02:33 +000064static unsigned get_bus_conf_done = 0;
65
66void get_bus_conf(void)
67{
68
Paul Menzel6a4e9b52013-10-18 09:42:55 +020069 unsigned apicid_base;
bxshifaea4c52006-11-02 16:02:33 +000070
Paul Menzel6a4e9b52013-10-18 09:42:55 +020071 device_t dev;
72 int i;
73 struct mb_sysconf_t *m;
bxshifaea4c52006-11-02 16:02:33 +000074
Paul Menzel6a4e9b52013-10-18 09:42:55 +020075 if (get_bus_conf_done == 1)
76 return; //do it only once
bxshifaea4c52006-11-02 16:02:33 +000077
Paul Menzel6a4e9b52013-10-18 09:42:55 +020078 get_bus_conf_done = 1;
bxshifaea4c52006-11-02 16:02:33 +000079
Paul Menzel6a4e9b52013-10-18 09:42:55 +020080 sysconf.mb = &mb_sysconf;
bxshifaea4c52006-11-02 16:02:33 +000081
Paul Menzel6a4e9b52013-10-18 09:42:55 +020082 m = sysconf.mb;
bxshifaea4c52006-11-02 16:02:33 +000083
Paul Menzel6a4e9b52013-10-18 09:42:55 +020084 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
bxshifaea4c52006-11-02 16:02:33 +000085
Paul Menzel6a4e9b52013-10-18 09:42:55 +020086 for (i = 0; i < sysconf.hc_possible_num; i++) {
87 sysconf.pci1234[i] = pci1234x[i];
88 sysconf.hcdn[i] = hcdnx[i];
89 }
bxshifaea4c52006-11-02 16:02:33 +000090
Paul Menzel6a4e9b52013-10-18 09:42:55 +020091 get_sblk_pci1234();
bxshifaea4c52006-11-02 16:02:33 +000092
Paul Menzel6a4e9b52013-10-18 09:42:55 +020093 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
94 m->sbdn2 = sysconf.hcdn[0] & 0xff; // bcm5780
bxshifaea4c52006-11-02 16:02:33 +000095
Paul Menzel6a4e9b52013-10-18 09:42:55 +020096 m->bus_bcm5785_0 = (sysconf.pci1234[0] >> 16) & 0xff;
97 m->bus_bcm5780[0] = m->bus_bcm5785_0;
bxshifaea4c52006-11-02 16:02:33 +000098
Paul Menzel6a4e9b52013-10-18 09:42:55 +020099 /* bcm5785 */
100 dev = dev_find_slot(m->bus_bcm5785_0, PCI_DEVFN(sysconf.sbdn, 0));
101 if (dev) {
102 m->bus_bcm5785_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
103 dev = dev_find_slot(m->bus_bcm5785_1, PCI_DEVFN(0xd, 0));
104 if (dev) {
105 m->bus_bcm5785_1_1 =
106 pci_read_config8(dev, PCI_SECONDARY_BUS);
107 }
108 } else {
109 printk(BIOS_DEBUG,
110 "ERROR - could not find PCI %02x:%02x.0, using defaults\n",
111 m->bus_bcm5785_0, sysconf.sbdn);
112 }
bxshifaea4c52006-11-02 16:02:33 +0000113
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200114 /* bcm5780 */
115 for (i = 1; i < 7; i++) {
116 dev =
117 dev_find_slot(m->bus_bcm5780[0],
118 PCI_DEVFN(m->sbdn2 + i - 1, 0));
119 if (dev) {
120 m->bus_bcm5780[i] =
121 pci_read_config8(dev, PCI_SECONDARY_BUS);
122 } else {
123 printk(BIOS_DEBUG,
124 "ERROR - could not find PCI %02x:%02x.0, using defaults\n",
125 m->bus_bcm5780[0], m->sbdn2 + i - 1);
126 }
127 }
bxshifaea4c52006-11-02 16:02:33 +0000128
129/*I/O APICs: APIC ID Version State Address*/
Patrick Georgie1667822012-05-05 15:29:32 +0200130#if CONFIG_LOGICAL_CPUS
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200131 apicid_base = get_apicid_base(3);
bxshifaea4c52006-11-02 16:02:33 +0000132#else
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200133 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
bxshifaea4c52006-11-02 16:02:33 +0000134#endif
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200135 for (i = 0; i < 3; i++)
136 m->apicid_bcm5785[i] = apicid_base + i;
bxshifaea4c52006-11-02 16:02:33 +0000137}