blob: 0b8a91b35276a3bf439af947e01666b47406edfb [file] [log] [blame]
Kerry She7b7b2c92011-09-08 21:16:19 +08001/*
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
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Kerry She7b7b2c92011-09-08 21:16:19 +080014 */
15
16#include <console/console.h>
17#include <arch/smp/mpspec.h>
18#include <device/pci.h>
19#include <arch/io.h>
20#include <string.h>
21#include <stdint.h>
22#include <SBPLATFORM.h>
23#include <cpu/amd/amdfam10_sysconf.h>
24
25extern int bus_isa;
26extern u8 bus_rs780[11];
Kyösti Mälkki9c7d73c2013-09-09 09:23:19 +030027extern u8 bus_sb800[6];
Kerry She7b7b2c92011-09-08 21:16:19 +080028extern u32 apicid_sb800;
Kerry She7b7b2c92011-09-08 21:16:19 +080029extern u32 sbdn_rs780;
30extern u32 sbdn_sb800;
31
32u8 intr_data[] = {
33 [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, /* INTA# - INTH# */
34 [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F, /* Misc-nil,0,1,2, INT from Serial irq */
35 [0x10] = 0x1F,0x1F,0x1F,0x10,0x1F,0x12,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
36 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
37 0x12,0x11,0x12,0x11,0x12,0x11,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
38 0x11,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
39 0x10,0x11,0x12,0x13
40};
41
42static void *smp_write_config_table(void *v)
43{
44 struct mp_config_table *mc;
45 u32 dword;
46 u8 byte;
47
48 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
49
Patrick Georgic8feedd2012-02-16 18:43:25 +010050 mptable_init(mc, LOCAL_APIC_ADDR);
Kerry She7b7b2c92011-09-08 21:16:19 +080051
52 smp_write_processors(mc);
53
54 get_bus_conf();
55
56 mptable_write_buses(mc, NULL, &bus_isa);
57
58 /* I/O APICs: APIC ID Version State Address */
59 ReadPMIO(SB_PMIOA_REG34, AccWidthUint32, &dword);
60 dword &= 0xFFFFFFF0;
61
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080062 smp_write_ioapic(mc, apicid_sb800, 0x11,(void *) dword);
Kerry She7b7b2c92011-09-08 21:16:19 +080063
64 for (byte = 0x0; byte < sizeof(intr_data); byte ++) {
65 outb(byte | 0x80, 0xC00);
66 outb(intr_data[byte], 0xC01);
67 }
68
69 /* I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
70#define IO_LOCAL_INT(type, intr, apicid, pin) \
71 smp_write_intsrc(mc, (type), MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, bus_isa, (intr), (apicid), (pin));
72
73 mptable_add_isa_interrupts(mc, bus_isa, apicid_sb800, 0);
74
Kerry She7b7b2c92011-09-08 21:16:19 +080075
76 /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
77 IO_LOCAL_INT(mp_ExtINT, 0x0, MP_APIC_ALL, 0x0);
78 IO_LOCAL_INT(mp_NMI, 0x0, MP_APIC_ALL, 0x1);
79 /* There is no extension information... */
80
81 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +020082 return mptable_finalize(mc);
Kerry She7b7b2c92011-09-08 21:16:19 +080083}
84
85unsigned long write_smp_table(unsigned long addr)
86{
87 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +020088 v = smp_write_floating_table(addr, 0);
Kerry She7b7b2c92011-09-08 21:16:19 +080089 return (unsigned long)smp_write_config_table(v);
90}