65
#include "target/arm/cpu.h"
66
#include "target/arm/multiprocessing.h"
67
#include "hw/watchdog/sbsa_gwdt.h"
68
+#include "hw/acpi/wdat-gwdt.h"
69
70
#include "smmuv3-accel.h"
71
#include "tegra241-cmdqv.h"
860
* 5.2.25 Generic Timer Description Table (GTDT)
861
*/
862
static void
862
-build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
863
+build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms,
864
+ bool add_watchdog)
865
{
866
/*
867
* Table 5-117 Flag Definitions
872
AcpiTable table = { .sig = "GTDT", .rev = 3, .oem_id = vms->oem_id,
873
.oem_table_id = vms->oem_table_id };
874
uint32_t gtdt_start = table_data->len;
873
- Object *wdt = object_resolve_type_unambiguous(TYPE_WDT_SBSA, NULL);
875
876
acpi_table_begin(&table, table_data);
877
904
build_append_int_noprefix(table_data, 0xFFFFFFFFFFFFFFFF, 8);
905
906
/* Platform Timer Count */
906
- build_append_int_noprefix(table_data, wdt ? 1 : 0, 4);
907
+ build_append_int_noprefix(table_data, add_watchdog ? 1 : 0, 4);
908
/* Platform Timer Offset */
909
build_append_int_noprefix(table_data,
909
- wdt ? (table_data->len - gtdt_start) +
910
- 4 + 4 + 4 /* len of this & following 2 fields to skip */
911
- : 0, 4);
910
+ add_watchdog ? (table_data->len - gtdt_start) +
911
+ 4 + 4 + 4 /* len of this & following 2 fields to skip */
912
+ : 0, 4);
913
914
if (vms->ns_el2_virt_timer_irq) {
915
/* Virtual EL2 Timer GSIV */
922
}
923
924
/* ACPI 6.5 spec: 5.2.25.2 ARM Generic Watchdog Structure (Table 5-124) */
924
- if (wdt) {
925
+ if (add_watchdog) {
926
hwaddr rbase = vms->memmap[VIRT_GWDT_REFRESH].base;
927
hwaddr cbase = vms->memmap[VIRT_GWDT_CONTROL].base;
928
int irq = ARM_SPI_BASE + vms->irqmap[VIRT_GWDT_WS0];
1333
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
1334
GArray *table_offsets;
1335
unsigned dsdt, xsdt;
1336
+ bool has_wdat = false;
1337
GArray *tables_blob = tables->table_data;
1338
MachineState *ms = MACHINE(vms);
1339
CPUCoreCaches caches[CPU_MAX_CACHES];
1340
unsigned int num_caches;
1341
+ Object *wdt = object_resolve_type_unambiguous(TYPE_WDT_SBSA, NULL);
1342
1343
num_caches = virt_get_caches(vms, caches);
1344
1345
+ if (wdt) {
1346
+ has_wdat = object_property_get_bool(wdt, "wdat", &error_abort);
1347
+ }
1348
+
1349
table_offsets = g_array_new(false, true /* clear */,
1350
sizeof(uint32_t));
1351
1364
acpi_add_table(table_offsets, tables_blob);
1365
build_madt(tables_blob, tables->linker, vms);
1366
1367
+ acpi_add_table(table_offsets, tables_blob);
1368
+ if (wdt && has_wdat) {
1369
+ uint64_t freq = object_property_get_uint(wdt, "clock-frequency",
1370
+ &error_abort);
1371
+ build_gwdt_wdat(tables_blob, tables->linker,
1372
+ vms->oem_id, vms->oem_table_id,
1373
+ vms->memmap[VIRT_GWDT_REFRESH].base,
1374
+ vms->memmap[VIRT_GWDT_CONTROL].base,
1375
+ freq);
1376
+ }
1377
+
1378
if (!vmc->no_cpu_topology) {
1379
acpi_add_table(table_offsets, tables_blob);
1380
build_pptt(tables_blob, tables->linker, ms, vms->oem_id,
1382
}
1383
1384
acpi_add_table(table_offsets, tables_blob);
1367
- build_gtdt(tables_blob, tables->linker, vms);
1385
+ build_gtdt(tables_blob, tables->linker, vms, wdt && !has_wdat);
1386
1387
acpi_add_table(table_offsets, tables_blob);
1388
{