Skip to contentSkip to conversation

hw/arm: Add Allwinner H618 SoC and Orange Pi Zero 2W machine

PATCH Superseded Khai Do 1 participant 6 messages Oct 31

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
author
#2 lore raw

PATCH 2/5 hw/arm/orangepi-zero2w: Add Orange Pi Zero 2W machine

In reply to Khai Do

The Orange Pi Zero 2W is a single-board computer powered by the Allwinner H618 SoC. This commit adds machine emulation with:
- Allwinner H618 SoC instance
- 1 GiB default system SDRAM at 0x40000000
- Kernel and firmware loading via arm_load_kernel

---
 MAINTAINERS              |  1 +
 hw/arm/meson.build       |  2 +-
 hw/arm/orangepi-zero2w.c | 77 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/orangepi-zero2w.c
MAINTAINERS +1 -0
index 68f1c31d60..d5f60db054 100644
@@ -785,6 +785,7 @@ L: [email protected]
 S: Maintained
 F: hw/*/allwinner-h618*
 F: include/hw/*/allwinner-h618*
+F: hw/arm/orangepi-zero2w.c
 
 ARM PrimeCell and CMSDK devices
 M: Peter Maydell <[email protected]>
hw/arm/meson.build +1 -1
index 42ed065b17..947ee2c7b4 100644
@@ -24,7 +24,7 @@ arm_common_ss.add(when: 'CONFIG_OMAP', if_true: files('omap1.c'))
 arm_common_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubieboard.c'))
 arm_common_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c'))
 arm_common_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c', 'bananapi_m2u.c'))
