Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +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 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <console/console.h> |
| 19 | #include <arch/smp/mpspec.h> |
| 20 | #include <device/pci.h> |
| 21 | #include <string.h> |
| 22 | #include <stdint.h> |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 23 | #include <cpu/amd/amdfam10_sysconf.h> |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 24 | #include "mb_sysconf.h" |
| 25 | |
Myles Watson | 08e0fb8 | 2010-03-22 16:33:25 +0000 | [diff] [blame] | 26 | static void *smp_write_config_table(void *v) |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 27 | { |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 28 | struct mp_config_table *mc; |
| 29 | struct mb_sysconf_t *m; |
| 30 | unsigned sbdn; |
Patrick Georgi | 7411eab | 2010-11-22 14:14:56 +0000 | [diff] [blame] | 31 | int i, j, bus_isa; |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 32 | |
| 33 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 34 | |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 35 | mptable_init(mc, LOCAL_APIC_ADDR); |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 36 | |
| 37 | smp_write_processors(mc); |
| 38 | |
| 39 | get_bus_conf(); |
| 40 | sbdn = sysconf.sbdn; |
| 41 | m = sysconf.mb; |
| 42 | |
Patrick Georgi | 7411eab | 2010-11-22 14:14:56 +0000 | [diff] [blame] | 43 | mptable_write_buses(mc, NULL, &bus_isa); |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 44 | |
| 45 | /*I/O APICs: APIC ID Version State Address*/ |
| 46 | { |
| 47 | device_t dev; |
| 48 | struct resource *res; |
| 49 | uint32_t dword; |
| 50 | |
| 51 | dev = dev_find_slot(m->bus_mcp55[0], PCI_DEVFN(sbdn+ 0x1,0)); |
| 52 | if (dev) { |
| 53 | res = find_resource(dev, PCI_BASE_ADDRESS_1); |
| 54 | if (res) { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 55 | smp_write_ioapic(mc, m->apicid_mcp55, 0x11, |
| 56 | res2mmio(res, 0, 0)); |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | dword = 0x43c6c643; |
| 60 | pci_write_config32(dev, 0x7c, dword); |
| 61 | |
| 62 | dword = 0x81001a00; |
| 63 | pci_write_config32(dev, 0x80, dword); |
| 64 | |
| 65 | dword = 0xd00012d2; |
| 66 | pci_write_config32(dev, 0x84, dword); |
| 67 | |
| 68 | } |
| 69 | |
| 70 | |
| 71 | } |
| 72 | |
Patrick Georgi | 7411eab | 2010-11-22 14:14:56 +0000 | [diff] [blame] | 73 | mptable_add_isa_interrupts(mc, bus_isa, m->apicid_mcp55, 0); |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 74 | |
Patrick Georgi | c5b87c8 | 2010-05-20 15:28:19 +0000 | [diff] [blame] | 75 | /*I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */ |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 76 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+1)<<2)|1, m->apicid_mcp55, 0xa); |
| 77 | |
| 78 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+2)<<2)|0, m->apicid_mcp55, 0x16); // 22 |
| 79 | |
| 80 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+2)<<2)|1, m->apicid_mcp55, 0x17); // 23 |
| 81 | |
| 82 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+6)<<2)|1, m->apicid_mcp55, 0x17); // 23 |
| 83 | |
| 84 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+5)<<2)|0, m->apicid_mcp55, 0x14); // 20 |
| 85 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+5)<<2)|1, m->apicid_mcp55, 0x17); // 23 |
| 86 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+5)<<2)|2, m->apicid_mcp55, 0x15); // 21 |
| 87 | |
| 88 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+8)<<2)|0, m->apicid_mcp55, 0x16); // 22 |
| 89 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+9)<<2)|0, m->apicid_mcp55, 0x15); // 21 |
| 90 | |
| 91 | for(j=7; j>=2; j--) { |
| 92 | if(!m->bus_mcp55[j]) continue; |
| 93 | for(i=0;i<4;i++) { |
| 94 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[j], (0x00<<2)|i, m->apicid_mcp55, 0x10 + (2+j+i+4-sbdn%4)%4); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | for(j=0; j<1; j++) |
| 99 | for(i=0;i<4;i++) { |
| 100 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[1], ((0x04+j)<<2)|i, m->apicid_mcp55, 0x10 + (2+i+j)%4); |
| 101 | } |
| 102 | |
| 103 | /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/ |
Patrick Georgi | 6eb7a53 | 2011-10-07 21:42:52 +0200 | [diff] [blame] | 104 | mptable_lintsrc(mc, bus_isa); |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 105 | /* There is no extension information... */ |
| 106 | |
| 107 | /* Compute the checksums */ |
Patrick Georgi | b0a9c5c | 2011-10-07 23:01:55 +0200 | [diff] [blame] | 108 | return mptable_finalize(mc); |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | unsigned long write_smp_table(unsigned long addr) |
| 112 | { |
| 113 | void *v; |
Patrick Georgi | c75c79b | 2011-10-07 22:41:07 +0200 | [diff] [blame] | 114 | v = smp_write_floating_table(addr, 0); |
Ward Vandewege | 2583dd2 | 2009-09-30 14:46:43 +0000 | [diff] [blame] | 115 | return (unsigned long)smp_write_config_table(v); |
| 116 | } |