Skip to contentSkip to conversation

Add ASPEED AST2400 SoC and Palmetto BMC machine

PATCH Applied Andrew Jeffery 2 participants 6 messages Mar 16, 2016 Arm/Aspeed machine support

lore
Share & tools
lore
#0 lore raw

v5 cover Add ASPEED AST2400 SoC and Palmetto BMC machine

This patch series models enough of the ASPEED AST2400 ARM9 SoC[0] to boot an aspeed_defconfig Linux kernel[1][2]. Specifically, the series implements the ASPEED timer and VIC devices, integrates them into an AST2400 SoC and exposes it all through a new palmetto-bmc machine. The device model patches only partially implement the hardware features of the timer and VIC, again mostly just enough to boot Linux.

Unfortunately the datasheet describing the devices is not generally available, but I'll try to add comments to any unclear areas.

The addition of the AST2400 to QEMU is motivated by use of the SoC as a BMC in OpenPOWER[2][3] machines and the ongoing development of OpenBMC[4]. The presence of a machine model utilising the AST2400 will help with development and testing of the OpenBMC stack.

Cheers,

Andrew

[0] http://www.aspeedtech.com/products.php?fPath=20&rId=376
[1] https://github.com/openbmc/linux/tree/dev-4.3
[2] git fetch [email protected]:openbmc/linux.git dev-4.3
[3] http://openpowerfoundation.org/
[4] https://github.com/open-power/
[5] https://github.com/openbmc/openbmc

Changes since v4:

* Switch approach to modelling a specific machine type (palmetto-bmc) rather than something generic that may have no corresponding hardware implementation
* Address review comments from Jeremy Kerr, Cédric Le Goater, Dmitry Osipenko

Changes since v3:

Address comments from Peter Maydell, splitting the machine model from hw/arm/ast2400.c into hw/arm/opbmc2400.c amongst other minor cleanups to the timer and VIC.

Changes since v2:

This re-roll is a reasonable rework of the patches in the series, which may make it difficult to compare v1 to v2.

Addressed reviews/comments from:
* Peter Maydell
* Alexey Kardashevskiy
* Joel Stanley

Changes since v1:

Addressed reviews/comments from:
* Cédric Le Goater

Andrew Jeffery (4):
hw/timer: Add ASPEED timer device model
hw/intc: Add (new) ASPEED VIC device model
hw/arm: Add ASPEED AST2400 SoC model
hw/arm: Add palmetto-bmc machine

 default-configs/arm-softmmu.mak |   1 +
 hw/arm/Makefile.objs            |   1 +
 hw/arm/ast2400.c                | 137 ++++++++++++
 hw/arm/palmetto-bmc.c           |  65 ++++++
 hw/intc/Makefile.objs           |   1 +
 hw/intc/aspeed_vic.c            | 339 ++++++++++++++++++++++++++++++
 hw/timer/Makefile.objs          |   1 +
 hw/timer/aspeed_timer.c         | 449 ++++++++++++++++++++++++++++++++++++++++
 include/hw/arm/ast2400.h        |  35 ++++
 include/hw/intc/aspeed_vic.h    |  48 +++++
 include/hw/timer/aspeed_timer.h |  59 ++++++
 trace-events                    |  16 ++
 12 files changed, 1152 insertions(+)
 create mode 100644 hw/arm/ast2400.c
 create mode 100644 hw/arm/palmetto-bmc.c
 create mode 100644 hw/intc/aspeed_vic.c
 create mode 100644 hw/timer/aspeed_timer.c
 create mode 100644 include/hw/arm/ast2400.h
 create mode 100644 include/hw/intc/aspeed_vic.h
 create mode 100644 include/hw/timer/aspeed_timer.h
Signature · 1 line
2.5.0
#1 lore raw

PATCH v5 1/4 hw/timer: Add ASPEED timer device model

Implement basic ASPEED timer functionality for the AST2400 SoC[1]: Up to 8 timers can independently be configured, enabled, reset and disabled. Some hardware features are not implemented, namely clock value matching and pulse generation, but the implementation is enough to boot the Linux kernel configured with aspeed_defconfig.

