Skip to content

Commit

Permalink
hw/misc/allwinner-dramc: Move sysbus_mmio_map call from init -> realize
Browse files Browse the repository at this point in the history
In order to make the next commit trivial, move the sysbus_init_mmio()
call in allwinner_r40_dramc_init() just before the corresponding
sysbus_mmio_map_overlap() call in allwinner_r40_dramc_realize().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20231019071611.98885-4-philmd@linaro.org>
  • Loading branch information
philmd committed Oct 19, 2023
1 parent a540087 commit d71af7c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions hw/misc/allwinner-r40-dramc.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,20 @@ static void allwinner_r40_dramc_reset(DeviceState *dev)
static void allwinner_r40_dramc_realize(DeviceState *dev, Error **errp)
{
AwR40DramCtlState *s = AW_R40_DRAMC(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);

if (!get_match_ddr(s->ram_size)) {
error_report("%s: ram-size %u MiB is not supported",
__func__, s->ram_size);
exit(1);
}

/* detect_cells */
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s), 3, s->ram_addr, 10);
/* R40 support max 2G memory but we only support up to 1G now. index 3 */
memory_region_init_io(&s->detect_cells, OBJECT(s),
&allwinner_r40_detect_ops, s,
"DRAMCELLS", 1 * GiB);
sysbus_init_mmio(sbd, &s->detect_cells);
sysbus_mmio_map_overlap(sbd, 3, s->ram_addr, 10);
memory_region_set_enabled(&s->detect_cells, false);

/*
Expand Down Expand Up @@ -458,12 +463,6 @@ static void allwinner_r40_dramc_init(Object *obj)
&allwinner_r40_dramphy_ops, s,
"DRAMPHY", 4 * KiB);
sysbus_init_mmio(sbd, &s->dramphy_iomem);

/* R40 support max 2G memory but we only support up to 1G now. index 3 */
memory_region_init_io(&s->detect_cells, OBJECT(s),
&allwinner_r40_detect_ops, s,
"DRAMCELLS", 1 * GiB);
sysbus_init_mmio(sbd, &s->detect_cells);
}

static Property allwinner_r40_dramc_properties[] = {
Expand Down

0 comments on commit d71af7c

Please sign in to comment.