blob: bc6aded97fc4aaec05c0950d111d91aab9e7fa44 [file] [log] [blame]
Yinghai Luf55b58d2007-02-17 14:28:11 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Yinghai Luf55b58d2007-02-17 14:28:11 +00003 *
4 * Copyright (C) 2007 AMD
5 * Written by Yinghai Lu <yinghailu@amd.com> for AMD.
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; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
Stefan Reinauer14e22772010-04-27 06:56:47 +000022/* This file was generated by getpir.c, do not modify!
Yinghai Luf55b58d2007-02-17 14:28:11 +000023 (but if you do, please run checkpir on it to verify)
24 Contains the IRQ Routing Table dumped directly from your memory , wich BIOS sets up
25
26 Documentation at : http://www.microsoft.com/hwdev/busbios/PCIIRQ.HTM
27*/
28#include <console/console.h>
29#include <device/pci.h>
30#include <string.h>
31#include <stdint.h>
32#include <arch/pirq_routing.h>
33
34#include <cpu/amd/amdk8_sysconf.h>
35
Stefan Reinauer14e22772010-04-27 06:56:47 +000036static void write_pirq_info(struct irq_info *pirq_info, uint8_t bus, uint8_t devfn, uint8_t link0, uint16_t bitmap0,
Yinghai Luf55b58d2007-02-17 14:28:11 +000037 uint8_t link1, uint16_t bitmap1, uint8_t link2, uint16_t bitmap2,uint8_t link3, uint16_t bitmap3,
38 uint8_t slot, uint8_t rfu)
39{
Stefan Reinauer14e22772010-04-27 06:56:47 +000040 pirq_info->bus = bus;
Yinghai Luf55b58d2007-02-17 14:28:11 +000041 pirq_info->devfn = devfn;
42 pirq_info->irq[0].link = link0;
43 pirq_info->irq[0].bitmap = bitmap0;
44 pirq_info->irq[1].link = link1;
45 pirq_info->irq[1].bitmap = bitmap1;
46 pirq_info->irq[2].link = link2;
47 pirq_info->irq[2].bitmap = bitmap2;
48 pirq_info->irq[3].link = link3;
49 pirq_info->irq[3].bitmap = bitmap3;
50 pirq_info->slot = slot;
51 pirq_info->rfu = rfu;
52}
53extern unsigned char bus_isa;
54extern unsigned char bus_mcp55[8]; //1
55
Stefan Reinauere9de1e22010-04-07 15:30:11 +000056
Carl-Daniel Hailfingera5436c62008-12-22 17:41:01 +000057
Yinghai Luf55b58d2007-02-17 14:28:11 +000058unsigned long write_pirq_routing_table(unsigned long addr)
59{
60
61 struct irq_routing_table *pirq;
62 struct irq_info *pirq_info;
63 unsigned slot_num;
64 uint8_t *v;
65 unsigned sbdn;
66
67 uint8_t sum=0;
68 int i;
69
70 get_bus_conf(); // it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c
71 sbdn = sysconf.sbdn;
72
73 /* Align the table to be 16 byte aligned. */
74 addr += 15;
75 addr &= ~15;
76
77 /* This table must be betweeen 0xf0000 & 0x100000 */
Myles Watson08e0fb82010-03-22 16:33:25 +000078 printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr);
Yinghai Luf55b58d2007-02-17 14:28:11 +000079
80 pirq = (void *)(addr);
81 v = (uint8_t *)(addr);
Stefan Reinauer14e22772010-04-27 06:56:47 +000082
Yinghai Luf55b58d2007-02-17 14:28:11 +000083 pirq->signature = PIRQ_SIGNATURE;
84 pirq->version = PIRQ_VERSION;
Stefan Reinauer14e22772010-04-27 06:56:47 +000085
Yinghai Luf55b58d2007-02-17 14:28:11 +000086 pirq->rtr_bus = bus_mcp55[0];
87 pirq->rtr_devfn = ((sbdn+6)<<3)|0;
88
89 pirq->exclusive_irqs = 0;
Stefan Reinauer14e22772010-04-27 06:56:47 +000090
Yinghai Luf55b58d2007-02-17 14:28:11 +000091 pirq->rtr_vendor = 0x10de;
92 pirq->rtr_device = 0x0370;
93
94 pirq->miniport_data = 0;
95
96 memset(pirq->rfu, 0, sizeof(pirq->rfu));
97
98 pirq_info = (void *) ( &pirq->checksum + 1);
99 slot_num = 0;
100//pci bridge
101 write_pirq_info(pirq_info, bus_mcp55[0], ((sbdn+6)<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0);
102 pirq_info++; slot_num++;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000103
104 pirq->size = 32 + 16 * slot_num;
Yinghai Luf55b58d2007-02-17 14:28:11 +0000105
106 for (i = 0; i < pirq->size; i++)
Stefan Reinauer14e22772010-04-27 06:56:47 +0000107 sum += v[i];
Yinghai Luf55b58d2007-02-17 14:28:11 +0000108
109 sum = pirq->checksum - sum;
110
111 if (sum != pirq->checksum) {
112 pirq->checksum = sum;
113 }
114
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000115 printk(BIOS_INFO, "done.\n");
Yinghai Luf55b58d2007-02-17 14:28:11 +0000116
117 return (unsigned long) pirq_info;
118
119}