Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 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 |
Paul Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +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> |
| 26 | #include <cpu/amd/amdfam14.h> |
Paul Menzel | 2120460 | 2013-03-29 13:23:31 +0100 | [diff] [blame] | 27 | #include "agesawrapper.h" |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 28 | #if CONFIG_AMD_SB_CIMX |
Paul Menzel | 6974396 | 2013-04-19 10:05:57 +0200 | [diff] [blame] | 29 | #include <sb_cimx.h> |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 30 | #endif |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 31 | |
| 32 | |
| 33 | /* Global variables for MB layouts and these will be shared by irqtable mptable |
| 34 | * and acpi_tables busnum is default. |
| 35 | */ |
| 36 | u8 bus_isa; |
Kyösti Mälkki | 9c7d73c | 2013-09-09 09:23:19 +0300 | [diff] [blame] | 37 | u8 bus_sb800[6]; |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 38 | u32 apicid_sb800; |
| 39 | |
| 40 | /* |
| 41 | * Here you only need to set value in pci1234 for HT-IO that could be installed or not |
| 42 | * You may need to preset pci1234 for HTIO board, |
| 43 | * please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail |
| 44 | */ |
| 45 | u32 pci1234x[] = { |
| 46 | 0x0000ff0, |
| 47 | }; |
| 48 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 49 | u32 bus_type[256]; |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 50 | u32 sbdn_sb800; |
| 51 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 52 | static u32 get_bus_conf_done = 0; |
| 53 | |
| 54 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 55 | void get_bus_conf(void) |
| 56 | { |
| 57 | u32 apicid_base; |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 58 | |
| 59 | device_t dev; |
| 60 | int i, j; |
| 61 | |
| 62 | if (get_bus_conf_done == 1) |
| 63 | return; /* do it only once */ |
| 64 | |
| 65 | get_bus_conf_done = 1; |
| 66 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 67 | sbdn_sb800 = 0; |
| 68 | |
Kyösti Mälkki | 9c7d73c | 2013-09-09 09:23:19 +0300 | [diff] [blame] | 69 | memset(bus_sb800, 0, sizeof(bus_sb800)); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 70 | |
| 71 | for (i = 0; i < 256; i++) { |
| 72 | bus_type[i] = 0; /* default ISA bus. */ |
| 73 | } |
| 74 | |
| 75 | |
| 76 | bus_type[0] = 1; /* pci */ |
| 77 | |
| 78 | // bus_sb800[0] = (sysconf.pci1234[0] >> 16) & 0xff; |
| 79 | bus_sb800[0] = (pci1234x[0] >> 16) & 0xff; |
| 80 | |
| 81 | /* sb800 */ |
| 82 | dev = dev_find_slot(bus_sb800[0], PCI_DEVFN(sbdn_sb800 + 0x14, 4)); |
| 83 | |
| 84 | |
| 85 | |
| 86 | if (dev) { |
| 87 | bus_sb800[1] = pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 88 | |
| 89 | bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS); |
| 90 | bus_isa++; |
| 91 | for (j = bus_sb800[1]; j < bus_isa; j++) |
| 92 | bus_type[j] = 1; |
| 93 | } |
| 94 | |
| 95 | for (i = 0; i < 4; i++) { |
| 96 | dev = dev_find_slot(bus_sb800[0], PCI_DEVFN(sbdn_sb800 + 0x14, i)); |
| 97 | if (dev) { |
| 98 | bus_sb800[2 + i] = pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 99 | bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS); |
| 100 | bus_isa++; |
| 101 | } |
| 102 | } |
| 103 | for (j = bus_sb800[2]; j < bus_isa; j++) |
| 104 | bus_type[j] = 1; |
| 105 | |
| 106 | |
| 107 | /* I/O APICs: APIC ID Version State Address */ |
| 108 | bus_isa = 10; |
Marshall Buschman | 6d5ee2d | 2011-06-04 15:43:15 +0000 | [diff] [blame] | 109 | apicid_base = CONFIG_MAX_CPUS; |
Peter Stuge | d1760c8 | 2011-06-04 15:48:14 +0000 | [diff] [blame] | 110 | apicid_sb800 = apicid_base; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 111 | |
| 112 | #if CONFIG_AMD_SB_CIMX |
| 113 | sb_Late_Post(); |
| 114 | #endif |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 115 | } |