1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <acpi/acpi_device.h>
4 #include <acpi/acpigen.h>
5 #include <console/console.h>
6 #include <device/device.h>
7 #include <device/path.h>
12 #define CROS_EC_I2C_TUNNEL_HID "GOOG0012"
13 #define CROS_EC_I2C_TUNNEL_DDN "Cros EC I2C Tunnel"
15 static void crosec_i2c_tunnel_fill_ssdt(const struct device
*dev
)
17 const char *scope
= acpi_device_scope(dev
);
18 struct ec_google_chromeec_i2c_tunnel_config
*cfg
= dev
->chip_info
;
24 acpigen_write_scope(scope
);
26 acpigen_write_device(acpi_device_name(dev
));
27 acpigen_write_name_string("_HID", CROS_EC_I2C_TUNNEL_HID
);
28 acpigen_write_name_integer("_UID", cfg
->uid
);
29 acpigen_write_name_string("_DDN", CROS_EC_I2C_TUNNEL_DDN
);
30 acpigen_write_STA(acpi_device_status(dev
));
32 dsd
= acpi_dp_new_table("_DSD");
33 acpi_dp_add_integer(dsd
, "google,remote-bus", cfg
->remote_bus
);
36 acpigen_pop_len(); /* Device */
37 acpigen_pop_len(); /* Scope */
39 printk(BIOS_INFO
, "%s: %s at %s\n", acpi_device_path(dev
), CROS_EC_I2C_TUNNEL_DDN
,
43 static const char *crosec_i2c_tunnel_acpi_name(const struct device
*dev
)
45 struct ec_google_chromeec_i2c_tunnel_config
*cfg
= dev
->chip_info
;
51 snprintf(name
, sizeof(name
), "TUN%X", dev
->path
.generic
.id
);
55 static struct device_operations crosec_i2c_tunnel_ops
= {
56 .read_resources
= noop_read_resources
,
57 .set_resources
= noop_set_resources
,
58 .acpi_name
= crosec_i2c_tunnel_acpi_name
,
59 .acpi_fill_ssdt
= crosec_i2c_tunnel_fill_ssdt
,
60 .scan_bus
= scan_static_bus
,
63 static void crosec_i2c_tunnel_enable(struct device
*dev
)
65 dev
->ops
= &crosec_i2c_tunnel_ops
;
68 struct chip_operations ec_google_chromeec_i2c_tunnel_ops
= {
69 .name
= "CrosEC I2C Tunnel Device",
70 .enable_dev
= crosec_i2c_tunnel_enable