Skip to content

Commit 24ce762

Browse files
philmdalistair23
authored andcommitted
hw/char/mchp_pfsoc_mmuart: Use a MemoryRegion container
Our device have 2 different I/O regions: - a 16550 UART mapped for 32-bit accesses - 13 extra registers Instead of mapping each region on the main bus, introduce a container, map the 2 devices regions on the container, and map the container on the main bus. Before: (qemu) info mtree ... 0000000020100000-000000002010001f (prio 0, i/o): serial 0000000020100020-000000002010101f (prio 0, i/o): mchp.pfsoc.mmuart 0000000020102000-000000002010201f (prio 0, i/o): serial 0000000020102020-000000002010301f (prio 0, i/o): mchp.pfsoc.mmuart 0000000020104000-000000002010401f (prio 0, i/o): serial 0000000020104020-000000002010501f (prio 0, i/o): mchp.pfsoc.mmuart 0000000020106000-000000002010601f (prio 0, i/o): serial 0000000020106020-000000002010701f (prio 0, i/o): mchp.pfsoc.mmuart After: (qemu) info mtree ... 0000000020100000-0000000020100fff (prio 0, i/o): mchp.pfsoc.mmuart 0000000020100000-000000002010001f (prio 0, i/o): serial 0000000020100020-0000000020100fff (prio 0, i/o): mchp.pfsoc.mmuart.regs 0000000020102000-0000000020102fff (prio 0, i/o): mchp.pfsoc.mmuart 0000000020102000-000000002010201f (prio 0, i/o): serial 0000000020102020-0000000020102fff (prio 0, i/o): mchp.pfsoc.mmuart.regs 0000000020104000-0000000020104fff (prio 0, i/o): mchp.pfsoc.mmuart 0000000020104000-000000002010401f (prio 0, i/o): serial 0000000020104020-0000000020104fff (prio 0, i/o): mchp.pfsoc.mmuart.regs 0000000020106000-0000000020106fff (prio 0, i/o): mchp.pfsoc.mmuart 0000000020106000-000000002010601f (prio 0, i/o): serial 0000000020106020-0000000020106fff (prio 0, i/o): mchp.pfsoc.mmuart.regs Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Tested-by: Bin Meng <[email protected]> Message-id: [email protected] Signed-off-by: Alistair Francis <[email protected]>
1 parent 284a66a commit 24ce762

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

hw/char/mchp_pfsoc_mmuart.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "chardev/char.h"
2626
#include "hw/char/mchp_pfsoc_mmuart.h"
2727

28+
#define REGS_OFFSET 0x20
29+
2830
static uint64_t mchp_pfsoc_mmuart_read(void *opaque, hwaddr addr, unsigned size)
2931
{
3032
MchpPfSoCMMUartState *s = opaque;
@@ -72,16 +74,19 @@ MchpPfSoCMMUartState *mchp_pfsoc_mmuart_create(MemoryRegion *sysmem,
7274

7375
s = g_new0(MchpPfSoCMMUartState, 1);
7476

77+
memory_region_init(&s->container, NULL, "mchp.pfsoc.mmuart", 0x1000);
78+
7579
memory_region_init_io(&s->iomem, NULL, &mchp_pfsoc_mmuart_ops, s,
76-
"mchp.pfsoc.mmuart", 0x1000);
80+
"mchp.pfsoc.mmuart.regs", 0x1000 - REGS_OFFSET);
81+
memory_region_add_subregion(&s->container, REGS_OFFSET, &s->iomem);
7782

7883
s->base = base;
7984
s->irq = irq;
8085

81-
s->serial = serial_mm_init(sysmem, base, 2, irq, 399193, chr,
86+
s->serial = serial_mm_init(&s->container, 0, 2, irq, 399193, chr,
8287
DEVICE_LITTLE_ENDIAN);
8388

84-
memory_region_add_subregion(sysmem, base + 0x20, &s->iomem);
89+
memory_region_add_subregion(sysmem, base, &s->container);
8590

8691
return s;
8792
}

include/hw/char/mchp_pfsoc_mmuart.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define MCHP_PFSOC_MMUART_REG_COUNT 13
3434

3535
typedef struct MchpPfSoCMMUartState {
36+
MemoryRegion container;
3637
MemoryRegion iomem;
3738
hwaddr base;
3839
qemu_irq irq;

0 commit comments

Comments
 (0)