]> git.sur5r.net Git - u-boot/blobdiff - arch/x86/lib/pirq_routing.c
x86: doc: Fix reference to EFI doc in U-Boot
[u-boot] / arch / x86 / lib / pirq_routing.c
index ba4116908c92017b9267215bf090e1ea30dce220..e5f0e6142418930c65ec35b8f3064ec7f50fd3f5 100644 (file)
@@ -1,20 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  *
  * Part of this file is ported from coreboot src/arch/x86/boot/pirq_routing.c
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <pci.h>
 #include <asm/pci.h>
 #include <asm/pirq_routing.h>
-#include <asm/tables.h>
-
-static bool irq_already_routed[16];
 
-static u8 pirq_get_next_free_irq(u8 *pirq, u16 bitmap)
+static u8 pirq_get_next_free_irq(struct udevice *dev, u8 *pirq, u16 bitmap,
+                                bool irq_already_routed[])
 {
        int i, link;
        u8 irq = 0;
@@ -33,7 +30,7 @@ static u8 pirq_get_next_free_irq(u8 *pirq, u16 bitmap)
                        continue;
 
                for (link = 0; link < CONFIG_MAX_PIRQ_LINKS; link++) {
-                       if (pirq_check_irq_routed(link, irq)) {
+                       if (pirq_check_irq_routed(dev, link, irq)) {
                                irq_already_routed[irq] = true;
                                break;
                        }
@@ -52,13 +49,15 @@ static u8 pirq_get_next_free_irq(u8 *pirq, u16 bitmap)
        return irq;
 }
 
-void pirq_route_irqs(struct irq_info *irq, int num)
+void pirq_route_irqs(struct udevice *dev, struct irq_info *irq, int num)
 {
        unsigned char irq_slot[MAX_INTX_ENTRIES];
        unsigned char pirq[CONFIG_MAX_PIRQ_LINKS];
+       bool irq_already_routed[16];
        int i, intx;
 
        memset(pirq, 0, CONFIG_MAX_PIRQ_LINKS);
+       memset(irq_already_routed, '\0', sizeof(irq_already_routed));
 
        /* Set PCI IRQs */
        for (i = 0; i < num; i++) {
@@ -80,11 +79,12 @@ void pirq_route_irqs(struct irq_info *irq, int num)
                        }
 
                        /* translate link value to link number */
-                       link = pirq_translate_link(link);
+                       link = pirq_translate_link(dev, link);
 
                        /* yet not routed */
                        if (!pirq[link]) {
-                               irq = pirq_get_next_free_irq(pirq, bitmap);
+                               irq = pirq_get_next_free_irq(dev, pirq, bitmap,
+                                               irq_already_routed);
                                pirq[link] = irq;
                        } else {
                                irq = pirq[link];
@@ -94,7 +94,7 @@ void pirq_route_irqs(struct irq_info *irq, int num)
                        irq_slot[intx] = irq;
 
                        /* Assign IRQ in the interrupt router */
-                       pirq_assign_irq(link, irq);
+                       pirq_assign_irq(dev, link, irq);
                }
 
                /* Bus, device, slots IRQs for {A,B,C,D} */
@@ -111,21 +111,18 @@ u32 copy_pirq_routing_table(u32 addr, struct irq_routing_table *rt)
 {
        struct irq_routing_table *rom_rt;
 
-       /* Fix up the table checksum */
-       rt->checksum = table_compute_checksum(rt, rt->size);
-
        /* Align the table to be 16 byte aligned */
        addr = ALIGN(addr, 16);
 
        debug("Copying Interrupt Routing Table to 0x%x\n", addr);
-       memcpy((void *)addr, rt, rt->size);
+       memcpy((void *)(uintptr_t)addr, rt, rt->size);
 
        /*
         * We do the sanity check here against the copied table after memcpy,
         * as something might go wrong after the memcpy, which is normally
         * due to the F segment decode is not turned on to systeam RAM.
         */
-       rom_rt = (struct irq_routing_table *)addr;
+       rom_rt = (struct irq_routing_table *)(uintptr_t)addr;
        if (rom_rt->signature != PIRQ_SIGNATURE ||
            rom_rt->version != PIRQ_VERSION || rom_rt->size % 16) {
                printf("Interrupt Routing Table not valid\n");