Skip to content

Commit

Permalink
versal: add LPD INT config and status register block
Browse files Browse the repository at this point in the history
Split the LPD INT CSR state structure into a header file for
inclusion in Versal SoC.

There is a large gap in the register space from R_IR_DISABLE_MISSION2
to R_LPD_AFIFM_ADMA_APB, which results in a large unused space
allocated as part of the reg array in the state structure.
Since HVP does not attempt to configure the registers at 0x10000
offset and above, I have commented out these registers and associated
handlers.

Contains meson changes to build the LPD interrupt config device when
Xilinx Versal is configured to be built.

Signed-off-by: Nelson Ho <[email protected]>
  • Loading branch information
ho28 committed Dec 10, 2024
1 parent 92330dc commit 45823bd
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 27 deletions.
1 change: 1 addition & 0 deletions hw/misc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ system_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files(
'xlnx-versal-lpd-iou-slcr.c',
'xlnx-versal-lpd-slcr.c',
'xlnx-serbs.c',
'xlnx-versal-intlpd-config.c',
))
system_ss.add(when: 'CONFIG_XLNX_VERSAL_TRNG', if_true: files(
'xlnx-versal-trng.c',
Expand Down
52 changes: 25 additions & 27 deletions hw/misc/xlnx-versal-intlpd-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@
* QEMU model of the INTLPD_CONFIG LPD Interconnect isolation, reset and
* status registers
*
* Copyright (c) 2023, Advanced Micro Devices, Inc.
* Copyright (c) 2024 Wind River Systems, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Autogenerated by xregqemu.py 2023-08-02.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Copyright (c) 2023, Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -32,20 +45,13 @@
#include "qemu/log.h"
#include "migration/vmstate.h"
#include "hw/irq.h"
#include "hw/misc/xlnx-serbs.h"
#include "hw/qdev-properties.h"
#include "hw/misc/xlnx-versal-intlpd-config.h"

#ifndef XILINX_INTLPD_CONFIG_ERR_DEBUG
#define XILINX_INTLPD_CONFIG_ERR_DEBUG 0
#endif

#define TYPE_XILINX_INTLPD_CONFIG "xlnx-intlpd-config"

#define XILINX_INTLPD_CONFIG(obj) \
OBJECT_CHECK(INTLPD_CONFIG, (obj), TYPE_XILINX_INTLPD_CONFIG)

#define AFIFS_SERBS_ID 1

REG32(IR_STATUS, 0x0)
FIELD(IR_STATUS, IF_INTLPD_OCM2_AXI_T_MAINTIMEOUT, 31, 1)
FIELD(IR_STATUS, IF_INTLPD_HSDP_APB_T_MAINTIMEOUT, 30, 1)
Expand Down Expand Up @@ -399,6 +405,7 @@ REG32(IR_DISABLE_MISSION2, 0xac)
FIELD(IR_DISABLE_MISSION2, CPM_PS_AXI0, 2, 1)
FIELD(IR_DISABLE_MISSION2, AFIFM_LPD_AXI, 1, 1)
FIELD(IR_DISABLE_MISSION2, ADMA_LPD_AXI, 0, 1)
/*
REG32(LPD_AFIFM_ADMA_APB, 0x10000)
FIELD(LPD_AFIFM_ADMA_APB, RAW_RST_N, 4, 1)
FIELD(LPD_AFIFM_ADMA_APB, POWER_IDLEREQ, 3, 1)
Expand Down Expand Up @@ -513,22 +520,9 @@ REG32(INTLPD_OCM2_AXI, 0x1f0000)
FIELD(INTLPD_OCM2_AXI, POWER_IDLEACK, 2, 1)
FIELD(INTLPD_OCM2_AXI, POWER_IDLE, 1, 1)
FIELD(INTLPD_OCM2_AXI, MAINEXTEN, 0, 1)
*/

#define INTLPD_CONFIG_R_MAX (R_INTLPD_OCM2_AXI + 1)

typedef struct INTLPD_CONFIG {
SysBusDevice parent_obj;
MemoryRegion iomem;
qemu_irq irq_ir_mission1;
qemu_irq irq_ir_mission2;
qemu_irq irq_ir;
qemu_irq irq_ir_perr;

xlnx_serbs_if *AFIFSSerbs;
int tov;
uint32_t regs[INTLPD_CONFIG_R_MAX];
RegisterInfo regs_info[INTLPD_CONFIG_R_MAX];
} INTLPD_CONFIG;
G_STATIC_ASSERT(INTLPD_CONFIG_R_MAX == (R_IR_DISABLE_MISSION2 + 1));

static void ir_mission1_update_irq(INTLPD_CONFIG *s)
{
Expand Down Expand Up @@ -664,6 +658,7 @@ static uint64_t ir_disable_perr_prew(RegisterInfo *reg, uint64_t val64)
return 0;
}

/*
static void intlpd_afifslpd_axi_postw(RegisterInfo *reg, uint64_t val64)
{
INTLPD_CONFIG *s = XILINX_INTLPD_CONFIG(reg->opaque);
Expand All @@ -673,6 +668,7 @@ static void intlpd_afifslpd_axi_postw(RegisterInfo *reg, uint64_t val64)
ARRAY_FIELD_EX32(s->regs, INTLPD_AFIFSLPD_AXI, MAINEXTEN));
}
}
*/

static const RegisterAccessInfo intlpd_config_regs_info[] = {
{ .name = "IR_STATUS", .addr = A_IR_STATUS,
Expand Down Expand Up @@ -747,6 +743,7 @@ static const RegisterAccessInfo intlpd_config_regs_info[] = {
},{ .name = "IR_DISABLE_MISSION2", .addr = A_IR_DISABLE_MISSION2,
.rsvd = 0xe0000000,
.pre_write = ir_disable_mission2_prew,
/*
},{ .name = "LPD_AFIFM_ADMA_APB", .addr = A_LPD_AFIFM_ADMA_APB,
.reset = 0x16,
.rsvd = 0xffffffe0,
Expand Down Expand Up @@ -824,6 +821,7 @@ static const RegisterAccessInfo intlpd_config_regs_info[] = {
.reset = 0x16,
.rsvd = 0xffffffe0,
.ro = 0x6,
*/
}
};

Expand All @@ -837,7 +835,7 @@ static void intlpd_config_reset_enter(Object *obj, ResetType type)
}
}

static void intlpd_config_reset_hold(Object *obj)
static void intlpd_config_reset_hold(Object *obj, ResetType type)
{
INTLPD_CONFIG *s = XILINX_INTLPD_CONFIG(obj);

Expand Down Expand Up @@ -907,7 +905,7 @@ static void intlpd_config_init(Object *obj)
sysbus_init_irq(sbd, &s->irq_ir_perr);
object_property_add_link(obj, "afifs-serbs", TYPE_XLNX_SERBS_IF,
(Object **)&s->AFIFSSerbs,
qdev_prop_allow_set_link,
qdev_prop_allow_set_link_before_realize,
OBJ_PROP_LINK_STRONG);
}

Expand Down
51 changes: 51 additions & 0 deletions include/hw/misc/xlnx-versal-intlpd-config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* xlnx-versal-intlpd-config.h
*
* QEMU model of Xilinx LPD interrupt configuration and status registers
*
* Copyright (c) 2024 Wind River Systems, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef XLNX_VERSAL_INTLPD_CONFIG_H
#define XLNX_VERSAL_INTLPD_CONFIG_H

#include "hw/misc/xlnx-serbs.h"
#include "qom/object.h"

#define TYPE_XILINX_INTLPD_CONFIG "xlnx-intlpd-config"

#define XILINX_INTLPD_CONFIG(obj) \
OBJECT_CHECK(INTLPD_CONFIG, (obj), TYPE_XILINX_INTLPD_CONFIG)

#define AFIFS_SERBS_ID 1

#define INTLPD_CONFIG_R_MAX 44

typedef struct INTLPD_CONFIG {
SysBusDevice parent_obj;
MemoryRegion iomem;
qemu_irq irq_ir_mission1;
qemu_irq irq_ir_mission2;
qemu_irq irq_ir;
qemu_irq irq_ir_perr;

xlnx_serbs_if *AFIFSSerbs;
int tov;
uint32_t regs[INTLPD_CONFIG_R_MAX];
RegisterInfo regs_info[INTLPD_CONFIG_R_MAX];
} INTLPD_CONFIG;

#endif /* XLNX_VERSAL_INTLPD_CONFIG_H */

0 comments on commit 45823bd

Please sign in to comment.