Debian Codegraph @

src/mainboard/getac/p470/acpi_tables.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <string.h>
4 #include <console/console.h>
5 #include <acpi/acpi.h>
6 #include <device/device.h>
7
8 #include "mainboard.h"
9
10 static long acpi_create_ecdt(acpi_ecdt_t * ecdt)
11 {
12 /* Attention: Make sure these match the values from
13 * the DSDT's ec.asl
14 */
15 static const char ec_id[] = "\\_SB.PCI0.LPCB.EC0";
16 int ecdt_len = sizeof(acpi_ecdt_t) + strlen(ec_id) + 1;
17
18 acpi_header_t *header = &(ecdt->header);
19
20 memset((void *)ecdt, 0, ecdt_len);
21
22 /* fill out header fields */
23 memcpy(header->signature, "ECDT", 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);
27
28 header->length = ecdt_len;
29 header->revision = 1;
30
31 /* Location of the two EC registers */
32 ecdt->ec_control.space_id = ACPI_ADDRESS_SPACE_IO;
33 ecdt->ec_control.bit_width = 8;
34 ecdt->ec_control.bit_offset = 0;
35 ecdt->ec_control.addrl = 0x66;
36 ecdt->ec_control.addrh = 0;
37
38 ecdt->ec_data.space_id = ACPI_ADDRESS_SPACE_IO;
39 ecdt->ec_data.bit_width = 8;
40 ecdt->ec_data.bit_offset = 0;
41 ecdt->ec_data.addrl = 0x62;
42 ecdt->ec_data.addrh = 0;
43
44 ecdt->uid = 1; // Must match _UID of the EC0 node.
45
46 ecdt->gpe_bit = 23; // SCI interrupt within GPEx_STS
47
48 memcpy(ecdt->ec_id, ec_id, sizeof(ec_id));
49
50 header->checksum =
51 acpi_checksum((void *)ecdt, ecdt_len);
52
53 return header->length;
54 }
55
56 unsigned long mainboard_write_acpi_tables(const struct device *device,
57 unsigned long start,
58 acpi_rsdp_t *rsdp)
59 {
60 unsigned long current;
61 acpi_header_t *ecdt;
62
63 current = start;
64
65 /* Align ACPI tables to 16byte */
66 current = acpi_align_current(current);
67
68 printk(BIOS_DEBUG, "ACPI: * ECDT\n");
69 ecdt = (acpi_header_t *)current;
70 current += acpi_create_ecdt((acpi_ecdt_t *)current);
71 current = acpi_align_current(current);
72 acpi_add_table(rsdp, ecdt);
73
74 printk(BIOS_DEBUG, "current = %lx\n", current);
75 return current;
76 }