blob: e6cb28bb71fbb81ac092f5c0b78ee294db7547ed [file] [log] [blame]
Yinghai Luf55b58d2007-02-17 14:28:11 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Yinghai Luf55b58d2007-02-17 14:28:11 +00003 *
4 * Copyright (C) 2007 AMD
5 * Written by Yinghai Lu <yinghailu@amd.com> for AMD.
Harald Gutmannda833612009-06-18 10:05:41 +00006 * Copyright (C) 2009 Harald Gutmann <harald.gutmann@gmx.net>
Yinghai Luf55b58d2007-02-17 14:28:11 +00007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
Yinghai Luf55b58d2007-02-17 14:28:11 +000017 */
18
19#include <console/console.h>
20#include <arch/smp/mpspec.h>
21#include <device/pci.h>
22#include <string.h>
23#include <stdint.h>
Yinghai Luf55b58d2007-02-17 14:28:11 +000024#include <cpu/amd/amdk8_sysconf.h>
Uwe Hermann55dc2232010-10-25 15:32:07 +000025
Yinghai Luf55b58d2007-02-17 14:28:11 +000026extern unsigned char bus_mcp55[8]; //1
27
28extern unsigned apicid_mcp55;
29
Myles Watson08e0fb82010-03-22 16:33:25 +000030static void *smp_write_config_table(void *v)
Yinghai Luf55b58d2007-02-17 14:28:11 +000031{
Yinghai Luf55b58d2007-02-17 14:28:11 +000032 struct mp_config_table *mc;
33 unsigned sbdn;
Patrick Georgi5244e1b2010-11-21 14:41:07 +000034 int i, j, k, bus_isa;
Yinghai Luf55b58d2007-02-17 14:28:11 +000035
36 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Yinghai Luf55b58d2007-02-17 14:28:11 +000037
Patrick Georgic8feedd2012-02-16 18:43:25 +010038 mptable_init(mc, LOCAL_APIC_ADDR);
Yinghai Luf55b58d2007-02-17 14:28:11 +000039
40 smp_write_processors(mc);
41
42 get_bus_conf();
43 sbdn = sysconf.sbdn;
44
Patrick Georgi5244e1b2010-11-21 14:41:07 +000045 mptable_write_buses(mc, NULL, &bus_isa);
Yinghai Luf55b58d2007-02-17 14:28:11 +000046
47/*I/O APICs: APIC ID Version State Address*/
48 {
49 device_t dev;
50 struct resource *res;
Yinghai Luf55b58d2007-02-17 14:28:11 +000051
52 dev = dev_find_slot(bus_mcp55[0], PCI_DEVFN(sbdn+ 0x1,0));
53 if (dev) {
54 res = find_resource(dev, PCI_BASE_ADDRESS_1);
55 if (res) {
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080056 smp_write_ioapic(mc, apicid_mcp55, 0x11,
57 res2mmio(res, 0, 0));
Yinghai Luf55b58d2007-02-17 14:28:11 +000058 }
Harald Gutmannda833612009-06-18 10:05:41 +000059 /* set up the interrupt registers of mcp55 */
60 pci_write_config32(dev, 0x7c, 0xc643c643);
61 pci_write_config32(dev, 0x80, 0x8da01009);
62 pci_write_config32(dev, 0x84, 0x200018d2);
Yinghai Luf55b58d2007-02-17 14:28:11 +000063 }
64 }
Harald Gutmannda833612009-06-18 10:05:41 +000065
Patrick Georgic5b87c82010-05-20 15:28:19 +000066 mptable_add_isa_interrupts(mc, bus_isa, apicid_mcp55, 0);
Yinghai Luf55b58d2007-02-17 14:28:11 +000067
Torsten Duwef4c57a92008-01-07 11:13:16 +000068/* PCI interrupts are level triggered, and are
69 * associated with a specific bus/device/function tuple.
70 */
71#define PCI_INT(bus, dev, fn, pin) \
72 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,\
73 bus_mcp55[bus], (((dev)<<2)|(fn)), apicid_mcp55, (pin))
Yinghai Luf55b58d2007-02-17 14:28:11 +000074
Stefan Reinauer14e22772010-04-27 06:56:47 +000075 PCI_INT(0,sbdn+1,1, 10); /* SMBus */
Harald Gutmannda833612009-06-18 10:05:41 +000076 PCI_INT(0,sbdn+2,0, 22); /* USB */
77 PCI_INT(0,sbdn+2,1, 23); /* USB */
78 PCI_INT(0,sbdn+4,0, 21); /* IDE */
79 PCI_INT(0,sbdn+5,0, 20); /* SATA */
80 PCI_INT(0,sbdn+5,1, 21); /* SATA */
81 PCI_INT(0,sbdn+5,2, 22); /* SATA */
82 PCI_INT(0,sbdn+6,1, 23); /* HD Audio */
83 PCI_INT(0,sbdn+8,0, 20); /* GBit Ethernet */
Yinghai Luf55b58d2007-02-17 14:28:11 +000084
Torsten Duwef4c57a92008-01-07 11:13:16 +000085 /* The PCIe slots, each on its own bus */
Harald Gutmannda833612009-06-18 10:05:41 +000086 k = 1;
87 for(i=0; i<4; i++){
88 for(j=7; j>1; j--){
89 if(k>3) k=0;
90 PCI_INT(j,0,i, 16+k);
91 k++;
92 }
93 k--;
94 }
Yinghai Luf55b58d2007-02-17 14:28:11 +000095
Harald Gutmannda833612009-06-18 10:05:41 +000096 /* On bus 1: the PCI bus slots...
Patrick Georgi5244e1b2010-11-21 14:41:07 +000097 physical PCI slots are j = 7,8
Stefan Reinauer14e22772010-04-27 06:56:47 +000098 FireWire is j = 10
Harald Gutmannda833612009-06-18 10:05:41 +000099 */
100 k=2;
101 for(i=0; i<4; i++){
102 for(j=6; j<11; j++){
103 if(k>3) k=0;
104 PCI_INT(1,j,i, 16+k);
105 k++;
106 }
107 }
Torsten Duwef4c57a92008-01-07 11:13:16 +0000108
Yinghai Luf55b58d2007-02-17 14:28:11 +0000109/*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/
Patrick Georgi6eb7a532011-10-07 21:42:52 +0200110 mptable_lintsrc(mc, bus_isa);
Yinghai Luf55b58d2007-02-17 14:28:11 +0000111 /* There is no extension information... */
112
113 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +0200114 return mptable_finalize(mc);
Yinghai Luf55b58d2007-02-17 14:28:11 +0000115}
116
117unsigned long write_smp_table(unsigned long addr)
118{
119 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +0200120 v = smp_write_floating_table(addr, 0);
Yinghai Luf55b58d2007-02-17 14:28:11 +0000121 return (unsigned long)smp_write_config_table(v);
122}