summaryrefslogtreecommitdiff
path: root/src/ec/lenovo/h8/ssdt.c
blob: 6b821a40f2fb6a6d75d42b51e1fe834db93d9ee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* SPDX-License-Identifier: GPL-2.0-only */
/* This file is part of the coreboot project. */

#include <console/console.h>
#include <arch/acpigen.h>
#include <string.h>

#include "h8.h"
#include "chip.h"

static char *h8_dsdt_scope(struct device *dev, const char *scope)
{
	static char buf[DEVICE_PATH_MAX] = {};
	const char *path = acpi_device_path(dev);

	memset(buf, 0, sizeof(buf));
	snprintf(buf, sizeof(buf) - 1, "%s.%s", path, scope);

	return buf;
}

/*
 * Generates EC SSDT.
 */
void h8_ssdt_generator(struct device *dev)
{
	struct ec_lenovo_h8_config *conf = dev->chip_info;

	if (!acpi_device_path(dev))
		return;

	printk(BIOS_INFO, "ACPI:    * H8\n");

	/* Scope HKEY */
	acpigen_write_scope(h8_dsdt_scope(dev, "HKEY"));

	/* Used by thinkpad_acpi */
	acpigen_write_name_byte("HBDC", h8_has_bdc(dev) ? ONE_OP : ZERO_OP);
	acpigen_write_name_byte("HWAN", h8_has_wwan(dev) ? ONE_OP : ZERO_OP);
	acpigen_write_name_byte("HKBL", (conf && conf->has_keyboard_backlight) ?
				ONE_OP : ZERO_OP);
	acpigen_write_name_byte("HUWB", (conf && conf->has_uwb) ?
				ONE_OP : ZERO_OP);

	acpigen_pop_len(); /* Scope HKEY */
}