Marc Jones | 2ce8bfd | 2007-12-19 01:49:44 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Marc Jones | 2ce8bfd | 2007-12-19 01:49:44 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2007 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. |
Marc Jones | 2ce8bfd | 2007-12-19 01:49:44 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <string.h> |
| 20 | #include <stdint.h> |
| 21 | #include <arch/pirq_routing.h> |
| 22 | #include <cpu/amd/amdfam10_sysconf.h> |
| 23 | |
| 24 | #include "mb_sysconf.h" |
| 25 | |
| 26 | static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn, u8 link0, u16 bitmap0, |
| 27 | u8 link1, u16 bitmap1, u8 link2, u16 bitmap2,u8 link3, u16 bitmap3, |
| 28 | u8 slot, u8 rfu) |
| 29 | { |
| 30 | pirq_info->bus = bus; |
| 31 | pirq_info->devfn = devfn; |
| 32 | pirq_info->irq[0].link = link0; |
| 33 | pirq_info->irq[0].bitmap = bitmap0; |
| 34 | pirq_info->irq[1].link = link1; |
| 35 | pirq_info->irq[1].bitmap = bitmap1; |
| 36 | pirq_info->irq[2].link = link2; |
| 37 | pirq_info->irq[2].bitmap = bitmap2; |
| 38 | pirq_info->irq[3].link = link3; |
| 39 | pirq_info->irq[3].bitmap = bitmap3; |
| 40 | pirq_info->slot = slot; |
| 41 | pirq_info->rfu = rfu; |
| 42 | } |
| 43 | |
| 44 | |
Stefan Reinauer | e9de1e2 | 2010-04-07 15:30:11 +0000 | [diff] [blame] | 45 | |
Marc Jones | 2ce8bfd | 2007-12-19 01:49:44 +0000 | [diff] [blame] | 46 | |
| 47 | unsigned long write_pirq_routing_table(unsigned long addr) |
| 48 | { |
| 49 | |
| 50 | struct irq_routing_table *pirq; |
| 51 | struct irq_info *pirq_info; |
| 52 | u32 slot_num; |
| 53 | u8 *v; |
| 54 | |
| 55 | u8 sum=0; |
| 56 | int i; |
| 57 | |
| 58 | struct mb_sysconf_t *m; |
| 59 | |
| 60 | get_bus_conf(); // it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c |
| 61 | |
| 62 | m = sysconf.mb; |
| 63 | |
| 64 | /* Align the table to be 16 byte aligned. */ |
| 65 | addr += 15; |
| 66 | addr &= ~15; |
| 67 | |
Kyösti Mälkki | 9533d83 | 2014-06-26 05:30:54 +0300 | [diff] [blame] | 68 | /* This table must be between 0xf0000 & 0x100000 */ |
Myles Watson | 08e0fb8 | 2010-03-22 16:33:25 +0000 | [diff] [blame] | 69 | printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr); |
Marc Jones | 2ce8bfd | 2007-12-19 01:49:44 +0000 | [diff] [blame] | 70 | |
| 71 | pirq = (void *)(addr); |
| 72 | v = (u8 *)(addr); |
| 73 | |
| 74 | pirq->signature = PIRQ_SIGNATURE; |
| 75 | pirq->version = PIRQ_VERSION; |
| 76 | |
| 77 | pirq->rtr_bus = m->bus_8111_0; |
| 78 | pirq->rtr_devfn = ((sysconf.sbdn+1)<<3)|0; |
| 79 | |
| 80 | pirq->exclusive_irqs = 0; |
| 81 | |
| 82 | pirq->rtr_vendor = 0x1022; |
| 83 | pirq->rtr_device = 0x746b; |
| 84 | |
| 85 | pirq->miniport_data = 0; |
| 86 | |
| 87 | memset(pirq->rfu, 0, sizeof(pirq->rfu)); |
| 88 | |
| 89 | pirq_info = (void *) ( &pirq->checksum + 1); |
| 90 | slot_num = 0; |
| 91 | |
| 92 | |
| 93 | //pci bridge |
| 94 | write_pirq_info(pirq_info, m->bus_8111_0, ((sysconf.sbdn+1)<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 95 | pirq_info++; slot_num++; |
| 96 | |
| 97 | |
| 98 | //pcix bridge |
| 99 | // write_pirq_info(pirq_info, m->bus_8132_0, (sbdn3<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 100 | // pirq_info++; slot_num++; |
| 101 | |
| 102 | int j=0; |
| 103 | |
| 104 | for(i=1; i< sysconf.hc_possible_num; i++) { |
| 105 | if(!(sysconf.pci1234[i] & 0x1) ) continue; |
| 106 | u32 busn = (sysconf.pci1234[i] >> 12) & 0xff; |
| 107 | u32 devn = sysconf.hcdn[i] & 0xff; |
| 108 | |
| 109 | write_pirq_info(pirq_info, busn, (devn<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 110 | pirq_info++; slot_num++; |
| 111 | j++; |
| 112 | |
| 113 | } |
| 114 | |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 115 | #if CONFIG_CBB |
| 116 | write_pirq_info(pirq_info, CONFIG_CBB, (0<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
Marc Jones | 2ce8bfd | 2007-12-19 01:49:44 +0000 | [diff] [blame] | 117 | pirq_info++; slot_num++; |
| 118 | if(sysconf.nodes>32) { |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 119 | write_pirq_info(pirq_info, CONFIG_CBB-1, (0<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
Marc Jones | 2ce8bfd | 2007-12-19 01:49:44 +0000 | [diff] [blame] | 120 | pirq_info++; slot_num++; |
| 121 | } |
| 122 | #endif |
| 123 | |
| 124 | pirq->size = 32 + 16 * slot_num; |
| 125 | |
| 126 | for (i = 0; i < pirq->size; i++) { |
| 127 | sum += v[i]; |
| 128 | } |
| 129 | |
| 130 | sum = pirq->checksum - sum; |
| 131 | |
| 132 | if (sum != pirq->checksum) { |
| 133 | pirq->checksum = sum; |
| 134 | } |
| 135 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 136 | printk(BIOS_INFO, "done.\n"); |
Marc Jones | 2ce8bfd | 2007-12-19 01:49:44 +0000 | [diff] [blame] | 137 | |
| 138 | return (unsigned long) pirq_info; |
| 139 | |
| 140 | } |