[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 34/46] hw/misc/allwinner-dramc: Do not use SysBus API to map local
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 34/46] hw/misc/allwinner-dramc: Do not use SysBus API to map local MMIO region |
Date: |
Thu, 19 Oct 2023 23:17:59 +0200 |
There is no point in exposing an internal MMIO region via
SysBus and directly mapping it in the very same device.
Just map it without using the SysBus API.
Transformation done using the following coccinelle script:
@@
expression sbdev;
expression index;
expression addr;
expression subregion;
@@
- sysbus_init_mmio(sbdev, subregion);
... when != sbdev
- sysbus_mmio_map(sbdev, index, addr);
+ memory_region_add_subregion(get_system_memory(),
+ addr, subregion);
@@
expression priority;
@@
- sysbus_init_mmio(sbdev, subregion);
... when != sbdev
- sysbus_mmio_map_overlap(sbdev, index, addr, priority);
+ memory_region_add_subregion_overlap(get_system_memory(),
+ addr,
+ subregion, priority);
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20231019071611.98885-5-philmd@linaro.org>
---
hw/misc/allwinner-r40-dramc.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/hw/misc/allwinner-r40-dramc.c b/hw/misc/allwinner-r40-dramc.c
index 2cc0254a55..3d81ddb2e1 100644
--- a/hw/misc/allwinner-r40-dramc.c
+++ b/hw/misc/allwinner-r40-dramc.c
@@ -414,7 +414,6 @@ 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",
@@ -422,23 +421,23 @@ static void allwinner_r40_dramc_realize(DeviceState *dev,
Error **errp)
exit(1);
}
- /* R40 support max 2G memory but we only support up to 1G now. index 3 */
+ /* R40 support max 2G memory but we only support up to 1G now. */
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_add_subregion_overlap(get_system_memory(), s->ram_addr,
+ &s->detect_cells, 10);
memory_region_set_enabled(&s->detect_cells, false);
/*
* We only support DRAM size up to 1G now, so prepare a high memory page
- * after 1G for dualrank detect. index = 4
+ * after 1G for dualrank detect.
*/
memory_region_init_io(&s->dram_high, OBJECT(s),
&allwinner_r40_dualrank_detect_ops, s,
"DRAMHIGH", KiB);
- sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->dram_high);
- sysbus_mmio_map(SYS_BUS_DEVICE(s), 4, s->ram_addr + GiB);
+ memory_region_add_subregion(get_system_memory(), s->ram_addr + GiB,
+ &s->dram_high);
}
static void allwinner_r40_dramc_init(Object *obj)
--
2.41.0
- [PULL 24/46] hw/ppc/pnv_xscom: Rename pnv_xscom_realize(Error **) -> pnv_xscom_init(), (continued)
- [PULL 24/46] hw/ppc/pnv_xscom: Rename pnv_xscom_realize(Error **) -> pnv_xscom_init(), Philippe Mathieu-Daudé, 2023/10/19
- [PULL 25/46] hw/ppc/pnv_xscom: Move sysbus_mmio_map() call within pnv_xscom_init(), Philippe Mathieu-Daudé, 2023/10/19
- [PULL 26/46] hw/ppc/pnv_xscom: Do not use SysBus API to map local MMIO region, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 27/46] hw/ppc/pnv: Do not use SysBus API to map local MMIO region, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 28/46] hw/intc/spapr_xive: Move sysbus_init_mmio() calls around, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 29/46] hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 30/46] hw/audio/pcspk: Inline pcspk_init(), Philippe Mathieu-Daudé, 2023/10/19
- [PULL 31/46] hw/i386/amd_iommu: Do not use SysBus API to map local MMIO region, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 32/46] hw/i386/intel_iommu: Do not use SysBus API to map local MMIO region, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 33/46] hw/misc/allwinner-dramc: Move sysbus_mmio_map call from init -> realize, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 34/46] hw/misc/allwinner-dramc: Do not use SysBus API to map local MMIO region,
Philippe Mathieu-Daudé <=
- [PULL 35/46] hw/pci-host/bonito: Do not use SysBus API to map local MMIO region, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 36/46] hw/acpi: Realize ACPI_GED sysbus device before accessing it, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 37/46] hw/arm/virt: Realize ARM_GICV2M sysbus device before accessing it, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 38/46] hw/isa: Realize ISA bridge device before accessing it, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 39/46] hw/s390x/css-bridge: Realize sysbus device before accessing it, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 40/46] hw/virtio/virtio-pmem: Replace impossible check by assertion, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 41/46] hw/block/vhost-user-blk: Use DEVICE() / VIRTIO_DEVICE() macros, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 42/46] hw/display/virtio-gpu: Use VIRTIO_DEVICE() macro, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 43/46] hw/scsi/virtio-scsi: Use VIRTIO_SCSI_COMMON() macro, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 44/46] hw/dma: Declare link using static DEFINE_PROP_LINK() macro, Philippe Mathieu-Daudé, 2023/10/19