aboutsummaryrefslogtreecommitdiff
path: root/hw/misc
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2022-06-08 09:53:29 -0400
committerMichael S. Tsirkin <mst@redhat.com>2022-06-09 19:32:49 -0400
commit1d7ea915003a2064dc542ffee8d02104a2dee728 (patch)
treec41379f119e199bd7cd925a8eac77c69c0c887ed /hw/misc
parentcde55744e9bcaefe1fbce6194a21bb3b7b9c2ae7 (diff)
acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML
.. 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> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20220608135340.3304695-25-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/misc')
-rw-r--r--hw/misc/applesmc.c29
1 files changed, 29 insertions, 0 deletions
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)