From 53b62130c978a6de1fa4abae2ebf94cfa1cc0d21 Mon Sep 17 00:00:00 2001 From: Daniel Kurtz Date: Thu, 8 Feb 2018 11:56:14 -0700 Subject: 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 Reviewed-on: https://review.coreboot.org/23659 Reviewed-by: Martin Roth Tested-by: Martin Roth --- src/drivers/generic/adau7002/Kconfig | 2 + src/drivers/generic/adau7002/Makefile.inc | 1 + src/drivers/generic/adau7002/adau7002.c | 74 +++++++++++++++++++++++++++++++ src/drivers/generic/adau7002/chip.h | 4 ++ 4 files changed, 81 insertions(+) create mode 100644 src/drivers/generic/adau7002/Kconfig create mode 100644 src/drivers/generic/adau7002/Makefile.inc create mode 100644 src/drivers/generic/adau7002/adau7002.c create mode 100644 src/drivers/generic/adau7002/chip.h (limited to 'src/drivers') 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 +#include +#include +#include +#include +#include +#include +#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 + +struct drivers_generic_adau7002_config { +}; -- cgit v1.2.3