1 /* SPDX-License-Identifier: GPL-2.0-only */
5 #include <console/console.h>
6 #include <device/device.h>
7 #include <device/mmio.h>
11 /* http://www.intel.com/hardwaredesign/hpetspec_1.pdf */
12 static void acpi_create_hpet(acpi_hpet_t
*hpet
)
14 acpi_header_t
*header
= &(hpet
->header
);
15 acpi_addr_t
*addr
= &(hpet
->addr
);
17 memset((void *)hpet
, 0, sizeof(acpi_hpet_t
));
22 /* Fill out header fields. */
23 memcpy(header
->signature
, "HPET", 4);
24 memcpy(header
->oem_id
, OEM_ID
, 6);
25 memcpy(header
->oem_table_id
, ACPI_TABLE_CREATOR
, 8);
26 memcpy(header
->asl_compiler_id
, ASLC
, 4);
28 header
->asl_compiler_revision
= asl_revision
;
29 header
->length
= sizeof(acpi_hpet_t
);
30 header
->revision
= get_acpi_table_revision(HPET
);
32 /* Fill out HPET address. */
33 addr
->space_id
= ACPI_ADDRESS_SPACE_MEMORY
;
36 addr
->addrl
= HPET_BASE_ADDRESS
& 0xffffffff;
37 addr
->addrh
= ((unsigned long long)HPET_BASE_ADDRESS
) >> 32;
39 hpet
->id
= read32p(HPET_BASE_ADDRESS
);
41 hpet
->min_tick
= CONFIG_HPET_MIN_TICKS
;
43 header
->checksum
= acpi_checksum((void *)hpet
, sizeof(acpi_hpet_t
));
46 unsigned long acpi_write_hpet(const struct device
*device
, unsigned long current
,
52 * We explicitly add these tables later on:
54 printk(BIOS_DEBUG
, "ACPI: * HPET\n");
56 hpet
= (acpi_hpet_t
*)current
;
57 current
+= sizeof(acpi_hpet_t
);
58 current
= ALIGN_UP(current
, 16);
59 acpi_create_hpet(hpet
);
60 acpi_add_table(rsdp
, hpet
);