Commit 2bfd9ac3 authored by Andre Przywara's avatar Andre Przywara Committed by Will Deacon
Browse files

kvmtool: ARM: allow level interrupts in device tree



Currently we describe every interrupt for each device in the FDT
as being edge triggered.
Add a parameter to the irq property generation to allow devices to
specify their interrupts as level triggered if needed.

Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 045fc040
......@@ -74,12 +74,12 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
_FDT(fdt_end_node(fdt));
}
static void generate_irq_prop(void *fdt, u8 irq)
static void generate_irq_prop(void *fdt, u8 irq, enum irq_type irq_type)
{
u32 irq_prop[] = {
cpu_to_fdt32(GIC_FDT_IRQ_TYPE_SPI),
cpu_to_fdt32(irq - GIC_SPI_IRQ_BASE),
cpu_to_fdt32(IRQ_TYPE_EDGE_RISING),
cpu_to_fdt32(irq_type)
};
_FDT(fdt_property(fdt, "interrupts", irq_prop, sizeof(irq_prop)));
......@@ -127,7 +127,7 @@ static int setup_fdt(struct kvm *kvm)
void *fdt_dest = guest_flat_to_host(kvm,
kvm->arch.dtb_guest_start);
void (*generate_mmio_fdt_nodes)(void *, struct device_header *,
void (*)(void *, u8));
void (*)(void *, u8, enum irq_type));
void (*generate_cpu_peripheral_fdt_nodes)(void *, struct kvm *, u32)
= kvm->cpus[0]->generate_fdt_nodes;
......
......@@ -367,9 +367,11 @@ static bool serial8250_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port,
#ifdef CONFIG_HAS_LIBFDT
#define DEVICE_NAME_MAX_LEN 32
static void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt,
void (*generate_irq_prop)(void *fdt,
u8 irq))
static
void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt,
void (*generate_irq_prop)(void *fdt,
u8 irq,
enum irq_type))
{
char dev_name[DEVICE_NAME_MAX_LEN];
struct serial8250_device *dev = ioport->priv;
......@@ -384,7 +386,7 @@ static void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt,
_FDT(fdt_begin_node(fdt, dev_name));
_FDT(fdt_property_string(fdt, "compatible", "ns16550a"));
_FDT(fdt_property(fdt, "reg", reg_prop, sizeof(reg_prop)));
generate_irq_prop(fdt, dev->irq);
generate_irq_prop(fdt, dev->irq, IRQ_TYPE_EDGE_RISING);
_FDT(fdt_property_cell(fdt, "clock-frequency", 1843200));
_FDT(fdt_end_node(fdt));
}
......
......@@ -4,6 +4,7 @@
#include "kvm/devices.h"
#include "kvm/kvm-cpu.h"
#include "kvm/rbtree-interval.h"
#include "kvm/fdt.h"
#include <stdbool.h>
#include <limits.h>
......@@ -31,7 +32,9 @@ struct ioport_operations {
bool (*io_in)(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void *data, int size);
bool (*io_out)(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void *data, int size);
void (*generate_fdt_node)(struct ioport *ioport, void *fdt,
void (*generate_irq_prop)(void *fdt, u8 irq));
void (*generate_irq_prop)(void *fdt,
u8 irq,
enum irq_type));
};
void ioport__setup_arch(struct kvm *kvm);
......
......@@ -59,7 +59,8 @@ static void ioport_remove(struct rb_root *root, struct ioport *data)
static void generate_ioport_fdt_node(void *fdt,
struct device_header *dev_hdr,
void (*generate_irq_prop)(void *fdt,
u8 irq))
u8 irq,
enum irq_type))
{
struct ioport *ioport = container_of(dev_hdr, struct ioport, dev_hdr);
struct ioport_operations *ops = ioport->ops;
......@@ -71,7 +72,8 @@ static void generate_ioport_fdt_node(void *fdt,
static void generate_ioport_fdt_node(void *fdt,
struct device_header *dev_hdr,
void (*generate_irq_prop)(void *fdt,
u8 irq))
u8 irq,
enum irq_type))
{
die("Unable to generate device tree nodes without libfdt\n");
}
......
......@@ -230,10 +230,12 @@ static void virtio_mmio_mmio_callback(struct kvm_cpu *vcpu,
#ifdef CONFIG_HAS_LIBFDT
#define DEVICE_NAME_MAX_LEN 32
static void generate_virtio_mmio_fdt_node(void *fdt,
struct device_header *dev_hdr,
void (*generate_irq_prop)(void *fdt,
u8 irq))
static
void generate_virtio_mmio_fdt_node(void *fdt,
struct device_header *dev_hdr,
void (*generate_irq_prop)(void *fdt,
u8 irq,
enum irq_type))
{
char dev_name[DEVICE_NAME_MAX_LEN];
struct virtio_mmio *vmmio = container_of(dev_hdr,
......@@ -250,7 +252,7 @@ static void generate_virtio_mmio_fdt_node(void *fdt,
_FDT(fdt_begin_node(fdt, dev_name));
_FDT(fdt_property_string(fdt, "compatible", "virtio,mmio"));
_FDT(fdt_property(fdt, "reg", reg_prop, sizeof(reg_prop)));
generate_irq_prop(fdt, vmmio->irq);
generate_irq_prop(fdt, vmmio->irq, IRQ_TYPE_EDGE_RISING);
_FDT(fdt_end_node(fdt));
}
#else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment