[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 24/35] acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to pro
From: |
Igor Mammedov |
Subject: |
[PATCH 24/35] acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML |
Date: |
Mon, 16 May 2022 11:25:59 -0400 |
.. and clean up not longer needed conditionals in DSTD build
code. applesmc AML will be fetched and included when ISA bridge
will build its own AML code (incl. 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>
---
include/hw/isa/isa.h | 14 --------------
hw/i386/acpi-build.c | 22 ----------------------
hw/misc/applesmc.c | 29 +++++++++++++++++++++++++++++
3 files changed, 29 insertions(+), 36 deletions(-)
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index 5c5a3d43a7..6f9380007d 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -16,20 +16,6 @@ OBJECT_DECLARE_TYPE(ISADevice, ISADeviceClass, ISA_DEVICE)
#define TYPE_ISA_BUS "ISA"
OBJECT_DECLARE_SIMPLE_TYPE(ISABus, ISA_BUS)
-#define TYPE_APPLE_SMC "isa-applesmc"
-#define APPLESMC_MAX_DATA_LENGTH 32
-#define APPLESMC_PROP_IO_BASE "iobase"
-
-static inline uint16_t applesmc_port(void)
-{
- Object *obj = object_resolve_path_type("", TYPE_APPLE_SMC, NULL);
-
- if (obj) {
- return object_property_get_uint(obj, APPLESMC_PROP_IO_BASE, NULL);
- }
- return 0;
-}
-
#define TYPE_ISADMA "isa-dma"
typedef struct IsaDmaClass IsaDmaClass;
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 33ee5bfcfb..517818cd9f 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -118,7 +118,6 @@ typedef struct AcpiMiscInfo {
const unsigned char *dsdt_code;
unsigned dsdt_size;
uint16_t pvpanic_port;
- uint16_t applesmc_io_base;
} AcpiMiscInfo;
typedef struct AcpiBuildPciBusHotplugState {
@@ -304,7 +303,6 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
info->tpm_version = tpm_get_version(tpm_find());
#endif
info->pvpanic_port = pvpanic_port();
- info->applesmc_io_base = applesmc_port();
}
/*
@@ -1751,26 +1749,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
aml_append(dsdt, scope);
}
- if (misc->applesmc_io_base) {
- scope = aml_scope("\\_SB.PCI0.ISA");
- dev = aml_device("SMC");
-
- aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
- /* device present, functioning, decoding, not shown in UI */
- aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
-
- crs = aml_resource_template();
- aml_append(crs,
- aml_io(AML_DECODE16, misc->applesmc_io_base,
misc->applesmc_io_base,
- 0x01, APPLESMC_MAX_DATA_LENGTH)
- );
- aml_append(crs, aml_irq_no_flags(6));
- aml_append(dev, aml_name_decl("_CRS", crs));
-
- aml_append(scope, dev);
- aml_append(dsdt, scope);
- }
-
if (misc->pvpanic_port) {
scope = aml_scope("\\_SB.PCI0.ISA");
diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c
index 81cd6b6423..5f9c742e50 100644
--- a/hw/misc/applesmc.c
+++ b/hw/misc/applesmc.c
@@ -37,10 +37,14 @@
#include "qemu/module.h"
#include "qemu/timer.h"
#include "qom/object.h"
+#include "hw/acpi/acpi_aml_interface.h"
/* #define DEBUG_SMC */
#define APPLESMC_DEFAULT_IOBASE 0x300
+#define TYPE_APPLE_SMC "isa-applesmc"
+#define APPLESMC_MAX_DATA_LENGTH 32
+#define APPLESMC_PROP_IO_BASE "iobase"
enum {
APPLESMC_DATA_PORT = 0x00,
@@ -347,14 +351,35 @@ static Property applesmc_isa_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
+static void build_applesmc_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+ Aml *crs;
+ AppleSMCState *s = APPLE_SMC(adev);
+ uint32_t iobase = s->iobase;
+ Aml *dev = aml_device("SMC");
+
+ aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
+ /* device present, functioning, decoding, not shown in UI */
+ aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
+ crs = aml_resource_template();
+ aml_append(crs,
+ aml_io(AML_DECODE16, iobase, iobase, 0x01, APPLESMC_MAX_DATA_LENGTH)
+ );
+ aml_append(crs, aml_irq_no_flags(6));
+ aml_append(dev, aml_name_decl("_CRS", crs));
+ aml_append(scope, dev);
+}
+
static void qdev_applesmc_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
dc->realize = applesmc_isa_realize;
dc->reset = qdev_applesmc_isa_reset;
device_class_set_props(dc, applesmc_isa_properties);
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+ adevc->build_dev_aml = build_applesmc_aml;
}
static const TypeInfo applesmc_isa_info = {
@@ -362,6 +387,10 @@ static const TypeInfo applesmc_isa_info = {
.parent = TYPE_ISA_DEVICE,
.instance_size = sizeof(AppleSMCState),
.class_init = qdev_applesmc_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_ACPI_DEV_AML_IF },
+ { },
+ },
};
static void applesmc_register_types(void)
--
2.31.1
- [PATCH 15/35] acpi: ich9-smb: add support for AcpiDevAmlIf interface, (continued)
- [PATCH 15/35] acpi: ich9-smb: add support for AcpiDevAmlIf interface, Igor Mammedov, 2022/05/16
- [PATCH 19/35] acpi: pc: isa bridge: use AcpiDevAmlIf interface to build ISA device descriptors, Igor Mammedov, 2022/05/16
- [PATCH 16/35] acpi: ipmi: use AcpiDevAmlIf interface to build IPMI device descriptors, Igor Mammedov, 2022/05/16
- [PATCH 17/35] q35: acpi: drop not needed PCMachineClass::do_not_add_smb_acpi, Igor Mammedov, 2022/05/16
- [PATCH 18/35] tests: acpi: white-list to be re-factored pc/q35 DSDT, Igor Mammedov, 2022/05/16
- [PATCH 09/35] tests: acpi: add and whitelist DSDT.ipmismbus expected blob, Igor Mammedov, 2022/05/16
- [PATCH 20/35] acpi: q35: isa bridge: use AcpiDevAmlIf interface to build ISA device descriptors, Igor Mammedov, 2022/05/16
- [PATCH 23/35] tests: acpi: add applesmc testcase, Igor Mammedov, 2022/05/16
- [PATCH 22/35] tests: acpi: add and white-list DSDT.applesmc expected blob, Igor Mammedov, 2022/05/16
- [PATCH 21/35] tests: acpi: update expected blobs, Igor Mammedov, 2022/05/16
- [PATCH 24/35] acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML,
Igor Mammedov <=
- [PATCH 26/35] tests: acpi: white-lists expected DSDT.pvpanic-isa blob, Igor Mammedov, 2022/05/16
- [PATCH 27/35] tests: acpi: add pvpanic-isa: testcase, Igor Mammedov, 2022/05/16
- [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML, Igor Mammedov, 2022/05/16
- Re: [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML, Igor Mammedov, 2022/05/17
- Re: [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML, Igor Mammedov, 2022/05/19