-arm_common_ss.add(when: 'CONFIG_ALLWINNER_H618', if_true: files('allwinner-h618.c'))
+arm_common_ss.add(when: 'CONFIG_ALLWINNER_H618', if_true: files('allwinner-h618.c', 'orangepi-zero2w.c'))
 arm_common_ss.add(when: 'CONFIG_MAX78000_SOC', if_true: files('max78000_soc.c'))
 arm_common_ss.add(when: 'CONFIG_RASPI', if_true: files(
   'bcm2836.c',
hw/arm/orangepi-zero2w.c new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.43.0
author
#4 lore raw

PATCH 4/5 hw/misc/allwinner-sid: Support configurable eFuse capacity up to 512 bytes

In reply to Khai Do

Allwinner SoCs provide different eFuse capacities: older SoCs have 16 to 256 bytes, while newer 64-bit SoCs (e.g. H618) provide up to 512 bytes of eFuse storage.

Add a "size" property (defaulting to 16 bytes for backward compatibility) and an internal storage buffer up to 512 bytes (AW_SID_SIZE_MAX).

---
 hw/misc/allwinner-sid.c         | 8 +++++++-
 include/hw/misc/allwinner-sid.h | 8 ++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
hw/misc/allwinner-sid.c +7 -1
index b5f827d4bd..0068b07eee 100644
@@ -83,6 +83,9 @@ static void allwinner_sid_write(void *opaque, hwaddr offset,
 
             if (id <= sizeof(QemuUUID) - sizeof(s->rdkey)) {
                 s->rdkey = ldl_be_p(&s->identifier.data[id]);
+            } else if (s->size >= sizeof(s->rdkey) &&
+                       id <= s->size - sizeof(s->rdkey)) {
+                s->rdkey = ldl_be_p(&s->storage[id]);
             }
         }
         s->control &= ~REG_PRCTL_WRITE;
@@ -129,16 +132,19 @@ static void allwinner_sid_init(Object *obj)
 
 static const Property allwinner_sid_properties[] = {
     DEFINE_PROP_UUID_NODEFAULT("identifier", AwSidState, identifier),
+    DEFINE_PROP_UINT32("size", AwSidState, size, sizeof(QemuUUID)),
 };
 
 static const VMStateDescription allwinner_sid_vmstate = {
     .name = "allwinner-sid",
-    .version_id = 1,
+    .version_id = 2,
     .minimum_version_id = 1,
     .fields = (const VMStateField[]) {
         VMSTATE_UINT32(control, AwSidState),
         VMSTATE_UINT32(rdkey, AwSidState),
         VMSTATE_UINT8_ARRAY_V(identifier.data, AwSidState, sizeof(QemuUUID), 1),
+        VMSTATE_UINT32_V(size, AwSidState, 2),
+        VMSTATE_UINT8_ARRAY_V(storage, AwSidState, AW_SID_SIZE_MAX, 2),
         VMSTATE_END_OF_LIST()
     }
 };
include/hw/misc/allwinner-sid.h +8 -0
index cfa22a4d7f..da8c235c5d 100644
@@ -24,6 +24,9 @@
 #include "hw/core/sysbus.h"
 #include "qemu/uuid.h"
 
+/** Maximum eFuse storage size supported */
+#define AW_SID_SIZE_MAX (512)
+
 /**
  * Object model
  * @{
@@ -54,6 +57,11 @@ struct AwSidState {
     /** Stores the emulated device identifier */
     QemuUUID identifier;
 
+    /** Size of eFuse storage */
+    uint32_t size;
+
+    /** eFuse storage buffer */
+    uint8_t storage[AW_SID_SIZE_MAX];
 };
 
 #endif /* HW_MISC_ALLWINNER_SID_H */
Signature · 1 line
2.43.0

Khai Do

author
#0 lore raw

cover hw/arm: Add Allwinner H618 SoC and Orange Pi Zero 2W machine

This patch series adds emulation support for the Allwinner H618 SoC and the Orange Pi Zero 2W single-board computer (SBC).

The Allwinner H618 is a quad-core 64-bit ARM Cortex-A53 SoC. This series follows the incremental skeleton design established for Allwinner SoCs:
- Patch 1: Introduces the basic H618 SoC model with 4x Cortex-A53 cores, GICv2, ARM Generic Timer PPIs, UART0/1, SRAM A1/A2, and stubbed unimp MMIO.
- Patch 2: Adds the Orange Pi Zero 2W machine with 1 GiB SDRAM and kernel loader.
- Patch 3: Separates the ALLWINNER_SID Kconfig symbol so other SoCs can reuse it.
- Patch 4: Extends the Allwinner SID eFuse controller to support configurable capacity up to 512 bytes (required by H618), preserving backward compatibility.
- Patch 5: Connects the SID controller into the H618 SoC and sets the default UID.

Verification:
- The series has been tested using Zephyr RTOS (v4.5) running on the orangepi-zero2w target, verifying UART0 output, multi-threading with ARM Generic Timer (k_msleep), HWINFO UID reading, and SID OTP (512B capacity).
- All patches pass ./scripts/checkpatch.pl with 0 errors and 0 warnings.

Khai Do (5):
hw/arm/allwinner-h618: Add Allwinner H618 SoC emulation hw/arm/orangepi-zero2w: Add Orange Pi Zero 2W machine hw/misc/allwinner-sid: Separate ALLWINNER_SID config symbol hw/misc/allwinner-sid: Support configurable eFuse capacity up to 512
bytes
hw/arm/allwinner-h618: Connect Allwinner SID controller

 MAINTAINERS                     |   8 ++
 hw/arm/Kconfig                  |   9 ++
 hw/arm/allwinner-h618.c         | 233 ++++++++++++++++++++++++++++++++
 hw/arm/meson.build              |   1 +
 hw/arm/orangepi-zero2w.c        |  85 ++++++++++++
 hw/misc/Kconfig                 |   3 +
 hw/misc/allwinner-sid.c         |   8 +-
 hw/misc/meson.build             |   2 +-
 include/hw/arm/allwinner-h618.h |  60 ++++++++
 include/hw/misc/allwinner-sid.h |   8 ++
 10 files changed, 415 insertions(+), 2 deletions(-)
 create mode 100644 hw/arm/allwinner-h618.c
 create mode 100644 hw/arm/orangepi-zero2w.c
 create mode 100644 include/hw/arm/allwinner-h618.h
Signature · 1 line
2.43.0
author
#5 lore raw

PATCH 5/5 hw/arm/allwinner-h618: Connect Allwinner SID controller

Wire up the Allwinner Security ID (SID) eFuse controller into the H618 SoC model:
- Map SID MMIO registers at 0x03006000 with 512 bytes capacity
- Remove sid from unimplemented peripheral list
- Configure default fixed SID identifier in Orange Pi Zero 2W machine
- Select ALLWINNER_SID in Kconfig

---
 hw/arm/Kconfig                  |  1 +
 hw/arm/allwinner-h618.c         | 11 ++++++++++-
 hw/arm/orangepi-zero2w.c        |  8 ++++++++
 include/hw/arm/allwinner-h618.h |  3 +++
 4 files changed, 22 insertions(+), 1 deletion(-)
hw/arm/Kconfig +1 -0
index 21480e277d..a1c09272fd 100644
@@ -339,6 +339,7 @@ config ALLWINNER_H618
     default y if TCG && AARCH64
     select SERIAL_MM
     select ARM_GIC
+    select ALLWINNER_SID
     select UNIMP
 
 config MAX78000_SOC
hw/arm/allwinner-h618.c +10 -1
index 59e0196fc6..2135df78e7 100644
@@ -29,6 +29,7 @@ const hwaddr allwinner_h618_memmap[] = {
     [AW_H618_DEV_GIC_CPU]  = 0x03022000,
     [AW_H618_DEV_GIC_HYP]  = 0x03024000,
     [AW_H618_DEV_GIC_VCPU] = 0x03026000,
+    [AW_H618_DEV_SID]      = 0x03006000,
     [AW_H618_DEV_UART0]    = 0x05000000,
     [AW_H618_DEV_UART1]    = 0x05000400,
     [AW_H618_DEV_UART2]    = 0x05000800,
@@ -44,7 +45,6 @@ static const struct AwH618Unimplemented {
 } unimplemented[] = {
     { "ccu",       0x03001000, 4 * KiB },
     { "dma",       0x03002000, 4 * KiB },
-    { "sid",       0x03006000, 4 * KiB },
     { "smc",       0x03007000, 4 * KiB },
     { "timer",     0x03009000, 4 * KiB },
     { "pwm",       0x0300a000, 4 * KiB },
@@ -91,6 +91,10 @@ static void allwinner_h618_init(Object *obj)
     }
 
     object_initialize_child(obj, "gic", &s->gic, TYPE_ARM_GIC);
+
+    object_initialize_child(obj, "sid", &s->sid, TYPE_AW_SID);
+    object_property_add_alias(obj, "identifier", OBJECT(&s->sid),
+                              "identifier");
 }
 
 static void allwinner_h618_realize(DeviceState *dev, Error **errp)
@@ -172,6 +176,11 @@ static void allwinner_h618_realize(DeviceState *dev, Error **errp)
                                             ppibase + AW_H618_GIC_PPI_MAINT));
     }
 
