Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 17 | * Foundation, Inc. |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include <console/console.h> |
| 21 | #include <device/pci.h> |
| 22 | #include <device/pci_ids.h> |
| 23 | #include <string.h> |
| 24 | #include <stdint.h> |
| 25 | #include <stdlib.h> |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 26 | #include <cpu/amd/multicore.h> |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 27 | |
| 28 | #include <cpu/amd/amdk8_sysconf.h> |
| 29 | |
| 30 | /* Global variables for MB layouts and these will be shared by irqtable mptable |
| 31 | * and acpi_tables busnum is default. |
| 32 | */ |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 33 | u8 bus_rs690[8]; |
| 34 | u8 bus_sb600[2]; |
| 35 | u32 apicid_sb600; |
| 36 | |
| 37 | /* |
| 38 | * 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, |
| 40 | * please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail |
| 41 | */ |
| 42 | u32 pci1234x[] = { |
| 43 | 0x0000ff0, |
| 44 | }; |
| 45 | |
| 46 | /* |
| 47 | * HT Chain device num, actually it is unit id base of every ht device in chain, |
| 48 | * assume every chain only have 4 ht device at most |
| 49 | */ |
| 50 | u32 hcdnx[] = { |
| 51 | 0x20202020, |
| 52 | }; |
| 53 | |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 54 | u32 sbdn_rs690; |
| 55 | u32 sbdn_sb600; |
| 56 | |
| 57 | |
| 58 | |
| 59 | static u32 get_bus_conf_done = 0; |
| 60 | |
| 61 | void get_bus_conf(void) |
| 62 | { |
| 63 | u32 apicid_base; |
| 64 | device_t dev; |
Patrick Georgi | c5ae306 | 2011-10-06 14:34:22 +0200 | [diff] [blame] | 65 | int i; |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 66 | |
| 67 | if (get_bus_conf_done == 1) |
| 68 | return; /* do it only once */ |
| 69 | get_bus_conf_done = 1; |
| 70 | |
| 71 | sysconf.hc_possible_num = ARRAY_SIZE(pci1234x); |
| 72 | for (i = 0; i < sysconf.hc_possible_num; i++) { |
| 73 | sysconf.pci1234[i] = pci1234x[i]; |
| 74 | sysconf.hcdn[i] = hcdnx[i]; |
| 75 | } |
| 76 | |
| 77 | get_sblk_pci1234(); |
| 78 | |
| 79 | sysconf.sbdn = (sysconf.hcdn[0] & 0xff); |
| 80 | sbdn_rs690 = sysconf.sbdn; |
| 81 | sbdn_sb600 = 0; |
| 82 | |
| 83 | for (i = 0; i < 2; i++) { |
| 84 | bus_sb600[i] = 0; |
| 85 | } |
| 86 | for (i = 0; i < 8; i++) { |
| 87 | bus_rs690[i] = 0; |
| 88 | } |
| 89 | |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 90 | bus_rs690[0] = (sysconf.pci1234[0] >> 16) & 0xff; |
| 91 | bus_sb600[0] = bus_rs690[0]; |
| 92 | |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 93 | /* sb600 */ |
| 94 | dev = dev_find_slot(bus_sb600[0], PCI_DEVFN(sbdn_sb600 + 0x14, 4)); |
| 95 | if (dev) { |
| 96 | bus_sb600[1] = pci_read_config8(dev, PCI_SECONDARY_BUS); |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | /* rs690 */ |
| 100 | for (i = 1; i < 8; i++) { |
| 101 | dev = dev_find_slot(bus_rs690[0], PCI_DEVFN(sbdn_rs690 + i, 0)); |
| 102 | if (dev) { |
| 103 | bus_rs690[i] = pci_read_config8(dev, PCI_SECONDARY_BUS); |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
| 107 | /* I/O APICs: APIC ID Version State Address */ |
Timothy Pearson | d4bbfe8 | 2015-10-27 16:48:36 -0500 | [diff] [blame^] | 108 | if (IS_ENABLED(CONFIG_LOGICAL_CPUS)) |
| 109 | apicid_base = get_apicid_base(1); |
| 110 | else |
| 111 | apicid_base = CONFIG_MAX_PHYSICAL_CPUS; |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 112 | apicid_sb600 = apicid_base + 0; |
| 113 | } |