Push the logic to talk with the MSI/MSI-X interrupt controller to the FDT

attachment. This is where it will live when we import intrng as it will
need to look at either the msi-parent or msi-map FDT properties.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Andrew Turner 2016-05-10 15:45:59 +00:00
parent 13a8942827
commit fb853e4270
2 changed files with 84 additions and 19 deletions

View File

@ -128,9 +128,9 @@ static struct resource * thunder_pem_alloc_resource(device_t, device_t, int,
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
static int thunder_pem_alloc_msi(device_t, device_t, int, int, int *);
static int thunder_pem_release_msi(device_t, device_t, int, int *);
static int thunder_pem_map_msi(device_t, device_t, int, uint64_t *, uint32_t *);
static int thunder_pem_alloc_msix(device_t, device_t, int *);
static int thunder_pem_release_msix(device_t, device_t, int);
static int thunder_pem_map_msi(device_t, device_t, int, uint64_t *, uint32_t *);
static int thunder_pem_attach(device_t);
static int thunder_pem_deactivate_resource(device_t, device_t, int, int,
struct resource *);
@ -177,11 +177,11 @@ static device_method_t thunder_pem_methods[] = {
DEVMETHOD(pcib_maxslots, thunder_pem_maxslots),
DEVMETHOD(pcib_read_config, thunder_pem_read_config),
DEVMETHOD(pcib_write_config, thunder_pem_write_config),
DEVMETHOD(pcib_map_msi, thunder_pem_map_msi),
DEVMETHOD(pcib_alloc_msix, thunder_pem_alloc_msix),
DEVMETHOD(pcib_release_msix, thunder_pem_release_msix),
DEVMETHOD(pcib_alloc_msi, thunder_pem_alloc_msi),
DEVMETHOD(pcib_release_msi, thunder_pem_release_msi),
DEVMETHOD(pcib_map_msi, thunder_pem_map_msi),
DEVMETHOD_END
};
@ -327,37 +327,48 @@ static int
thunder_pem_alloc_msi(device_t pci, device_t child, int count, int maxcount,
int *irqs)
{
device_t bus;
return (arm_alloc_msi(pci, child, count, maxcount, irqs));
bus = device_get_parent(pci);
return (PCIB_ALLOC_MSI(device_get_parent(bus), child, count, maxcount,
irqs));
}
static int
thunder_pem_release_msi(device_t pci, device_t child, int count, int *irqs)
{
device_t bus;
return (arm_release_msi(pci, child, count, irqs));
bus = device_get_parent(pci);
return (PCIB_RELEASE_MSI(device_get_parent(bus), child, count, irqs));
}
static int
thunder_pem_alloc_msix(device_t pci, device_t child, int *irq)
{
device_t bus;
bus = device_get_parent(pci);
return (PCIB_ALLOC_MSIX(device_get_parent(bus), child, irq));
}
static int
thunder_pem_release_msix(device_t pci, device_t child, int irq)
{
device_t bus;
bus = device_get_parent(pci);
return (PCIB_RELEASE_MSIX(device_get_parent(bus), child, irq));
}
static int
thunder_pem_map_msi(device_t pci, device_t child, int irq, uint64_t *addr,
uint32_t *data)
{
device_t bus;
return (arm_map_msi(pci, child, irq, addr, data));
}
static int
thunder_pem_alloc_msix(device_t pci, device_t child, int *irq)
{
return (arm_alloc_msix(pci, child, irq));
}
static int
thunder_pem_release_msix(device_t pci, device_t child, int irq)
{
return (arm_release_msix(pci, child, irq));
bus = device_get_parent(pci);
return (PCIB_MAP_MSI(device_get_parent(bus), child, irq, addr, data));
}
static int

View File

@ -51,15 +51,32 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcib_private.h>
#include <dev/pci/pci_host_generic.h>
#include <machine/intr.h>
#include "thunder_pcie_common.h"
#include "thunder_pcie_pem.h"
#include "pcib_if.h"
static int thunder_pem_fdt_probe(device_t);
static int thunder_pem_fdt_alloc_msix(device_t, device_t, int *);
static int thunder_pem_fdt_release_msix(device_t, device_t, int);
static int thunder_pem_fdt_alloc_msi(device_t, device_t, int, int, int *);
static int thunder_pem_fdt_release_msi(device_t, device_t, int, int *);
static int thunder_pem_fdt_map_msi(device_t, device_t, int, uint64_t *,
uint32_t *);
static device_method_t thunder_pem_fdt_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, thunder_pem_fdt_probe),
/* pcib interface */
DEVMETHOD(pcib_alloc_msix, thunder_pem_fdt_alloc_msix),
DEVMETHOD(pcib_release_msix, thunder_pem_fdt_release_msix),
DEVMETHOD(pcib_alloc_msi, thunder_pem_fdt_alloc_msi),
DEVMETHOD(pcib_release_msi, thunder_pem_fdt_release_msi),
DEVMETHOD(pcib_map_msi, thunder_pem_fdt_map_msi),
/* End */
DEVMETHOD_END
};
@ -88,3 +105,40 @@ thunder_pem_fdt_probe(device_t dev)
return (ENXIO);
}
static int
thunder_pem_fdt_alloc_msi(device_t pci, device_t child, int count, int maxcount,
int *irqs)
{
return (arm_alloc_msi(pci, child, count, maxcount, irqs));
}
static int
thunder_pem_fdt_release_msi(device_t pci, device_t child, int count, int *irqs)
{
return (arm_release_msi(pci, child, count, irqs));
}
static int
thunder_pem_fdt_alloc_msix(device_t pci, device_t child, int *irq)
{
return (arm_alloc_msix(pci, child, irq));
}
static int
thunder_pem_fdt_release_msix(device_t pci, device_t child, int irq)
{
return (arm_release_msix(pci, child, irq));
}
static int
thunder_pem_fdt_map_msi(device_t pci, device_t child, int irq, uint64_t *addr,
uint32_t *data)
{
return (arm_map_msi(pci, child, irq, addr, data));
}