blob: 9fee2113c1dc5ea47d3caffa0796d110940030a0 [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.
bxshifaea4c52006-11-02 16:02:33 +000019 */
20#include <console/console.h>
21#include <device/pci.h>
22#include <device/pci_ids.h>
23#include <string.h>
24#include <stdint.h>
Stefan Reinauer9a16e3e2010-03-29 14:45:36 +000025#include <cpu/amd/multicore.h>
bxshifaea4c52006-11-02 16:02:33 +000026
27#include <cpu/amd/amdk8_sysconf.h>
28
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000029#include <stdlib.h>
bxshifaea4c52006-11-02 16:02:33 +000030#include "mb_sysconf.h"
31
32// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
33struct mb_sysconf_t mb_sysconf;
34
Paul Menzel6a4e9b52013-10-18 09:42:55 +020035static unsigned pci1234x[] = { //Here you only need to set value in pci1234 for HT-IO that could be installed or not
36 //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
37 0x0000ff0,
38 0x0000ff0,
bxshifaea4c52006-11-02 16:02:33 +000039// 0x0000ff0,
40// 0x0000ff0,
41// 0x0000ff0,
42// 0x0000ff0,
43// 0x0000ff0,
44// 0x0000ff0
45};
Paul Menzel6a4e9b52013-10-18 09:42:55 +020046
47static 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
48 0x20202020,
49 0x20202020,
bxshifaea4c52006-11-02 16:02:33 +000050// 0x20202020,
51// 0x20202020,
52// 0x20202020,
53// 0x20202020,
54// 0x20202020,
55// 0x20202020,
56};
57
bxshifaea4c52006-11-02 16:02:33 +000058static unsigned get_bus_conf_done = 0;
59
60void get_bus_conf(void)
61{
62
Paul Menzel6a4e9b52013-10-18 09:42:55 +020063 unsigned apicid_base;
bxshifaea4c52006-11-02 16:02:33 +000064
Paul Menzel6a4e9b52013-10-18 09:42:55 +020065 device_t dev;
66 int i;
67 struct mb_sysconf_t *m;
bxshifaea4c52006-11-02 16:02:33 +000068
Paul Menzel6a4e9b52013-10-18 09:42:55 +020069 if (get_bus_conf_done == 1)
70 return; //do it only once
bxshifaea4c52006-11-02 16:02:33 +000071
Paul Menzel6a4e9b52013-10-18 09:42:55 +020072 get_bus_conf_done = 1;
bxshifaea4c52006-11-02 16:02:33 +000073
Paul Menzel6a4e9b52013-10-18 09:42:55 +020074 sysconf.mb = &mb_sysconf;
bxshifaea4c52006-11-02 16:02:33 +000075
Paul Menzel6a4e9b52013-10-18 09:42:55 +020076 m = sysconf.mb;
bxshifaea4c52006-11-02 16:02:33 +000077
Paul Menzel6a4e9b52013-10-18 09:42:55 +020078 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
bxshifaea4c52006-11-02 16:02:33 +000079
Paul Menzel6a4e9b52013-10-18 09:42:55 +020080 for (i = 0; i < sysconf.hc_possible_num; i++) {
81 sysconf.pci1234[i] = pci1234x[i];
82 sysconf.hcdn[i] = hcdnx[i];
83 }
bxshifaea4c52006-11-02 16:02:33 +000084
Paul Menzel6a4e9b52013-10-18 09:42:55 +020085 get_sblk_pci1234();
bxshifaea4c52006-11-02 16:02:33 +000086
Paul Menzel6a4e9b52013-10-18 09:42:55 +020087 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
88 m->sbdn2 = sysconf.hcdn[0] & 0xff; // bcm5780
bxshifaea4c52006-11-02 16:02:33 +000089
Paul Menzel6a4e9b52013-10-18 09:42:55 +020090 m->bus_bcm5785_0 = (sysconf.pci1234[0] >> 16) & 0xff;
91 m->bus_bcm5780[0] = m->bus_bcm5785_0;
bxshifaea4c52006-11-02 16:02:33 +000092
Paul Menzel6a4e9b52013-10-18 09:42:55 +020093 /* bcm5785 */
94 dev = dev_find_slot(m->bus_bcm5785_0, PCI_DEVFN(sysconf.sbdn, 0));
95 if (dev) {
96 m->bus_bcm5785_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
97 dev = dev_find_slot(m->bus_bcm5785_1, PCI_DEVFN(0xd, 0));
98 if (dev) {
99 m->bus_bcm5785_1_1 =
100 pci_read_config8(dev, PCI_SECONDARY_BUS);
101 }
102 } else {
103 printk(BIOS_DEBUG,
104 "ERROR - could not find PCI %02x:%02x.0, using defaults\n",
105 m->bus_bcm5785_0, sysconf.sbdn);
106 }
bxshifaea4c52006-11-02 16:02:33 +0000107
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200108 /* bcm5780 */
109 for (i = 1; i < 7; i++) {
110 dev =
111 dev_find_slot(m->bus_bcm5780[0],
112 PCI_DEVFN(m->sbdn2 + i - 1, 0));
113 if (dev) {
114 m->bus_bcm5780[i] =
115 pci_read_config8(dev, PCI_SECONDARY_BUS);
116 } else {
117 printk(BIOS_DEBUG,
118 "ERROR - could not find PCI %02x:%02x.0, using defaults\n",
119 m->bus_bcm5780[0], m->sbdn2 + i - 1);
120 }
121 }
bxshifaea4c52006-11-02 16:02:33 +0000122
123/*I/O APICs: APIC ID Version State Address*/
Timothy Pearsond4bbfe82015-10-27 16:48:36 -0500124 if (IS_ENABLED(CONFIG_LOGICAL_CPUS))
125 apicid_base = get_apicid_base(3);
126 else
127 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200128 for (i = 0; i < 3; i++)
129 m->apicid_bcm5785[i] = apicid_base + i;
bxshifaea4c52006-11-02 16:02:33 +0000130}