• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <acpi/acpigen.h>
5 #include <stdio.h>
6 #include <string.h>
7 
8 #include "h8.h"
9 #include "chip.h"
10 
h8_dsdt_scope(const struct device * dev,const char * scope)11 static char *h8_dsdt_scope(const struct device *dev, const char *scope)
12 {
13 	static char buf[DEVICE_PATH_MAX] = {};
14 	const char *path = acpi_device_path(dev);
15 
16 	memset(buf, 0, sizeof(buf));
17 	snprintf(buf, sizeof(buf) - 1, "%s.%s", path, scope);
18 
19 	return buf;
20 }
21 
22 /*
23  * Generates EC SSDT.
24  */
h8_ssdt_generator(const struct device * dev)25 void h8_ssdt_generator(const struct device *dev)
26 {
27 	struct ec_lenovo_h8_config *conf = dev->chip_info;
28 
29 	if (!acpi_device_path(dev))
30 		return;
31 
32 	printk(BIOS_INFO, "ACPI:    * H8\n");
33 
34 	/* Scope HKEY */
35 	acpigen_write_scope(h8_dsdt_scope(dev, "HKEY"));
36 
37 	/* Used by thinkpad_acpi */
38 	acpigen_write_name_byte("HBDC", h8_has_bdc(dev) ? ONE_OP : ZERO_OP);
39 	acpigen_write_name_byte("HWAN", h8_has_wwan(dev) ? ONE_OP : ZERO_OP);
40 	acpigen_write_name_byte("HKBL", (conf && conf->has_keyboard_backlight) ?
41 				ONE_OP : ZERO_OP);
42 	acpigen_write_name_byte("HUWB", (conf && conf->has_uwb) ?
43 				ONE_OP : ZERO_OP);
44 
45 	acpigen_pop_len(); /* Scope HKEY */
46 }
47