Kerry She | 6401fdb | 2011-05-07 09:15:02 +0000 | [diff] [blame] | 1 | /* |
| 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 She | 6401fdb | 2011-05-07 09:15:02 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <console/console.h> |
| 17 | #include <device/pci.h> |
| 18 | #include <string.h> |
| 19 | #include <stdint.h> |
| 20 | #include <arch/pirq_routing.h> |
| 21 | #include <cpu/amd/amdfam10_sysconf.h> |
| 22 | |
| 23 | static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn, |
| 24 | u8 link0, u16 bitmap0, u8 link1, u16 bitmap1, |
| 25 | u8 link2, u16 bitmap2, u8 link3, u16 bitmap3, |
| 26 | u8 slot, u8 rfu) |
| 27 | { |
| 28 | pirq_info->bus = bus; |
| 29 | pirq_info->devfn = devfn; |
| 30 | pirq_info->irq[0].link = link0; |
| 31 | pirq_info->irq[0].bitmap = bitmap0; |
| 32 | pirq_info->irq[1].link = link1; |
| 33 | pirq_info->irq[1].bitmap = bitmap1; |
| 34 | pirq_info->irq[2].link = link2; |
| 35 | pirq_info->irq[2].bitmap = bitmap2; |
| 36 | pirq_info->irq[3].link = link3; |
| 37 | pirq_info->irq[3].bitmap = bitmap3; |
| 38 | pirq_info->slot = slot; |
| 39 | pirq_info->rfu = rfu; |
| 40 | } |
| 41 | |
| 42 | extern u8 bus_isa; |
| 43 | extern u8 bus_rs780[8]; |
Kyösti Mälkki | 9c7d73c | 2013-09-09 09:23:19 +0300 | [diff] [blame] | 44 | extern u8 bus_sb800[6]; |
Kerry She | 6401fdb | 2011-05-07 09:15:02 +0000 | [diff] [blame] | 45 | extern unsigned long sbdn_sb800; |
| 46 | |
| 47 | unsigned long write_pirq_routing_table(unsigned long addr) |
| 48 | { |
| 49 | struct irq_routing_table *pirq; |
| 50 | struct irq_info *pirq_info; |
| 51 | u32 slot_num; |
| 52 | u8 *v; |
| 53 | |
| 54 | u8 sum = 0; |
| 55 | int i; |
| 56 | |
| 57 | get_bus_conf(); /* it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c */ |
| 58 | |
| 59 | /* Align the table to be 16 byte aligned. */ |
| 60 | addr += 15; |
| 61 | addr &= ~15; |
| 62 | |
Kyösti Mälkki | 9533d83 | 2014-06-26 05:30:54 +0300 | [diff] [blame] | 63 | /* This table must be between 0xf0000 & 0x100000 */ |
Kerry She | 6401fdb | 2011-05-07 09:15:02 +0000 | [diff] [blame] | 64 | printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr); |
| 65 | |
| 66 | pirq = (void *)(addr); |
| 67 | v = (u8 *) (addr); |
| 68 | |
| 69 | pirq->signature = PIRQ_SIGNATURE; |
| 70 | pirq->version = PIRQ_VERSION; |
| 71 | |
| 72 | pirq->rtr_bus = bus_sb800[0]; |
| 73 | pirq->rtr_devfn = ((sbdn_sb800 + 0x14) << 3) | 4; |
| 74 | |
| 75 | pirq->exclusive_irqs = 0; |
| 76 | |
| 77 | pirq->rtr_vendor = 0x1002; |
| 78 | pirq->rtr_device = 0x4384; |
| 79 | |
| 80 | pirq->miniport_data = 0; |
| 81 | |
| 82 | memset(pirq->rfu, 0, sizeof(pirq->rfu)); |
| 83 | |
| 84 | pirq_info = (void *)(&pirq->checksum + 1); |
| 85 | slot_num = 0; |
| 86 | |
| 87 | /* pci bridge */ |
| 88 | write_pirq_info(pirq_info, bus_sb800[0], ((sbdn_sb800 + 0x14) << 3) | 4, |
| 89 | 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, |
| 90 | 0); |
| 91 | pirq_info++; |
| 92 | slot_num++; |
| 93 | |
| 94 | pirq->size = 32 + 16 * slot_num; |
| 95 | |
| 96 | for (i = 0; i < pirq->size; i++) |
| 97 | sum += v[i]; |
| 98 | |
| 99 | sum = pirq->checksum - sum; |
| 100 | if (sum != pirq->checksum) { |
| 101 | pirq->checksum = sum; |
| 102 | } |
| 103 | |
| 104 | printk(BIOS_INFO, "write_pirq_routing_table done.\n"); |
| 105 | |
| 106 | return (unsigned long)pirq_info; |
| 107 | } |