[1] http://www.aspeedtech.com/products.php?fPath=20&rId=376

---
Since v4:
* Fix to compile when using GCC 4.x
* Drop unnecessary asserts

Since v3:
* Drop unnecessary mention of VMStateDescription in timer_to_ctrl description
* Mention hw/timer/a9gtimer.c with respect to clock value matching
* Add missing VMSTATE_END_OF_LIST() to vmstate_aspeed_timer_state

Since v2:
* Improve handling of timer configuration with respect to enabled state
* Remove redundant enabled member from AspeedTimer
* Implement VMStateDescriptions
* Fix interrupt behaviour (edge triggered, both edges)
* Fix various issues with trace-event declarations
* Include qemu/osdep.h

Since v1:
* Refactor initialisation of and respect requested clock rates (APB/External)
* Simplify some index calculations
* Use tracing infrastructure instead of internal DPRINTF
* Enforce access size constraints and alignment in MemoryRegionOps

 default-configs/arm-softmmu.mak |   1 +
 hw/timer/Makefile.objs          |   1 +
 hw/timer/aspeed_timer.c         | 449 ++++++++++++++++++++++++++++++++++++++++
 include/hw/timer/aspeed_timer.h |  59 ++++++
 trace-events                    |   9 +
 5 files changed, 519 insertions(+)
 create mode 100644 hw/timer/aspeed_timer.c
 create mode 100644 include/hw/timer/aspeed_timer.h
default-configs/arm-softmmu.mak +1 -0
index a9f82a1..2bcd236 100644
@@ -110,3 +110,4 @@ CONFIG_IOH3420=y
 CONFIG_I82801B11=y
 CONFIG_ACPI=y
 CONFIG_SMBIOS=y
+CONFIG_ASPEED_SOC=y
hw/timer/Makefile.objs +1 -0
index 5cfea6e..003c14f 100644
@@ -32,3 +32,4 @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
 obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
 
 common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
+common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
hw/timer/aspeed_timer.c new file +449 -0

449 lines not on this page · raw message

include/hw/timer/aspeed_timer.h new file +59 -0

59 lines not on this page · raw message

trace-events +9 -0
index 0ad8a1c..e589230 100644
@@ -1892,3 +1892,12 @@ qio_channel_command_new_pid(void *ioc, int writefd, int readfd, int pid) "Comman
 qio_channel_command_new_spawn(void *ioc, const char *binary, int flags) "Command new spawn ioc=%p binary=%s flags=%d"
 qio_channel_command_abort(void *ioc, int pid) "Command abort ioc=%p pid=%d"
 qio_channel_command_wait(void *ioc, int pid, int ret, int status) "Command abort ioc=%p pid=%d ret=%d status=%d"
+
+# hw/timer/aspeed_timer.c
+aspeed_timer_ctrl_enable(uint8_t i, bool enable) "Timer %" PRIu8 ": %d"
+aspeed_timer_ctrl_external_clock(uint8_t i, bool enable) "Timer %" PRIu8 ": %d"
+aspeed_timer_ctrl_overflow_interrupt(uint8_t i, bool enable) "Timer %" PRIu8 ": %d"
+aspeed_timer_ctrl_pulse_enable(uint8_t i, bool enable) "Timer %" PRIu8 ": %d"
+aspeed_timer_set_ctrl2(uint32_t value) "Value: 0x%" PRIx32
+aspeed_timer_set_value(int timer, int reg, uint32_t value) "Timer %d register %d: 0x%" PRIx32
+aspeed_timer_read(uint64_t offset, unsigned size, uint64_t value) "From 0x%" PRIx64 ": of size %u: 0x%" PRIx64
Signature · 1 line
2.5.0
#2 lore raw

PATCH v5 2/4 hw/intc: Add (new) ASPEED VIC device model

In reply to Andrew Jeffery

