Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007 AMD |
| 5 | * (Written by Yinghai Lu <yinghailu@amd.com> for AMD) |
| 6 | * Copyright (C) 2007 Philipp Degler <pdegler@rumms.uni-mannheim.de> |
| 7 | * (Thanks to LSRA University of Mannheim for their support) |
| 8 | * Copyright (C) 2008 Jonathan A. Kollasch <jakllsch@kollasch.net> |
| 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. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 | */ |
| 24 | |
| 25 | #include <console/console.h> |
| 26 | #include <arch/smp/mpspec.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame^] | 27 | #include <arch/ioapic.h> |
Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 28 | #include <device/pci.h> |
| 29 | #include <string.h> |
| 30 | #include <stdint.h> |
Uwe Hermann | 5df4168 | 2010-09-25 16:17:20 +0000 | [diff] [blame] | 31 | #include "southbridge/via/vt8237r/vt8237r.h" |
Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 32 | |
Myles Watson | 08e0fb8 | 2010-03-22 16:33:25 +0000 | [diff] [blame] | 33 | static void *smp_write_config_table(void *v) |
Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 34 | { |
| 35 | static const char sig[4] = "PCMP"; |
Stefan Reinauer | d653211 | 2010-04-16 00:31:44 +0000 | [diff] [blame] | 36 | static const char oem[8] = "COREBOOT"; |
Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 37 | static const char productid[12] = "PC2500 "; |
| 38 | struct mp_config_table *mc; |
| 39 | |
Patrick Georgi | 2097958 | 2010-09-24 18:42:56 +0000 | [diff] [blame] | 40 | int isa_bus; |
Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 41 | |
| 42 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
| 43 | memset(mc, 0, sizeof(*mc)); |
| 44 | |
| 45 | memcpy(mc->mpc_signature, sig, sizeof(sig)); |
| 46 | mc->mpc_length = sizeof(*mc); /* initially just the header */ |
| 47 | mc->mpc_spec = 0x04; |
| 48 | mc->mpc_checksum = 0; /* not yet computed */ |
| 49 | memcpy(mc->mpc_oem, oem, sizeof(oem)); |
| 50 | memcpy(mc->mpc_productid, productid, sizeof(productid)); |
| 51 | mc->mpc_oemptr = 0; |
| 52 | mc->mpc_oemsize = 0; |
| 53 | mc->mpc_entry_count = 0; /* No entries yet... */ |
| 54 | mc->mpc_lapic = LAPIC_ADDR; |
| 55 | mc->mpe_length = 0; |
| 56 | mc->mpe_checksum = 0; |
| 57 | mc->reserved = 0; |
| 58 | |
| 59 | smp_write_processors(mc); |
Patrick Georgi | 2097958 | 2010-09-24 18:42:56 +0000 | [diff] [blame] | 60 | mptable_write_buses(mc, NULL, &isa_bus); |
Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 61 | |
| 62 | /* I/O APICs: APIC ID Version State Address*/ |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame^] | 63 | smp_write_ioapic(mc, VT8237R_APIC_ID, 0x20, IO_APIC_ADDR); |
Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 64 | |
| 65 | /* Now, assemble the table. */ |
Patrick Georgi | 2097958 | 2010-09-24 18:42:56 +0000 | [diff] [blame] | 66 | mptable_add_isa_interrupts(mc, isa_bus, VT8237R_APIC_ID, 0); |
Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 67 | |
| 68 | #define PCI_INT(bus, dev, fn, pin) \ |
| 69 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, \ |
| 70 | bus, (((dev)<<2)|(fn)), VT8237R_APIC_ID, (pin)) |
| 71 | |
| 72 | // PCI slot 1 |
| 73 | PCI_INT(0, 8, 0, 16); |
| 74 | PCI_INT(0, 8, 1, 17); |
| 75 | PCI_INT(0, 8, 2, 18); |
| 76 | PCI_INT(0, 8, 3, 19); |
| 77 | |
| 78 | // PCI slot 2 |
| 79 | PCI_INT(0, 9, 0, 17); |
| 80 | PCI_INT(0, 9, 1, 18); |
| 81 | PCI_INT(0, 9, 2, 19); |
| 82 | PCI_INT(0, 9, 3, 16); |
| 83 | |
| 84 | // SATA |
| 85 | PCI_INT(0, 15, 1, 20); |
| 86 | |
| 87 | // USB |
| 88 | PCI_INT(0, 16, 0, 21); |
| 89 | PCI_INT(0, 16, 1, 21); |
| 90 | PCI_INT(0, 16, 2, 21); |
| 91 | PCI_INT(0, 16, 3, 21); |
| 92 | |
| 93 | // Audio |
| 94 | PCI_INT(0, 17, 2, 22); |
| 95 | |
| 96 | // Ethernet |
| 97 | PCI_INT(0, 18, 0, 23); |
| 98 | |
| 99 | /* Onboard VGA */ |
| 100 | PCI_INT(1, 0, 0, 16); |
| 101 | |
| 102 | /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/ |
| 103 | smp_write_lintsrc(mc, mp_ExtINT, |
| 104 | MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, |
| 105 | 0, 0x0, MP_APIC_ALL, 0x0); |
| 106 | smp_write_lintsrc(mc, mp_NMI, |
| 107 | MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, |
| 108 | 0, 0x0, MP_APIC_ALL, 0x1); |
| 109 | |
| 110 | /* There is no extension information... */ |
| 111 | |
| 112 | /* Compute the checksums */ |
| 113 | mc->mpe_checksum = |
| 114 | smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); |
| 115 | mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 116 | printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", |
Jonathan A. Kollasch | 48994e1 | 2008-12-20 04:08:40 +0000 | [diff] [blame] | 117 | mc, smp_next_mpe_entry(mc)); |
| 118 | return smp_next_mpe_entry(mc); |
| 119 | } |
| 120 | |
| 121 | unsigned long write_smp_table(unsigned long addr) |
| 122 | { |
| 123 | void *v; |
| 124 | v = smp_write_floating_table(addr); |
| 125 | return (unsigned long)smp_write_config_table(v); |
| 126 | } |