Oskar Enoksson | adc0a63 | 2014-02-11 22:19:35 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011,2014 Oskar Enoksson <enok@lysator.liu.se> |
| 3 | * Subject to the GNU GPL v2, or (at your option) any later version. |
| 4 | */ |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <device/pci.h> |
| 7 | #include <device/pci_ids.h> |
| 8 | #include <string.h> |
| 9 | #include <stdint.h> |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 10 | #include <cpu/amd/multicore.h> |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 11 | |
| 12 | #include <cpu/amd/amdk8_sysconf.h> |
| 13 | #include <stdlib.h> |
| 14 | |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 15 | #include "mb_sysconf.h" |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 16 | |
| 17 | // Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 18 | struct mb_sysconf_t mb_sysconf; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 19 | |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 20 | static unsigned pci1234x[] = |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 21 | { //Here you only need to set value in pci1234 for HT-IO that could be installed or not |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 22 | //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 23 | 0x0000ff0, |
| 24 | // 0x0000ff0, |
| 25 | // 0x0000ff0, |
| 26 | // 0x0000ff0, |
| 27 | // 0x0000ff0, |
| 28 | // 0x0000ff0, |
| 29 | // 0x0000ff0, |
| 30 | // 0x0000ff0 |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 31 | }; |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 32 | static unsigned hcdnx[] = |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 33 | { //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 |
| 34 | 0x20202020, |
| 35 | // 0x20202020, |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 36 | // 0x20202020, |
| 37 | // 0x20202020, |
| 38 | // 0x20202020, |
| 39 | // 0x20202020, |
| 40 | // 0x20202020, |
| 41 | // 0x20202020, |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 42 | }; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 43 | |
| 44 | |
| 45 | static unsigned get_bus_conf_done = 0; |
| 46 | |
| 47 | void get_bus_conf(void) |
| 48 | { |
| 49 | |
| 50 | unsigned apicid_base; |
| 51 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 52 | device_t dev; |
| 53 | int i; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 54 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 55 | if(get_bus_conf_done==1) return; //do it only once |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 56 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 57 | get_bus_conf_done = 1; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 58 | |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 59 | sysconf.mb = &mb_sysconf; |
| 60 | struct mb_sysconf_t *m = sysconf.mb; |
| 61 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 62 | sysconf.hc_possible_num = ARRAY_SIZE(pci1234x); |
| 63 | for(i=0;i<sysconf.hc_possible_num; i++) { |
| 64 | sysconf.pci1234[i] = pci1234x[i]; |
| 65 | sysconf.hcdn[i] = hcdnx[i]; |
| 66 | } |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 67 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 68 | get_sblk_pci1234(); |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 69 | |
| 70 | sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff; |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 71 | m->sbdn3 = sysconf.hcdn[0] & 0xff; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 72 | |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 73 | m->bus_8131_0 = (sysconf.pci1234[0] >> 16) & 0xff; |
| 74 | m->bus_8111_0 = m->bus_8131_0; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 75 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 76 | /* 8111 */ |
| 77 | dev = dev_find_slot(m->bus_8111_0, PCI_DEVFN(sysconf.sbdn,0)); |
| 78 | if (dev) { |
| 79 | m->bus_8111_1 = pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 80 | } |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 81 | else { |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 82 | printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:03.0, using defaults\n", m->bus_8111_0); |
| 83 | } |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 84 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 85 | /* 8131-1 */ |
| 86 | dev = dev_find_slot(m->bus_8131_0, PCI_DEVFN(m->sbdn3,0)); |
| 87 | if (dev) { |
| 88 | m->bus_8131_1 = pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 89 | } |
| 90 | else { |
| 91 | printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:01.0, using defaults\n", m->bus_8131_0); |
| 92 | } |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 93 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 94 | /* 8131-2 */ |
| 95 | dev = dev_find_slot(m->bus_8131_0, PCI_DEVFN(m->sbdn3+1,0)); |
| 96 | if (dev) { |
| 97 | m->bus_8131_2 = pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 98 | } |
| 99 | else { |
| 100 | printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:02.0, using defaults\n", m->bus_8131_0); |
| 101 | } |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 102 | |
| 103 | |
| 104 | /*I/O APICs: APIC ID Version State Address*/ |
Timothy Pearson | d4bbfe8 | 2015-10-27 16:48:36 -0500 | [diff] [blame] | 105 | if (IS_ENABLED(CONFIG_LOGICAL_CPUS)) |
| 106 | apicid_base = get_apicid_base(3); |
| 107 | else |
| 108 | apicid_base = CONFIG_MAX_PHYSICAL_CPUS; |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 109 | m->apicid_8111 = apicid_base+0; |
| 110 | m->apicid_8131_1 = apicid_base+1; |
| 111 | m->apicid_8131_2 = apicid_base+2; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 112 | } |