xref: /openbmc/qemu/hw/virtio/virtio-acpi.c (revision ee88df50)
157ba8436SSunil V L // SPDX-License-Identifier: GPL-2.0+
257ba8436SSunil V L /*
357ba8436SSunil V L  * virtio ACPI Support
457ba8436SSunil V L  *
557ba8436SSunil V L  */
657ba8436SSunil V L 
7*ee88df50SPeter Maydell #include "qemu/osdep.h"
857ba8436SSunil V L #include "hw/virtio/virtio-acpi.h"
957ba8436SSunil V L #include "hw/acpi/aml-build.h"
1057ba8436SSunil V L 
virtio_acpi_dsdt_add(Aml * scope,const hwaddr base,const hwaddr size,uint32_t mmio_irq,long int start_index,int num)1157ba8436SSunil V L void virtio_acpi_dsdt_add(Aml *scope, const hwaddr base, const hwaddr size,
1257ba8436SSunil V L                           uint32_t mmio_irq, long int start_index, int num)
1357ba8436SSunil V L {
1457ba8436SSunil V L     hwaddr virtio_base = base;
1557ba8436SSunil V L     uint32_t irq = mmio_irq;
1657ba8436SSunil V L     long int i;
1757ba8436SSunil V L 
1857ba8436SSunil V L     for (i = start_index; i < start_index + num; i++) {
1957ba8436SSunil V L         Aml *dev = aml_device("VR%02u", (unsigned)i);
2057ba8436SSunil V L         aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005")));
2157ba8436SSunil V L         aml_append(dev, aml_name_decl("_UID", aml_int(i)));
2257ba8436SSunil V L         aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
2357ba8436SSunil V L 
2457ba8436SSunil V L         Aml *crs = aml_resource_template();
2557ba8436SSunil V L         aml_append(crs, aml_memory32_fixed(virtio_base, size, AML_READ_WRITE));
2657ba8436SSunil V L         aml_append(crs,
2757ba8436SSunil V L                    aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
2857ba8436SSunil V L                                  AML_EXCLUSIVE, &irq, 1));
2957ba8436SSunil V L         aml_append(dev, aml_name_decl("_CRS", crs));
3057ba8436SSunil V L         aml_append(scope, dev);
3157ba8436SSunil V L         virtio_base += size;
3257ba8436SSunil V L         irq++;
3357ba8436SSunil V L     }
3457ba8436SSunil V L }
35