Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 1 | /* |
| 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. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 19 | */ |
| 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 Reinauer | 9a16e3e | 2010-03-29 14:45:36 +0000 | [diff] [blame] | 26 | #include <cpu/amd/multicore.h> |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 27 | |
| 28 | #include <cpu/amd/amdk8_sysconf.h> |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 29 | #include <stdlib.h> |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 30 | |
| 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. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 35 | unsigned char bus_ck804[6]; |
| 36 | unsigned apicid_ck804; |
| 37 | |
| 38 | unsigned 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 | }; |
| 42 | 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 |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 43 | 0x20202020, //ms7135 has only one ht-chain |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 44 | }; |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 45 | |
| 46 | static unsigned get_bus_conf_done = 0; |
| 47 | |
| 48 | void get_bus_conf(void) |
| 49 | { |
| 50 | unsigned apicid_base; |
| 51 | |
| 52 | device_t dev; |
| 53 | unsigned sbdn; |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 54 | int i; |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 55 | |
| 56 | if (get_bus_conf_done == 1) |
| 57 | return; //do it only once |
| 58 | |
| 59 | get_bus_conf_done = 1; |
| 60 | |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 61 | sysconf.hc_possible_num = ARRAY_SIZE(pci1234x); |
| 62 | sysconf.hc_possible_num = ARRAY_SIZE(pci1234x); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 63 | 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. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 77 | bus_ck804[0] = (sysconf.pci1234[0] >> 16) & 0xff; |
| 78 | |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 79 | /* 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 Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 85 | case 3: dn = 14; break; |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 86 | 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. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | |
| 94 | /*I/O APICs: APIC ID Version State Address*/ |
Timothy Pearson | d4bbfe8 | 2015-10-27 16:48:36 -0500 | [diff] [blame] | 95 | if (IS_ENABLED(CONFIG_LOGICAL_CPUS)) |
| 96 | apicid_base = get_apicid_base(3); |
| 97 | else |
| 98 | apicid_base = CONFIG_MAX_PHYSICAL_CPUS; |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 99 | apicid_ck804 = apicid_base + 0; |
| 100 | } |