mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
hw/riscv: virt: Add PMU DT node to the device tree
Qemu virt machine can support few cache events and cycle/instret counters. It also supports counter overflow for these events. Add a DT node so that OpenSBI/Linux kernel is aware of the virt machine capabilities. There are some dummy nodes added for testing as well. Acked-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com> Signed-off-by: Atish Patra <atishp@rivosinc.com> Message-Id: <20220824221701.41932-5-atishp@rivosinc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
892320facd
commit
abd9a20665
3 changed files with 74 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "hw/char/serial.h"
|
||||
#include "target/riscv/cpu.h"
|
||||
#include "hw/core/sysbus-fdt.h"
|
||||
#include "target/riscv/pmu.h"
|
||||
#include "hw/riscv/riscv_hart.h"
|
||||
#include "hw/riscv/virt.h"
|
||||
#include "hw/riscv/boot.h"
|
||||
|
@ -708,6 +709,20 @@ static void create_fdt_socket_aplic(RISCVVirtState *s,
|
|||
aplic_phandles[socket] = aplic_s_phandle;
|
||||
}
|
||||
|
||||
static void create_fdt_pmu(RISCVVirtState *s)
|
||||
{
|
||||
char *pmu_name;
|
||||
MachineState *mc = MACHINE(s);
|
||||
RISCVCPU hart = s->soc[0].harts[0];
|
||||
|
||||
pmu_name = g_strdup_printf("/soc/pmu");
|
||||
qemu_fdt_add_subnode(mc->fdt, pmu_name);
|
||||
qemu_fdt_setprop_string(mc->fdt, pmu_name, "compatible", "riscv,pmu");
|
||||
riscv_pmu_generate_fdt_node(mc->fdt, hart.cfg.pmu_num, pmu_name);
|
||||
|
||||
g_free(pmu_name);
|
||||
}
|
||||
|
||||
static void create_fdt_sockets(RISCVVirtState *s, const MemMapEntry *memmap,
|
||||
bool is_32_bit, uint32_t *phandle,
|
||||
uint32_t *irq_mmio_phandle,
|
||||
|
@ -1036,6 +1051,7 @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,
|
|||
|
||||
create_fdt_flash(s, memmap);
|
||||
create_fdt_fw_cfg(s, memmap);
|
||||
create_fdt_pmu(s);
|
||||
|
||||
update_bootargs:
|
||||
if (cmdline && *cmdline) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue