Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +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> |
Stefan Reinauer | 23836e2 | 2010-04-15 12:39:29 +0000 | [diff] [blame] | 6 | #include <cpu/amd/amdk8_sysconf.h> |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 7 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 8 | static void write_pirq_info(struct irq_info *pirq_info, uint8_t bus, uint8_t devfn, uint8_t link0, uint16_t bitmap0, |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 9 | uint8_t link1, uint16_t bitmap1, uint8_t link2, uint16_t bitmap2,uint8_t link3, uint16_t bitmap3, |
| 10 | uint8_t slot, uint8_t rfu) |
| 11 | { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 12 | pirq_info->bus = bus; |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 13 | pirq_info->devfn = devfn; |
| 14 | pirq_info->irq[0].link = link0; |
| 15 | pirq_info->irq[0].bitmap = bitmap0; |
| 16 | pirq_info->irq[1].link = link1; |
| 17 | pirq_info->irq[1].bitmap = bitmap1; |
| 18 | pirq_info->irq[2].link = link2; |
| 19 | pirq_info->irq[2].bitmap = bitmap2; |
| 20 | pirq_info->irq[3].link = link3; |
| 21 | pirq_info->irq[3].bitmap = bitmap3; |
| 22 | pirq_info->slot = slot; |
| 23 | pirq_info->rfu = rfu; |
| 24 | } |
| 25 | |
| 26 | extern unsigned char bus_ck804_0; //1 |
| 27 | extern unsigned char bus_ck804_1; //2 |
| 28 | extern unsigned char bus_ck804_2; //3 |
| 29 | extern unsigned char bus_ck804_3; //4 |
| 30 | extern unsigned char bus_ck804_4; //5 |
| 31 | extern unsigned char bus_ck804_5; //6 |
| 32 | extern unsigned char bus_8131_0; //7 |
| 33 | extern unsigned char bus_8131_1; //8 |
| 34 | extern unsigned char bus_8131_2; //9 |
| 35 | extern unsigned char bus_ck804b_0;//a |
| 36 | extern unsigned char bus_ck804b_1;//b |
| 37 | extern unsigned char bus_ck804b_2;//c |
| 38 | extern unsigned char bus_ck804b_3;//d |
| 39 | extern unsigned char bus_ck804b_4;//e |
| 40 | extern unsigned char bus_ck804b_5;//f |
| 41 | |
| 42 | extern unsigned pci1234[]; |
| 43 | |
| 44 | extern unsigned sbdn; |
| 45 | extern unsigned hcdn[]; |
| 46 | extern unsigned sbdn3; |
| 47 | extern unsigned sbdnb; |
| 48 | |
Stefan Reinauer | e9de1e2 | 2010-04-07 15:30:11 +0000 | [diff] [blame] | 49 | |
Carl-Daniel Hailfinger | a5436c6 | 2008-12-22 17:41:01 +0000 | [diff] [blame] | 50 | |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 51 | unsigned long write_pirq_routing_table(unsigned long addr) |
| 52 | { |
| 53 | |
| 54 | struct irq_routing_table *pirq; |
| 55 | struct irq_info *pirq_info; |
| 56 | unsigned slot_num; |
| 57 | uint8_t *v; |
| 58 | |
| 59 | uint8_t sum=0; |
| 60 | int i; |
| 61 | |
| 62 | get_bus_conf(); // it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c |
| 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); |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 70 | |
| 71 | pirq = (void *)(addr); |
| 72 | v = (uint8_t *)(addr); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 73 | |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 74 | pirq->signature = PIRQ_SIGNATURE; |
| 75 | pirq->version = PIRQ_VERSION; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 76 | |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 77 | pirq->rtr_bus = bus_ck804_0; |
| 78 | pirq->rtr_devfn = ((sbdn+9)<<3)|0; |
| 79 | |
| 80 | pirq->exclusive_irqs = 0; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 81 | |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 82 | pirq->rtr_vendor = 0x10de; |
| 83 | pirq->rtr_device = 0x005c; |
| 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 | //pci bridge |
| 92 | write_pirq_info(pirq_info, bus_ck804_0, ((sbdn+9)<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 93 | pirq_info++; slot_num++; |
| 94 | //pcix bridge |
| 95 | write_pirq_info(pirq_info, bus_8131_0, (sbdn3<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 96 | pirq_info++; slot_num++; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 97 | |
| 98 | if(pci1234[2] & 0xf) { |
| 99 | //second pci beidge |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 100 | write_pirq_info(pirq_info, bus_ck804b_0, ((sbdnb+9)<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0x0, 0); |
| 101 | pirq_info++; slot_num++; |
| 102 | } |
| 103 | #if 0 |
| 104 | //smbus |
| 105 | write_pirq_info(pirq_info, bus_ck804_0, ((sbdn+1)<<3)|0, 0x2, 0xdef8, 0, 0, 0, 0, 0, 0, 0, 0); |
| 106 | pirq_info++; slot_num++; |
| 107 | |
| 108 | //usb |
| 109 | write_pirq_info(pirq_info, bus_ck804_0, ((sbdn+2)<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0, 0, 0, 0, 0, 0); |
| 110 | pirq_info++; slot_num++; |
| 111 | |
| 112 | //audio |
| 113 | write_pirq_info(pirq_info, bus_ck804_0, ((sbdn+4)<<3)|0, 0x1, 0xdef8, 0, 0, 0, 0, 0, 0, 0, 0); |
| 114 | pirq_info++; slot_num++; |
| 115 | //sata |
| 116 | write_pirq_info(pirq_info, bus_ck804_0, ((sbdn+7)<<3)|0, 0x1, 0xdef8, 0, 0, 0, 0, 0, 0, 0, 0); |
| 117 | pirq_info++; slot_num++; |
| 118 | //sata |
| 119 | write_pirq_info(pirq_info, bus_ck804_0, ((sbdn+8)<<3)|0, 0x1, 0xdef8, 0, 0, 0, 0, 0, 0, 0, 0); |
| 120 | pirq_info++; slot_num++; |
| 121 | //nic |
| 122 | write_pirq_info(pirq_info, bus_ck804_0, ((sbdn+0xa)<<3)|0, 0x1, 0xdef8, 0, 0, 0, 0, 0, 0, 0, 0); |
| 123 | pirq_info++; slot_num++; |
| 124 | |
| 125 | //Slot1 PCIE x16 |
| 126 | write_pirq_info(pirq_info, bus_ck804_5, (0<<3)|0, 0x3, 0xdef8, 0x4, 0xdef8, 0x1, 0xdef8, 0x2, 0xdef8, 1, 0); |
| 127 | pirq_info++; slot_num++; |
| 128 | |
| 129 | //firewire |
| 130 | write_pirq_info(pirq_info, bus_ck804_1, (0x5<<3)|0, 0x3, 0xdef8, 0, 0, 0, 0, 0, 0, 0, 0); |
| 131 | pirq_info++; slot_num++; |
| 132 | |
| 133 | //Slot2 pci |
| 134 | write_pirq_info(pirq_info, bus_ck804_1, (0x4<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 2, 0); |
| 135 | pirq_info++; slot_num++; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 136 | //nic |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 137 | write_pirq_info(pirq_info, bus_ck804b_0, ((sbdnb+0xa)<<3)|0, 0x1, 0xdef8, 0, 0, 0, 0, 0, 0, 0, 0); |
| 138 | pirq_info++; slot_num++; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 139 | //Slot3 PCIE x16 |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 140 | write_pirq_info(pirq_info, bus_ck804b_5, (0<<3)|0, 0x3, 0xdef8, 0x4, 0xdef8, 0x1, 0xdef8, 0x2, 0xdef8, 3, 0); |
| 141 | pirq_info++; slot_num++; |
| 142 | |
| 143 | //Slot4 PCIX |
| 144 | write_pirq_info(pirq_info, bus_8131_2, (4<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 4, 0); |
| 145 | pirq_info++; slot_num++; |
| 146 | |
| 147 | //Slot5 PCIX |
| 148 | write_pirq_info(pirq_info, bus_8131_2, (9<<3)|0, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0x1, 0xdef8, 5, 0); |
| 149 | pirq_info++; slot_num++; |
| 150 | |
| 151 | //onboard scsi |
| 152 | write_pirq_info(pirq_info, bus_8131_2, (6<<3)|0, 0x2, 0xdef8, 0x3, 0xdef8, 0, 0, 0, 0, 0, 0); |
| 153 | pirq_info++; slot_num++; |
| 154 | |
| 155 | //Slot6 PCIX |
| 156 | write_pirq_info(pirq_info, bus_8131_1, (4<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 6, 0); |
| 157 | pirq_info++; slot_num++; |
| 158 | #endif |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 159 | |
| 160 | pirq->size = 32 + 16 * slot_num; |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 161 | |
| 162 | for (i = 0; i < pirq->size; i++) |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 163 | sum += v[i]; |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 164 | |
| 165 | sum = pirq->checksum - sum; |
| 166 | |
| 167 | if (sum != pirq->checksum) { |
| 168 | pirq->checksum = sum; |
| 169 | } |
| 170 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 171 | printk(BIOS_INFO, "done.\n"); |
Ronald G. Minnich | 90e68ae | 2006-08-07 20:02:02 +0000 | [diff] [blame] | 172 | |
| 173 | return (unsigned long) pirq_info; |
| 174 | |
| 175 | } |