mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-04-28 19:03:41 +00:00
We had GIC specific defines for the IRQ type identifiers in kvmtool. But in fact the specification of being a level or edge interrupt is quite generic, with the GIC binding using the generic Linux defines. So lets replace the GIC specific #defines in favour of the more general names copied from Linux' include/linux/irq.h. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
42 lines
1.2 KiB
C
42 lines
1.2 KiB
C
#include "kvm/fdt.h"
|
|
#include "kvm/kvm.h"
|
|
#include "kvm/kvm-cpu.h"
|
|
#include "kvm/util.h"
|
|
|
|
#include "arm-common/gic.h"
|
|
#include "arm-common/timer.h"
|
|
|
|
void timer__generate_fdt_nodes(void *fdt, struct kvm *kvm, int *irqs)
|
|
{
|
|
const char compatible[] = "arm,armv8-timer\0arm,armv7-timer";
|
|
|
|
u32 cpu_mask = (((1 << kvm->nrcpus) - 1) << GIC_FDT_IRQ_PPI_CPU_SHIFT) \
|
|
& GIC_FDT_IRQ_PPI_CPU_MASK;
|
|
u32 irq_prop[] = {
|
|
cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI),
|
|
cpu_to_fdt32(irqs[0]),
|
|
cpu_to_fdt32(cpu_mask | IRQ_TYPE_EDGE_RISING),
|
|
|
|
cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI),
|
|
cpu_to_fdt32(irqs[1]),
|
|
cpu_to_fdt32(cpu_mask | IRQ_TYPE_EDGE_RISING),
|
|
|
|
cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI),
|
|
cpu_to_fdt32(irqs[2]),
|
|
cpu_to_fdt32(cpu_mask | IRQ_TYPE_EDGE_RISING),
|
|
|
|
cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI),
|
|
cpu_to_fdt32(irqs[3]),
|
|
cpu_to_fdt32(cpu_mask | IRQ_TYPE_EDGE_RISING),
|
|
};
|
|
|
|
_FDT(fdt_begin_node(fdt, "timer"));
|
|
_FDT(fdt_property(fdt, "compatible", compatible, sizeof(compatible)));
|
|
_FDT(fdt_property(fdt, "interrupts", irq_prop, sizeof(irq_prop)));
|
|
_FDT(fdt_property(fdt, "always-on", NULL, 0));
|
|
if (kvm->cfg.arch.force_cntfrq > 0)
|
|
_FDT(fdt_property_cell(fdt, "clock-frequency", kvm->cfg.arch.force_cntfrq));
|
|
_FDT(fdt_end_node(fdt));
|
|
}
|
|
|