printk_foo -> printk(BIOS_FOO, ...)
[coreboot.git] / src / mainboard / msi / ms9282 / irq_tables.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2006 AMD
5  * Written by Yinghai Lu <yinghailu@amd.com> for AMD.
6  *
7  * Copyright (C) 2006 MSI
8  * Written by Bingxun Shi <bingxunshi@gmail.com> for MSI.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
23  */
24
25 /* This file was generated by getpir.c, do not modify!
26    (but if you do, please run checkpir on it to verify)
27    Contains the IRQ Routing Table dumped directly from your memory , wich BIOS sets up
28
29    Documentation at : http://www.microsoft.com/hwdev/busbios/PCIIRQ.HTM
30 */
31 #include <console/console.h>
32 #include <device/pci.h>
33 #include <string.h>
34 #include <stdint.h>
35 #include <arch/pirq_routing.h>
36
37 #include <cpu/amd/amdk8_sysconf.h>
38 #include "mb_sysconf.h"
39
40 static void write_pirq_info(struct irq_info *pirq_info, uint8_t bus, uint8_t devfn, uint8_t link0, uint16_t bitmap0,
41                uint8_t link1, uint16_t bitmap1, uint8_t link2, uint16_t bitmap2,uint8_t link3, uint16_t bitmap3,
42                uint8_t slot, uint8_t rfu)
43 {
44         pirq_info->bus = bus;
45         pirq_info->devfn = devfn;
46                 pirq_info->irq[0].link = link0;
47                 pirq_info->irq[0].bitmap = bitmap0;
48                 pirq_info->irq[1].link = link1;
49                 pirq_info->irq[1].bitmap = bitmap1;
50                 pirq_info->irq[2].link = link2;
51                 pirq_info->irq[2].bitmap = bitmap2;
52                 pirq_info->irq[3].link = link3;
53                 pirq_info->irq[3].bitmap = bitmap3;
54         pirq_info->slot = slot;
55         pirq_info->rfu = rfu;
56 }
57
58 extern void get_bus_conf(void);
59
60 unsigned long write_pirq_routing_table(unsigned long addr)
61 {
62
63        struct irq_routing_table *pirq;
64        struct irq_info *pirq_info;
65        unsigned slot_num;
66        uint8_t *v;
67        struct mb_sysconf_t *m;
68        unsigned sbdn;
69
70         uint8_t sum=0;
71         int i;
72
73         get_bus_conf(); // it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c
74        sbdn = sysconf.sbdn;
75        m = sysconf.mb;
76
77         /* Align the table to be 16 byte aligned. */
78         addr += 15;
79         addr &= ~15;
80
81         /* This table must be betweeen 0xf0000 & 0x100000 */
82         printk(BIOS_INFO, "Writing IRQ routing tables to 0x%x...", addr);
83
84        pirq = (void *)(addr);
85        v = (uint8_t *)(addr);
86
87        pirq->signature = PIRQ_SIGNATURE;
88        pirq->version  = PIRQ_VERSION;
89
90        pirq->rtr_bus = m->bus_mcp55[0];
91        pirq->rtr_devfn = ((sbdn+6)<<3)|0;
92
93        pirq->exclusive_irqs = 0;
94
95        pirq->rtr_vendor = 0x10de;
96        pirq->rtr_device = 0x0370;
97
98        pirq->miniport_data = 0;
99
100        memset(pirq->rfu, 0, sizeof(pirq->rfu));
101
102        pirq_info = (void *) ( &pirq->checksum + 1);
103        slot_num = 0;
104 //pci bridge
105        write_pirq_info(pirq_info, m->bus_mcp55[0], ((sbdn+6)<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0);
106        pirq_info++; slot_num++;
107
108         for(i=1; i< sysconf.hc_possible_num; i++) {
109                 if(!(sysconf.pci1234[i] & 0x1) ) continue;
110                 unsigned busn = (sysconf.pci1234[i] >> 16) & 0xff;
111                 unsigned devn = sysconf.hcdn[i] & 0xff;
112
113                 write_pirq_info(pirq_info, busn, (devn<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0);
114                 pirq_info++; slot_num++;
115        }
116
117        pirq->size = 32 + 16 * slot_num;
118
119         for (i = 0; i < pirq->size; i++)
120                 sum += v[i];
121
122        sum = pirq->checksum - sum;
123
124         if (sum != pirq->checksum) {
125                 pirq->checksum = sum;
126         }
127
128        printk(BIOS_INFO, "done.\n");
129
130        return  (unsigned long) pirq_info;
131
132 }