Zheng Bao | 910f4ca | 2011-03-28 04:38:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2010 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. |
Zheng Bao | 910f4ca | 2011-03-28 04:38:14 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <console/console.h> |
| 17 | #include <string.h> |
| 18 | #include <arch/acpi.h> |
| 19 | #include <arch/ioapic.h> |
| 20 | #include <device/pci.h> |
| 21 | #include <device/pci_ids.h> |
Zheng Bao | 910f4ca | 2011-03-28 04:38:14 +0000 | [diff] [blame] | 22 | #include <cpu/amd/amdfam10_sysconf.h> |
| 23 | |
| 24 | #include "mb_sysconf.h" |
| 25 | |
Zheng Bao | 910f4ca | 2011-03-28 04:38:14 +0000 | [diff] [blame] | 26 | unsigned long acpi_fill_madt(unsigned long current) |
| 27 | { |
| 28 | device_t dev; |
| 29 | u32 dword; |
Elyes HAOUAS | a5aad2e | 2016-09-19 09:47:16 -0600 | [diff] [blame] | 30 | u32 gsi_base = 0; |
Zheng Bao | 910f4ca | 2011-03-28 04:38:14 +0000 | [diff] [blame] | 31 | /* create all subtables for processors */ |
| 32 | current = acpi_create_madt_lapics(current); |
| 33 | |
| 34 | /* Write SB700 IOAPIC, only one */ |
| 35 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current, 2, |
| 36 | IO_APIC_ADDR, gsi_base); |
| 37 | /* IOAPIC on rs5690 */ |
| 38 | gsi_base += 24; /* SB700 has 24 IOAPIC entries. */ |
| 39 | dev = dev_find_slot(0, PCI_DEVFN(0, 0)); |
| 40 | if (dev) { |
| 41 | pci_write_config32(dev, 0xF8, 0x1); |
| 42 | dword = pci_read_config32(dev, 0xFC) & 0xfffffff0; |
| 43 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current, 2+1, |
| 44 | dword, gsi_base); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 49 | current, 0, 0, 2, 0); |
| 50 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 51 | current, 0, 9, 9, 0xF); |
| 52 | /* 0: mean bus 0--->ISA */ |
| 53 | /* 0: PIC 0 */ |
| 54 | /* 2: APIC 2 */ |
Kyösti Mälkki | d874757 | 2014-06-26 05:30:54 +0300 | [diff] [blame] | 55 | /* 5 mean: 0101 --> Edge-triggered, Active high */ |
Zheng Bao | 910f4ca | 2011-03-28 04:38:14 +0000 | [diff] [blame] | 56 | |
| 57 | /* create all subtables for processors */ |
| 58 | /* current = acpi_create_madt_lapic_nmis(current, 5, 1); */ |
| 59 | /* 1: LINT1 connect to NMI */ |
| 60 | |
| 61 | return current; |
| 62 | } |
Timothy Pearson | 44e4a4e | 2015-08-11 17:49:06 -0500 | [diff] [blame] | 63 | |
| 64 | unsigned long acpi_fill_ivrs_ioapic(acpi_ivrs_t* ivrs, unsigned long current) |
| 65 | { |
| 66 | uint8_t *p; |
| 67 | |
| 68 | uint32_t apicid_sp5100; |
| 69 | uint32_t apicid_sr5650; |
| 70 | |
| 71 | apicid_sp5100 = 0x20; |
| 72 | apicid_sr5650 = apicid_sp5100 + 1; |
| 73 | |
| 74 | /* Describe NB IOAPIC */ |
| 75 | p = (uint8_t *)current; |
| 76 | p[0] = 0x48; /* Entry type */ |
| 77 | p[1] = 0; /* Device */ |
| 78 | p[2] = 0; /* Bus */ |
| 79 | p[3] = 0x0; /* Data */ |
| 80 | p[4] = apicid_sr5650; /* IOAPIC ID */ |
| 81 | p[5] = 0x1; /* Device 0 Function 1 */ |
| 82 | p[6] = 0x0; /* Northbridge bus */ |
| 83 | p[7] = 0x1; /* Variety */ |
| 84 | current += 8; |
| 85 | |
| 86 | /* Describe SB IOAPIC */ |
| 87 | p = (uint8_t *)current; |
| 88 | p[0] = 0x48; /* Entry type */ |
| 89 | p[1] = 0; /* Device */ |
| 90 | p[2] = 0; /* Bus */ |
| 91 | p[3] = 0xd7; /* Data */ |
| 92 | p[4] = apicid_sp5100; /* IOAPIC ID */ |
| 93 | p[5] = 0x14 << 3; /* Device 0x14 Function 0 */ |
| 94 | p[6] = 0x0; /* Southbridge bus */ |
| 95 | p[7] = 0x1; /* Variety */ |
| 96 | current += 8; |
| 97 | |
| 98 | return current; |
| 99 | } |