blob: 77b0b07a66e32a21725d700dc314800cb269b438 [file] [log] [blame]
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007 AMD
5 * (Written by Yinghai Lu <yinghailu@amd.com> for AMD)
6 * Copyright (C) 2007 Philipp Degler <pdegler@rumms.uni-mannheim.de>
7 * (Thanks to LSRA University of Mannheim for their support)
8 * Copyright (C) 2008 Jonathan A. Kollasch <jakllsch@kollasch.net>
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.
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000019 */
20
21#include <console/console.h>
22#include <device/pci.h>
23#include <device/pci_ids.h>
24#include <string.h>
25#include <stdint.h>
Stefan Reinauer9a16e3e2010-03-29 14:45:36 +000026#include <cpu/amd/multicore.h>
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000027
28#include <cpu/amd/amdk8_sysconf.h>
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000029#include <stdlib.h>
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000030
31/* Global variables for MB layouts and these will be shared by irqtable,
32 * mptable and acpi_tables.
33 */
34/* busnum is default */
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000035unsigned char bus_ck804[6];
36unsigned apicid_ck804;
37
38unsigned pci1234x[] = { //Here you only need to set value in pci1234 for HT-IO that could be installed or not
39 //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
40 0x0000ff0, //no HTIO for ms7135
41};
42unsigned 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
Stefan Reinauer14e22772010-04-27 06:56:47 +000043 0x20202020, //ms7135 has only one ht-chain
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000044};
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000045
46static unsigned get_bus_conf_done = 0;
47
48void get_bus_conf(void)
49{
50 unsigned apicid_base;
51
52 device_t dev;
53 unsigned sbdn;
Patrick Georgi5244e1b2010-11-21 14:41:07 +000054 int i;
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000055
56 if (get_bus_conf_done == 1)
57 return; //do it only once
58
59 get_bus_conf_done = 1;
60
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000061 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
62 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000063 for (i = 0; i < sysconf.hc_possible_num; i++) {
64 sysconf.pci1234[i] = pci1234x[i];
65 sysconf.hcdn[i] = hcdnx[i];
66 }
67
68 get_sblk_pci1234();
69
70 sysconf.sbdn = (sysconf.hcdn[0] & 0xff); // first byte of first chain
71 sbdn = sysconf.sbdn;
72
73 for (i = 0; i < 6; i++) {
74 bus_ck804[i] = 0;
75 }
76
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000077 bus_ck804[0] = (sysconf.pci1234[0] >> 16) & 0xff;
78
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000079 /* CK804 */
80 int dn = -1;
81 for (i = 1; i < 4; i++) {
82 switch (i) {
83 case 1: dn = 9; break;
84 case 2: dn = 13; break;
Stefan Reinauer14e22772010-04-27 06:56:47 +000085 case 3: dn = 14; break;
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000086 default: dn = -1; break;
87 }
88 dev = dev_find_slot(bus_ck804[0], PCI_DEVFN(sbdn + dn, 0));
89 if (dev) {
90 bus_ck804[i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000091 }
92 }
93
94/*I/O APICs: APIC ID Version State Address*/
Timothy Pearsond4bbfe82015-10-27 16:48:36 -050095 if (IS_ENABLED(CONFIG_LOGICAL_CPUS))
96 apicid_base = get_apicid_base(3);
97 else
98 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
Jonathan A. Kollasch8eff1e32008-02-20 15:59:30 +000099 apicid_ck804 = apicid_base + 0;
100}