Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +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 |
Paul Menzel | a8ae1c6 | 2013-02-20 13:21:20 +0100 | [diff] [blame] | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 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 | 7d75fbd | 2013-02-20 13:40:14 +0100 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +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> |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 27 | #include "agesawrapper.h" |
Mike Loptien | cbc783f | 2014-06-06 15:21:28 -0600 | [diff] [blame] | 28 | #include <arch/ioapic.h> |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 29 | #if CONFIG_AMD_SB_CIMX |
| 30 | #include <sb_cimx.h> |
| 31 | #endif |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 32 | |
| 33 | |
| 34 | /* Global variables for MB layouts and these will be shared by irqtable mptable |
| 35 | * and acpi_tables busnum is default. |
| 36 | */ |
| 37 | u8 bus_isa; |
Kyösti Mälkki | 9c7d73c | 2013-09-09 09:23:19 +0300 | [diff] [blame] | 38 | u8 bus_sb800[6]; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 39 | u32 apicid_sb800; |
Mike Loptien | cbc783f | 2014-06-06 15:21:28 -0600 | [diff] [blame] | 40 | u32 apicver_sb800; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 41 | |
| 42 | /* |
| 43 | * Here you only need to set value in pci1234 for HT-IO that could be installed or not |
| 44 | * You may need to preset pci1234 for HTIO board, |
| 45 | * please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail |
| 46 | */ |
| 47 | u32 pci1234x[] = { |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 48 | 0x0000ff0, |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 51 | u32 bus_type[256]; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 52 | u32 sbdn_sb800; |
| 53 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 54 | static u32 get_bus_conf_done = 0; |
| 55 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 56 | void get_bus_conf(void) |
| 57 | { |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 58 | u32 apicid_base; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 59 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 60 | device_t dev; |
| 61 | int i, j; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 62 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 63 | if (get_bus_conf_done == 1) |
| 64 | return; /* do it only once */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 65 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 66 | get_bus_conf_done = 1; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 67 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 68 | sbdn_sb800 = 0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 69 | |
Kyösti Mälkki | 9c7d73c | 2013-09-09 09:23:19 +0300 | [diff] [blame] | 70 | memset(bus_sb800, 0, sizeof(bus_sb800)); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 71 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 72 | for (i = 0; i < 256; i++) { |
| 73 | bus_type[i] = 0; /* default ISA bus. */ |
| 74 | } |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 75 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 76 | bus_type[0] = 1; /* pci */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 77 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 78 | // bus_sb800[0] = (sysconf.pci1234[0] >> 16) & 0xff; |
| 79 | bus_sb800[0] = (pci1234x[0] >> 16) & 0xff; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 80 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 81 | /* sb800 */ |
| 82 | dev = dev_find_slot(bus_sb800[0], PCI_DEVFN(sbdn_sb800 + 0x14, 4)); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 83 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 84 | if (dev) { |
| 85 | bus_sb800[1] = pci_read_config8(dev, PCI_SECONDARY_BUS); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 86 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 87 | bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS); |
| 88 | bus_isa++; |
| 89 | for (j = bus_sb800[1]; j < bus_isa; j++) |
| 90 | bus_type[j] = 1; |
| 91 | } |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 92 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 93 | for (i = 0; i < 4; i++) { |
| 94 | dev = dev_find_slot(bus_sb800[0], PCI_DEVFN(sbdn_sb800 + 0x14, i)); |
| 95 | if (dev) { |
| 96 | bus_sb800[2 + i] = pci_read_config8(dev, PCI_SECONDARY_BUS); |
| 97 | bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS); |
| 98 | bus_isa++; |
| 99 | } |
| 100 | } |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 101 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 102 | for (j = bus_sb800[2]; j < bus_isa; j++) |
| 103 | bus_type[j] = 1; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 104 | |
zbao | f543c7b | 2012-04-13 13:42:46 +0800 | [diff] [blame] | 105 | |
| 106 | /* I/O APICs: APIC ID Version State Address */ |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 107 | bus_isa = 10; |
| 108 | apicid_base = CONFIG_MAX_CPUS; |
Mike Loptien | cbc783f | 2014-06-06 15:21:28 -0600 | [diff] [blame] | 109 | |
| 110 | /* |
| 111 | * By the time this function gets called, the IOAPIC registers |
| 112 | * have been written so they can be read to get the correct |
| 113 | * APIC ID and Version |
| 114 | */ |
| 115 | apicid_sb800 = (io_apic_read(IO_APIC_ADDR, 0x00) >> 24); |
| 116 | apicver_sb800 = (io_apic_read(IO_APIC_ADDR, 0x01) & 0xFF); |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 117 | |
| 118 | #if CONFIG_AMD_SB_CIMX |
| 119 | sb_Late_Post(); |
| 120 | #endif |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 121 | } |