blob: cbad73536ccec4dcbf02b20ffe0cf45dd8eaa53a [file] [log] [blame]
Bingxun Shifb1fddb2007-02-09 00:26:10 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Bingxun Shifb1fddb2007-02-09 00:26:10 +00003 *
4 * Copyright (C) 2006 AMD
5 * Written by Yinghai Lu <yinghailu@amd.com> for AMD.
6 *
7 * Copyright (C) 2006 MSI
8 * Written by Bingxun Shi <bingxunshi@gmail.com> for MSI.
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.
Bingxun Shifb1fddb2007-02-09 00:26:10 +000019 */
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>
Bingxun Shifb1fddb2007-02-09 00:26:10 +000026#include <cpu/amd/amdk8_sysconf.h>
Bingxun Shifb1fddb2007-02-09 00:26:10 +000027#include "mb_sysconf.h"
28
Myles Watson08e0fb82010-03-22 16:33:25 +000029static void *smp_write_config_table(void *v)
Bingxun Shifb1fddb2007-02-09 00:26:10 +000030{
Elyes HAOUASd36905c2014-07-23 09:23:29 +020031 struct mp_config_table *mc;
Stefan Reinauerf8b19232010-04-07 00:38:09 +000032 struct mb_sysconf_t *m;
33 unsigned sbdn;
Bingxun Shifb1fddb2007-02-09 00:26:10 +000034
Patrick Georgi5244e1b2010-11-21 14:41:07 +000035 int i, j, bus_isa;
Bingxun Shifb1fddb2007-02-09 00:26:10 +000036
Elyes HAOUASd36905c2014-07-23 09:23:29 +020037 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Bingxun Shifb1fddb2007-02-09 00:26:10 +000038
Patrick Georgic8feedd2012-02-16 18:43:25 +010039 mptable_init(mc, LOCAL_APIC_ADDR);
Bingxun Shifb1fddb2007-02-09 00:26:10 +000040
Elyes HAOUASd36905c2014-07-23 09:23:29 +020041 smp_write_processors(mc);
Bingxun Shifb1fddb2007-02-09 00:26:10 +000042
Patrick Georgi5244e1b2010-11-21 14:41:07 +000043 get_bus_conf();
44 sbdn = sysconf.sbdn;
45 m = sysconf.mb;
Bingxun Shifb1fddb2007-02-09 00:26:10 +000046
Patrick Georgi5244e1b2010-11-21 14:41:07 +000047 mptable_write_buses(mc, NULL, &bus_isa);
Bingxun Shifb1fddb2007-02-09 00:26:10 +000048
Elyes HAOUASd36905c2014-07-23 09:23:29 +020049/*I/O APICs: APIC ID Version State Address*/
50 {
51 device_t dev;
52 struct resource *res;
53 uint32_t dword;
Bingxun Shifb1fddb2007-02-09 00:26:10 +000054
Elyes HAOUASd36905c2014-07-23 09:23:29 +020055 dev = dev_find_slot(m->bus_mcp55[0], PCI_DEVFN(sbdn+ 0x1,0));
56 if (dev) {
57 res = find_resource(dev, PCI_BASE_ADDRESS_1);
58 if (res) {
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080059 smp_write_ioapic(mc, m->apicid_mcp55, 0x11,
60 res2mmio(res, 0, 0));
Elyes HAOUASd36905c2014-07-23 09:23:29 +020061 }
Bingxun Shifb1fddb2007-02-09 00:26:10 +000062
Elyes HAOUASd36905c2014-07-23 09:23:29 +020063 dword = 0x43c6c643;
64 pci_write_config32(dev, 0x7c, dword);
Bingxun Shifb1fddb2007-02-09 00:26:10 +000065
Elyes HAOUASd36905c2014-07-23 09:23:29 +020066 dword = 0x81001a00;
67 pci_write_config32(dev, 0x80, dword);
Bingxun Shifb1fddb2007-02-09 00:26:10 +000068
Elyes HAOUASd36905c2014-07-23 09:23:29 +020069 dword = 0xd00002d2;
70 pci_write_config32(dev, 0x84, dword);
Bingxun Shifb1fddb2007-02-09 00:26:10 +000071
Elyes HAOUASd36905c2014-07-23 09:23:29 +020072 }
Bingxun Shifb1fddb2007-02-09 00:26:10 +000073
74
Elyes HAOUASd36905c2014-07-23 09:23:29 +020075 }
Bingxun Shifb1fddb2007-02-09 00:26:10 +000076
Patrick Georgi5244e1b2010-11-21 14:41:07 +000077 mptable_add_isa_interrupts(mc, bus_isa, m->apicid_mcp55, 0);
Bingxun Shifb1fddb2007-02-09 00:26:10 +000078
79//SMBUS
Elyes HAOUASd36905c2014-07-23 09:23:29 +020080 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);
Bingxun Shifb1fddb2007-02-09 00:26:10 +000081
82//USB1.1
Elyes HAOUASd36905c2014-07-23 09:23:29 +020083 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
Bingxun Shifb1fddb2007-02-09 00:26:10 +000084
85//USB2.0
Elyes HAOUASd36905c2014-07-23 09:23:29 +020086 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
Bingxun Shifb1fddb2007-02-09 00:26:10 +000087
88//SATA1
Elyes HAOUASd36905c2014-07-23 09:23:29 +020089 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
Bingxun Shifb1fddb2007-02-09 00:26:10 +000090
91//SATA2
Elyes HAOUASd36905c2014-07-23 09:23:29 +020092 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
Bingxun Shifb1fddb2007-02-09 00:26:10 +000093
94//SATA3
Elyes HAOUASd36905c2014-07-23 09:23:29 +020095 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
Bingxun Shifb1fddb2007-02-09 00:26:10 +000096
97//NIC1
Elyes HAOUASd36905c2014-07-23 09:23:29 +020098 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
Bingxun Shifb1fddb2007-02-09 00:26:10 +000099//NIC2
Elyes HAOUASd36905c2014-07-23 09:23:29 +0200100 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
Bingxun Shifb1fddb2007-02-09 00:26:10 +0000101
Elyes HAOUASd36905c2014-07-23 09:23:29 +0200102 for(j=7; j>=2; j--) {
103 if(!m->bus_mcp55[j]) continue;
104 for(i=0;i<4;i++) {
105 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);
106 }
107 }
Bingxun Shifb1fddb2007-02-09 00:26:10 +0000108
Elyes HAOUASd36905c2014-07-23 09:23:29 +0200109 for(j=0; j<1; j++)
110 for(i=0;i<4;i++) {
111 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);
112 }
Bingxun Shifb1fddb2007-02-09 00:26:10 +0000113
114/*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/
Elyes HAOUASd36905c2014-07-23 09:23:29 +0200115 mptable_lintsrc(mc, bus_isa);
116 /* There is no extension information... */
Bingxun Shifb1fddb2007-02-09 00:26:10 +0000117
Elyes HAOUASd36905c2014-07-23 09:23:29 +0200118 /* Compute the checksums */
119 return mptable_finalize(mc);
Bingxun Shifb1fddb2007-02-09 00:26:10 +0000120}
121
122unsigned long write_smp_table(unsigned long addr)
123{
Elyes HAOUASd36905c2014-07-23 09:23:29 +0200124 void *v;
125 v = smp_write_floating_table(addr, 0);
126 return (unsigned long)smp_write_config_table(v);
Bingxun Shifb1fddb2007-02-09 00:26:10 +0000127}