aboutsummaryrefslogtreecommitdiff
path: root/src/ec/google/chromeec/mux/conn/conn.c
blob: 43f5595aa71e6592ef154edebde58e10ff7cb63d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include <acpi/acpigen.h>

static const char *conn_acpi_name(const struct device *dev)
{
	static char name[5];
	snprintf(name, sizeof(name), "CON%1X", dev->path.generic.id);
	return name;
}

static void conn_fill_ssdt(const struct device *dev)
{
	const char *name;
	name = acpi_device_name(dev);
	if (!name)
		return;

	acpigen_write_scope(acpi_device_scope(dev));
	acpigen_write_device(name);

	acpigen_write_name_integer("_ADR", dev->path.generic.id);

	acpigen_write_device_end();
	acpigen_write_scope_end();
}

static struct device_operations conn_dev_ops = {
	.read_resources	= noop_read_resources,
	.set_resources	= noop_set_resources,
	.acpi_name	= conn_acpi_name,
	.acpi_fill_ssdt	= conn_fill_ssdt,
};

static void conn_enable(struct device *dev)
{
	dev->ops = &conn_dev_ops;
}

struct chip_operations ec_google_chromeec_mux_conn_ops = {
	CHIP_NAME("CrosEC Type C Mux device")
	.enable_dev	= conn_enable,
};