mb/google/nissa/var/rull: Configure Acoustic noise mitigation
[coreboot2.git] / src / ec / google / chromeec / audio_codec / audio_codec.c
blobfe2a459515b85cbfa06de37e3c0f0eaf142ece25
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>
8 #include <stdio.h>
10 #include "chip.h"
12 #define CROS_EC_AUDIO_CODEC_HID "GOOG0013"
13 #define CROS_EC_AUDIO_CODEC_DDN "Cros EC audio codec"
15 static void crosec_audio_codec_fill_ssdt(const struct device *dev)
17 const char *scope = acpi_device_scope(dev);
18 struct ec_google_chromeec_audio_codec_config *cfg = dev->chip_info;
20 if (!scope || !cfg)
21 return;
23 acpigen_write_scope(scope);
25 acpigen_write_device(acpi_device_name(dev));
26 acpigen_write_name_string("_HID", CROS_EC_AUDIO_CODEC_HID);
27 acpigen_write_name_integer("_UID", cfg->uid);
28 acpigen_write_name_string("_DDN", CROS_EC_AUDIO_CODEC_DDN);
29 acpigen_write_STA(acpi_device_status(dev));
31 acpigen_pop_len(); /* Device */
32 acpigen_pop_len(); /* Scope */
34 printk(BIOS_INFO, "%s: %s at %s\n", acpi_device_path(dev), CROS_EC_AUDIO_CODEC_DDN,
35 dev_path(dev));
38 static const char *crosec_audio_codec_acpi_name(const struct device *dev)
40 struct ec_google_chromeec_audio_codec_config *cfg = dev->chip_info;
41 static char name[5];
43 if (cfg->name)
44 return cfg->name;
46 snprintf(name, sizeof(name), "ECA%X", dev->path.generic.id);
47 return name;
50 static struct device_operations crosec_audio_codec_ops = {
51 .read_resources = noop_read_resources,
52 .set_resources = noop_set_resources,
53 .acpi_name = crosec_audio_codec_acpi_name,
54 .acpi_fill_ssdt = crosec_audio_codec_fill_ssdt,
55 .scan_bus = scan_static_bus,
58 static void crosec_audio_codec_enable(struct device *dev)
60 dev->ops = &crosec_audio_codec_ops;
63 struct chip_operations ec_google_chromeec_audio_codec_ops = {
64 .name = "CrosEC Audio Codec Device",
65 .enable_dev = crosec_audio_codec_enable