blob: 43cc42fe99c8198af89cf9b104692c371a18a696 [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
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24#include <console/console.h>
25#include <device/pci.h>
26#include <device/pci_ids.h>
27#include <string.h>
28#include <stdint.h>
29#if CONFIG_LOGICAL_CPUS==1
30#include <cpu/amd/dualcore.h>
31#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
41static unsigned pci1234x[] =
42{ //Here you only need to set value in pci1234 for HT-IO that could be installed or not
43 //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
44 0x0000ff0,
45 0x0000ff0,
46// 0x0000ff0,
47// 0x0000ff0,
48// 0x0000ff0,
49// 0x0000ff0,
50// 0x0000ff0,
51// 0x0000ff0
52};
53static unsigned hcdnx[] =
54{ //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
55 0x20202020,
56 0x20202020,
57// 0x20202020,
58// 0x20202020,
59// 0x20202020,
60// 0x20202020,
61// 0x20202020,
62// 0x20202020,
63};
64
65extern void get_sblk_pci1234(void);
66
67static unsigned get_bus_conf_done = 0;
68
69void get_bus_conf(void)
70{
71
72 unsigned apicid_base;
73
74 device_t dev;
75 int i;
76 struct mb_sysconf_t *m;
77
78 if(get_bus_conf_done==1) return; //do it only once
79
80 get_bus_conf_done = 1;
81
82 sysconf.mb = &mb_sysconf;
83
84 m = sysconf.mb;
85
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000086 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
bxshifaea4c52006-11-02 16:02:33 +000087
88 for(i=0;i<sysconf.hc_possible_num; i++) {
89 sysconf.pci1234[i] = pci1234x[i];
90 sysconf.hcdn[i] = hcdnx[i];
91 }
92
93 get_sblk_pci1234();
94
95 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
96 m->sbdn2 = sysconf.hcdn[0] & 0xff; // bcm5780
97
98 m->bus_bcm5785_0 = (sysconf.pci1234[0] >> 16) & 0xff;
99 m->bus_bcm5780[0] = m->bus_bcm5785_0;
100
101 /* bcm5785 */
102 dev = dev_find_slot(m->bus_bcm5785_0, PCI_DEVFN(sysconf.sbdn,0));
103 if (dev) {
104 m->bus_bcm5785_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
105 dev = dev_find_slot(m->bus_bcm5785_1, PCI_DEVFN(0xd,0));
106 if(dev) {
107 m->bus_bcm5785_1_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
108#if HT_CHAIN_END_UNITID_BASE >= HT_CHAIN_UNITID_BASE
109 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
110 m->bus_isa++;
111 printk_debug("bus_isa=%d\n",m->bus_isa);
112#endif
113 }
114 }
115 else {
116 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_bcm5785_0, sysconf.sbdn);
117 }
118
119 /* bcm5780 */
120 for(i = 1; i < 7; i++) {
121 dev = dev_find_slot(m->bus_bcm5780[0], PCI_DEVFN(m->sbdn2 + i - 1,0));
122 if(dev) {
123 m->bus_bcm5780[i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
124#if HT_CHAIN_END_UNITID_BASE < HT_CHAIN_UNITID_BASE
125 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
126 m->bus_isa++;
127 printk_debug("bus_isa=%d\n",m->bus_isa);
128#endif
129
130 }
131 else {
132 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_bcm5780[0], m->sbdn2+i-1);
133 }
134 }
135
136
137/*I/O APICs: APIC ID Version State Address*/
138#if CONFIG_LOGICAL_CPUS==1
139 apicid_base = get_apicid_base(3);
140#else
141 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
142#endif
143 for(i=0;i<3;i++)
144 m->apicid_bcm5785[i] = apicid_base+i;
145}