blob: 5dc334f1076f1502a1c74fbf57af206282f4452b [file] [log] [blame]
Angel Pons210a0082020-04-02 23:48:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Rudolphf1114d82017-11-14 19:00:20 +01002
3#include <console/console.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -07004#include <acpi/acpigen.h>
Patrick Rudolphf1114d82017-11-14 19:00:20 +01005#include <string.h>
6
7#include "h8.h"
8#include "chip.h"
9
Furquan Shaikh7536a392020-04-24 21:59:21 -070010static char *h8_dsdt_scope(const struct device *dev, const char *scope)
Patrick Rudolphf1114d82017-11-14 19:00:20 +010011{
12 static char buf[DEVICE_PATH_MAX] = {};
13 const char *path = acpi_device_path(dev);
14
15 memset(buf, 0, sizeof(buf));
16 snprintf(buf, sizeof(buf) - 1, "%s.%s", path, scope);
17
18 return buf;
19}
20
21/*
22 * Generates EC SSDT.
23 */
Furquan Shaikh7536a392020-04-24 21:59:21 -070024void h8_ssdt_generator(const struct device *dev)
Patrick Rudolphf1114d82017-11-14 19:00:20 +010025{
Patrick Rudolph6b7178a2017-08-14 17:46:58 +020026 struct ec_lenovo_h8_config *conf = dev->chip_info;
27
Patrick Rudolphf1114d82017-11-14 19:00:20 +010028 if (!acpi_device_path(dev))
29 return;
30
31 printk(BIOS_INFO, "ACPI: * H8\n");
32
33 /* Scope HKEY */
34 acpigen_write_scope(h8_dsdt_scope(dev, "HKEY"));
35
36 /* Used by thinkpad_acpi */
37 acpigen_write_name_byte("HBDC", h8_has_bdc(dev) ? ONE_OP : ZERO_OP);
Patrick Rudolph60eca532017-08-13 12:55:41 +020038 acpigen_write_name_byte("HWAN", h8_has_wwan(dev) ? ONE_OP : ZERO_OP);
Patrick Rudolph6b7178a2017-08-14 17:46:58 +020039 acpigen_write_name_byte("HKBL", (conf && conf->has_keyboard_backlight) ?
40 ONE_OP : ZERO_OP);
Patrick Rudolphf281b6d2017-08-14 18:41:32 +020041 acpigen_write_name_byte("HUWB", (conf && conf->has_uwb) ?
42 ONE_OP : ZERO_OP);
Patrick Rudolphf1114d82017-11-14 19:00:20 +010043
44 acpigen_pop_len(); /* Scope HKEY */
45}