summaryrefslogtreecommitdiff
path: root/src/drivers/generic
diff options
context:
space:
mode:
authorDaniel Kurtz <djkurtz@chromium.org>2018-02-08 11:56:14 -0700
committerMartin Roth <martinroth@google.com>2018-02-10 23:56:32 +0000
commit53b62130c978a6de1fa4abae2ebf94cfa1cc0d21 (patch)
tree58fafc556d2e09d48b9c92626c065f2755c65ef5 /src/drivers/generic
parent76e9d6b1ac5b89fbc5fb5ad77b128920c11b995d (diff)
downloadcoreboot-53b62130c978a6de1fa4abae2ebf94cfa1cc0d21.tar.xz
drivers/adau7002: Add driver for handling ADAU7002
The ADAU7002 is a family of Stereo PDM-to-I2S/TDM conversion ICs from Analog Devices. On some boards they are a used to convert a PDM audio data stream from a DMIC to an I2S signal. Add a driver for populating ACPI table entries for this part. BUG=b:72121803 TEST=With grunt audio kernel patches, "aplay -l" shows playback devices: **** List of PLAYBACK Hardware Devices **** card 0: acpd7219m98357 [acpd7219m98357], device 0: Playback da7219-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: acpd7219m98357 [acpd7219m98357], device 2: HiFi Playback HiFi-2 [] Subdevices: 1/1 Subdevice #0: subdevice #0 Change-Id: I2b64c8e1cbc0a68984482a7d496f8c4498cb6cbe Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Reviewed-on: https://review.coreboot.org/23659 Reviewed-by: Martin Roth <martinroth@google.com> Tested-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'src/drivers/generic')
-rw-r--r--src/drivers/generic/adau7002/Kconfig2
-rw-r--r--src/drivers/generic/adau7002/Makefile.inc1
-rw-r--r--src/drivers/generic/adau7002/adau7002.c74
-rw-r--r--src/drivers/generic/adau7002/chip.h4
4 files changed, 81 insertions, 0 deletions
diff --git a/src/drivers/generic/adau7002/Kconfig b/src/drivers/generic/adau7002/Kconfig
new file mode 100644
index 0000000000..b981a3065b
--- /dev/null
+++ b/src/drivers/generic/adau7002/Kconfig
@@ -0,0 +1,2 @@
+config DRIVERS_GENERIC_ADAU7002
+ bool
diff --git a/src/drivers/generic/adau7002/Makefile.inc b/src/drivers/generic/adau7002/Makefile.inc
new file mode 100644
index 0000000000..b2f7dfef52
--- /dev/null
+++ b/src/drivers/generic/adau7002/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_GENERIC_ADAU7002) += adau7002.c
diff --git a/src/drivers/generic/adau7002/adau7002.c b/src/drivers/generic/adau7002/adau7002.c
new file mode 100644
index 0000000000..d21d513c59
--- /dev/null
+++ b/src/drivers/generic/adau7002/adau7002.c
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018 Google LLC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/acpi_device.h>
+#include <arch/acpigen.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/path.h>
+#include <stdint.h>
+#include <string.h>
+#include "chip.h"
+
+#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
+
+#define ADAU7002_ACPI_NAME "ADAU"
+#define ADAU7002_ACPI_HID "ADAU7002"
+
+static void adau7002_fill_ssdt(struct device *dev)
+{
+ if (!dev->enabled)
+ return;
+
+ /* Device */
+ acpigen_write_scope(acpi_device_scope(dev));
+ acpigen_write_device(acpi_device_name(dev));
+ acpigen_write_name_string("_HID", ADAU7002_ACPI_HID);
+ acpigen_write_name_integer("_UID", 0);
+ acpigen_write_name_string("_DDN", dev->chip_ops->name);
+ acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+
+ acpigen_pop_len(); /* Device */
+ acpigen_pop_len(); /* Scope */
+
+ printk(BIOS_INFO, "%s: %s\n", acpi_device_path(dev),
+ dev->chip_ops->name);
+}
+
+static const char *adau7002_acpi_name(const struct device *dev)
+{
+ return ADAU7002_ACPI_NAME;
+}
+#endif
+
+static struct device_operations adau7002_ops = {
+ .read_resources = DEVICE_NOOP,
+ .set_resources = DEVICE_NOOP,
+ .enable_resources = DEVICE_NOOP,
+#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
+ .acpi_name = &adau7002_acpi_name,
+ .acpi_fill_ssdt_generator = &adau7002_fill_ssdt,
+#endif
+};
+
+static void adau7002_enable(struct device *dev)
+{
+ dev->ops = &adau7002_ops;
+}
+
+struct chip_operations drivers_generic_adau7002_ops = {
+ CHIP_NAME("Analog Digital DMIC")
+ .enable_dev = &adau7002_enable
+};
diff --git a/src/drivers/generic/adau7002/chip.h b/src/drivers/generic/adau7002/chip.h
new file mode 100644
index 0000000000..809a680dee
--- /dev/null
+++ b/src/drivers/generic/adau7002/chip.h
@@ -0,0 +1,4 @@
+#include <arch/acpi_device.h>
+
+struct drivers_generic_adau7002_config {
+};