[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/11] hw/loongarch/virt: add plug handler for TPM on SysBus
From: |
Joelle van Dyne |
Subject: |
[PATCH 08/11] hw/loongarch/virt: add plug handler for TPM on SysBus |
Date: |
Wed, 12 Jul 2023 20:51:13 -0700 |
TPM needs to know its own base address in order to generate its DSDT
device entry.
Signed-off-by: Joelle van Dyne <j@getutm.app>
---
hw/loongarch/virt.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index e19b042ce8..9c536c52bc 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -1040,6 +1040,37 @@ static void virt_mem_plug(HotplugHandler *hotplug_dev,
dev, &error_abort);
}
+#ifdef CONFIG_TPM
+static void virt_tpm_plug(LoongArchMachineState *lams, TPMIf *tpmif)
+{
+ PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(lams->platform_bus_dev);
+ hwaddr pbus_base = VIRT_PLATFORM_BUS_BASEADDRESS;
+ SysBusDevice *sbdev = SYS_BUS_DEVICE(tpmif);
+ MemoryRegion *sbdev_mr;
+ hwaddr tpm_base;
+ uint64_t tpm_size;
+
+ if (!sbdev || !object_dynamic_cast(OBJECT(sbdev), TYPE_SYS_BUS_DEVICE)) {
+ return;
+ }
+
+ tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
+ assert(tpm_base != -1);
+
+ tpm_base += pbus_base;
+
+ sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
+ tpm_size = memory_region_size(sbdev_mr);
+
+ if (object_property_find(OBJECT(sbdev), "baseaddr")) {
+ object_property_set_uint(OBJECT(sbdev), "baseaddr", tpm_base, NULL);
+ }
+ if (object_property_find(OBJECT(sbdev), "size")) {
+ object_property_set_uint(OBJECT(sbdev), "size", tpm_size, NULL);
+ }
+}
+#endif
+
static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
@@ -1054,6 +1085,12 @@ static void
loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev,
} else if (memhp_type_supported(dev)) {
virt_mem_plug(hotplug_dev, dev, errp);
}
+
+#ifdef CONFIG_TPM
+ if (object_dynamic_cast(OBJECT(dev), TYPE_TPM_IF)) {
+ virt_tpm_plug(lams, TPM_IF(dev));
+ }
+#endif
}
static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
--
2.39.2 (Apple Git-143)
- Re: [PATCH 04/11] tpm_crb: use a single read-as-mem/write-as-mmio mapping, (continued)
[PATCH 10/11] tpm_tis_sysbus: move DSDT AML generation to device, Joelle van Dyne, 2023/07/12
[PATCH 05/11] tpm_crb: use the ISA bus, Joelle van Dyne, 2023/07/12
[PATCH 07/11] hw/arm/virt: add plug handler for TPM on SysBus, Joelle van Dyne, 2023/07/12
[PATCH 08/11] hw/loongarch/virt: add plug handler for TPM on SysBus,
Joelle van Dyne <=
[PATCH 11/11] tpm_crb_sysbus: introduce TPM CRB SysBus device, Joelle van Dyne, 2023/07/12
[PATCH 09/11] tpm_tis_sysbus: fix crash when PPI is enabled, Joelle van Dyne, 2023/07/12
Re: [PATCH 00/11] tpm: introduce TPM CRB SysBus device, Stefan Berger, 2023/07/13