Skip to contentSkip to conversation

Add an embedded controller to sbsa-ref machine

PATCH Applied Graeme Gregory 3 participants 5 messages Aug 26, 2020 – Sep 1, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover Add an embedded controller to sbsa-ref machine

This series is to an add embedded controller to the sbsa-ref machine so that PSCI can communicate platform power states to the platform which in this case is QEMU.

v1->v2
- broke out the EC itself as hw/misc/sbsa_ec.c as seperate patch
- applied review comments to date

#1 lore raw

PATCH v2 1/2 hw/misc/sbsa_ec : Add an embedded controller for sbsa-ref

A difference between sbsa platform and the virt platform is PSCI is handled by ARM-TF in the sbsa platform. This means that the PSCI code there needs to communicate some of the platform power changes down to the qemu code for things like shutdown/reset control.

Space has been left to extend the EC if we find other use cases in future where ARM-TF and qemu need to communicate.

---
 hw/misc/meson.build |  2 +
 hw/misc/sbsa_ec.c   | 98 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+)
 create mode 100644 hw/misc/sbsa_ec.c
hw/misc/meson.build +2 -0
index 84fed0494d..e1576b81cf 100644
@@ -97,3 +97,5 @@ specific_ss.add(when: 'CONFIG_MAC_VIA', if_true: files('mac_via.c'))
 
 specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_cmgcr.c', 'mips_cpc.c'))
 specific_ss.add(when: 'CONFIG_MIPS_ITU', if_true: files('mips_itu.c'))
+
+specific_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c'))
hw/misc/sbsa_ec.c new file +98 -0

98 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/2 hw/arm/sbsa-ref : Add embedded controller in secure memory

In reply to Graeme Gregory

Add the previously created sbsa-ec device to the sbsa-ref machine in secure memory so the PSCI implementation in ARM-TF can access it, but not expose it to non secure firmware or OS except by via ARM-TF.

---
 hw/arm/sbsa-ref.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
hw/arm/sbsa-ref.c +14 -0
index 2a7d9a61fc..8614709bfb 100644
@@ -62,6 +62,7 @@ enum {
     SBSA_CPUPERIPHS,
     SBSA_GIC_DIST,
     SBSA_GIC_REDIST,
+    SBSA_SECURE_EC,
     SBSA_SMMU,
     SBSA_UART,
     SBSA_RTC,
@@ -107,6 +108,7 @@ static const MemMapEntry sbsa_ref_memmap[] = {
     [SBSA_CPUPERIPHS] =         { 0x40000000, 0x00040000 },
     [SBSA_GIC_DIST] =           { 0x40060000, 0x00010000 },
     [SBSA_GIC_REDIST] =         { 0x40080000, 0x04000000 },
+    [SBSA_SECURE_EC] =          { 0x50000000, 0x00001000 },
     [SBSA_UART] =               { 0x60000000, 0x00001000 },
     [SBSA_RTC] =                { 0x60010000, 0x00001000 },
     [SBSA_GPIO] =               { 0x60020000, 0x00001000 },
@@ -585,6 +587,16 @@ static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size)
     return board->fdt;
 }
 
+static void create_secure_ec(MemoryRegion *mem)
+{
+    hwaddr base = sbsa_ref_memmap[SBSA_SECURE_EC].base;
+    DeviceState *dev = qdev_new("sbsa-ec");
+    SysBusDevice *s = SYS_BUS_DEVICE(dev);
+
+    memory_region_add_subregion(mem, base,
+                                sysbus_mmio_get_region(s, 0));
+}
+
 static void sbsa_ref_init(MachineState *machine)
 {
     unsigned int smp_cpus = machine->smp.cpus;
@@ -708,6 +720,8 @@ static void sbsa_ref_init(MachineState *machine)
 
     create_pcie(sms);
 
+    create_secure_ec(secure_sysmem);
+
     sms->bootinfo.ram_size = machine->ram_size;
     sms->bootinfo.nb_cpus = smp_cpus;
     sms->bootinfo.board_id = -1;
Signature · 1 line
2.25.1
Reviewed-by Tested-by on the v2 series
#3 lore raw
In reply to Graeme Gregory
Quoted 7 lines · Graeme Gregory

This series is to an add embedded controller to the sbsa-ref machine so that PSCI can communicate platform power states to the platform which in this case is QEMU.

v1->v2
- broke out the EC itself as hw/misc/sbsa_ec.c as seperate patch
- applied review comments to date

For the series:

Thanks!

#4 lore raw
In reply to Graeme Gregory
Quoted 9 lines · Graeme Gregory

This series is to an add embedded controller to the sbsa-ref machine so that PSCI can communicate platform power states to the platform which in this case is QEMU.

v1->v2
- broke out the EC itself as hw/misc/sbsa_ec.c as seperate patch
- applied review comments to date

Applied to target-arm.next, thanks.

-- PMM