acpi: tpm-tis: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

.. and clean up not longer needed conditionals in DSTD build code
tpm-tis AML will be fetched and included when ISA bridge will
build its own AML code (including attached devices).

Expected AML change:
    the device under separate _SB.PCI0.ISA scope is moved directly
    under Device(ISA) node.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Message-Id: <20220608135340.3304695-34-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Igor Mammedov 2022-06-08 09:53:38 -04:00 committed by Michael S. Tsirkin
parent d3ecb22c93
commit 168e3aa7ac
2 changed files with 32 additions and 34 deletions

View file

@ -1804,40 +1804,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
Aml *scope = aml_scope("PCI0");
/* Scan all PCI buses. Generate tables to support hotplug. */
build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
#ifdef CONFIG_TPM
if (TPM_IS_TIS_ISA(tpm)) {
dev = aml_device("ISA.TPM");
if (misc->tpm_version == TPM_VERSION_2_0) {
aml_append(dev, aml_name_decl("_HID",
aml_string("MSFT0101")));
aml_append(dev,
aml_name_decl("_STR",
aml_string("TPM 2.0 Device")));
} else {
aml_append(dev, aml_name_decl("_HID",
aml_eisaid("PNP0C31")));
}
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
crs = aml_resource_template();
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
/*
FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
Rewrite to take IRQ from TPM device model and
fix default IRQ value there to use some unused IRQ
*/
/* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
aml_append(dev, aml_name_decl("_CRS", crs));
tpm_build_ppi_acpi(tpm, dev);
aml_append(scope, dev);
}
#endif
aml_append(sb_scope, scope);
}
}

View file

@ -30,6 +30,7 @@
#include "tpm_prop.h"
#include "tpm_tis.h"
#include "qom/object.h"
#include "hw/acpi/acpi_aml_interface.h"
struct TPMStateISA {
/*< private >*/
@ -138,10 +139,39 @@ static void tpm_tis_isa_realizefn(DeviceState *dev, Error **errp)
}
}
static void build_tpm_tis_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
{
Aml *dev, *crs;
TPMStateISA *isadev = TPM_TIS_ISA(adev);
TPMIf *ti = TPM_IF(isadev);
dev = aml_device("TPM");
if (tpm_tis_isa_get_tpm_version(ti) == TPM_VERSION_2_0) {
aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device")));
} else {
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
}
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
crs = aml_resource_template();
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE, TPM_TIS_ADDR_SIZE,
AML_READ_WRITE));
/*
* FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
* fix default TPM_TIS_IRQ value there to use some unused IRQ
*/
/* aml_append(crs, aml_irq_no_flags(isadev->state.irq_num)); */
aml_append(dev, aml_name_decl("_CRS", crs));
tpm_build_ppi_acpi(ti, dev);
aml_append(scope, dev);
}
static void tpm_tis_isa_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
TPMIfClass *tc = TPM_IF_CLASS(klass);
AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
device_class_set_props(dc, tpm_tis_isa_properties);
dc->vmsd = &vmstate_tpm_tis_isa;
@ -151,6 +181,7 @@ static void tpm_tis_isa_class_init(ObjectClass *klass, void *data)
tc->request_completed = tpm_tis_isa_request_completed;
tc->get_version = tpm_tis_isa_get_tpm_version;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
adevc->build_dev_aml = build_tpm_tis_isa_aml;
}
static const TypeInfo tpm_tis_isa_info = {
@ -161,6 +192,7 @@ static const TypeInfo tpm_tis_isa_info = {
.class_init = tpm_tis_isa_class_init,
.interfaces = (InterfaceInfo[]) {
{ TYPE_TPM_IF },
{ TYPE_ACPI_DEV_AML_IF },
{ }
}
};