| 1 |
|
| 2 |
|
| 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> |
| 9 |
|
| 10 |
#include "chip.h" |
| 11 |
|
| 12 |
#define CROS_EC_AUDIO_CODEC_HID "GOOG0013" |
| 13 |
#define CROS_EC_AUDIO_CODEC_DDN "Cros EC audio codec" |
| 14 |
|
| 15 |
static void crosec_audio_codec_fill_ssdt(const struct device *dev) |
| 16 |
{ |
| 17 |
const char *scope = acpi_device_scope(dev); |
| 18 |
struct ec_google_chromeec_audio_codec_config *cfg = dev->chip_info; |
| 19 |
|
| 20 |
if (!scope || !cfg) |
| 21 |
return; |
| 22 |
|
| 23 |
acpigen_write_scope(scope); |
| 24 |
|
| 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)); |
| 30 |
|
| 31 |
acpigen_pop_len(); |
| 32 |
acpigen_pop_len(); |
| 33 |
|
| 34 |
printk(BIOS_INFO, "%s: %s at %s\n", acpi_device_path(dev), CROS_EC_AUDIO_CODEC_DDN, |
| 35 |
dev_path(dev)); |
| 36 |
} |
| 37 |
|
| 38 |
static const char *crosec_audio_codec_acpi_name(const struct device *dev) |
| 39 |
{ |
| 40 |
struct ec_google_chromeec_audio_codec_config *cfg = dev->chip_info; |
| 41 |
static char name[5]; |
| 42 |
|
| 43 |
if (cfg->name) |
| 44 |
return cfg->name; |
| 45 |
|
| 46 |
snprintf(name, sizeof(name), "ECA%X", dev->path.generic.id); |
| 47 |
return name; |
| 48 |
} |
| 49 |
|
| 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, |
| 56 |
}; |
| 57 |
|
| 58 |
static void crosec_audio_codec_enable(struct device *dev) |
| 59 |
{ |
| 60 |
dev->ops = &crosec_audio_codec_ops; |
| 61 |
} |
| 62 |
|
| 63 |
struct chip_operations ec_google_chromeec_audio_codec_ops = { |
| 64 |
.name = "CrosEC Audio Codec Device", |
| 65 |
.enable_dev = crosec_audio_codec_enable |
| 66 |
}; |