Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 3 | * |
| 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 16 | */ |
| 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 Reinauer | 9a16e3e | 2010-03-29 14:45:36 +0000 | [diff] [blame] | 23 | #include <cpu/amd/multicore.h> |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 24 | |
| 25 | #include <cpu/amd/amdk8_sysconf.h> |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 26 | #include <stdlib.h> |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 27 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 28 | // Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables |
| 29 | //busnum is default |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 30 | unsigned char bus_mcp55[8]; //1 |
| 31 | unsigned apicid_mcp55; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 32 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 33 | unsigned 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 36 | // 0x0000ff0, |
| 37 | // 0x0000ff0, |
| 38 | // 0x0000ff0, |
| 39 | // 0x0000ff0, |
| 40 | // 0x0000ff0, |
| 41 | // 0x0000ff0, |
| 42 | // 0x0000ff0 |
| 43 | }; |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 44 | |
| 45 | unsigned 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 46 | 0x20202020, |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 47 | // 0x20202020, |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 48 | // 0x20202020, |
| 49 | // 0x20202020, |
| 50 | // 0x20202020, |
| 51 | // 0x20202020, |
| 52 | // 0x20202020, |
| 53 | // 0x20202020, |
| 54 | }; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 55 | |
| 56 | static unsigned get_bus_conf_done = 0; |
| 57 | |
| 58 | void get_bus_conf(void) |
| 59 | { |
| 60 | |
| 61 | unsigned apicid_base; |
| 62 | unsigned sbdn; |
| 63 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 64 | device_t dev; |
| 65 | int i; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 66 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 67 | if (get_bus_conf_done == 1) |
| 68 | return; //do it only once |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 69 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 70 | get_bus_conf_done = 1; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 71 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 72 | 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 77 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 78 | get_sblk_pci1234(); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 79 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 80 | sysconf.sbdn = (sysconf.hcdn[0] & 0xff); // first byte of first chain |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 81 | sbdn = sysconf.sbdn; |
| 82 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 83 | for (i = 0; i < 8; i++) { |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 84 | bus_mcp55[i] = 0; |
| 85 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 86 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 87 | bus_mcp55[0] = (sysconf.pci1234[0] >> 16) & 0xff; |
| 88 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 89 | /* 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 99 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 100 | bus_mcp55[1] = 2; |
| 101 | bus_mcp55[2] = 3; |
| 102 | } |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 103 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 104 | 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 110 | } |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 111 | } |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 112 | |
| 113 | /*I/O APICs: APIC ID Version State Address*/ |
Timothy Pearson | d4bbfe8 | 2015-10-27 16:48:36 -0500 | [diff] [blame] | 114 | if (IS_ENABLED(CONFIG_LOGICAL_CPUS)) |
| 115 | apicid_base = get_apicid_base(1); |
| 116 | else |
| 117 | apicid_base = CONFIG_MAX_PHYSICAL_CPUS; |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 118 | apicid_mcp55 = apicid_base + 0; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 119 | |
| 120 | } |