Angel Pons | 210a008 | 2020-04-02 23:48:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Rudolph | f1114d8 | 2017-11-14 19:00:20 +0100 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 4 | #include <acpi/acpigen.h> |
Patrick Rudolph | f1114d8 | 2017-11-14 19:00:20 +0100 | [diff] [blame] | 5 | #include <string.h> |
| 6 | |
| 7 | #include "h8.h" |
| 8 | #include "chip.h" |
| 9 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 10 | static char *h8_dsdt_scope(const struct device *dev, const char *scope) |
Patrick Rudolph | f1114d8 | 2017-11-14 19:00:20 +0100 | [diff] [blame] | 11 | { |
| 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 Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 24 | void h8_ssdt_generator(const struct device *dev) |
Patrick Rudolph | f1114d8 | 2017-11-14 19:00:20 +0100 | [diff] [blame] | 25 | { |
Patrick Rudolph | 6b7178a | 2017-08-14 17:46:58 +0200 | [diff] [blame] | 26 | struct ec_lenovo_h8_config *conf = dev->chip_info; |
| 27 | |
Patrick Rudolph | f1114d8 | 2017-11-14 19:00:20 +0100 | [diff] [blame] | 28 | 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 Rudolph | 60eca53 | 2017-08-13 12:55:41 +0200 | [diff] [blame] | 38 | acpigen_write_name_byte("HWAN", h8_has_wwan(dev) ? ONE_OP : ZERO_OP); |
Patrick Rudolph | 6b7178a | 2017-08-14 17:46:58 +0200 | [diff] [blame] | 39 | acpigen_write_name_byte("HKBL", (conf && conf->has_keyboard_backlight) ? |
| 40 | ONE_OP : ZERO_OP); |
Patrick Rudolph | f281b6d | 2017-08-14 18:41:32 +0200 | [diff] [blame] | 41 | acpigen_write_name_byte("HUWB", (conf && conf->has_uwb) ? |
| 42 | ONE_OP : ZERO_OP); |
Patrick Rudolph | f1114d8 | 2017-11-14 19:00:20 +0100 | [diff] [blame] | 43 | |
| 44 | acpigen_pop_len(); /* Scope HKEY */ |
| 45 | } |