Saurabh Satija (saurabh.satija(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15023
-gerrit
commit de71a4201202c6cc35d5fedf0b0d7e2dd7278f30
Author: Saurabh Satija <saurabh.satija(a)intel.com>
Date: Thu May 26 15:53:41 2016 -0700
Add common Audio support for intel platforms
The use of a NHLT table is required to make audio work
on the intel SoCs employing the internal DSP. The table
describes the audo endpoints (render vs capture) along with
their supported formats. These formats are not only dependent
on the audio peripheral but also hardware interfaces. As such
each format has an associated blob of DSP settings to make
the peripheral work. Lastly, each of these settings are provided
by Intel and need to be generated for each device's hardware
connection plus mode/format it supports. This patch does not
include the dsp setting blobs.
Change-Id: I3c75d3537288c47d29e8949ca253ea8c5c1a387d
Signed-off-by: Saurabh Satija <saurabh.satija(a)intel.com>
---
src/drivers/intel/audio/Kconfig | 48 +++++++++++++
src/drivers/intel/audio/Makefile.inc | 43 +++++++++++
src/drivers/intel/audio/dmic.c | 53 ++++++++++++++
src/drivers/intel/audio/headset.c | 60 ++++++++++++++++
src/drivers/intel/audio/include/drivers/audio.h | 59 +++++++++++++++
src/drivers/intel/audio/nhlt.c | 95 +++++++++++++++++++++++++
src/drivers/intel/audio/speaker.c | 40 +++++++++++
7 files changed, 398 insertions(+)
diff --git a/src/drivers/intel/audio/Kconfig b/src/drivers/intel/audio/Kconfig
new file mode 100644
index 0000000..fdc494c
--- /dev/null
+++ b/src/drivers/intel/audio/Kconfig
@@ -0,0 +1,48 @@
+config USE_COMMON_AUDIO
+ bool
+ default n
+ help
+ Build support for drivers audio code, common to intel
+ platforms that use NHLT.
+
+config AUDIO_DMIC_2CH_16B
+ bool
+ depends on USE_COMMON_AUDIO
+ default n
+ help
+ Include DSP firmware settings for 2 channel 16B DMIC array.
+
+config AUDIO_DMIC_2CH_32B
+ bool
+ depends on USE_COMMON_AUDIO
+ default n
+ help
+ Include DSP firmware settings for 2 channel 32B DMIC array.
+
+config AUDIO_DMIC_4CH_16B
+ bool
+ depends on USE_COMMON_AUDIO
+ default n
+ help
+ Include DSP firmware settings for 4 channel 16B DMIC array.
+
+config AUDIO_DMIC_4CH_32B
+ bool
+ depends on USE_COMMON_AUDIO
+ default n
+ help
+ Include DSP firmware settings for 4 channel 32B DMIC array.
+
+config AUDIO_HEADSET
+ bool
+ depends on USE_COMMON_AUDIO
+ default n
+ help
+ Include DSP firmware settings for headset codec.
+
+config AUDIO_SPEAKER
+ bool
+ depends on USE_COMMON_AUDIO
+ default n
+ help
+ Include DSP firmware settings for speaker amplifier.
diff --git a/src/drivers/intel/audio/Makefile.inc b/src/drivers/intel/audio/Makefile.inc
new file mode 100644
index 0000000..6bea190
--- /dev/null
+++ b/src/drivers/intel/audio/Makefile.inc
@@ -0,0 +1,43 @@
+ifeq ($(CONFIG_USE_COMMON_AUDIO),y)
+ramstage-y += nhlt.c
+ramstage-y += dmic.c
+ramstage-y += headset.c
+ramstage-y += speaker.c
+
+# DSP firmware settings files.
+NHLT_BLOB_PATH = 3rdparty/blobs/soc/intel/apollolake/nhlt-blobs
+DMIC_2CH_48KHZ_16B = dmic-2ch-48khz-16b.bin
+DMIC_2CH_48KHZ_32B = dmic-2ch-48khz-32b.bin
+DMIC_4CH_48KHZ_16B = dmic-4ch-48khz-16b.bin
+DMIC_4CH_48KHZ_32B = dmic-4ch-48khz-32b.bin
+
+HEADSET = headset-2ch-48khz-24b.bin
+
+SPEAKER_RENDER = max98357-render-2ch-48khz-24b.bin
+
+cbfs-files-$(CONFIG_AUDIO_DMIC_2CH_16B) += $(DMIC_2CH_48KHZ_16B)
+$(DMIC_2CH_48KHZ_16B)-file := $(NHLT_BLOB_PATH)/$(DMIC_2CH_48KHZ_16B)
+$(DMIC_2CH_48KHZ_16B)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_DMIC_2CH_32B) += $(DMIC_2CH_48KHZ_32B)
+$(DMIC_2CH_48KHZ_32B)-file := $(NHLT_BLOB_PATH)/$(DMIC_2CH_48KHZ_32B)
+$(DMIC_2CH_48KHZ_32B)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_DMIC_4CH_16B) += $(DMIC_4CH_48KHZ_16B)
+$(DMIC_4CH_48KHZ_16B)-file := $(NHLT_BLOB_PATH)/$(DMIC_4CH_48KHZ_16B)
+$(DMIC_4CH_48KHZ_16B)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_DMIC_4CH_32B) += $(DMIC_4CH_48KHZ_32B)
+$(DMIC_4CH_48KHZ_32B)-file := $(NHLT_BLOB_PATH)/$(DMIC_4CH_48KHZ_32B)
+$(DMIC_4CH_48KHZ_32B)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_HEADSET) += $(HEADSET)
+$(HEADSET)-file := $(NHLT_BLOB_PATH)/$(HEADSET)
+$(HEADSET)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_SPEAKER) += $(SPEAKER_RENDER)
+$(SPEAKER_RENDER)-file := $(NHLT_BLOB_PATH)/$(SPEAKER_RENDER)
+$(SPEAKER_RENDER)-type := raw
+endif
+
+CPPFLAGS_common += -I$(src)/drivers/intel/audio/include
diff --git a/src/drivers/intel/audio/dmic.c b/src/drivers/intel/audio/dmic.c
new file mode 100644
index 0000000..fe11d51
--- /dev/null
+++ b/src/drivers/intel/audio/dmic.c
@@ -0,0 +1,53 @@
+ /*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google, Inc.
+ *
+ * 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 <drivers/audio.h>
+#include <string.h>
+
+int nhlt_soc_add_dmic_array(struct nhlt *nhlt, const struct nhlt_format_config *dmic_ch_cfg, int fmt_size, int num_channels)
+{
+ struct nhlt_endpoint *endp;
+ struct nhlt_dmic_array_config mic_config;
+ const struct nhlt_format_config *formats;
+
+ if (num_channels != 2 && num_channels != 4)
+ return -1;
+
+ endp = nhlt_soc_add_endpoint(nhlt, AUDIO_LINK_DMIC, AUDIO_DEV_DMIC,
+ NHLT_DIR_CAPTURE);
+
+ if (endp == NULL)
+ return -1;
+
+ memset(&mic_config, 0, sizeof(mic_config));
+ mic_config.tdm_config.config_type = NHLT_TDM_MIC_ARRAY;
+
+ formats = dmic_ch_cfg;
+
+ switch (num_channels) {
+ case 2:
+ mic_config.array_type = NHLT_MIC_ARRAY_2CH_SMALL;
+ break;
+ case 4:
+ mic_config.array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED;
+ break;
+ }
+
+ if (nhlt_endpoint_append_config(endp, &mic_config, sizeof(mic_config)))
+ return -1;
+
+ return nhlt_endpoint_add_formats(endp, formats, fmt_size);
+}
+
diff --git a/src/drivers/intel/audio/headset.c b/src/drivers/intel/audio/headset.c
new file mode 100644
index 0000000..68acee2
--- /dev/null
+++ b/src/drivers/intel/audio/headset.c
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google, Inc.
+ *
+ * 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 <drivers/audio.h>
+#include <console/console.h>
+
+/* The same DSP firmwware settings are used for both the capture and
+ * render endpoints. */
+int nhlt_soc_add_headset(struct nhlt *nhlt, const struct nhlt_format_config *headset_cfg, int fmt_size, struct nhlt_tdm_config *tdm_config, int hwlink)
+{
+ struct nhlt_endpoint *endp;
+ /* The headphone codec has headphones and a mic. Both the capture and
+ * render endpoints occupy the same virtual slot. */
+ const void *fmt_cfg = headset_cfg;
+ size_t fmt_sz = fmt_size;
+
+ /* Render Endpoint */
+ endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S,
+ NHLT_DIR_RENDER);
+ if (endp == NULL)
+ return -1;
+
+ if(tdm_config != NULL){
+ if (nhlt_endpoint_append_config(endp, tdm_config, 1))
+ return -1;
+ }
+
+ if (nhlt_endpoint_add_formats(endp, fmt_cfg, fmt_sz))
+ return -1;
+
+ /* Capture Endpoint */
+ endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S,
+ NHLT_DIR_CAPTURE);
+ if (endp == NULL)
+ return -1;
+
+ if(tdm_config != NULL){
+ if (nhlt_endpoint_append_config(endp, &tdm_config, 1))
+ return -1;
+ }
+
+ if (nhlt_endpoint_add_formats(endp, fmt_cfg, fmt_sz))
+ return -1;
+
+ nhlt_next_instance(nhlt, NHLT_LINK_SSP);
+
+ return 0;
+}
diff --git a/src/drivers/intel/audio/include/drivers/audio.h b/src/drivers/intel/audio/include/drivers/audio.h
new file mode 100644
index 0000000..caf1edc
--- /dev/null
+++ b/src/drivers/intel/audio/include/drivers/audio.h
@@ -0,0 +1,59 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google, Inc.
+ *
+ * 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.
+ */
+
+#ifndef _DRIVERS_AUDIO_H_
+#define _DRIVERS_AUDIO_H_
+
+#include <nhlt.h>
+
+/*
+ * Skylake NHLT device and hardware link types. These values are to be used
+ * with nhlt_soc_add_endpoint().
+ */
+
+enum {
+ AUDIO_LINK_SSP0,
+ AUDIO_LINK_SSP1,
+ AUDIO_LINK_SSP2, /* Only Bluetooth supported on SSP2. */
+ AUDIO_LINK_SSP3,
+ AUDIO_LINK_SSP4,
+ AUDIO_LINK_SSP5,
+ AUDIO_LINK_DMIC,
+};
+
+enum {
+ AUDIO_DEV_I2S,
+ AUDIO_DEV_DMIC,
+ AUDIO_DEV_BT,
+};
+
+/*
+ * Add a dmic array composed of the provided number of channels.
+ * Returns 0 on success, < 0 on error.
+ */
+int nhlt_soc_add_dmic_array(struct nhlt *nhlt, const struct nhlt_format_config *dmic_ch_config, int cfg_size, int num_channels);
+
+/*
+ * Add headset codec on provided SSP link. Return 0 on succes, < 0 on error.
+ */
+int nhlt_soc_add_headset(struct nhlt *nhlt, const struct nhlt_format_config *headset_cfg, int cfg_size, struct nhlt_tdm_config *tdm_config, int hwlink);
+
+/*
+ * Add speaker amplifier in stereo configuration on provide SSP link.
+ * Return 0 on success, < 0 on error.
+ */
+int nhlt_soc_add_speaker(struct nhlt *nhlt, const struct nhlt_format_config *speaker_cfg, int cfg_size, struct nhlt_tdm_config *tdm_config, int hwlink);
+
+#endif
diff --git a/src/drivers/intel/audio/nhlt.c b/src/drivers/intel/audio/nhlt.c
new file mode 100644
index 0000000..0f8e6e1
--- /dev/null
+++ b/src/drivers/intel/audio/nhlt.c
@@ -0,0 +1,95 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google, Inc.
+ *
+ * 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 <cbmem.h>
+#include <soc/acpi.h>
+#include <drivers/audio.h>
+
+#define NHLT_VID 0x8086
+#define NHLT_DID_DMIC 0xae20
+#define NHLT_DID_BT 0xae30
+#define NHLT_DID_SSP 0xae34
+
+struct nhlt_endpoint *nhlt_soc_add_endpoint(struct nhlt *nhlt, int soc_hwintf,
+ int soc_devtype, int dir)
+{
+ int nhlt_link_type;
+ int nhlt_dev_type;
+ uint16_t did;
+ struct nhlt_endpoint *endp;
+
+ /* Check link type and device type. */
+ switch (soc_hwintf) {
+ case AUDIO_LINK_SSP0:
+ case AUDIO_LINK_SSP1:
+ case AUDIO_LINK_SSP5:
+ case AUDIO_LINK_SSP2:
+ nhlt_link_type = NHLT_LINK_SSP;
+ break;
+ case AUDIO_LINK_DMIC:
+ /* Only DMIC devices on DMIC links. */
+ if (soc_devtype != AUDIO_DEV_DMIC)
+ return NULL;
+ nhlt_link_type = NHLT_LINK_PDM;
+ break;
+ default:
+ return NULL;
+ }
+
+ switch (soc_devtype) {
+ case AUDIO_DEV_I2S:
+ nhlt_dev_type = NHLT_SSP_DEV_I2S;
+ did = NHLT_DID_SSP;
+ break;
+ case AUDIO_DEV_DMIC:
+ nhlt_dev_type = NHLT_PDM_DEV;
+ did = NHLT_DID_DMIC;
+ break;
+ case AUDIO_DEV_BT:
+ nhlt_dev_type = NHLT_SSP_DEV_BT;
+ did = NHLT_DID_BT;
+ break;
+ default:
+ return NULL;
+ }
+
+ endp = nhlt_add_endpoint(nhlt, nhlt_link_type, nhlt_dev_type, dir,
+ NHLT_VID, did);
+
+ if (endp == NULL)
+ return NULL;
+
+ /* Virtual bus id of SSP links are the hardware port ids proper. */
+ if (nhlt_link_type == NHLT_LINK_SSP)
+ endp->virtual_bus_id = soc_hwintf;
+
+ return endp;
+}
+
+uintptr_t nhlt_soc_serialize(struct nhlt *nhlt, uintptr_t acpi_addr)
+{
+ struct global_nvs_t *gnvs;
+
+ gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS);
+
+ if (gnvs == NULL)
+ return acpi_addr;
+
+ /* Update NHLT GNVS Data */
+ gnvs->nhla = (uintptr_t)acpi_addr;
+ gnvs->nhll = nhlt_current_size(nhlt);
+
+ return nhlt_serialize(nhlt, acpi_addr);
+}
diff --git a/src/drivers/intel/audio/speaker.c b/src/drivers/intel/audio/speaker.c
new file mode 100644
index 0000000..63dba66
--- /dev/null
+++ b/src/drivers/intel/audio/speaker.c
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google, Inc.
+ *
+ * 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 <drivers/audio.h>
+
+int nhlt_soc_add_speaker(struct nhlt *nhlt, const struct nhlt_format_config *speaker_cfg, int fmt_size, struct nhlt_tdm_config *tdm_config, int hwlink)
+{
+ struct nhlt_endpoint *endp;
+
+ /* Render Endpoint */
+ endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S,
+ NHLT_DIR_RENDER);
+
+ if (endp == NULL)
+ return -1;
+
+ if(tdm_config != NULL){
+ if (nhlt_endpoint_append_config(endp, &tdm_config, 1))
+ return -1;
+ }
+
+ if (nhlt_endpoint_add_formats(endp, speaker_cfg, fmt_size))
+ return -1;
+
+ nhlt_next_instance(nhlt, NHLT_LINK_SSP);
+
+ return 0;
+}
the following patch was just integrated into master:
commit bc518d5cab4234a0d0d06a7d3829bbca9e318ba6
Author: Lee Leahy <leroy.p.leahy(a)intel.com>
Date: Mon May 30 15:01:06 2016 -0700
quark: Enable HSUART0 as console
The use of HSUART0 on galileo requires early initialization of the I2C
GPIO expanders to direct the RXD and TXD signals to DIGITAL 0 and 1
on the expansion connector.
TEST=None
Change-Id: I11195d79e954c1f6bc91eafe257d7ddc1310b2e7
Signed-off-by: Lee Leahy <leroy.p.leahy(a)intel.com>
Reviewed-on: https://review.coreboot.org/15010
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth(a)google.com>
See https://review.coreboot.org/15010 for details.
-gerrit
the following patch was just integrated into master:
commit ac78db3a53a7653a73409936455d68c754291e9d
Author: Lee Leahy <leroy.p.leahy(a)intel.com>
Date: Mon May 30 14:35:15 2016 -0700
soc/intel/quark: Move UART init into romstage.c
Move UART initialization into romstage.c and eliminate uart.c.
TEST=Build and run on Galileo Gen2
Change-Id: I5f2c9b4c566008000c2201c422a0bba63da64487
Signed-off-by: Lee Leahy <leroy.p.leahy(a)intel.com>
Reviewed-on: https://review.coreboot.org/15009
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth(a)google.com>
See https://review.coreboot.org/15009 for details.
-gerrit
the following patch was just integrated into master:
commit fd91dee42001cd055d5a51c13750c8e1abc0e7e1
Author: Lee Leahy <leroy.p.leahy(a)intel.com>
Date: Mon May 30 11:23:49 2016 -0700
mainboard/intel/quark: Enable reg_access during romstage
Turn on reg_access during romstage.
TEST=Build and run on Galileo Gen2
Change-Id: Iff1616836d6031f43d7741693febefa0bf26b948
Signed-off-by: Lee Leahy <leroy.p.leahy(a)intel.com>
Reviewed-on: https://review.coreboot.org/15008
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth(a)google.com>
See https://review.coreboot.org/15008 for details.
-gerrit
the following patch was just integrated into master:
commit a5258cba6fc2b6cf47380581065cc22f06ecccae
Author: Lee Leahy <leroy.p.leahy(a)intel.com>
Date: Mon May 30 14:06:25 2016 -0700
soc/intel/quark: Split I2C out from driver
Split out the I2C code to allow I2C transactions during early romstage.
TEST=Build and run on Galileo Gen2
Change-Id: I87ceb0a8cf660e4337738b3bcde9d4fdeae0159d
Signed-off-by: Lee Leahy <leroy.p.leahy(a)intel.com>
Reviewed-on: https://review.coreboot.org/15007
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth(a)google.com>
See https://review.coreboot.org/15007 for details.
-gerrit
the following patch was just integrated into master:
commit 56c99f28501bbb79a9f8b7a1e1bd698788b42f0e
Author: Lee Leahy <leroy.p.leahy(a)intel.com>
Date: Mon May 30 14:16:10 2016 -0700
soc/intel/quark: Set temporary I2C base address
Set a temporary I2C base address during romstage.
TEST=Build and run on Galileo Gen2
Change-Id: I4b427c66a4e7e6d30cc611d4d3c40bb0ea36066d
Signed-off-by: Lee Leahy <leroy.p.leahy(a)intel.com>
Reviewed-on: https://review.coreboot.org/15006
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth(a)google.com>
See https://review.coreboot.org/15006 for details.
-gerrit