Skip to content

Commit

Permalink
pc: acpi: move HPET from DSDT to SSDT
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Igor Mammedov authored and mstsirkin committed Jan 9, 2016
1 parent 5ca5efa commit a57d708
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 54 deletions.
53 changes: 53 additions & 0 deletions hw/i386/acpi-build.c
Expand Up @@ -52,6 +52,7 @@
#include "hw/pci/pci_bus.h"
#include "hw/pci-host/q35.h"
#include "hw/i386/intel_iommu.h"
#include "hw/timer/hpet.h"

#include "hw/i386/q35-acpi-dsdt.hex"
#include "hw/i386/acpi-dsdt.hex"
Expand Down Expand Up @@ -1147,6 +1148,57 @@ static void build_memory_devices(Aml *sb_scope, int nr_mem,
aml_append(sb_scope, method);
}

static void build_hpet_aml(Aml *table)
{
Aml *crs;
Aml *field;
Aml *method;
Aml *if_ctx;
Aml *scope = aml_scope("_SB");
Aml *dev = aml_device("HPET");
Aml *zero = aml_int(0);
Aml *id = aml_local(0);
Aml *period = aml_local(1);

aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0103")));
aml_append(dev, aml_name_decl("_UID", zero));

aml_append(dev,
aml_operation_region("HPTM", AML_SYSTEM_MEMORY, HPET_BASE, HPET_LEN));
field = aml_field("HPTM", AML_DWORD_ACC, AML_LOCK, AML_PRESERVE);
aml_append(field, aml_named_field("VEND", 32));
aml_append(field, aml_named_field("PRD", 32));
aml_append(dev, field);

method = aml_method("_STA", 0, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_name("VEND"), id));
aml_append(method, aml_store(aml_name("PRD"), period));
aml_append(method, aml_shiftright(id, aml_int(16), id));
if_ctx = aml_if(aml_lor(aml_equal(id, zero),
aml_equal(id, aml_int(0xffff))));
{
aml_append(if_ctx, aml_return(zero));
}
aml_append(method, if_ctx);

if_ctx = aml_if(aml_lor(aml_equal(period, zero),
aml_lgreater(period, aml_int(100000000))));
{
aml_append(if_ctx, aml_return(zero));
}
aml_append(method, if_ctx);

aml_append(method, aml_return(aml_int(0x0F)));
aml_append(dev, method);

crs = aml_resource_template();
aml_append(crs, aml_memory32_fixed(HPET_BASE, HPET_LEN, AML_READ_ONLY));
aml_append(dev, aml_name_decl("_CRS", crs));

aml_append(scope, dev);
aml_append(table, scope);
}

static void
build_ssdt(GArray *table_data, GArray *linker,
AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
Expand All @@ -1167,6 +1219,7 @@ build_ssdt(GArray *table_data, GArray *linker,
/* Reserve space for header */
acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));

build_hpet_aml(ssdt);
build_cpu_hotplug_aml(ssdt);
build_memory_hotplug_aml(ssdt, nr_mem, pm->mem_hp_io_base,
pm->mem_hp_io_len);
Expand Down
48 changes: 0 additions & 48 deletions hw/i386/acpi-dsdt-hpet.dsl

This file was deleted.

2 changes: 0 additions & 2 deletions hw/i386/acpi-dsdt.dsl
Expand Up @@ -41,8 +41,6 @@ DefinitionBlock (
}
}

#include "acpi-dsdt-hpet.dsl"

/****************************************************************
* PIIX4 PM
****************************************************************/
Expand Down
3 changes: 0 additions & 3 deletions hw/i386/q35-acpi-dsdt.dsl
Expand Up @@ -115,9 +115,6 @@ DefinitionBlock (
}
}

#include "acpi-dsdt-hpet.dsl"


/****************************************************************
* LPC ISA bridge
****************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion hw/timer/hpet.c
Expand Up @@ -713,7 +713,7 @@ static void hpet_init(Object *obj)
HPETState *s = HPET(obj);

/* HPET Area */
memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", 0x400);
memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", HPET_LEN);
sysbus_init_mmio(sbd, &s->iomem);
}

Expand Down
1 change: 1 addition & 0 deletions include/hw/timer/hpet.h
Expand Up @@ -16,6 +16,7 @@
#include "qom/object.h"

#define HPET_BASE 0xfed00000
#define HPET_LEN 0x400
#define HPET_CLK_PERIOD 10 /* 10 ns*/

#define FS_PER_NS 1000000 /* 1000000 femtoseconds == 1 ns */
Expand Down

0 comments on commit a57d708

Please sign in to comment.