All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, Ani Sinha <ani@anisinha.ca>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH v2 33/35] acpi: tpm-tis: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML
Date: Wed,  8 Jun 2022 09:53:38 -0400	[thread overview]
Message-ID: <20220608135340.3304695-34-imammedo@redhat.com> (raw)
In-Reply-To: <20220608135340.3304695-1-imammedo@redhat.com>

.. 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>
---
 hw/i386/acpi-build.c | 34 ----------------------------------
 hw/tpm/tpm_tis_isa.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 1204b6da05..0b65fc99cd 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
         }
     }
diff --git a/hw/tpm/tpm_tis_isa.c b/hw/tpm/tpm_tis_isa.c
index 3477afd735..91e3792248 100644
--- a/hw/tpm/tpm_tis_isa.c
+++ b/hw/tpm/tpm_tis_isa.c
@@ -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 },
         { }
     }
 };
-- 
2.31.1



  parent reply	other threads:[~2022-06-08 14:30 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 13:53 [PATCH v2 00/35] pc/q35: refactor ISA and SMBUS AML generation Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 01/35] acpi: add interface to build device specific AML Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 02/35] acpi: make isa_build_aml() support AcpiDevAmlIf interface Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 03/35] acpi: fdc-isa: replace ISADeviceClass::build_aml with AcpiDevAmlIfClass:build_dev_aml Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 04/35] acpi: parallel port: " Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 05/35] acpi: serial-is: " Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 06/35] acpi: mc146818rtc: " Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 07/35] acpi: pckbd: " Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 08/35] isa-bus: drop no longer used ISADeviceClass::build_aml Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 09/35] tests: acpi: add and whitelist DSDT.ipmismbus expected blob Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 10/35] tests: acpi: q35: add test for smbus-ipmi device Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 11/35] tests: acpi: update expected blob DSDT.ipmismbus Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 12/35] tests: acpi: whitelist DSDT.ipmismbus expected blob Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 13/35] ipmi: acpi: use relative path to resource source Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 14/35] tests: acpi: update expected DSDT.ipmismbus blob Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 15/35] acpi: ich9-smb: add support for AcpiDevAmlIf interface Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 16/35] acpi: ipmi: use AcpiDevAmlIf interface to build IPMI device descriptors Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 17/35] q35: acpi: drop not needed PCMachineClass::do_not_add_smb_acpi Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 18/35] tests: acpi: white-list to be re-factored pc/q35 DSDT Igor Mammedov
2022-06-09 11:48   ` [PATCH v3 " Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 19/35] acpi: pc: isa bridge: use AcpiDevAmlIf interface to build ISA device descriptors Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 20/35] acpi: q35: " Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 21/35] tests: acpi: update expected blobs Igor Mammedov
2022-06-09 11:51   ` [PATCH v3 " Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 22/35] tests: acpi: add and white-list DSDT.applesmc expected blob Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 23/35] tests: acpi: add applesmc testcase Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 24/35] acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 25/35] tests: acpi: update expected blobs Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 26/35] tests: acpi: white-lists expected DSDT.pvpanic-isa blob Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 27/35] tests: acpi: add pvpanic-isa: testcase Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 29/35] tests: acpi: update expected DSDT.pvpanic-isa blob Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 30/35] tests: acpi: white-list DSDT.tis.tpm2/DSDT.tis.tpm12 expected blobs Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 31/35] acpi: pc/q35: tpm-tis: fix TPM device scope Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 32/35] acpi: pc/q35: remove not needed 'if' condition on pci bus Igor Mammedov
2022-06-08 13:53 ` Igor Mammedov [this message]
2022-06-08 13:53 ` [PATCH v2 34/35] tests: acpi: update expected DSDT.tis.tpm2/DSDT.tis.tpm12 blobs Igor Mammedov
2022-06-08 13:53 ` [PATCH v2 35/35] x86: acpi-build: do not include hw/isa/isa.h directly Igor Mammedov
2022-06-09  9:30 ` [PATCH v2 00/35] pc/q35: refactor ISA and SMBUS AML generation Igor Mammedov
2022-06-09 11:55   ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220608135340.3304695-34-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=ani@anisinha.ca \
    --cc=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.