blob: cb7478ab128383599f4a465b371772c7d20978ef [file] [log] [blame]
Prashant Malani688105b2022-04-01 20:19:20 +00001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
3#include <acpi/acpigen.h>
4
Prashant Malani1e0d2e02022-06-13 21:51:52 +00005#include "chip.h"
6
Prashant Malani688105b2022-04-01 20:19:20 +00007static 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
14static void conn_fill_ssdt(const struct device *dev)
15{
Prashant Malani1e0d2e02022-06-13 21:51:52 +000016 const struct ec_google_chromeec_mux_conn_config *config = dev->chip_info;
Prashant Malani688105b2022-04-01 20:19:20 +000017 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 Malani1e0d2e02022-06-13 21:51:52 +000027 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 Malani688105b2022-04-01 20:19:20 +000033 acpigen_write_device_end();
34 acpigen_write_scope_end();
35}
36
37static 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
44static void conn_enable(struct device *dev)
45{
46 dev->ops = &conn_dev_ops;
47}
48
49struct chip_operations ec_google_chromeec_mux_conn_ops = {
50 CHIP_NAME("CrosEC Type C Mux device")
51 .enable_dev = conn_enable,
52};