Implement a basic ASPEED VIC device model for the AST2400 SoC[1], with enough functionality to boot an aspeed_defconfig Linux kernel. The model implements the 'new' (revised) register set: While the hardware exposes both the new and legacy register sets, accesses to the model's legacy register set will not be serviced (however the access will be logged).

[1] http://www.aspeedtech.com/products.php?fPath=20&rId=376

---
Since v3:
* Switch from g_assert() to qemu_log_mask(LOG_GUEST_ERROR, ...) in guest path

Since v2:
* Implement all supported interrupt types and configurations
* Implement a VMStateDescription
* Log accesses to legacy IO space
* Add documentation on some implementation and hardware details
* Switch to extract64/deposit64 where possible
* Drop int_ prefix from some struct member names
* Fix various issues with trace-event declarations
* Include qemu/osdep.h

 hw/intc/Makefile.objs        |   1 +
 hw/intc/aspeed_vic.c         | 339 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/intc/aspeed_vic.h |  48 ++++++
 trace-events                 |   7 +
 4 files changed, 395 insertions(+)
 create mode 100644 hw/intc/aspeed_vic.c
 create mode 100644 include/hw/intc/aspeed_vic.h
hw/intc/Makefile.objs +1 -0
index 6a13a39..0e47f0f 100644
@@ -31,3 +31,4 @@ obj-$(CONFIG_XICS_KVM) += xics_kvm.o
 obj-$(CONFIG_ALLWINNER_A10_PIC) += allwinner-a10-pic.o
 obj-$(CONFIG_S390_FLIC) += s390_flic.o
 obj-$(CONFIG_S390_FLIC_KVM) += s390_flic_kvm.o
+obj-$(CONFIG_ASPEED_SOC) += aspeed_vic.o
hw/intc/aspeed_vic.c new file +339 -0

339 lines not on this page · raw message

include/hw/intc/aspeed_vic.h new file +48 -0

48 lines not on this page · raw message

trace-events +7 -0
index e589230..d494de1 100644
@@ -1901,3 +1901,10 @@ aspeed_timer_ctrl_pulse_enable(uint8_t i, bool enable) "Timer %" PRIu8 ": %d"
 aspeed_timer_set_ctrl2(uint32_t value) "Value: 0x%" PRIx32
 aspeed_timer_set_value(int timer, int reg, uint32_t value) "Timer %d register %d: 0x%" PRIx32
 aspeed_timer_read(uint64_t offset, unsigned size, uint64_t value) "From 0x%" PRIx64 ": of size %u: 0x%" PRIx64
+
+# hw/intc/aspeed_vic.c
+aspeed_vic_set_irq(int irq, int level) "Enabling IRQ %d: %d"
+aspeed_vic_update_fiq(int flags) "Raising FIQ: %d"
+aspeed_vic_update_irq(int flags) "Raising IRQ: %d"
+aspeed_vic_read(uint64_t offset, unsigned size, uint32_t value) "From 0x%" PRIx64 " of size %u: 0x%" PRIx32
+aspeed_vic_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32
Signature · 1 line
2.5.0
#3 lore raw

PATCH v5 3/4 hw/arm: Add ASPEED AST2400 SoC model

In reply to Andrew Jeffery

While the ASPEED AST2400 SoC[1] has a broad range of capabilities this implementation is minimal, comprising an ARM926 processor, ASPEED VIC and timer devices, and a 8250 UART.

[1] http://www.aspeedtech.com/products.php?fPath=20&rId=376

---
Since v3:

* Split the SoC from the machine implementation

Since v2:
* Implement a SOC model to move code out from the machine definition
* Rework the machine to better use QOM
* Include qemu/osdep.h
* Revert back to qemu_log_mask(LOG_UNIMP, ...) in IO handlers

 hw/arm/Makefile.objs     |   1 +
 hw/arm/ast2400.c         | 137 +++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/arm/ast2400.h |  35 ++++++++++++
 3 files changed, 173 insertions(+)
 create mode 100644 hw/arm/ast2400.c
 create mode 100644 include/hw/arm/ast2400.h
