1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <commonlib/bsd/helpers.h>
5 #include <device/pci_def.h>
8 #include <arch/pirq_routing.h>
10 static void write_pirq_info(struct irq_info
*pirq_info
, u8 bus
, u8 devfn
,
11 u8 link0
, u16 bitmap0
, u8 link1
, u16 bitmap1
,
12 u8 link2
, u16 bitmap2
, u8 link3
, u16 bitmap3
,
16 pirq_info
->devfn
= devfn
;
17 pirq_info
->irq
[0].link
= link0
;
18 pirq_info
->irq
[0].bitmap
= bitmap0
;
19 pirq_info
->irq
[1].link
= link1
;
20 pirq_info
->irq
[1].bitmap
= bitmap1
;
21 pirq_info
->irq
[2].link
= link2
;
22 pirq_info
->irq
[2].bitmap
= bitmap2
;
23 pirq_info
->irq
[3].link
= link3
;
24 pirq_info
->irq
[3].bitmap
= bitmap3
;
25 pirq_info
->slot
= slot
;
29 unsigned long write_pirq_routing_table(unsigned long addr
)
31 struct irq_routing_table
*pirq
;
32 struct irq_info
*pirq_info
;
39 /* Align the table to be 16 byte aligned. */
40 addr
= ALIGN_UP(addr
, 16);
42 /* This table must be between 0xf0000 & 0x100000 */
43 printk(BIOS_INFO
, "Writing IRQ routing tables to 0x%lx...", addr
);
45 pirq
= (void *)(addr
);
48 pirq
->signature
= PIRQ_SIGNATURE
;
49 pirq
->version
= PIRQ_VERSION
;
52 pirq
->rtr_devfn
= PCI_DEVFN(0x14, 4);
54 pirq
->exclusive_irqs
= 0;
56 pirq
->rtr_vendor
= 0x1002;
57 pirq
->rtr_device
= 0x4384;
59 pirq
->miniport_data
= 0;
61 memset(pirq
->rfu
, 0, sizeof(pirq
->rfu
));
63 pirq_info
= (void *)(&pirq
->checksum
+ 1);
67 write_pirq_info(pirq_info
, 0, PCI_DEVFN(0x14, 4),
68 0x1, 0xdee8, 0x2, 0xdee8, 0x3, 0xdee8, 0x4, 0xdee8, 0,
74 pirq
->size
= 32 + 16 * slot_num
;
76 for (i
= 0; i
< pirq
->size
; i
++)
79 sum
= pirq
->checksum
- sum
;
81 if (sum
!= pirq
->checksum
) {
85 printk(BIOS_INFO
, "%s done.\n", __func__
);
87 return (unsigned long)pirq_info
;