2 * This file is part of the coreboot project.
4 * Copyright (C) 2012 Advanced Micro Devices, Inc.
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.
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.
16 #include <console/console.h>
17 #include <device/pci.h>
20 #include <arch/pirq_routing.h>
21 #include <cpu/amd/amdfam16.h>
23 static void write_pirq_info(struct irq_info
*pirq_info
, u8 bus
, u8 devfn
,
24 u8 link0
, u16 bitmap0
, u8 link1
, u16 bitmap1
,
25 u8 link2
, u16 bitmap2
, u8 link3
, u16 bitmap3
,
29 pirq_info
->devfn
= devfn
;
30 pirq_info
->irq
[0].link
= link0
;
31 pirq_info
->irq
[0].bitmap
= bitmap0
;
32 pirq_info
->irq
[1].link
= link1
;
33 pirq_info
->irq
[1].bitmap
= bitmap1
;
34 pirq_info
->irq
[2].link
= link2
;
35 pirq_info
->irq
[2].bitmap
= bitmap2
;
36 pirq_info
->irq
[3].link
= link3
;
37 pirq_info
->irq
[3].bitmap
= bitmap3
;
38 pirq_info
->slot
= slot
;
43 unsigned long write_pirq_routing_table(unsigned long addr
)
45 struct irq_routing_table
*pirq
;
46 struct irq_info
*pirq_info
;
53 /* Align the table to be 16 byte aligned. */
57 /* This table must be between 0xf0000 & 0x100000 */
58 printk(BIOS_INFO
, "Writing IRQ routing tables to 0x%lx...", addr
);
60 pirq
= (void *)(addr
);
63 pirq
->signature
= PIRQ_SIGNATURE
;
64 pirq
->version
= PIRQ_VERSION
;
67 pirq
->rtr_devfn
= PCI_DEVFN(0x14, 4);
69 pirq
->exclusive_irqs
= 0;
71 pirq
->rtr_vendor
= 0x1002;
72 pirq
->rtr_device
= 0x4384;
74 pirq
->miniport_data
= 0;
76 memset(pirq
->rfu
, 0, sizeof(pirq
->rfu
));
78 pirq_info
= (void *)(&pirq
->checksum
+ 1);
82 write_pirq_info(pirq_info
, 0, PCI_DEVFN(0x14, 4),
83 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0,
89 pirq
->size
= 32 + 16 * slot_num
;
91 for (i
= 0; i
< pirq
->size
; i
++)
94 sum
= pirq
->checksum
- sum
;
96 if (sum
!= pirq
->checksum
) {
100 printk(BIOS_INFO
, "write_pirq_routing_table done.\n");
102 return (unsigned long)pirq_info
;