hw/arm/Makefile.objs +1 -0
index a711e4d..f333b7f 100644
@@ -16,3 +16,4 @@ obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
 obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o
 obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
 obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
+obj-$(CONFIG_ASPEED_SOC) += ast2400.o
hw/arm/ast2400.c new file +137 -0

137 lines not on this page · raw message

include/hw/arm/ast2400.h new file +35 -0
new file mode 100644
index 0000000..f16a1ed
@@ -0,0 +1,35 @@
+/*
+ * ASPEED AST2400 SoC
+ *
+ * Andrew Jeffery <[email protected]>
+ *
+ * Copyright 2016 IBM Corp.
+ *
+ * This code is licensed under the GPL version 2 or later.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#ifndef AST2400_H
+#define AST2400_H
+
+#include "hw/arm/arm.h"
+#include "hw/intc/aspeed_vic.h"
+#include "hw/timer/aspeed_timer.h"
+
+typedef struct AST2400State {
+    /*< private >*/
+    DeviceState parent;
+
+    /*< public >*/
+    ARMCPU *cpu;
+    MemoryRegion iomem;
+    AspeedVICState vic;
+    AspeedTimerCtrlState timerctrl;
+} AST2400State;
+
+#define TYPE_AST2400 "ast2400"
+#define AST2400(obj) OBJECT_CHECK(AST2400State, (obj), TYPE_AST2400)
+
+#define AST2400_SDRAM_BASE       0x40000000
+
+#endif /* AST2400_H */
Signature · 1 line
2.5.0
#4 lore raw

PATCH v5 4/4 hw/arm: Add palmetto-bmc machine

In reply to Andrew Jeffery

The new machine is a thin layer over the AST2400 ARM926-based SoC[1]. Between the minimal machine and the current SoC implementation there is enough functionality to boot an aspeed_defconfig Linux kernel to userspace. Nothing yet is specific to the Palmetto's BMC (other than using an AST2400 SoC), but creating specific machine types is preferable to a generic machine that doesn't match any particular hardware.

[1] http://www.aspeedtech.com/products.php?fPath=20&rId=376

---
Since v4:
* Rename to hw/arm/palmetto-bmc.c, update functions, structs and strings

Since v3:
* Split the machine from the SoC implementation

Since v2:
* Implement a SOC model to move code out from the machine definition
* Rework the machine to better use QOM
* Include qemu/osdep.h
* Revert back to qemu_log_mask(LOG_UNIMP, ...) in IO handlers

 hw/arm/Makefile.objs  |  2 +-
 hw/arm/palmetto-bmc.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/palmetto-bmc.c
hw/arm/Makefile.objs +1 -1
index f333b7f..954c9fe 100644
@@ -16,4 +16,4 @@ obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
 obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o
 obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
 obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
-obj-$(CONFIG_ASPEED_SOC) += ast2400.o
+obj-$(CONFIG_ASPEED_SOC) += ast2400.o palmetto-bmc.o
hw/arm/palmetto-bmc.c new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.5.0
#5 lore raw
In reply to Andrew Jeffery
Quoted 7 lines · Andrew Jeffery

This patch series models enough of the ASPEED AST2400 ARM9 SoC[0] to boot an aspeed_defconfig Linux kernel[1][2]. Specifically, the series implements the ASPEED timer and VIC devices, integrates them into an AST2400 SoC and exposes it all through a new palmetto-bmc machine. The device model patches only partially implement the hardware features of the timer and VIC, again mostly just enough to boot Linux.

Quoted 7 lines

Unfortunately the datasheet describing the devices is not generally available, but I'll try to add comments to any unclear areas.

The addition of the AST2400 to QEMU is motivated by use of the SoC as a BMC in OpenPOWER[2][3] machines and the ongoing development of OpenBMC[4]. The presence of a machine model utilising the AST2400 will help with development and testing of the OpenBMC stack.

Thanks, applied to target-arm.next.

-- PMM