Jonathan A. Kollasch | d924782 | 2015-10-30 18:15:55 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 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 | |
| 18 | /* This file was generated by getpir.c, do not modify! |
| 19 | * (but if you do, please run checkpir on it to verify) |
| 20 | * Contains the IRQ Routing Table dumped directly from your memory , wich BIOS sets up |
| 21 | |
| 22 | * Documentation at : http://www.microsoft.com/hwdev/busbios/PCIIRQ.HTM |
| 23 | */ |
| 24 | #include <console/console.h> |
| 25 | #include <device/pci.h> |
| 26 | #include <string.h> |
| 27 | #include <stdint.h> |
| 28 | #include <arch/pirq_routing.h> |
| 29 | |
| 30 | #include <cpu/amd/amdk8_sysconf.h> |
| 31 | #include "mb_sysconf.h" |
| 32 | |
| 33 | static void write_pirq_info(struct irq_info *pirq_info, uint8_t bus, uint8_t devfn, uint8_t link0, uint16_t bitmap0, |
| 34 | uint8_t link1, uint16_t bitmap1, uint8_t link2, uint16_t bitmap2,uint8_t link3, uint16_t bitmap3, |
| 35 | uint8_t slot, uint8_t rfu) |
| 36 | { |
| 37 | pirq_info->bus = bus; |
| 38 | pirq_info->devfn = devfn; |
| 39 | pirq_info->irq[0].link = link0; |
| 40 | pirq_info->irq[0].bitmap = bitmap0; |
| 41 | pirq_info->irq[1].link = link1; |
| 42 | pirq_info->irq[1].bitmap = bitmap1; |
| 43 | pirq_info->irq[2].link = link2; |
| 44 | pirq_info->irq[2].bitmap = bitmap2; |
| 45 | pirq_info->irq[3].link = link3; |
| 46 | pirq_info->irq[3].bitmap = bitmap3; |
| 47 | pirq_info->slot = slot; |
| 48 | pirq_info->rfu = rfu; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | |
| 53 | unsigned long write_pirq_routing_table(unsigned long addr) |
| 54 | { |
| 55 | |
| 56 | struct irq_routing_table *pirq; |
| 57 | struct irq_info *pirq_info; |
| 58 | unsigned slot_num; |
| 59 | uint8_t *v; |
| 60 | struct mb_sysconf_t *m; |
| 61 | unsigned sbdn; |
| 62 | |
| 63 | uint8_t sum=0; |
| 64 | int i; |
| 65 | |
| 66 | get_bus_conf(); // it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c |
| 67 | sbdn = sysconf.sbdn; |
| 68 | m = sysconf.mb; |
| 69 | |
| 70 | /* Align the table to be 16 byte aligned. */ |
| 71 | addr += 15; |
| 72 | addr &= ~15; |
| 73 | |
| 74 | /* This table must be between 0xf0000 & 0x100000 */ |
| 75 | printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr); |
| 76 | |
| 77 | pirq = (void *)(addr); |
| 78 | v = (uint8_t *)(addr); |
| 79 | |
| 80 | pirq->signature = PIRQ_SIGNATURE; |
| 81 | pirq->version = PIRQ_VERSION; |
| 82 | |
| 83 | pirq->rtr_bus = m->bus_mcp55; |
| 84 | pirq->rtr_devfn = ((sbdn+6)<<3)|0; |
| 85 | |
| 86 | pirq->exclusive_irqs = 0; |
| 87 | |
| 88 | pirq->rtr_vendor = 0x10de; |
| 89 | pirq->rtr_device = 0x0370; |
| 90 | |
| 91 | pirq->miniport_data = 0; |
| 92 | |
| 93 | memset(pirq->rfu, 0, sizeof(pirq->rfu)); |
| 94 | |
| 95 | pirq_info = (void *) ( &pirq->checksum + 1); |
| 96 | slot_num = 0; |
| 97 | //pci bridge |
| 98 | write_pirq_info(pirq_info, m->bus_mcp55, ((sbdn+6)<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 99 | pirq_info++; slot_num++; |
| 100 | |
| 101 | for (i = 1; i < sysconf.hc_possible_num; i++) { |
| 102 | if(!(sysconf.pci1234[i] & 0x1) ) continue; |
| 103 | unsigned busn = (sysconf.pci1234[i] >> 16) & 0xff; |
| 104 | unsigned devn = sysconf.hcdn[i] & 0xff; |
| 105 | |
| 106 | write_pirq_info(pirq_info, busn, (devn<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 107 | pirq_info++; slot_num++; |
| 108 | } |
| 109 | |
| 110 | pirq->size = 32 + 16 * slot_num; |
| 111 | |
| 112 | for (i = 0; i < pirq->size; i++) |
| 113 | sum += v[i]; |
| 114 | |
| 115 | sum = pirq->checksum - sum; |
| 116 | |
| 117 | if (sum != pirq->checksum) { |
| 118 | pirq->checksum = sum; |
| 119 | } |
| 120 | |
| 121 | printk(BIOS_INFO, "done.\n"); |
| 122 | |
| 123 | return (unsigned long) pirq_info; |
| 124 | |
| 125 | } |