+    /* Security Identifier */
+    qdev_prop_set_uint32(DEVICE(&s->sid), "size", 512);
+    sysbus_realize(SYS_BUS_DEVICE(&s->sid), &error_fatal);
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->sid), 0, s->memmap[AW_H618_DEV_SID]);
+
     /* SRAM */
     memory_region_init_ram(&s->sram_a1, OBJECT(dev), "sram A1",
                            64 * KiB, &error_abort);
hw/arm/orangepi-zero2w.c +8 -0
index fe87a98efc..1cc9ad7ba6 100644
@@ -40,6 +40,14 @@ static void orangepi_zero2w_init(MachineState *machine)
     object_property_add_child(OBJECT(machine), "soc", OBJECT(h618));
     object_unref(OBJECT(h618));
 
+    /* Setup SID properties. Currently using a default fixed SID identifier. */
+    if (qemu_uuid_is_null(&h618->sid.identifier)) {
+        qdev_prop_set_string(DEVICE(h618), "identifier",
+                             "03006180-1111-2222-3333-000044556677");
+    } else if (ldl_be_p(&h618->sid.identifier.data[0]) != 0x03006180) {
+        warn_report("Security Identifier value does not include H618 prefix");
+    }
+
     /* Mark H618 object realized */
     qdev_realize(DEVICE(h618), NULL, &error_abort);
 
include/hw/arm/allwinner-h618.h +3 -0
index e1b7162759..d4c3d19725 100644
@@ -11,6 +11,7 @@
 
 #include "qom/object.h"
 #include "hw/intc/arm_gic.h"
