diff options
author | Furquan Shaikh <furquan@google.com> | 2020-07-02 15:59:08 -0700 |
---|---|---|
committer | Furquan Shaikh <furquan@google.com> | 2020-07-05 18:34:02 +0000 |
commit | 31b816b42f913ad964fb9e41e77690cd8e6b317b (patch) | |
tree | e717fbdf28c0adf717dc2ed1d59a72e4c6402002 /src/ec | |
parent | dfd7e9d560b24a193e8bcfb51782e99e6c4a9142 (diff) |
ec/google/chromeec: Add driver for audio codec device
This change adds driver for audio codec device (HID `GOOG0013`) living
behind Chrome EC. This driver generates the required ACPI node for the
codec device. In a later change, GOOG0013 device will be dropped
the .asl file.
Change-Id: Ib2759eac60265ef81df70af1d4f1f72bd9d987e8
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/43041
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/ec')
-rw-r--r-- | src/ec/google/chromeec/Makefile.inc | 1 | ||||
-rw-r--r-- | src/ec/google/chromeec/audio_codec/Kconfig | 10 | ||||
-rw-r--r-- | src/ec/google/chromeec/audio_codec/Makefile.inc | 1 | ||||
-rw-r--r-- | src/ec/google/chromeec/audio_codec/audio_codec.c | 64 | ||||
-rw-r--r-- | src/ec/google/chromeec/audio_codec/chip.h | 13 |
5 files changed, 89 insertions, 0 deletions
diff --git a/src/ec/google/chromeec/Makefile.inc b/src/ec/google/chromeec/Makefile.inc index b11f5c8507..1f7e03d88e 100644 --- a/src/ec/google/chromeec/Makefile.inc +++ b/src/ec/google/chromeec/Makefile.inc @@ -1,5 +1,6 @@ ifeq ($(CONFIG_EC_GOOGLE_CHROMEEC),y) +subdirs-y += audio_codec subdirs-y += i2c_tunnel bootblock-$(CONFIG_EC_GOOGLE_CHROMEEC_BOARDID) += ec_boardid.c diff --git a/src/ec/google/chromeec/audio_codec/Kconfig b/src/ec/google/chromeec/audio_codec/Kconfig new file mode 100644 index 0000000000..148a7a8d96 --- /dev/null +++ b/src/ec/google/chromeec/audio_codec/Kconfig @@ -0,0 +1,10 @@ +if EC_GOOGLE_CHROMEEC + +config EC_GOOGLE_CHROMEEC_AUDIO_CODEC + bool + depends on HAVE_ACPI_TABLES + help + This enables the Cros EC audio codec driver that is required to fill the + SSDT nodes for the codec device used by the mainboard. + +endif diff --git a/src/ec/google/chromeec/audio_codec/Makefile.inc b/src/ec/google/chromeec/audio_codec/Makefile.inc new file mode 100644 index 0000000000..8726b928b5 --- /dev/null +++ b/src/ec/google/chromeec/audio_codec/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_EC_GOOGLE_CHROMEEC_AUDIO_CODEC) += audio_codec.c diff --git a/src/ec/google/chromeec/audio_codec/audio_codec.c b/src/ec/google/chromeec/audio_codec/audio_codec.c new file mode 100644 index 0000000000..612b1f6995 --- /dev/null +++ b/src/ec/google/chromeec/audio_codec/audio_codec.c @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <acpi/acpi_device.h> +#include <acpi/acpigen.h> +#include <console/console.h> +#include <device/device.h> +#include <device/path.h> +#include "chip.h" + +#define CROS_EC_AUDIO_CODEC_HID "GOOG0013" +#define CROS_EC_AUDIO_CODEC_DDN "Cros EC audio codec" + +static void crosec_audio_codec_fill_ssdt(const struct device *dev) +{ + const char *scope = acpi_device_scope(dev); + struct ec_google_chromeec_audio_codec_config *cfg = dev->chip_info; + + if (!dev->enabled || !scope || !cfg) + return; + + acpigen_write_scope(scope); + + acpigen_write_device(acpi_device_name(dev)); + acpigen_write_name_string("_HID", CROS_EC_AUDIO_CODEC_HID); + acpigen_write_name_integer("_UID", cfg->uid); + acpigen_write_name_string("_DDN", CROS_EC_AUDIO_CODEC_DDN); + acpigen_write_STA(acpi_device_status(dev)); + + acpigen_pop_len(); /* Device */ + acpigen_pop_len(); /* Scope */ + + printk(BIOS_INFO, "%s: %s at %s\n", acpi_device_path(dev), CROS_EC_AUDIO_CODEC_DDN, + dev_path(dev)); +} + +static const char *crosec_audio_codec_acpi_name(const struct device *dev) +{ + struct ec_google_chromeec_audio_codec_config *cfg = dev->chip_info; + static char name[5]; + + if (cfg->name) + return cfg->name; + + snprintf(name, sizeof(name), "ECA%X", dev->path.generic.id); + return name; +} + +static struct device_operations crosec_audio_codec_ops = { + .read_resources = noop_read_resources, + .set_resources = noop_set_resources, + .acpi_name = crosec_audio_codec_acpi_name, + .acpi_fill_ssdt = crosec_audio_codec_fill_ssdt, + .scan_bus = scan_static_bus, +}; + +static void crosec_audio_codec_enable(struct device *dev) +{ + dev->ops = &crosec_audio_codec_ops; +} + +struct chip_operations ec_google_chromeec_audio_codec_ops = { + CHIP_NAME("CrosEC Audio Codec Device") + .enable_dev = crosec_audio_codec_enable +}; diff --git a/src/ec/google/chromeec/audio_codec/chip.h b/src/ec/google/chromeec/audio_codec/chip.h new file mode 100644 index 0000000000..30a83ef6d8 --- /dev/null +++ b/src/ec/google/chromeec/audio_codec/chip.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef __EC_GOOGLE_CHROMEEC_AUDIO_CODEC__ +#define __EC_GOOGLE_CHROMEEC_AUDIO_CODEC__ + +struct ec_google_chromeec_audio_codec_config { + /* ACPI device name */ + const char *name; + /* ACPI _UID */ + unsigned int uid; +}; + +#endif /* __EC_GOOGLE_CHROMEEC_AUDIO_CODEC__ */ |