63b532d3a82ac0edf224a393801b19a62b0c87aa
[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_isa;
72 extern u8 bus_rs690[8];
73 extern u8 bus_sb600[2];
74 extern unsigned long sbdn_sb600;
75
76 unsigned long write_pirq_routing_table(unsigned long addr)
77 {
78         struct irq_routing_table *pirq;
79         struct irq_info *pirq_info;
80         u32 slot_num;
81         u8 *v;
82
83         u8 sum = 0;
84         int i;
85
86         get_bus_conf();         /* it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c */
87
88         /* Align the table to be 16 byte aligned. */
89         addr += 15;
90         addr &= ~15;
91
92         /* This table must be betweeen 0xf0000 & 0x100000 */
93         printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr);
94
95         pirq = (void *)(addr);
96         v = (u8 *) (addr);
97
98         pirq->signature = PIRQ_SIGNATURE;
99         pirq->version = PIRQ_VERSION;
100
101         pirq->rtr_bus = bus_sb600[0];
102         pirq->rtr_devfn = ((sbdn_sb600 + 0x14) << 3) | 4;
103
104         pirq->exclusive_irqs = 0;
105
106         pirq->rtr_vendor = 0x1002;
107         pirq->rtr_device = 0x4384;
108
109         pirq->miniport_data = 0;
110
111         memset(pirq->rfu, 0, sizeof(pirq->rfu));
112
113         pirq_info = (void *)(&pirq->checksum + 1);
114         slot_num = 0;
115
116         /* pci bridge */
117         write_pirq_info(pirq_info, bus_sb600[0], ((sbdn_sb600 + 0x14) << 3) | 4, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 1, 0);
118         pirq_info++;
119         slot_num++;
120
121         pirq->size = 32 + 16 * slot_num;
122
123         for (i = 0; i < pirq->size; i++)
124                 sum += v[i];
125
126         sum = pirq->checksum - sum;
127         if (sum != pirq->checksum) {
128                 pirq->checksum = sum;
129         }
130
131         printk(BIOS_INFO, "write_pirq_routing_table done.\n");
132
133         return (unsigned long)pirq_info;
134 }