1*909d7f77SJonathan Austin #include "kvm/fdt.h" 2*909d7f77SJonathan Austin #include "kvm/kvm.h" 3*909d7f77SJonathan Austin #include "kvm/kvm-cpu.h" 4*909d7f77SJonathan Austin #include "kvm/util.h" 5*909d7f77SJonathan Austin 6*909d7f77SJonathan Austin #include "arm-common/gic.h" 7*909d7f77SJonathan Austin #include "arm-common/timer.h" 8*909d7f77SJonathan Austin 9*909d7f77SJonathan Austin void timer__generate_fdt_nodes(void *fdt, struct kvm *kvm, int *irqs) 10*909d7f77SJonathan Austin { 11*909d7f77SJonathan Austin const char compatible[] = "arm,armv8-timer\0arm,armv7-timer"; 12*909d7f77SJonathan Austin 13*909d7f77SJonathan Austin u32 cpu_mask = (((1 << kvm->nrcpus) - 1) << GIC_FDT_IRQ_PPI_CPU_SHIFT) \ 14*909d7f77SJonathan Austin & GIC_FDT_IRQ_PPI_CPU_MASK; 15*909d7f77SJonathan Austin u32 irq_prop[] = { 16*909d7f77SJonathan Austin cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI), 17*909d7f77SJonathan Austin cpu_to_fdt32(irqs[0]), 18*909d7f77SJonathan Austin cpu_to_fdt32(cpu_mask | GIC_FDT_IRQ_FLAGS_EDGE_LO_HI), 19*909d7f77SJonathan Austin 20*909d7f77SJonathan Austin cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI), 21*909d7f77SJonathan Austin cpu_to_fdt32(irqs[1]), 22*909d7f77SJonathan Austin cpu_to_fdt32(cpu_mask | GIC_FDT_IRQ_FLAGS_EDGE_LO_HI), 23*909d7f77SJonathan Austin 24*909d7f77SJonathan Austin cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI), 25*909d7f77SJonathan Austin cpu_to_fdt32(irqs[2]), 26*909d7f77SJonathan Austin cpu_to_fdt32(cpu_mask | GIC_FDT_IRQ_FLAGS_EDGE_LO_HI), 27*909d7f77SJonathan Austin 28*909d7f77SJonathan Austin cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI), 29*909d7f77SJonathan Austin cpu_to_fdt32(irqs[3]), 30*909d7f77SJonathan Austin cpu_to_fdt32(cpu_mask | GIC_FDT_IRQ_FLAGS_EDGE_LO_HI), 31*909d7f77SJonathan Austin }; 32*909d7f77SJonathan Austin 33*909d7f77SJonathan Austin _FDT(fdt_begin_node(fdt, "timer")); 34*909d7f77SJonathan Austin _FDT(fdt_property(fdt, "compatible", compatible, sizeof(compatible))); 35*909d7f77SJonathan Austin _FDT(fdt_property(fdt, "interrupts", irq_prop, sizeof(irq_prop))); 36*909d7f77SJonathan Austin _FDT(fdt_end_node(fdt)); 37*909d7f77SJonathan Austin } 38