Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2007 AMD |
| 5 | * Written by Yinghai Lu <yinghailu@amd.com> for AMD. |
Harald Gutmann | da83361 | 2009-06-18 10:05:41 +0000 | [diff] [blame] | 6 | * Copyright (C) 2009 Harald Gutmann <harald.gutmann@gmx.net> |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 7 | * |
| 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 17 | */ |
| 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 24 | #include <cpu/amd/amdk8_sysconf.h> |
Uwe Hermann | 55dc223 | 2010-10-25 15:32:07 +0000 | [diff] [blame] | 25 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 26 | extern unsigned char bus_mcp55[8]; //1 |
| 27 | |
| 28 | extern unsigned apicid_mcp55; |
| 29 | |
Myles Watson | 08e0fb8 | 2010-03-22 16:33:25 +0000 | [diff] [blame] | 30 | static void *smp_write_config_table(void *v) |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 31 | { |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 32 | struct mp_config_table *mc; |
| 33 | unsigned sbdn; |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 34 | int i, j, k, bus_isa; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 35 | |
| 36 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 37 | |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 38 | mptable_init(mc, LOCAL_APIC_ADDR); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 39 | |
| 40 | smp_write_processors(mc); |
| 41 | |
| 42 | get_bus_conf(); |
| 43 | sbdn = sysconf.sbdn; |
| 44 | |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 45 | mptable_write_buses(mc, NULL, &bus_isa); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 46 | |
| 47 | /*I/O APICs: APIC ID Version State Address*/ |
| 48 | { |
| 49 | device_t dev; |
| 50 | struct resource *res; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 51 | |
| 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 Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 56 | smp_write_ioapic(mc, apicid_mcp55, 0x11, |
| 57 | res2mmio(res, 0, 0)); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 58 | } |
Harald Gutmann | da83361 | 2009-06-18 10:05:41 +0000 | [diff] [blame] | 59 | /* 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 63 | } |
| 64 | } |
Harald Gutmann | da83361 | 2009-06-18 10:05:41 +0000 | [diff] [blame] | 65 | |
Patrick Georgi | c5b87c8 | 2010-05-20 15:28:19 +0000 | [diff] [blame] | 66 | mptable_add_isa_interrupts(mc, bus_isa, apicid_mcp55, 0); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 67 | |
Torsten Duwe | f4c57a9 | 2008-01-07 11:13:16 +0000 | [diff] [blame] | 68 | /* 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 74 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 75 | PCI_INT(0,sbdn+1,1, 10); /* SMBus */ |
Harald Gutmann | da83361 | 2009-06-18 10:05:41 +0000 | [diff] [blame] | 76 | 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 84 | |
Torsten Duwe | f4c57a9 | 2008-01-07 11:13:16 +0000 | [diff] [blame] | 85 | /* The PCIe slots, each on its own bus */ |
Harald Gutmann | da83361 | 2009-06-18 10:05:41 +0000 | [diff] [blame] | 86 | 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 Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 95 | |
Harald Gutmann | da83361 | 2009-06-18 10:05:41 +0000 | [diff] [blame] | 96 | /* On bus 1: the PCI bus slots... |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 97 | physical PCI slots are j = 7,8 |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 98 | FireWire is j = 10 |
Harald Gutmann | da83361 | 2009-06-18 10:05:41 +0000 | [diff] [blame] | 99 | */ |
| 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 Duwe | f4c57a9 | 2008-01-07 11:13:16 +0000 | [diff] [blame] | 108 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 109 | /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/ |
Patrick Georgi | 6eb7a53 | 2011-10-07 21:42:52 +0200 | [diff] [blame] | 110 | mptable_lintsrc(mc, bus_isa); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 111 | /* There is no extension information... */ |
| 112 | |
| 113 | /* Compute the checksums */ |
Patrick Georgi | b0a9c5c | 2011-10-07 23:01:55 +0200 | [diff] [blame] | 114 | return mptable_finalize(mc); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | unsigned long write_smp_table(unsigned long addr) |
| 118 | { |
| 119 | void *v; |
Patrick Georgi | c75c79b | 2011-10-07 22:41:07 +0200 | [diff] [blame] | 120 | v = smp_write_floating_table(addr, 0); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 121 | return (unsigned long)smp_write_config_table(v); |
| 122 | } |