Uwe Hermann | 29c7dfca | 2010-12-13 13:44:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de> |
| 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; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Uwe Hermann | 29c7dfca | 2010-12-13 13:44:33 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <arch/smp/mpspec.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <string.h> |
| 21 | #include <stdint.h> |
| 22 | #include <cpu/amd/amdk8_sysconf.h> |
| 23 | |
| 24 | #define PCI_INT(bus, dev, fn, pin) \ |
| 25 | smp_write_intsrc(mc, mp_INT, \ |
| 26 | MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, \ |
| 27 | bus_mcp55[bus], (((dev) << 2) | (fn)), apicid_mcp55, (pin)) |
| 28 | |
| 29 | extern unsigned char bus_mcp55[8]; |
| 30 | extern unsigned apicid_mcp55; |
| 31 | |
| 32 | static void *smp_write_config_table(void *v) |
| 33 | { |
| 34 | struct mp_config_table *mc; |
| 35 | unsigned int sbdn; |
| 36 | int i, j, bus_isa; |
| 37 | device_t dev; |
| 38 | struct resource *res; |
| 39 | |
| 40 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
| 41 | |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 42 | mptable_init(mc, LOCAL_APIC_ADDR); |
Uwe Hermann | 29c7dfca | 2010-12-13 13:44:33 +0000 | [diff] [blame] | 43 | |
| 44 | smp_write_processors(mc); |
| 45 | |
| 46 | get_bus_conf(); |
| 47 | sbdn = sysconf.sbdn; |
| 48 | |
| 49 | mptable_write_buses(mc, NULL, &bus_isa); |
| 50 | |
| 51 | dev = dev_find_slot(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, apicid_mcp55, 0x11, |
| 56 | res2mmio(res, 0, 0)); |
Uwe Hermann | 29c7dfca | 2010-12-13 13:44:33 +0000 | [diff] [blame] | 57 | |
| 58 | pci_write_config32(dev, 0x7c, 0x00000000); |
| 59 | pci_write_config32(dev, 0x80, 0x11002009); |
| 60 | pci_write_config32(dev, 0x84, 0x2000dd08); |
| 61 | } |
| 62 | |
| 63 | mptable_add_isa_interrupts(mc, bus_isa, apicid_mcp55, 0); |
| 64 | |
| 65 | /* I/O Ints */ |
| 66 | PCI_INT(0, sbdn + 1, 1, 10); /* SMBus */ |
| 67 | PCI_INT(0, sbdn + 2, 0, 20); /* USB 1.1 */ |
| 68 | PCI_INT(0, sbdn + 2, 1, 22); /* USB 2.0 */ |
| 69 | PCI_INT(0, sbdn + 4, 0, 14); /* IDE */ |
| 70 | PCI_INT(0, sbdn + 5, 0, 23); /* SATA 0 */ |
| 71 | PCI_INT(0, sbdn + 5, 1, 23); /* SATA 1 */ |
| 72 | PCI_INT(0, sbdn + 5, 2, 22); /* SATA 2 */ |
| 73 | PCI_INT(0, sbdn + 6, 1, 21); /* HD audio */ |
| 74 | PCI_INT(0, sbdn + 8, 0, 24); /* NIC */ |
| 75 | |
| 76 | /* PCI-E slots (two x1, one x4, one x16) */ |
| 77 | for (j = 7; j >= 2; j--) { |
| 78 | if (!bus_mcp55[j]) |
| 79 | continue; |
| 80 | for (i = 0; i < 4; i++) |
| 81 | PCI_INT(j, 0, i, 0x10 + (2 + j + i + 4 - sbdn % 4) % 4); |
| 82 | } |
| 83 | |
| 84 | /* PCI slots (three on this board) */ |
| 85 | for (j = 0; j < 3; j++) { |
| 86 | for (i = 0; i < 4; i++) |
| 87 | PCI_INT(1, 0x06 + j, i, 0x10 + (2 + i + j) % 4); |
| 88 | } |
| 89 | |
| 90 | /* Local Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */ |
Patrick Georgi | 6eb7a53 | 2011-10-07 21:42:52 +0200 | [diff] [blame] | 91 | mptable_lintsrc(mc, bus_isa); |
Uwe Hermann | 29c7dfca | 2010-12-13 13:44:33 +0000 | [diff] [blame] | 92 | |
| 93 | /* Compute the checksums. */ |
Patrick Georgi | b0a9c5c | 2011-10-07 23:01:55 +0200 | [diff] [blame] | 94 | return mptable_finalize(mc); |
Uwe Hermann | 29c7dfca | 2010-12-13 13:44:33 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | unsigned long write_smp_table(unsigned long addr) |
| 98 | { |
| 99 | void *v; |
Patrick Georgi | c75c79b | 2011-10-07 22:41:07 +0200 | [diff] [blame] | 100 | v = smp_write_floating_table(addr, 0); |
Uwe Hermann | 29c7dfca | 2010-12-13 13:44:33 +0000 | [diff] [blame] | 101 | return (unsigned long)smp_write_config_table(v); |
| 102 | } |