Skip to content

Commit

Permalink
versal: split lpd iou slcr state into header file
Browse files Browse the repository at this point in the history
Create a header file for LPD IOU SLCR control registers
so that the the device state can be included as a member
of the Versal SoC definition.

Signed-off-by: Nelson Ho <[email protected]>
  • Loading branch information
ho28 committed Dec 6, 2024
1 parent 1a5a6f9 commit 3654a48
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 20 deletions.
25 changes: 5 additions & 20 deletions hw/misc/xlnx-versal-lpd-iou-slcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,16 @@

#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/register.h"
#include "qemu/bitops.h"
#include "qemu/log.h"
#include "migration/vmstate.h"
#include "hw/irq.h"
#include "hw/misc/xlnx-versal-lpd-iou-slcr.h"

#ifndef XILINX_LPD_IOU_SLCR_ERR_DEBUG
#define XILINX_LPD_IOU_SLCR_ERR_DEBUG 0
#endif

#define TYPE_XILINX_LPD_IOU_SLCR "xlnx.versal-lpd-iou-slcr"

#define XILINX_LPD_IOU_SLCR(obj) \
OBJECT_CHECK(LPD_IOU_SLCR, (obj), TYPE_XILINX_LPD_IOU_SLCR)

REG32(MIO_PIN_0, 0x0)
FIELD(MIO_PIN_0, L3_SEL, 7, 3)
FIELD(MIO_PIN_0, L2_SEL, 5, 2)
Expand Down Expand Up @@ -416,17 +411,7 @@ REG32(PARITY_ITR, 0x724)
REG32(WPROT0, 0x728)
FIELD(WPROT0, ACTIVE, 0, 1)

#define LPD_IOU_SLCR_R_MAX (R_WPROT0 + 1)

typedef struct LPD_IOU_SLCR {
SysBusDevice parent_obj;
MemoryRegion iomem;
qemu_irq irq_parity_imr;
qemu_irq irq_imr;

uint32_t regs[LPD_IOU_SLCR_R_MAX];
RegisterInfo regs_info[LPD_IOU_SLCR_R_MAX];
} LPD_IOU_SLCR;
G_STATIC_ASSERT(LPD_IOU_SLCR_R_MAX == R_WPROT0 + 1);

static void parity_imr_update_irq(LPD_IOU_SLCR *s)
{
Expand Down Expand Up @@ -686,7 +671,7 @@ static void lpd_iou_slcr_init(Object *obj)
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
RegisterInfoArray *reg_array;

memory_region_init(&s->iomem, obj, TYPE_XILINX_LPD_IOU_SLCR, LPD_IOU_SLCR_R_MAX * 4);
memory_region_init(&s->iomem, obj, TYPE_XLNX_LPD_IOU_SLCR, LPD_IOU_SLCR_R_MAX * 4);
reg_array =
register_init_block32(DEVICE(obj), lpd_iou_slcr_regs_info,
ARRAY_SIZE(lpd_iou_slcr_regs_info),
Expand All @@ -703,7 +688,7 @@ static void lpd_iou_slcr_init(Object *obj)
}

static const VMStateDescription vmstate_lpd_iou_slcr = {
.name = TYPE_XILINX_LPD_IOU_SLCR,
.name = TYPE_XLNX_LPD_IOU_SLCR,
.version_id = 1,
.minimum_version_id = 1,
.fields = (VMStateField[]) {
Expand All @@ -722,7 +707,7 @@ static void lpd_iou_slcr_class_init(ObjectClass *klass, void *data)
}

static const TypeInfo lpd_iou_slcr_info = {
.name = TYPE_XILINX_LPD_IOU_SLCR,
.name = TYPE_XLNX_LPD_IOU_SLCR,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(LPD_IOU_SLCR),
.class_init = lpd_iou_slcr_class_init,
Expand Down
47 changes: 47 additions & 0 deletions include/hw/misc/xlnx-versal-lpd-iou-slcr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* xlnx-versal-lpd-iou-slcr.h
*
* QEMU model of Xilinx LPD System Level Control Registers for IOU
*
* 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_LPD_IOU_SLCR_H
#define XLNX_VERSAL_LPD_IOU_SLCR_H

#include "hw/register.h"
#include "qom/object.h"

#define TYPE_XLNX_LPD_IOU_SLCR "xlnx.versal-lpd-iou-slcr"

OBJECT_DECLARE_SIMPLE_TYPE(LPD_IOU_SLCR, XLNX_LPD_IOU_SLCR)

#define XILINX_LPD_IOU_SLCR(obj) \
OBJECT_CHECK(LPD_IOU_SLCR, (obj), TYPE_XLNX_LPD_IOU_SLCR)

#define LPD_IOU_SLCR_R_MAX 459

typedef struct LPD_IOU_SLCR {
SysBusDevice parent_obj;
MemoryRegion iomem;
qemu_irq irq_parity_imr;
qemu_irq irq_imr;

uint32_t regs[LPD_IOU_SLCR_R_MAX];
RegisterInfo regs_info[LPD_IOU_SLCR_R_MAX];
} LPD_IOU_SLCR;

#endif /* XLNX_VERSAL_LPD_IOU_SLCR_H */

0 comments on commit 3654a48

Please sign in to comment.