mb/google/brya: Create rull variant
[coreboot2.git] / src / mainboard / pcengines / apu2 / irq_tables.c
blob4d56145e7f3a5f556a653bd5d27bd25483604612
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>
6 #include <string.h>
7 #include <stdint.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,
13 u8 slot, u8 rfu)
15 pirq_info->bus = bus;
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;
26 pirq_info->rfu = rfu;
29 unsigned long write_pirq_routing_table(unsigned long addr)
31 struct irq_routing_table *pirq;
32 struct irq_info *pirq_info;
33 u32 slot_num;
34 u8 *v;
36 u8 sum = 0;
37 int i;
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);
46 v = (u8 *)(addr);
48 pirq->signature = PIRQ_SIGNATURE;
49 pirq->version = PIRQ_VERSION;
51 pirq->rtr_bus = 0;
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);
64 slot_num = 0;
66 /* pci bridge */
67 write_pirq_info(pirq_info, 0, PCI_DEVFN(0x14, 4),
68 0x1, 0xdee8, 0x2, 0xdee8, 0x3, 0xdee8, 0x4, 0xdee8, 0,
69 0);
70 pirq_info++;
72 slot_num++;
74 pirq->size = 32 + 16 * slot_num;
76 for (i = 0; i < pirq->size; i++)
77 sum += v[i];
79 sum = pirq->checksum - sum;
81 if (sum != pirq->checksum) {
82 pirq->checksum = sum;
85 printk(BIOS_INFO, "%s done.\n", __func__);
87 return (unsigned long)pirq_info;