blob: 1200b5c904de26d119fd2bd0904d4d72a5fb074c [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>
Elyes Haouasbdd03c22024-05-27 11:20:07 +02004#include <stdio.h>
Prashant Malani688105b2022-04-01 20:19:20 +00005
Prashant Malani1e0d2e02022-06-13 21:51:52 +00006#include "chip.h"
7
Prashant Malani688105b2022-04-01 20:19:20 +00008static const char *conn_acpi_name(const struct device *dev)
9{
10 static char name[5];
11 snprintf(name, sizeof(name), "CON%1X", dev->path.generic.id);
12 return name;
13}
14
15static void conn_fill_ssdt(const struct device *dev)
16{
Prashant Malani1e0d2e02022-06-13 21:51:52 +000017 const struct ec_google_chromeec_mux_conn_config *config = dev->chip_info;
Prashant Malani688105b2022-04-01 20:19:20 +000018 const char *name;
19 name = acpi_device_name(dev);
20 if (!name)
21 return;
22
23 acpigen_write_scope(acpi_device_scope(dev));
24 acpigen_write_device(name);
25
26 acpigen_write_name_integer("_ADR", dev->path.generic.id);
27
Prashant Malani8c3fa462022-12-29 18:46:47 +000028 if (config) {
Prashant Malani1e0d2e02022-06-13 21:51:52 +000029 struct acpi_dp *dsd = acpi_dp_new_table("_DSD");
Prashant Malani8c3fa462022-12-29 18:46:47 +000030
31 if (config->mode_switch)
32 acpi_dp_add_integer(dsd, "mode-switch", 1);
33 if (config->retimer_switch)
34 acpi_dp_add_integer(dsd, "retimer-switch", 1);
35
Prashant Malani1e0d2e02022-06-13 21:51:52 +000036 acpi_dp_write(dsd);
37 }
38
Prashant Malani688105b2022-04-01 20:19:20 +000039 acpigen_write_device_end();
40 acpigen_write_scope_end();
41}
42
43static struct device_operations conn_dev_ops = {
44 .read_resources = noop_read_resources,
45 .set_resources = noop_set_resources,
46 .acpi_name = conn_acpi_name,
47 .acpi_fill_ssdt = conn_fill_ssdt,
48};
49
50static void conn_enable(struct device *dev)
51{
52 dev->ops = &conn_dev_ops;
53}
54
55struct chip_operations ec_google_chromeec_mux_conn_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +090056 .name = "CrosEC Type C Mux device",
Prashant Malani688105b2022-04-01 20:19:20 +000057 .enable_dev = conn_enable,
58};