Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +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. |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include <console/console.h> |
| 22 | #include <arch/smp/mpspec.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <string.h> |
| 25 | #include <stdint.h> |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 26 | #include <cpu/amd/amdk8_sysconf.h> |
| 27 | |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 28 | extern unsigned char bus_ck804[6]; |
| 29 | extern unsigned apicid_ck804; |
| 30 | |
Myles Watson | 08e0fb8 | 2010-03-22 16:33:25 +0000 | [diff] [blame] | 31 | static void *smp_write_config_table(void *v) |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 32 | { |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 33 | struct mp_config_table *mc; |
Jonathan Kollasch | d208c1a | 2010-10-19 13:11:56 +0000 | [diff] [blame] | 34 | int bus_isa; |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 35 | unsigned sbdn; |
| 36 | |
Jonathan Kollasch | d208c1a | 2010-10-19 13:11:56 +0000 | [diff] [blame] | 37 | get_bus_conf(); |
| 38 | sbdn = sysconf.sbdn; |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 39 | |
| 40 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 41 | |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 42 | mptable_init(mc, LOCAL_APIC_ADDR); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 43 | |
| 44 | smp_write_processors(mc); |
Jonathan Kollasch | d208c1a | 2010-10-19 13:11:56 +0000 | [diff] [blame] | 45 | mptable_write_buses(mc, NULL, &bus_isa); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 46 | |
| 47 | /* I/O APICs: APIC ID Version State Address*/ |
| 48 | { |
| 49 | device_t dev; |
| 50 | struct resource *res; |
Jonathan A. Kollasch | c2ffc67 | 2011-08-01 14:15:28 -0500 | [diff] [blame] | 51 | u32 dword; |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 52 | |
| 53 | dev = dev_find_slot(bus_ck804[0], PCI_DEVFN(sbdn + 0x1, 0)); |
| 54 | if (dev) { |
| 55 | res = find_resource(dev, PCI_BASE_ADDRESS_1); |
| 56 | if (res) { |
| 57 | smp_write_ioapic(mc, apicid_ck804, 0x11, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 58 | res2mmio(res, 0, 0)); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | /* Initialize interrupt mapping */ |
| 62 | |
| 63 | /* copied from stock bios */ |
| 64 | /*0x01800500,0x1800d509,0x00520d08*/ |
| 65 | |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 66 | dword = 0x08d0d218; |
| 67 | pci_write_config32(dev, 0x7c, dword); |
| 68 | |
| 69 | dword = 0x8d001509; |
| 70 | pci_write_config32(dev, 0x80, dword); |
| 71 | |
| 72 | dword = 0x00010271; |
| 73 | pci_write_config32(dev, 0x84, dword); |
| 74 | |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /* Now, assemble the table. */ |
Patrick Georgi | c5b87c8 | 2010-05-20 15:28:19 +0000 | [diff] [blame] | 79 | mptable_add_isa_interrupts(mc, bus_isa, apicid_ck804, 0); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 80 | |
| 81 | #define PCI_INT(bus, dev, fn, pin) \ |
| 82 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, \ |
| 83 | bus_ck804[bus], (((dev)<<2)|(fn)), apicid_ck804, (pin)) |
| 84 | |
| 85 | #if 0 |
| 86 | // Onboard ck804 smbus |
| 87 | PCI_INT(0, sbdn+1, 1, 10); /* (this seems odd, how to test?) */ |
| 88 | |
| 89 | #endif |
| 90 | // Onboard ck804 USB |
| 91 | PCI_INT(0, sbdn+2, 0, 23); |
| 92 | PCI_INT(0, sbdn+2, 1, 23); |
| 93 | |
| 94 | // Onboard ck804 AC-97 |
| 95 | PCI_INT(0, sbdn+4, 0, 23); |
| 96 | |
| 97 | // Onboard ck804 SATA 0 |
| 98 | PCI_INT(0, sbdn+7, 0, 20); |
| 99 | |
| 100 | // Onboard ck804 SATA 1 |
| 101 | PCI_INT(0, sbdn+8, 0, 21); |
| 102 | |
| 103 | // Onboard ck804 NIC |
| 104 | PCI_INT(0, sbdn+10, 0, 22); |
| 105 | |
| 106 | |
Jonathan A. Kollasch | 4f91417 | 2008-05-06 13:26:32 +0000 | [diff] [blame] | 107 | /* "AGR" slot */ |
| 108 | PCI_INT(1, 0, 0, 16); |
| 109 | PCI_INT(1, 0, 1, 17); |
| 110 | |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 111 | /* legacy PCI */ |
| 112 | PCI_INT(1, 7, 0, 17); |
| 113 | PCI_INT(1, 7, 1, 18); |
| 114 | PCI_INT(1, 7, 2, 19); |
| 115 | PCI_INT(1, 7, 3, 16); |
| 116 | |
| 117 | PCI_INT(1, 8, 0, 18); |
| 118 | PCI_INT(1, 8, 1, 19); |
| 119 | PCI_INT(1, 8, 2, 16); |
| 120 | PCI_INT(1, 8, 3, 17); |
| 121 | |
| 122 | PCI_INT(1, 9, 0, 19); |
| 123 | PCI_INT(1, 9, 1, 16); |
| 124 | PCI_INT(1, 9, 2, 17); |
| 125 | PCI_INT(1, 9, 3, 18); |
| 126 | |
| 127 | |
| 128 | /* PCI-E x1 port */ |
| 129 | PCI_INT(2, 0, 0, 19); |
| 130 | /* XXX guesses */ |
| 131 | PCI_INT(2, 0, 1, 16); |
Jonathan A. Kollasch | 4f91417 | 2008-05-06 13:26:32 +0000 | [diff] [blame] | 132 | PCI_INT(2, 0, 2, 17); |
| 133 | PCI_INT(2, 0, 3, 18); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 134 | |
| 135 | /* PCI-E x16 port */ /* XXX fix me ? */ |
| 136 | PCI_INT(3, 0, 0, 18); |
| 137 | /* XXX guesses */ |
| 138 | PCI_INT(3, 0, 1, 19); |
| 139 | PCI_INT(3, 0, 2, 16); |
| 140 | PCI_INT(3, 0, 3, 17); |
| 141 | |
| 142 | /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/ |
Patrick Georgi | 6eb7a53 | 2011-10-07 21:42:52 +0200 | [diff] [blame] | 143 | mptable_lintsrc(mc, bus_ck804[0]); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 144 | |
| 145 | /* There is no extension information... */ |
| 146 | |
| 147 | /* Compute the checksums */ |
Patrick Georgi | b0a9c5c | 2011-10-07 23:01:55 +0200 | [diff] [blame] | 148 | return mptable_finalize(mc); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | unsigned long write_smp_table(unsigned long addr) |
| 152 | { |
| 153 | void *v; |
Patrick Georgi | c75c79b | 2011-10-07 22:41:07 +0200 | [diff] [blame] | 154 | v = smp_write_floating_table(addr, 0); |
Jonathan A. Kollasch | 8eff1e3 | 2008-02-20 15:59:30 +0000 | [diff] [blame] | 155 | return (unsigned long)smp_write_config_table(v); |
| 156 | } |