Commit 342bc75962 for qemu.org
commit 342bc759627aa956bd00e52ec6747433e9bee809
Author: Joel Stanley <joel@jms.id.au>
Date: Thu Sep 3 15:21:21 2026 +0930
hw/riscv/atlantis: Make UART unimp region a SoC device
Make the unimplemented region covering the remainder of the console
UART's register space a SoC child device, mapped using a helper. This
makes it easier to map it into the SoC's memory container along with
the other devices in the future.
While here, rename the region from uart0 to uart1. The uart0 name was
a leftover from an earlier revision that used a different device for
the console.
Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Message-ID: <20260903055131.257903-8-joel@jms.id.au>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
diff --git a/hw/riscv/tt_atlantis.c b/hw/riscv/tt_atlantis.c
index 8b07218152..6e1e50aaf6 100644
--- a/hw/riscv/tt_atlantis.c
+++ b/hw/riscv/tt_atlantis.c
@@ -410,6 +410,17 @@ static void load_fdt(TTAtlantisState *s)
create_fdt_memory(s);
}
+static void mmio_map_unimplemented(MemoryRegion *memory, SysBusDevice *dev,
+ const char *name, hwaddr addr, uint64_t size)
+{
+ qdev_prop_set_string(DEVICE(dev), "name", name);
+ qdev_prop_set_uint64(DEVICE(dev), "size", size);
+ sysbus_realize(dev, &error_abort);
+
+ memory_region_add_subregion_overlap(memory, addr,
+ sysbus_mmio_get_region(dev, 0), -1000);
+}
+
static void tt_atlantis_machine_done(Notifier *notifier, void *data)
{
TTAtlantisState *s = container_of(notifier, TTAtlantisState, machine_done);
@@ -561,9 +572,11 @@ static void tt_atlantis_machine_init(MachineState *machine)
* Create an unimplemented device region so writes don't fault
* and reads return zero, which keeps Linux happy.
*/
- create_unimplemented_device("tt-atlantis.uart0",
- s->memmap[TT_ATL_UART1].base,
- s->memmap[TT_ATL_UART1].size);
+ object_initialize_child(OBJECT(s), "uart1", &s->uart1,
+ TYPE_UNIMPLEMENTED_DEVICE);
+ mmio_map_unimplemented(system_memory, SYS_BUS_DEVICE(&s->uart1),
+ "tt-atlantis.uart1", s->memmap[TT_ATL_UART1].base,
+ s->memmap[TT_ATL_UART1].size);
/* I2C */
for (int i = 0; i < TT_ATL_NUM_I2C; i++) {
diff --git a/include/hw/riscv/tt_atlantis.h b/include/hw/riscv/tt_atlantis.h
index 7f7d4a5a59..c9308aa570 100644
--- a/include/hw/riscv/tt_atlantis.h
+++ b/include/hw/riscv/tt_atlantis.h
@@ -13,6 +13,7 @@
#include "hw/core/sysbus.h"
#include "hw/i2c/designware_i2c.h"
#include "hw/intc/riscv_imsic.h"
+#include "hw/misc/unimp.h"
#include "hw/riscv/riscv_hart.h"
#define TYPE_TT_ATLANTIS_MACHINE MACHINE_TYPE_NAME("tt-atlantis")
@@ -31,6 +32,7 @@ struct TTAtlantisState {
RISCVHartArrayState soc;
DeviceState *irqchip;
DesignWareI2CState i2c[TT_ATL_NUM_I2C];
+ UnimplementedDeviceState uart1;
int fdt_size;
};