blob: 67ddefe64ca6e752ba5fdbb0a3d83af57c0a3af7 [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
Patrick Georgib890a122015-03-26 15:17:45 +010022 * Foundation, Inc.
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>
Stefan Reinauer9a16e3e2010-03-29 14:45:36 +000029#include <cpu/amd/multicore.h>
bxshifaea4c52006-11-02 16:02:33 +000030
31#include <cpu/amd/amdk8_sysconf.h>
32
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000033#include <stdlib.h>
bxshifaea4c52006-11-02 16:02:33 +000034#include "mb_sysconf.h"
35
36// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
37struct mb_sysconf_t mb_sysconf;
38
Paul Menzel6a4e9b52013-10-18 09:42:55 +020039static unsigned pci1234x[] = { //Here you only need to set value in pci1234 for HT-IO that could be installed or not
40 //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
41 0x0000ff0,
42 0x0000ff0,
bxshifaea4c52006-11-02 16:02:33 +000043// 0x0000ff0,
44// 0x0000ff0,
45// 0x0000ff0,
46// 0x0000ff0,
47// 0x0000ff0,
48// 0x0000ff0
49};
Paul Menzel6a4e9b52013-10-18 09:42:55 +020050
51static 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
52 0x20202020,
53 0x20202020,
bxshifaea4c52006-11-02 16:02:33 +000054// 0x20202020,
55// 0x20202020,
56// 0x20202020,
57// 0x20202020,
58// 0x20202020,
59// 0x20202020,
60};
61
bxshifaea4c52006-11-02 16:02:33 +000062static unsigned get_bus_conf_done = 0;
63
64void get_bus_conf(void)
65{
66
Paul Menzel6a4e9b52013-10-18 09:42:55 +020067 unsigned apicid_base;
bxshifaea4c52006-11-02 16:02:33 +000068
Paul Menzel6a4e9b52013-10-18 09:42:55 +020069 device_t dev;
70 int i;
71 struct mb_sysconf_t *m;
bxshifaea4c52006-11-02 16:02:33 +000072
Paul Menzel6a4e9b52013-10-18 09:42:55 +020073 if (get_bus_conf_done == 1)
74 return; //do it only once
bxshifaea4c52006-11-02 16:02:33 +000075
Paul Menzel6a4e9b52013-10-18 09:42:55 +020076 get_bus_conf_done = 1;
bxshifaea4c52006-11-02 16:02:33 +000077
Paul Menzel6a4e9b52013-10-18 09:42:55 +020078 sysconf.mb = &mb_sysconf;
bxshifaea4c52006-11-02 16:02:33 +000079
Paul Menzel6a4e9b52013-10-18 09:42:55 +020080 m = sysconf.mb;
bxshifaea4c52006-11-02 16:02:33 +000081
Paul Menzel6a4e9b52013-10-18 09:42:55 +020082 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
bxshifaea4c52006-11-02 16:02:33 +000083
Paul Menzel6a4e9b52013-10-18 09:42:55 +020084 for (i = 0; i < sysconf.hc_possible_num; i++) {
85 sysconf.pci1234[i] = pci1234x[i];
86 sysconf.hcdn[i] = hcdnx[i];
87 }
bxshifaea4c52006-11-02 16:02:33 +000088
Paul Menzel6a4e9b52013-10-18 09:42:55 +020089 get_sblk_pci1234();
bxshifaea4c52006-11-02 16:02:33 +000090
Paul Menzel6a4e9b52013-10-18 09:42:55 +020091 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
92 m->sbdn2 = sysconf.hcdn[0] & 0xff; // bcm5780
bxshifaea4c52006-11-02 16:02:33 +000093
Paul Menzel6a4e9b52013-10-18 09:42:55 +020094 m->bus_bcm5785_0 = (sysconf.pci1234[0] >> 16) & 0xff;
95 m->bus_bcm5780[0] = m->bus_bcm5785_0;
bxshifaea4c52006-11-02 16:02:33 +000096
Paul Menzel6a4e9b52013-10-18 09:42:55 +020097 /* bcm5785 */
98 dev = dev_find_slot(m->bus_bcm5785_0, PCI_DEVFN(sysconf.sbdn, 0));
99 if (dev) {
100 m->bus_bcm5785_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
101 dev = dev_find_slot(m->bus_bcm5785_1, PCI_DEVFN(0xd, 0));
102 if (dev) {
103 m->bus_bcm5785_1_1 =
104 pci_read_config8(dev, PCI_SECONDARY_BUS);
105 }
106 } else {
107 printk(BIOS_DEBUG,
108 "ERROR - could not find PCI %02x:%02x.0, using defaults\n",
109 m->bus_bcm5785_0, sysconf.sbdn);
110 }
bxshifaea4c52006-11-02 16:02:33 +0000111
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200112 /* bcm5780 */
113 for (i = 1; i < 7; i++) {
114 dev =
115 dev_find_slot(m->bus_bcm5780[0],
116 PCI_DEVFN(m->sbdn2 + i - 1, 0));
117 if (dev) {
118 m->bus_bcm5780[i] =
119 pci_read_config8(dev, PCI_SECONDARY_BUS);
120 } else {
121 printk(BIOS_DEBUG,
122 "ERROR - could not find PCI %02x:%02x.0, using defaults\n",
123 m->bus_bcm5780[0], m->sbdn2 + i - 1);
124 }
125 }
bxshifaea4c52006-11-02 16:02:33 +0000126
127/*I/O APICs: APIC ID Version State Address*/
Timothy Pearsond4bbfe82015-10-27 16:48:36 -0500128 if (IS_ENABLED(CONFIG_LOGICAL_CPUS))
129 apicid_base = get_apicid_base(3);
130 else
131 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200132 for (i = 0; i < 3; i++)
133 m->apicid_bcm5785[i] = apicid_base + i;
bxshifaea4c52006-11-02 16:02:33 +0000134}