bxshi | faea4c5 | 2006-11-02 16:02:33 +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. |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2006 AMD |
| 5 | * Written by Yinghai Lu <yinghailu@gmail.com> for AMD. |
| 6 | * |
| 7 | * Copyright (C) 2006 MSI |
| 8 | * Written by bxshi <bingxunshi@gmail.com> for MSI. |
| 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. |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 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> |
Stefan Reinauer | 9a16e3e | 2010-03-29 14:45:36 +0000 | [diff] [blame] | 25 | #include <cpu/amd/multicore.h> |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 26 | |
| 27 | #include <cpu/amd/amdk8_sysconf.h> |
| 28 | |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 29 | #include <stdlib.h> |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 30 | #include "mb_sysconf.h" |
| 31 | |
| 32 | // Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables |
| 33 | struct mb_sysconf_t mb_sysconf; |
| 34 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 35 | static unsigned pci1234x[] = { //Here you only need to set value in pci1234 for HT-IO that could be installed or not |
| 36 | //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail |
| 37 | 0x0000ff0, |
| 38 | 0x0000ff0, |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 39 | // 0x0000ff0, |
| 40 | // 0x0000ff0, |
| 41 | // 0x0000ff0, |
| 42 | // 0x0000ff0, |
| 43 | // 0x0000ff0, |
| 44 | // 0x0000ff0 |
| 45 | }; |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 46 | |
| 47 | static 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 |
| 48 | 0x20202020, |
| 49 | 0x20202020, |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 50 | // 0x20202020, |
| 51 | // 0x20202020, |
| 52 | // 0x20202020, |
| 53 | // 0x20202020, |
| 54 | // 0x20202020, |
| 55 | // 0x20202020, |
| 56 | }; |
| 57 | |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 58 | static unsigned get_bus_conf_done = 0; |
| 59 | |
| 60 | void get_bus_conf(void) |
| 61 | { |
| 62 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 63 | unsigned apicid_base; |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 64 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 65 | device_t dev; |
| 66 | int i; |
| 67 | struct mb_sysconf_t *m; |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 68 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 69 | if (get_bus_conf_done == 1) |
| 70 | return; //do it only once |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 71 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 72 | get_bus_conf_done = 1; |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 73 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 74 | sysconf.mb = &mb_sysconf; |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 75 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 76 | m = sysconf.mb; |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 77 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 78 | sysconf.hc_possible_num = ARRAY_SIZE(pci1234x); |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 79 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 80 | for (i = 0; i < sysconf.hc_possible_num; i++) { |
| 81 | sysconf.pci1234[i] = pci1234x[i]; |
| 82 | sysconf.hcdn[i] = hcdnx[i]; |
| 83 | } |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 84 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 85 | get_sblk_pci1234(); |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 86 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 87 | sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff; |
| 88 | m->sbdn2 = sysconf.hcdn[0] & 0xff; // bcm5780 |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 89 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 90 | m->bus_bcm5785_0 = (sysconf.pci1234[0] >> 16) & 0xff; |
| 91 | m->bus_bcm5780[0] = m->bus_bcm5785_0; |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 92 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 93 | /* bcm5785 */ |
| 94 | dev = dev_find_slot(m->bus_bcm5785_0, PCI_DEVFN(sysconf.sbdn, 0)); |
| 95 | if (dev) { |
| 96 | m->bus_bcm5785_1 = pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 97 | dev = dev_find_slot(m->bus_bcm5785_1, PCI_DEVFN(0xd, 0)); |
| 98 | if (dev) { |
| 99 | m->bus_bcm5785_1_1 = |
| 100 | pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 101 | } |
| 102 | } else { |
| 103 | printk(BIOS_DEBUG, |
| 104 | "ERROR - could not find PCI %02x:%02x.0, using defaults\n", |
| 105 | m->bus_bcm5785_0, sysconf.sbdn); |
| 106 | } |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 107 | |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 108 | /* bcm5780 */ |
| 109 | for (i = 1; i < 7; i++) { |
| 110 | dev = |
| 111 | dev_find_slot(m->bus_bcm5780[0], |
| 112 | PCI_DEVFN(m->sbdn2 + i - 1, 0)); |
| 113 | if (dev) { |
| 114 | m->bus_bcm5780[i] = |
| 115 | pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 116 | } else { |
| 117 | printk(BIOS_DEBUG, |
| 118 | "ERROR - could not find PCI %02x:%02x.0, using defaults\n", |
| 119 | m->bus_bcm5780[0], m->sbdn2 + i - 1); |
| 120 | } |
| 121 | } |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 122 | |
| 123 | /*I/O APICs: APIC ID Version State Address*/ |
Timothy Pearson | d4bbfe8 | 2015-10-27 16:48:36 -0500 | [diff] [blame] | 124 | if (IS_ENABLED(CONFIG_LOGICAL_CPUS)) |
| 125 | apicid_base = get_apicid_base(3); |
| 126 | else |
| 127 | apicid_base = CONFIG_MAX_PHYSICAL_CPUS; |
Paul Menzel | 6a4e9b5 | 2013-10-18 09:42:55 +0200 | [diff] [blame] | 128 | for (i = 0; i < 3; i++) |
| 129 | m->apicid_bcm5785[i] = apicid_base + i; |
bxshi | faea4c5 | 2006-11-02 16:02:33 +0000 | [diff] [blame] | 130 | } |