blob: 87f065d59c5db64e56a9517ac2c0a61ec5b1ea5b [file] [log] [blame]
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +00001/*
2 * This file is part of the coreboot project.
3 *
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.
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +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>
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +000026
27#include <cpu/amd/amdk8_sysconf.h>
28
29#include "mb_sysconf.h"
30
31// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
32struct mb_sysconf_t mb_sysconf;
33
34static unsigned pci1234x[] =
35{ //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,
39// 0x0000ff0,
40// 0x0000ff0,
41// 0x0000ff0,
42// 0x0000ff0,
43// 0x0000ff0,
44// 0x0000ff0
45};
46static unsigned hcdnx[] =
47{ //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,
50// 0x20202020,
51// 0x20202020,
52// 0x20202020,
53// 0x20202020,
54// 0x20202020,
55// 0x20202020,
56};
57
Stefan Reinauere9de1e22010-04-07 15:30:11 +000058
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +000059
60static unsigned get_bus_conf_done = 0;
61
62void get_bus_conf(void)
63{
64
65 unsigned apicid_base;
66
67 device_t dev;
68 int i;
69 struct mb_sysconf_t *m;
70
71 if(get_bus_conf_done==1) return; //do it only once
72
73 get_bus_conf_done = 1;
74
75 sysconf.mb = &mb_sysconf;
76
77 m = sysconf.mb;
78
Edward O'Callaghan96c801bf2014-07-07 19:17:53 +100079 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +000080
81 for(i=0;i<sysconf.hc_possible_num; i++) {
82 sysconf.pci1234[i] = pci1234x[i];
83 sysconf.hcdn[i] = hcdnx[i];
84 }
85
86 get_sblk_pci1234();
87
88 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
89 m->sbdn2 = sysconf.hcdn[0] & 0xff; // bcm5780
90
91 m->bus_bcm5785_0 = (sysconf.pci1234[0] >> 16) & 0xff;
92 m->bus_bcm5780[0] = m->bus_bcm5785_0;
93
94 /* bcm5785 */
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000095 printk(BIOS_DEBUG, "search for def %d.0 on bus %d\n",sysconf.sbdn,m->bus_bcm5785_0);
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +000096 dev = dev_find_slot(m->bus_bcm5785_0, PCI_DEVFN(sysconf.sbdn,0));
97 if (dev) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000098 printk(BIOS_DEBUG, "found dev %s...\n",dev_path(dev));
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +000099 m->bus_bcm5785_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000100 printk(BIOS_DEBUG, "secondary is %d...\n",m->bus_bcm5785_1);
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +0000101 dev = dev_find_slot(m->bus_bcm5785_1, PCI_DEVFN(0xd,0));
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000102 printk(BIOS_DEBUG, "now found %s...\n",dev_path(dev));
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +0000103 if(dev) {
104 m->bus_bcm5785_1_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +0000105 }
106 }
107 else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000108 printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_bcm5785_0, sysconf.sbdn);
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +0000109 }
110
111 /* bcm5780 */
112 for(i = 1; i < 6; i++) {
113 dev = dev_find_slot(m->bus_bcm5780[0], PCI_DEVFN(m->sbdn2 + i - 1,0));
114 if(dev) {
115 m->bus_bcm5780[i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +0000116 }
117 else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000118 printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_bcm5780[0], m->sbdn2+i-1);
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +0000119 }
120 }
121
122
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;
Mondrian nuessle5b34bdd2009-04-22 20:34:05 +0000128 for(i=0;i<3;i++)
129 m->apicid_bcm5785[i] = apicid_base+i;
130}