Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 1 | #include <console/console.h> |
| 2 | #include <device/pci.h> |
| 3 | #include <string.h> |
| 4 | #include <stdint.h> |
| 5 | #include <arch/pirq_routing.h> |
| 6 | |
| 7 | #include <cpu/amd/amdk8_sysconf.h> |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 8 | #include "mb_sysconf.h" |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 9 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 10 | static void write_pirq_info(struct irq_info *pirq_info, uint8_t bus, |
| 11 | uint8_t devfn, uint8_t link0, uint16_t bitmap0, |
| 12 | uint8_t link1, uint16_t bitmap1, uint8_t link2, |
| 13 | uint16_t bitmap2, uint8_t link3, uint16_t bitmap3, |
| 14 | uint8_t slot, uint8_t rfu) |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 15 | { |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 16 | pirq_info->bus = bus; |
| 17 | pirq_info->devfn = devfn; |
| 18 | pirq_info->irq[0].link = link0; |
| 19 | pirq_info->irq[0].bitmap = bitmap0; |
| 20 | pirq_info->irq[1].link = link1; |
| 21 | pirq_info->irq[1].bitmap = bitmap1; |
| 22 | pirq_info->irq[2].link = link2; |
| 23 | pirq_info->irq[2].bitmap = bitmap2; |
| 24 | pirq_info->irq[3].link = link3; |
| 25 | pirq_info->irq[3].bitmap = bitmap3; |
| 26 | pirq_info->slot = slot; |
| 27 | pirq_info->rfu = rfu; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 30 | unsigned long write_pirq_routing_table(unsigned long addr) |
| 31 | { |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 32 | struct irq_routing_table *pirq; |
| 33 | struct irq_info *pirq_info; |
| 34 | unsigned slot_num; |
| 35 | uint8_t *v; |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 36 | struct mb_sysconf_t *m = sysconf.mb; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 37 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 38 | uint8_t sum = 0; |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 39 | int i; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 40 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 41 | get_bus_conf(); // it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 42 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 43 | /* Align the table to be 16 byte aligned. */ |
| 44 | addr += 15; |
| 45 | addr &= ~15; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 46 | |
Kyösti Mälkki | 9533d83 | 2014-06-26 05:30:54 +0300 | [diff] [blame] | 47 | /* This table must be between 0xf0000 & 0x100000 */ |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 48 | printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr); |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 49 | |
| 50 | pirq = (void *)(addr); |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 51 | v = (uint8_t *) (addr); |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 52 | |
| 53 | pirq->signature = PIRQ_SIGNATURE; |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 54 | pirq->version = PIRQ_VERSION; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 55 | |
Oskar Enoksson | df073cb | 2011-10-04 22:15:51 +0200 | [diff] [blame] | 56 | pirq->rtr_bus = m->bus_8111_0; |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 57 | pirq->rtr_devfn = ((sysconf.sbdn + 1) << 3) | 0; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 58 | |
| 59 | pirq->exclusive_irqs = 0; |
| 60 | |
| 61 | pirq->rtr_vendor = 0x1022; |
| 62 | pirq->rtr_device = 0x746b; |
| 63 | |
| 64 | pirq->miniport_data = 0; |
| 65 | |
| 66 | memset(pirq->rfu, 0, sizeof(pirq->rfu)); |
| 67 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 68 | pirq_info = (void *)(&pirq->checksum + 1); |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 69 | slot_num = 0; |
| 70 | //pci bridge |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 71 | write_pirq_info(pirq_info, m->bus_8111_0, ((sysconf.sbdn + 1) << 3) | 0, |
| 72 | 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, |
| 73 | 0); |
| 74 | pirq_info++; |
| 75 | slot_num++; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 76 | //pcix bridge |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 77 | // write_pirq_info(pirq_info, m->bus_8131_0, (m->sbdn3<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 78 | // pirq_info++; slot_num++; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 79 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 80 | pirq_info++; |
| 81 | slot_num++; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 82 | |
| 83 | pirq->size = 32 + 16 * slot_num; |
| 84 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 85 | for (i = 0; i < pirq->size; i++) |
| 86 | sum += v[i]; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 87 | |
| 88 | sum = pirq->checksum - sum; |
| 89 | |
Oskar Enoksson | f5e102d | 2011-11-07 18:31:33 +0100 | [diff] [blame] | 90 | if (sum != pirq->checksum) { |
| 91 | pirq->checksum = sum; |
| 92 | } |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 93 | |
| 94 | printk(BIOS_INFO, "done.\n"); |
| 95 | |
Paul Menzel | 95fe8fb | 2016-07-28 17:20:20 +0200 | [diff] [blame^] | 96 | return (unsigned long)pirq_info; |
Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame] | 97 | |
| 98 | } |