Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +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. |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 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. |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 18 | #include <console/console.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <string.h> |
| 21 | #include <stdint.h> |
| 22 | #include <arch/pirq_routing.h> |
| 23 | |
| 24 | #include <cpu/amd/amdk8_sysconf.h> |
| 25 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 26 | static void write_pirq_info(struct irq_info *pirq_info, uint8_t bus, |
| 27 | uint8_t devfn, uint8_t link0, uint16_t bitmap0, |
| 28 | uint8_t link1, uint16_t bitmap1, uint8_t link2, |
| 29 | uint16_t bitmap2, uint8_t link3, uint16_t bitmap3, |
| 30 | uint8_t slot, uint8_t rfu) |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 31 | { |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 32 | pirq_info->bus = bus; |
| 33 | pirq_info->devfn = devfn; |
| 34 | pirq_info->irq[0].link = link0; |
| 35 | pirq_info->irq[0].bitmap = bitmap0; |
| 36 | pirq_info->irq[1].link = link1; |
| 37 | pirq_info->irq[1].bitmap = bitmap1; |
| 38 | pirq_info->irq[2].link = link2; |
| 39 | pirq_info->irq[2].bitmap = bitmap2; |
| 40 | pirq_info->irq[3].link = link3; |
| 41 | pirq_info->irq[3].bitmap = bitmap3; |
| 42 | pirq_info->slot = slot; |
| 43 | pirq_info->rfu = rfu; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 44 | } |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 45 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 46 | extern unsigned char bus_isa; |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 47 | extern unsigned char bus_mcp55[8]; //1 |
Carl-Daniel Hailfinger | a5436c6 | 2008-12-22 17:41:01 +0000 | [diff] [blame] | 48 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 49 | unsigned long write_pirq_routing_table(unsigned long addr) |
| 50 | { |
| 51 | |
| 52 | struct irq_routing_table *pirq; |
| 53 | struct irq_info *pirq_info; |
| 54 | unsigned slot_num; |
| 55 | uint8_t *v; |
| 56 | unsigned sbdn; |
| 57 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 58 | uint8_t sum = 0; |
| 59 | int i; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 60 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 61 | get_bus_conf(); // it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 62 | sbdn = sysconf.sbdn; |
| 63 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 64 | /* Align the table to be 16 byte aligned. */ |
| 65 | addr += 15; |
| 66 | addr &= ~15; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 67 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 68 | /* This table must be between 0xf0000 & 0x100000 */ |
| 69 | printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 70 | |
| 71 | pirq = (void *)(addr); |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 72 | v = (uint8_t *) (addr); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 73 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 74 | pirq->signature = PIRQ_SIGNATURE; |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 75 | pirq->version = PIRQ_VERSION; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 76 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 77 | pirq->rtr_bus = bus_mcp55[0]; |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 78 | pirq->rtr_devfn = ((sbdn + 6) << 3) | 0; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 79 | |
| 80 | pirq->exclusive_irqs = 0; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 81 | |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 82 | pirq->rtr_vendor = 0x10de; |
| 83 | pirq->rtr_device = 0x0370; |
| 84 | |
| 85 | pirq->miniport_data = 0; |
| 86 | |
| 87 | memset(pirq->rfu, 0, sizeof(pirq->rfu)); |
| 88 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 89 | pirq_info = (void *)(&pirq->checksum + 1); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 90 | slot_num = 0; |
| 91 | //pci bridge |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 92 | write_pirq_info(pirq_info, bus_mcp55[0], ((sbdn + 6) << 3) | 0, 0x1, |
| 93 | 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 94 | pirq_info++; |
| 95 | slot_num++; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 96 | |
| 97 | pirq->size = 32 + 16 * slot_num; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 98 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 99 | for (i = 0; i < pirq->size; i++) |
| 100 | sum += v[i]; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 101 | |
| 102 | sum = pirq->checksum - sum; |
| 103 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 104 | if (sum != pirq->checksum) { |
| 105 | pirq->checksum = sum; |
| 106 | } |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 107 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 108 | printk(BIOS_INFO, "done.\n"); |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 109 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 110 | return (unsigned long)pirq_info; |
Yinghai Lu | f55b58d | 2007-02-17 14:28:11 +0000 | [diff] [blame] | 111 | |
| 112 | } |