hw/misc: Add basic Aspeed GFX model
Subsystems (2)
Joel Stanley
maintainerPATCH 1/1 hw/misc: Add basic Aspeed GFX model
Enough model to capture the pinmux writes to enable correct operation of the parts of pinmux that depend on GFX registers.
--- include/hw/arm/aspeed_soc.h | 3 + include/hw/misc/aspeed_gfx.h | 31 +++++++++ hw/arm/aspeed_ast2600.c | 11 ++++ hw/arm/aspeed_soc.c | 12 ++++ hw/misc/aspeed_gfx.c | 121 +++++++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + hw/misc/trace-events | 4 ++ 7 files changed, 183 insertions(+) create mode 100644 include/hw/misc/aspeed_gfx.h create mode 100644 hw/misc/aspeed_gfx.c
include/hw/arm/aspeed_soc.h +3 -0
@@ -26,6 +26,7 @@#include "hw/ssi/aspeed_smc.h" #include "hw/misc/aspeed_hace.h" #include "hw/misc/aspeed_sbc.h" +#include "hw/misc/aspeed_gfx.h" #include "hw/watchdog/wdt_aspeed.h" #include "hw/net/ftgmac100.h" #include "target/arm/cpu.h"
@@ -81,6 +82,7 @@ struct AspeedSoCState {AspeedSDHCIState emmc;AspeedLPCState lpc;AspeedPECIState peci; +AspeedGFXState gfx;SerialMM uart[ASPEED_UARTS_NUM ];Clock *sysclk;UnimplementedDeviceState iomem;
@@ -171,6 +173,7 @@ enum {ASPEED_DEV_EMMC ,ASPEED_DEV_KCS ,ASPEED_DEV_HACE , +ASPEED_DEV_GFX ,ASPEED_DEV_DPMCU ,ASPEED_DEV_DP , ASPEED_DEV_I3C,
include/hw/misc/aspeed_gfx.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* ASPEED GFX Controller +* +* Copyright (C) 2023 IBM Corp. +* +* This code is licensed under the GPL version 2 or later. See +* the COPYING file in the top-level directory. +*/ + +#ifndef ASPEED_GFX_H +#define ASPEED_GFX_H + +#include "hw/sysbus.h" + +#define TYPE_ASPEED_GFX "aspeed.gfx" +#define ASPEED_GFX (obj) OBJECT_CHECK(AspeedGFXState, (obj), TYPE_ASPEED_GFX) + +#define ASPEED_GFX_NR_REGS (0xFC >> 2) + +typedef struct AspeedGFXState { +/* <private> */ +SysBusDevice parent; + +/*< public >*/ +MemoryRegion iomem; +qemu_irq irq; + +uint32_t regs[ASPEED_GFX_NR_REGS ]; +}AspeedGFXState ; + +#endif /* _ASPEED_GFX_H_ */
hw/arm/aspeed_ast2600.c +11 -0
@@ -43,6 +43,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { [ASPEED_DEV_HACE] = 0x1E6D0000, [ASPEED_DEV_SDMC] = 0x1E6E0000, [ASPEED_DEV_SCU] = 0x1E6E2000, + [ASPEED_DEV_GFX] = 0x1E6E6000, [ASPEED_DEV_XDMA] = 0x1E6E7000, [ASPEED_DEV_ADC] = 0x1E6E9000, [ASPEED_DEV_DP] = 0x1E6EB000,
@@ -255,6 +256,8 @@ static void aspeed_soc_ast2600_init(Object *obj)object_initialize_child (obj,"sbc" , &s->sbc,TYPE_ASPEED_SBC ); +object_initialize_child (obj,"gfx" , &s->gfx,TYPE_ASPEED_GFX ); +object_initialize_child (obj,"iomem" , &s->iomem,TYPE_UNIMPLEMENTED_DEVICE );object_initialize_child (obj,"video" , &s->video,TYPE_UNIMPLEMENTED_DEVICE );object_initialize_child (obj,"dpmcu" , &s->dpmcu,TYPE_UNIMPLEMENTED_DEVICE );
@@ -607,6 +610,14 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)return ; }aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->sbc),0 , sc->memmap[ASPEED_DEV_SBC ]); + +/* GFX */ +if (!sysbus_realize (SYS_BUS_DEVICE (&s->gfx), errp)) { +return ; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->gfx),0 , sc->memmap[ASPEED_DEV_GFX ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->gfx),0 , +aspeed_soc_get_irq (s,ASPEED_DEV_GFX )); }static void aspeed_soc_ast2600_class_init (ObjectClass *oc,void *data)
hw/arm/aspeed_soc.c +12 -0
@@ -33,6 +33,7 @@ static const hwaddr aspeed_soc_ast2400_memmap[] = { [ASPEED_DEV_SDMC] = 0x1E6E0000, [ASPEED_DEV_SCU] = 0x1E6E2000, [ASPEED_DEV_HACE] = 0x1E6E3000, + [ASPEED_DEV_GFX] = 0x1E6E6000, [ASPEED_DEV_XDMA] = 0x1E6E7000, [ASPEED_DEV_VIDEO] = 0x1E700000, [ASPEED_DEV_ADC] = 0x1E6E9000,
@@ -69,6 +70,7 @@ static const hwaddr aspeed_soc_ast2500_memmap[] = { [ASPEED_DEV_SDMC] = 0x1E6E0000, [ASPEED_DEV_SCU] = 0x1E6E2000, [ASPEED_DEV_HACE] = 0x1E6E3000, + [ASPEED_DEV_GFX] = 0x1E6E6000, [ASPEED_DEV_XDMA] = 0x1E6E7000, [ASPEED_DEV_ADC] = 0x1E6E9000, [ASPEED_DEV_VIDEO] = 0x1E700000,
@@ -233,6 +235,8 @@ static void aspeed_soc_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.hace-%s" , socname);object_initialize_child (obj,"hace" , &s->hace, typename); +object_initialize_child (obj,"gfx" , &s->gfx,TYPE_ASPEED_GFX ); +object_initialize_child (obj,"iomem" , &s->iomem,TYPE_UNIMPLEMENTED_DEVICE );object_initialize_child (obj,"video" , &s->video,TYPE_UNIMPLEMENTED_DEVICE ); }
@@ -482,6 +486,14 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) sc->memmap[ASPEED_DEV_HACE]);sysbus_connect_irq (SYS_BUS_DEVICE (&s->hace),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_HACE )); + +/* GFX */ +if (!sysbus_realize (SYS_BUS_DEVICE (&s->gfx), errp)) { +return ; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->gfx),0 , sc->memmap[ASPEED_DEV_GFX ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->gfx),0 , +aspeed_soc_get_irq (s,ASPEED_DEV_GFX )); }static Property aspeed_soc_properties[] = { DEFINE_PROP_LINK("memory", AspeedSoCState, memory, TYPE_MEMORY_REGION,
hw/misc/aspeed_gfx.c new file +121 -0
121 lines not on this page · raw message
hw/misc/meson.build +1 -0
@@ -115,6 +115,7 @@ softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c')) softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( + 'aspeed_gfx.c', 'aspeed_hace.c', 'aspeed_i3c.c', 'aspeed_lpc.c',
hw/misc/trace-events +4 -0
@@ -211,6 +211,10 @@ aspeed_i3c_write(uint64_t offset, uint64_t data) "I3C write: offset 0x%" PRIx64 aspeed_i3c_device_read(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] read: offset 0x%" PRIx64 " data 0x%" PRIx64 aspeed_i3c_device_write(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] write: offset 0x%" PRIx64 " data 0x%" PRIx64 +# aspeed_gfx.c +aspeed_gfx_read(uint64_t offset, uint64_t data) "read: offset 0x%" PRIx64 " data 0x%" PRIx64 +aspeed_gfx_write(uint64_t offset, uint64_t data) "write: offset 0x%" PRIx64 " data 0x%" PRIx64 + # aspeed_sdmc.c aspeed_sdmc_write(uint64_t reg, uint64_t data) "reg @0x%" PRIx64 " data: 0x%" PRIx64 aspeed_sdmc_read(uint64_t reg, uint64_t data) "reg @0x%" PRIx64 " data: 0x%" PRIx64
Signature · 1 line
2.39.0
Quoted 50 lines · Joel Stanley
Enough model to capture the pinmux writes to enable correct operation of the parts of pinmux that depend on GFX registers.
Signed-off-by Joel Stanley <[email protected]>--- include/hw/arm/aspeed_soc.h | 3 + include/hw/misc/aspeed_gfx.h | 31 +++++++++ hw/arm/aspeed_ast2600.c | 11 ++++ hw/arm/aspeed_soc.c | 12 ++++ hw/misc/aspeed_gfx.c | 121 +++++++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + hw/misc/trace-events | 4 ++ 7 files changed, 183 insertions(+) create mode 100644 include/hw/misc/aspeed_gfx.h create mode 100644 hw/misc/aspeed_gfx.cinclude/hw/arm/aspeed_soc.h +3
-0@@ -26,6 +26,7 @@#include "hw/ssi/aspeed_smc.h" #include "hw/misc/aspeed_hace.h" #include "hw/misc/aspeed_sbc.h" +#include "hw/misc/aspeed_gfx.h" #include "hw/watchdog/wdt_aspeed.h" #include "hw/net/ftgmac100.h" #include "target/arm/cpu.h" @@ -81,6 +82,7 @@ struct AspeedSoCState {AspeedSDHCIState emmc;AspeedLPCState lpc;AspeedPECIState peci; +AspeedGFXState gfx;SerialMM uart[ASPEED_UARTS_NUM ];Clock *sysclk;UnimplementedDeviceState iomem;@@ -171,6 +173,7 @@ enum {ASPEED_DEV_EMMC ,ASPEED_DEV_KCS ,ASPEED_DEV_HACE , +ASPEED_DEV_GFX ,ASPEED_DEV_DPMCU ,ASPEED_DEV_DP , ASPEED_DEV_I3C,include/hw/misc/aspeed_gfx.h new file +0
-0
include/hw/misc/aspeed_gfx.h line 8
Quoted 8 lines
include/hw/misc/aspeed_gfx.h new file +8
-0@@ -0,0 +1,31 @@ +/* +* ASPEED GFX Controller +* +* Copyright (C) 2023 IBM Corp. +* +* This code is licensed under the GPL version 2 or later. See +* the COPYING file in the top-level directory. +*/
Use SPDX here?
Quoted 52 lines
include/hw/misc/aspeed_gfx.h new file +23
-0+ +#ifndef ASPEED_GFX_H +#define ASPEED_GFX_H + +#include "hw/sysbus.h" + +#define TYPE_ASPEED_GFX "aspeed.gfx" +#define ASPEED_GFX (obj) OBJECT_CHECK(AspeedGFXState, (obj), TYPE_ASPEED_GFX) + +#define ASPEED_GFX_NR_REGS (0xFC >> 2) + +typedef struct AspeedGFXState { +/* <private> */ +SysBusDevice parent; + +/*< public >*/ +MemoryRegion iomem; +qemu_irq irq; + +uint32_t regs[ASPEED_GFX_NR_REGS ]; +}AspeedGFXState ; + +#endif /* _ASPEED_GFX_H_ */ hw/arm/aspeed_ast2600.c +3
-0@@ -43,6 +43,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { [ASPEED_DEV_HACE] = 0x1E6D0000, [ASPEED_DEV_SDMC] = 0x1E6E0000, [ASPEED_DEV_SCU] = 0x1E6E2000, + [ASPEED_DEV_GFX] = 0x1E6E6000, [ASPEED_DEV_XDMA] = 0x1E6E7000, [ASPEED_DEV_ADC] = 0x1E6E9000, [ASPEED_DEV_DP] = 0x1E6EB000,@@ -255,6 +256,8 @@ static void aspeed_soc_ast2600_init(Object *obj)object_initialize_child (obj,"sbc" , &s->sbc,TYPE_ASPEED_SBC ); +object_initialize_child (obj,"gfx" , &s->gfx,TYPE_ASPEED_GFX ); +object_initialize_child (obj,"iomem" , &s->iomem,TYPE_UNIMPLEMENTED_DEVICE ); object_initialize_child(obj, "video", &s->video,TYPE_UNIMPLEMENTED_DEVICE); object_initialize_child(obj, "dpmcu", &s->dpmcu,
TYPE_UNIMPLEMENTED_DEVICE);hw/arm/aspeed_ast2600.c +0
-0@@ -607,6 +610,14 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)return ; } aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sbc), 0,
hw/arm/aspeed_ast2600.c static void aspeed_soc_ast2600_realize(DeviceState · line 623
Quoted 10 lines
hw/arm/aspeed_ast2600.c +8
-0sc->memmap[ASPEED_DEV_SBC]); + +/* GFX */ +if (!sysbus_realize (SYS_BUS_DEVICE (&s->gfx), errp)) { +return ; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->gfx),0 , sc->memmap[ASPEED_DEV_GFX ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->gfx),0 , +aspeed_soc_get_irq (s,ASPEED_DEV_GFX ));
I think we're missing an entry for ASPEED_DEV_GFX in the irqmap array?
Quoted 38 lines
}
static void
aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)hw/arm/aspeed_soc.c +4
-0@@ -33,6 +33,7 @@ static const hwaddr aspeed_soc_ast2400_memmap[] = { [ASPEED_DEV_SDMC] = 0x1E6E0000, [ASPEED_DEV_SCU] = 0x1E6E2000, [ASPEED_DEV_HACE] = 0x1E6E3000, + [ASPEED_DEV_GFX] = 0x1E6E6000, [ASPEED_DEV_XDMA] = 0x1E6E7000, [ASPEED_DEV_VIDEO] = 0x1E700000, [ASPEED_DEV_ADC] = 0x1E6E9000,@@ -69,6 +70,7 @@ static const hwaddr aspeed_soc_ast2500_memmap[] = { [ASPEED_DEV_SDMC] = 0x1E6E0000, [ASPEED_DEV_SCU] = 0x1E6E2000, [ASPEED_DEV_HACE] = 0x1E6E3000, + [ASPEED_DEV_GFX] = 0x1E6E6000, [ASPEED_DEV_XDMA] = 0x1E6E7000, [ASPEED_DEV_ADC] = 0x1E6E9000, [ASPEED_DEV_VIDEO] = 0x1E700000,@@ -233,6 +235,8 @@ static void aspeed_soc_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.hace-%s" , socname);object_initialize_child (obj,"hace" , &s->hace, typename); +object_initialize_child (obj,"gfx" , &s->gfx,TYPE_ASPEED_GFX ); +object_initialize_child (obj,"iomem" , &s->iomem,TYPE_UNIMPLEMENTED_DEVICE ); object_initialize_child(obj, "video", &s->video,
TYPE_UNIMPLEMENTED_DEVICE);
}hw/arm/aspeed_soc.c +0
-0@@ -482,6 +486,14 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) sc->memmap[ASPEED_DEV_HACE]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
hw/arm/aspeed_soc.c static void aspeed_soc_realize(DeviceState *dev, · line 498
Quoted 10 lines
hw/arm/aspeed_soc.c +8
-0aspeed_soc_get_irq(s, ASPEED_DEV_HACE)); + +/* GFX */ +if (!sysbus_realize (SYS_BUS_DEVICE (&s->gfx), errp)) { +return ; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->gfx),0 , sc->memmap[ASPEED_DEV_GFX ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->gfx),0 , +aspeed_soc_get_irq (s,ASPEED_DEV_GFX ));
Again with the irqmap
Quoted 10 lines
hw/arm/aspeed_soc.c +0
-0}static Property aspeed_soc_properties[] = {
DEFINE_PROP_LINK("memory", AspeedSoCState, memory,TYPE_MEMORY_REGION,hw/misc/aspeed_gfx.c new file +0
-0
hw/misc/aspeed_gfx.c line 8
Quoted 8 lines
hw/misc/aspeed_gfx.c new file +8
-0@@ -0,0 +1,121 @@ +/* +* ASPEED GFX Controller +* +* Copyright (C) 2023 IBM Corp. +* +* This code is licensed under the GPL version 2 or later. See +* the COPYING file in the top-level directory. +*/
SPDX again?
Cheers,
Andrew