blob: 9d13b0c573766513d0a18813b28a9d03748057f7 [file] [log] [blame]
Yinghai Luf55b58d2007-02-17 14:28:11 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Yinghai Luf55b58d2007-02-17 14:28:11 +00003 *
4 * Copyright (C) 2007 AMD
5 * Written by Yinghai Lu <yinghailu@amd.com> for AMD.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Yinghai Luf55b58d2007-02-17 14:28:11 +000016 */
17
18#include <console/console.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
21#include <string.h>
22#include <stdint.h>
Stefan Reinauer9a16e3e2010-03-29 14:45:36 +000023#include <cpu/amd/multicore.h>
Yinghai Luf55b58d2007-02-17 14:28:11 +000024
25#include <cpu/amd/amdk8_sysconf.h>
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000026#include <stdlib.h>
Yinghai Luf55b58d2007-02-17 14:28:11 +000027
Yinghai Luf55b58d2007-02-17 14:28:11 +000028// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
29//busnum is default
Paul Menzel6a4e9b52013-10-18 09:42:55 +020030unsigned char bus_mcp55[8]; //1
31unsigned apicid_mcp55;
Yinghai Luf55b58d2007-02-17 14:28:11 +000032
Paul Menzel6a4e9b52013-10-18 09:42:55 +020033unsigned pci1234x[] = { //Here you only need to set value in pci1234 for HT-IO that could be installed or not
34 //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
35 0x0000ff0,
Yinghai Luf55b58d2007-02-17 14:28:11 +000036// 0x0000ff0,
37// 0x0000ff0,
38// 0x0000ff0,
39// 0x0000ff0,
40// 0x0000ff0,
41// 0x0000ff0,
42// 0x0000ff0
43};
Paul Menzel6a4e9b52013-10-18 09:42:55 +020044
45unsigned 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
Yinghai Luf55b58d2007-02-17 14:28:11 +000046 0x20202020,
Paul Menzel6a4e9b52013-10-18 09:42:55 +020047// 0x20202020,
Yinghai Luf55b58d2007-02-17 14:28:11 +000048// 0x20202020,
49// 0x20202020,
50// 0x20202020,
51// 0x20202020,
52// 0x20202020,
53// 0x20202020,
54};
Yinghai Luf55b58d2007-02-17 14:28:11 +000055
56static unsigned get_bus_conf_done = 0;
57
58void get_bus_conf(void)
59{
60
61 unsigned apicid_base;
62 unsigned sbdn;
63
Paul Menzel6a4e9b52013-10-18 09:42:55 +020064 device_t dev;
65 int i;
Yinghai Luf55b58d2007-02-17 14:28:11 +000066
Paul Menzel6a4e9b52013-10-18 09:42:55 +020067 if (get_bus_conf_done == 1)
68 return; //do it only once
Yinghai Luf55b58d2007-02-17 14:28:11 +000069
Paul Menzel6a4e9b52013-10-18 09:42:55 +020070 get_bus_conf_done = 1;
Yinghai Luf55b58d2007-02-17 14:28:11 +000071
Paul Menzel6a4e9b52013-10-18 09:42:55 +020072 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
73 for (i = 0; i < sysconf.hc_possible_num; i++) {
74 sysconf.pci1234[i] = pci1234x[i];
75 sysconf.hcdn[i] = hcdnx[i];
76 }
Yinghai Luf55b58d2007-02-17 14:28:11 +000077
Paul Menzel6a4e9b52013-10-18 09:42:55 +020078 get_sblk_pci1234();
Yinghai Luf55b58d2007-02-17 14:28:11 +000079
Paul Menzel6a4e9b52013-10-18 09:42:55 +020080 sysconf.sbdn = (sysconf.hcdn[0] & 0xff); // first byte of first chain
Yinghai Luf55b58d2007-02-17 14:28:11 +000081 sbdn = sysconf.sbdn;
82
Paul Menzel6a4e9b52013-10-18 09:42:55 +020083 for (i = 0; i < 8; i++) {
Yinghai Luf55b58d2007-02-17 14:28:11 +000084 bus_mcp55[i] = 0;
85 }
Stefan Reinauer14e22772010-04-27 06:56:47 +000086
Yinghai Luf55b58d2007-02-17 14:28:11 +000087 bus_mcp55[0] = (sysconf.pci1234[0] >> 16) & 0xff;
88
Paul Menzel6a4e9b52013-10-18 09:42:55 +020089 /* MCP55 */
90 dev = dev_find_slot(bus_mcp55[0], PCI_DEVFN(sbdn + 0x06, 0));
91 if (dev) {
92 bus_mcp55[1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
93 bus_mcp55[2] = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
94 bus_mcp55[2]++;
95 } else {
96 printk(BIOS_DEBUG,
97 "ERROR - could not find PCI 1:%02x.0, using defaults\n",
98 sbdn + 0x06);
Yinghai Luf55b58d2007-02-17 14:28:11 +000099
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200100 bus_mcp55[1] = 2;
101 bus_mcp55[2] = 3;
102 }
Yinghai Luf55b58d2007-02-17 14:28:11 +0000103
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200104 for (i = 2; i < 8; i++) {
105 dev =
106 dev_find_slot(bus_mcp55[0],
107 PCI_DEVFN(sbdn + 0x0a + i - 2, 0));
108 if (dev) {
109 bus_mcp55[i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
Yinghai Luf55b58d2007-02-17 14:28:11 +0000110 }
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200111 }
Yinghai Luf55b58d2007-02-17 14:28:11 +0000112
113/*I/O APICs: APIC ID Version State Address*/
Timothy Pearsond4bbfe82015-10-27 16:48:36 -0500114 if (IS_ENABLED(CONFIG_LOGICAL_CPUS))
115 apicid_base = get_apicid_base(1);
116 else
117 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200118 apicid_mcp55 = apicid_base + 0;
Yinghai Luf55b58d2007-02-17 14:28:11 +0000119
120}