b2a96680d0787c3aaffe5b16adf34064674cddea
[coreboot.git] / src / mainboard / siemens / sitemp_g1p1 / irq_tables.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 /* This file was generated by getpir.c, do not modify!
21    (but if you do, please run checkpir on it to verify)
22    Contains the IRQ Routing Table dumped directly from your memory , wich BIOS sets up
23
24    Documentation at : http://www.microsoft.com/hwdev/busbios/PCIIRQ.HTM
25 */
26
27 #include <console/console.h>
28 #include <device/pci.h>
29 #include <string.h>
30 #include <stdint.h>
31 #include <arch/pirq_routing.h>
32
33 #include <cpu/amd/amdk8_sysconf.h>
34
35 /* Platform IRQs */
36 #define PIRQA 10
37 #define PIRQB 11
38 #define PIRQC 5
39 #define PIRQD 15
40
41 /* Map */
42 #define M_PIRQA (1 << PIRQA)    /* Bitmap of supported IRQs */
43 #define M_PIRQB (1 << PIRQB)    /* Bitmap of supported IRQs */
44 #define M_PIRQC (1 << PIRQC)    /* Bitmap of supported IRQs */
45 #define M_PIRQD (1 << PIRQD)    /* Bitmap of supported IRQs */
46
47 /* Link */
48 #define L_PIRQA  1              /* Means Slot INTx# Connects To Chipset INTA# */
49 #define L_PIRQB  2              /* Means Slot INTx# Connects To Chipset INTB# */
50 #define L_PIRQC  3              /* Means Slot INTx# Connects To Chipset INTC# */
51 #define L_PIRQD  4              /* Means Slot INTx# Connects To Chipset INTD# */
52
53 static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
54                             u8 link0, u16 bitmap0, u8 link1, u16 bitmap1,
55                             u8 link2, u16 bitmap2, u8 link3, u16 bitmap3,
56                             u8 slot, u8 rfu)
57 {
58         pirq_info->bus = bus;
59         pirq_info->devfn = devfn;
60         pirq_info->irq[0].link = link0;
61         pirq_info->irq[0].bitmap = bitmap0;
62         pirq_info->irq[1].link = link1;
63         pirq_info->irq[1].bitmap = bitmap1;
64         pirq_info->irq[2].link = link2;
65         pirq_info->irq[2].bitmap = bitmap2;
66         pirq_info->irq[3].link = link3;
67         pirq_info->irq[3].bitmap = bitmap3;
68         pirq_info->slot = slot;
69         pirq_info->rfu = rfu;
70 }
71 extern u8 bus_rs690[8];
72 extern u8 bus_sb600[2];
73 extern unsigned long sbdn_sb600;
74
75 unsigned long write_pirq_routing_table(unsigned long addr)
76 {
77         struct irq_routing_table *pirq;
78         struct irq_info *pirq_info;
79         u32 slot_num;
80         u8 *v;
81
82         u8 sum = 0;
83         int i;
84
85         get_bus_conf();         /* it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c */
86
87         /* Align the table to be 16 byte aligned. */
88         addr += 15;
89         addr &= ~15;
90
91         /* This table must be betweeen 0xf0000 & 0x100000 */
92         printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr);
93
94         pirq = (void *)(addr);
95         v = (u8 *) (addr);
96
97         pirq->signature = PIRQ_SIGNATURE;
98         pirq->version = PIRQ_VERSION;
99
100         pirq->rtr_bus = bus_sb600[0];
101         pirq->rtr_devfn = ((sbdn_sb600 + 0x14) << 3) | 4;
102
103         pirq->exclusive_irqs = 0;
104
105         pirq->rtr_vendor = 0x1002;
106         pirq->rtr_device = 0x4384;
107
108         pirq->miniport_data = 0;
109
110         memset(pirq->rfu, 0, sizeof(pirq->rfu));
111
112         pirq_info = (void *)(&pirq->checksum + 1);
113         slot_num = 0;
114
115         /* pci bridge */
116         write_pirq_info(pirq_info, bus_sb600[0], ((sbdn_sb600 + 0x14) << 3) | 4, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 1, 0);
117         pirq_info++;
118         slot_num++;
119
120         pirq->size = 32 + 16 * slot_num;
121
122         for (i = 0; i < pirq->size; i++)
123                 sum += v[i];
124
125         sum = pirq->checksum - sum;
126         if (sum != pirq->checksum) {
127                 pirq->checksum = sum;
128         }
129
130         printk(BIOS_INFO, "write_pirq_routing_table done.\n");
131
132         return (unsigned long)pirq_info;
133 }