Prashant Malani | 688105b | 2022-04-01 20:19:20 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include <acpi/acpigen.h> |
| 4 | |
Prashant Malani | 1e0d2e0 | 2022-06-13 21:51:52 +0000 | [diff] [blame^] | 5 | #include "chip.h" |
| 6 | |
Prashant Malani | 688105b | 2022-04-01 20:19:20 +0000 | [diff] [blame] | 7 | static const char *conn_acpi_name(const struct device *dev) |
| 8 | { |
| 9 | static char name[5]; |
| 10 | snprintf(name, sizeof(name), "CON%1X", dev->path.generic.id); |
| 11 | return name; |
| 12 | } |
| 13 | |
| 14 | static void conn_fill_ssdt(const struct device *dev) |
| 15 | { |
Prashant Malani | 1e0d2e0 | 2022-06-13 21:51:52 +0000 | [diff] [blame^] | 16 | const struct ec_google_chromeec_mux_conn_config *config = dev->chip_info; |
Prashant Malani | 688105b | 2022-04-01 20:19:20 +0000 | [diff] [blame] | 17 | const char *name; |
| 18 | name = acpi_device_name(dev); |
| 19 | if (!name) |
| 20 | return; |
| 21 | |
| 22 | acpigen_write_scope(acpi_device_scope(dev)); |
| 23 | acpigen_write_device(name); |
| 24 | |
| 25 | acpigen_write_name_integer("_ADR", dev->path.generic.id); |
| 26 | |
Prashant Malani | 1e0d2e0 | 2022-06-13 21:51:52 +0000 | [diff] [blame^] | 27 | if (config && config->mode_switch) { |
| 28 | struct acpi_dp *dsd = acpi_dp_new_table("_DSD"); |
| 29 | acpi_dp_add_integer(dsd, "mode-switch", 1); |
| 30 | acpi_dp_write(dsd); |
| 31 | } |
| 32 | |
Prashant Malani | 688105b | 2022-04-01 20:19:20 +0000 | [diff] [blame] | 33 | acpigen_write_device_end(); |
| 34 | acpigen_write_scope_end(); |
| 35 | } |
| 36 | |
| 37 | static struct device_operations conn_dev_ops = { |
| 38 | .read_resources = noop_read_resources, |
| 39 | .set_resources = noop_set_resources, |
| 40 | .acpi_name = conn_acpi_name, |
| 41 | .acpi_fill_ssdt = conn_fill_ssdt, |
| 42 | }; |
| 43 | |
| 44 | static void conn_enable(struct device *dev) |
| 45 | { |
| 46 | dev->ops = &conn_dev_ops; |
| 47 | } |
| 48 | |
| 49 | struct chip_operations ec_google_chromeec_mux_conn_ops = { |
| 50 | CHIP_NAME("CrosEC Type C Mux device") |
| 51 | .enable_dev = conn_enable, |
| 52 | }; |