+#include "hw/misc/allwinner-sid.h"
 #include "target/arm/cpu.h"
 
 /**
@@ -23,6 +24,7 @@ enum {
     AW_H618_DEV_GIC_CPU,
     AW_H618_DEV_GIC_HYP,
     AW_H618_DEV_GIC_VCPU,
+    AW_H618_DEV_SID,
     AW_H618_DEV_UART0,
     AW_H618_DEV_UART1,
     AW_H618_DEV_UART2,
@@ -50,6 +52,7 @@ struct AwH618State {
     ARMCPU cpus[AW_H618_NUM_CPUS];
     const hwaddr *memmap;
     GICState gic;
+    AwSidState sid;
     MemoryRegion sram_a1;
     MemoryRegion sram_a2;
 };
Signature · 1 line
2.43.0
author
#3 lore raw

PATCH 3/5 hw/misc/allwinner-sid: Separate ALLWINNER_SID config symbol

In reply to Khai Do

Introduce a dedicated CONFIG_ALLWINNER_SID Kconfig symbol and select it from CONFIG_ALLWINNER_H3 so the SID controller can be reused by other Allwinner SoCs.

---
 hw/arm/Kconfig      | 1 +
 hw/misc/Kconfig     | 3 +++
 hw/misc/meson.build | 2 +-
 3 files changed, 5 insertions(+), 1 deletion(-)
hw/arm/Kconfig +1 -0
index 616beae7bf..21480e277d 100644
@@ -309,6 +309,7 @@ config ALLWINNER_H3
     select ALLWINNER_SUN8I_EMAC
     select ALLWINNER_I2C
     select ALLWINNER_WDT
+    select ALLWINNER_SID
     select SERIAL_MM
     select ARM_TIMER
     select ARM_GIC
hw/misc/Kconfig +3 -0
index 685b7ff1e7..1639978874 100644
@@ -268,6 +268,9 @@ config LASI
 config ALLWINNER_SRAMC
     bool
 
+config ALLWINNER_SID
+    bool
+
 config ALLWINNER_A10_CCM
     bool
 
hw/misc/meson.build +1 -1
index fc3800baec..059d4c01a1 100644
@@ -55,7 +55,7 @@ system_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c'))
 system_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'))
 system_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
 system_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-sysctrl.c'))
-system_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sid.c'))
+system_ss.add(when: 'CONFIG_ALLWINNER_SID', if_true: files('allwinner-sid.c'))
 system_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40-ccu.c'))
 system_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40-dramc.c'))
 system_ss.add(when: 'CONFIG_AXP2XX_PMU', if_true: files('axp2xx.c'))
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH 1/5 hw/arm/allwinner-h618: Add Allwinner H618 SoC emulation

In reply to Khai Do

The Allwinner H618 is a 64-bit quad-core Cortex-A53 SoC. This commit adds baseline SoC emulation including:
- 4x Cortex-A53 cores with PSCI conduit for SMP
- ARM GICv2 interrupt controller and generic timer PPI connections
- SRAM A1, SRAM A2, and 16550 UART0/1 controllers
- Unimplemented memory regions for non-critical peripherals

---
 MAINTAINERS                     |   7 +
 hw/arm/Kconfig                  |   7 +
 hw/arm/allwinner-h618.c         | 224 ++++++++++++++++++++++++++++++++
 hw/arm/meson.build              |   1 +
 include/hw/arm/allwinner-h618.h |  57 ++++++++
 5 files changed, 296 insertions(+)
 create mode 100644 hw/arm/allwinner-h618.c
 create mode 100644 include/hw/arm/allwinner-h618.h
MAINTAINERS +7 -0
index 70e9fed776..68f1c31d60 100644
@@ -779,6 +779,13 @@ F: hw/arm/orangepi.c
 F: docs/system/arm/orangepi.rst
 F: tests/functional/arm/test_orangepi.py
 
+Allwinner-h618
+M: Khai Do <[email protected]>
+L: [email protected]
+S: Maintained
+F: hw/*/allwinner-h618*
+F: include/hw/*/allwinner-h618*
+
 ARM PrimeCell and CMSDK devices
 M: Peter Maydell <[email protected]>
 L: [email protected]
hw/arm/Kconfig +7 -0
index e9f796f718..616beae7bf 100644
@@ -333,6 +333,13 @@ config ALLWINNER_R40
     select USB_EHCI_SYSBUS
     select SD
 
+config ALLWINNER_H618
+    bool
+    default y if TCG && AARCH64
+    select SERIAL_MM
+    select ARM_GIC
+    select UNIMP
+
 config MAX78000_SOC
     bool
     select ARM_V7M
hw/arm/allwinner-h618.c new file +224 -0

224 lines not on this page · raw message

hw/arm/meson.build +1 -0
index bcc068de04..42ed065b17 100644
@@ -24,6 +24,7 @@ arm_common_ss.add(when: 'CONFIG_OMAP', if_true: files('omap1.c'))
 arm_common_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubieboard.c'))
 arm_common_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c'))
 arm_common_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c', 'bananapi_m2u.c'))
+arm_common_ss.add(when: 'CONFIG_ALLWINNER_H618', if_true: files('allwinner-h618.c'))
 arm_common_ss.add(when: 'CONFIG_MAX78000_SOC', if_true: files('max78000_soc.c'))
 arm_common_ss.add(when: 'CONFIG_RASPI', if_true: files(
   'bcm2836.c',
include/hw/arm/allwinner-h618.h new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
2.43.0