blob: 029dea8f807bdacc94d17312a1f0ae910029f4fd [file] [log] [blame]
Timothy Pearson53538be2015-04-30 01:47:31 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
5 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
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.
Timothy Pearson53538be2015-04-30 01:47:31 -050015 */
16
17#include <console/console.h>
18#include <device/pci_ids.h>
19#include <device/pci.h>
20#include <string.h>
21#include <stdint.h>
22#include <arch/pirq_routing.h>
23
24#include <cpu/amd/amdfam10_sysconf.h>
25
26static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
27 u8 link0, u16 bitmap0, u8 link1, u16 bitmap1,
28 u8 link2, u16 bitmap2, u8 link3, u16 bitmap3,
29 u8 slot, u8 rfu)
30{
31 pirq_info->bus = bus;
32 pirq_info->devfn = devfn;
33 pirq_info->irq[0].link = link0;
34 pirq_info->irq[0].bitmap = bitmap0;
35 pirq_info->irq[1].link = link1;
36 pirq_info->irq[1].bitmap = bitmap1;
37 pirq_info->irq[2].link = link2;
38 pirq_info->irq[2].bitmap = bitmap2;
39 pirq_info->irq[3].link = link3;
40 pirq_info->irq[3].bitmap = bitmap3;
41 pirq_info->slot = slot;
42 pirq_info->rfu = rfu;
43}
44extern u8 bus_isa;
45extern u8 bus_rs780[8];
46extern u8 bus_sp5100[2];
47extern unsigned long sbdn_sp5100;
48
49unsigned long write_pirq_routing_table(unsigned long addr)
50{
51 struct irq_routing_table *pirq;
52 struct irq_info *pirq_info;
53 u32 slot_num;
54 u8 *v;
55
56 u8 sum = 0;
57 int i;
58
59 get_bus_conf(); /* it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c */
60
61 /* Align the table to be 16 byte aligned. */
62 addr += 15;
63 addr &= ~15;
64
65 /* This table must be between 0xf0000 & 0x100000 */
66 printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr);
67
68 pirq = (void *)(addr);
69 v = (u8 *) (addr);
70
71 pirq->signature = PIRQ_SIGNATURE;
72 pirq->version = PIRQ_VERSION;
73
74 pirq->rtr_bus = bus_sp5100[0];
75 pirq->rtr_devfn = PCI_DEVFN(0x14, 4);
76
77 pirq->exclusive_irqs = 0;
78
79 pirq->rtr_vendor = PCI_VENDOR_ID_ATI;
80 pirq->rtr_device = PCI_DEVICE_ID_ATI_SB700_PCI;
81
82 pirq->miniport_data = 0;
83
84 memset(pirq->rfu, 0, sizeof(pirq->rfu));
85
86 pirq_info = (void *)(&pirq->checksum + 1);
87 slot_num = 0;
88
89 /* pci bridge */
90 write_pirq_info(pirq_info, bus_sp5100[0], ((sbdn_sp5100 + 0x14) << 3) | 4,
91 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0,
92 0);
93 pirq_info++;
94 slot_num++;
95
96 pirq->size = 32 + 16 * slot_num;
97
98 for (i = 0; i < pirq->size; i++)
99 sum += v[i];
100
101 sum = pirq->checksum - sum;
102 if (sum != pirq->checksum) {
103 pirq->checksum = sum;
104 }
105
106 printk(BIOS_INFO, "write_pirq_routing_table done.\n");
107
108 return (unsigned long)pirq_info;
109}