[coreboot-gerrit] New patch to review for coreboot: apollolake: Add NHLT support

Lijian Zhao (lijian.zhao@intel.com) gerrit at coreboot.org
Mon Jun 6 23:21:07 CEST 2016


Lijian Zhao (lijian.zhao at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15085

-gerrit

commit cb8ddf7885446e83dcce2fbaa0408f13a91b11f7
Author: Saurabh Satija <saurabh.satija at intel.com>
Date:   Mon Mar 7 18:49:47 2016 -0800

    apollolake: Add NHLT support
    
    The use of a NHLT table is required to make audio work
    on the apollolake 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.
    
    The current supported connections:
    - digital mic array 2 channel
    - Maxim 98357 amplifier
    - NAU88L25 and DA7219 headset codec
    
    Change-Id: I4f3373deef72d1fede2f68adbf5c465b72becb1c
    Signed-off-by: Saurabh Satija <saurabh.satija at intel.com>
    Reviewed-on: https://chromium.devtools.intel.com/7139
    Reviewed-by: Petrov, Andrey <andrey.petrov at intel.com>
    Reviewed-on: https://chromium.devtools.intel.com/7572
    Tested-by: Petrov, Andrey <andrey.petrov at intel.com>
---
 src/include/nhlt.h                                 |   3 +-
 src/soc/intel/apollolake/Kconfig                   |  55 +++++++++++
 src/soc/intel/apollolake/Makefile.inc              |   1 +
 src/soc/intel/apollolake/include/soc/nhlt.h        |  61 ++++++++++++
 src/soc/intel/apollolake/nhlt/Makefile.inc         |  22 +++++
 src/soc/intel/apollolake/nhlt/dmic.c               |  58 ++++++++++++
 src/soc/intel/apollolake/nhlt/hs_nau88l25_da7219.c |  72 ++++++++++++++
 src/soc/intel/apollolake/nhlt/max98357.c           |  47 ++++++++++
 src/soc/intel/apollolake/nhlt/nhlt.c               | 103 +++++++++++++++++++++
 9 files changed, 420 insertions(+), 2 deletions(-)

diff --git a/src/include/nhlt.h b/src/include/nhlt.h
index f0b3b6f..3d6a3b1 100644
--- a/src/include/nhlt.h
+++ b/src/include/nhlt.h
@@ -161,8 +161,7 @@ enum {
 	NHLT_SSP_DEV_BT, /* Bluetooth */
 	NHLT_SSP_DEV_MODEM,
 	NHLT_SSP_DEV_FM,
-	NHLT_SSP_DEV_RESERVED,
-	NHLT_SSP_DEV_I2S = 4,
+	NHLT_SSP_DEV_I2S = 3,
 };
 
 enum {
diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index 0b9c05a..1d915a410 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -160,8 +160,63 @@ config LBP2_FILE_NAME
 	help
 	  Name of file to store in the logical boot partition 2 region.
 
+config FSP_M_FILE
+	string "Intel FSP-M (memory init) binary path and filename"
+	depends on ADD_FSP_BINARIES
+	help
+	  The path and filename of the Intel FSP-M binary for this platform.
+
+config FSP_S_FILE
+	string "Intel FSP-S (silicon init) binary path and filename"
+	depends on ADD_FSP_BINARIES
+	help
+	  The path and filename of the Intel FSP-S binary for this platform.
+
+config VBT_FILE
+	string "VBT binary path and filename"
+	depends on ADD_VBT_DATA_FILE
+	help
+	  The path and filename of the VBT binary for this platform.
+
+config ADD_FSP_BINARIES
+	bool "Add Intel FSP 2.0 binaries to CBFS"
+	help
+	  Add the FSP-M and FSP-S binaries to CBFS. Note that coreboot does not
+	  use the FSP-T binary, so that will not be included.
+
+config ADD_VBT_DATA_FILE
+	bool "Add a Video Bios Table (VBT) binary to CBFS"
+	help
+	  Add a VBT file data file to CBFS. The VBT describes the integrated
+	  GPU and connections, and is needed by FSP in order to initialize the
+	  display.
+
 config HEAP_SIZE
 	hex
 	default 0x10000
 
+config DRIVERS_PS2_KEYBOARD
+	bool
+	default y
+	help
+	  Default PS/2 Keyboard to enabled on this board.
+
+config NHLT_DMIC_2CH
+	bool
+	default n
+	help
+	  Include DSP firmware settings for 2 channel DMIC array.
+
+config NHLT_HEADSET
+	bool
+	default n
+	help
+	  Include DSP firmware settings for nau88l25 and da7219 headset codec.
+
+config NHLT_MAX98357
+	bool
+	default n
+	help
+	  Include DSP firmware settings for max98357 amplifier.
+
 endif
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc
index 1ea21f6..636abdd 100644
--- a/src/soc/intel/apollolake/Makefile.inc
+++ b/src/soc/intel/apollolake/Makefile.inc
@@ -1,5 +1,6 @@
 ifeq ($(CONFIG_SOC_INTEL_APOLLOLAKE),y)
 
+subdirs-y += nhlt
 subdirs-y += ../../../cpu/intel/microcode
 subdirs-y += ../../../cpu/intel/turbo
 subdirs-y += ../../../cpu/x86/lapic
diff --git a/src/soc/intel/apollolake/include/soc/nhlt.h b/src/soc/intel/apollolake/include/soc/nhlt.h
new file mode 100644
index 0000000..8dbcbd2
--- /dev/null
+++ b/src/soc/intel/apollolake/include/soc/nhlt.h
@@ -0,0 +1,61 @@
+/*
+ * 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 _SOC_NHLT_H_
+#define _SOC_NHLT_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. The apollolake
+ * SoC currently only supports dmic arrays on the dmic signals. Only 2 channel
+ * arrays are supported. Returns 0 on success, < 0 on error.
+ */
+int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels);
+
+/*
+ * Add nau88l25 and da7219 headset codec on provided SSP link. Return 0 on succes, < 0
+ * on error.
+ */
+int nhlt_soc_add_headset(struct nhlt *nhlt, int hwlink);
+
+/*
+ * Add max98357a amplifier in stereo configuration on provide SSP link.
+ * Return 0 on success, < 0 on error.
+ */
+int nhlt_soc_add_max98357(struct nhlt *nhlt, int hwlink);
+
+#endif
diff --git a/src/soc/intel/apollolake/nhlt/Makefile.inc b/src/soc/intel/apollolake/nhlt/Makefile.inc
new file mode 100644
index 0000000..38ba23e
--- /dev/null
+++ b/src/soc/intel/apollolake/nhlt/Makefile.inc
@@ -0,0 +1,22 @@
+ramstage-y += nhlt.c
+ramstage-y += dmic.c
+ramstage-y += hs_nau88l25_da7219.c
+ramstage-y += max98357.c
+
+# DSP firmware settings files.
+NHLT_BLOB_PATH = 3rdparty/blobs/soc/intel/apollolake/nhlt-blobs
+DMIC_2CH_48KHZ_16B = dmic-2ch-48khz-16b.bin
+HEADSET = headset-2ch-48khz-24b.bin
+MAX98357_RENDER = max98357-render-2ch-48khz-24b.bin
+
+cbfs-files-$(CONFIG_NHLT_DMIC_2CH) += $(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_NHLT_HEADSET) += $(HEADSET)
+$(HEADSET)-file := $(NHLT_BLOB_PATH)/$(HEADSET)
+$(HEADSET)-type := raw
+
+cbfs-files-$(CONFIG_NHLT_MAX98357) += $(MAX98357_RENDER)
+$(MAX98357_RENDER)-file := $(NHLT_BLOB_PATH)/$(MAX98357_RENDER)
+$(MAX98357_RENDER)-type := raw
diff --git a/src/soc/intel/apollolake/nhlt/dmic.c b/src/soc/intel/apollolake/nhlt/dmic.c
new file mode 100644
index 0000000..3d0c017
--- /dev/null
+++ b/src/soc/intel/apollolake/nhlt/dmic.c
@@ -0,0 +1,58 @@
+ /*
+ * 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 <soc/nhlt.h>
+#include <string.h>
+
+static const struct nhlt_format_config dmic_2ch_cfg[] = {
+	/* 48 KHz 16-bits per sample. */
+	{
+		.num_channels = 2,
+		.sample_freq_khz = 48,
+		.container_bits_per_sample = 16,
+		.valid_bits_per_sample = 16,
+		.settings_file = "dmic-2ch-48khz-16b.bin",
+	},
+};
+
+int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels)
+{
+	struct nhlt_endpoint *endp;
+	struct nhlt_dmic_array_config mic_config;
+	const struct nhlt_format_config *formats;
+	size_t num_formats;
+
+	if (num_channels != 2)
+		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_2ch_cfg;
+	num_formats = ARRAY_SIZE(dmic_2ch_cfg);
+	mic_config.array_type = NHLT_MIC_ARRAY_2CH_SMALL;
+
+	if (nhlt_endpoint_append_config(endp, &mic_config, sizeof(mic_config)))
+		return -1;
+
+	return nhlt_endpoint_add_formats(endp, formats, num_formats);
+}
+
diff --git a/src/soc/intel/apollolake/nhlt/hs_nau88l25_da7219.c b/src/soc/intel/apollolake/nhlt/hs_nau88l25_da7219.c
new file mode 100644
index 0000000..b63eb6d
--- /dev/null
+++ b/src/soc/intel/apollolake/nhlt/hs_nau88l25_da7219.c
@@ -0,0 +1,72 @@
+/*
+ * 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 <soc/nhlt.h>
+
+/* The same DSP firmwware settings are used for both the capture and
+ * render endpoints. */
+static const struct nhlt_format_config headset_cfg[] = {
+	/* 48 KHz 24-bits per sample. */
+	{
+		.num_channels = 2,
+		.sample_freq_khz = 48,
+		.container_bits_per_sample = 32,
+		.valid_bits_per_sample = 24,
+		.settings_file = "headset-2ch-48khz-24b.bin",
+	},
+};
+
+int nhlt_soc_add_headset(struct nhlt *nhlt, int hwlink)
+{
+	struct nhlt_endpoint *endp;
+	/* The nau88l25 and da7219 just has headphones and a mic. Both the capture and
+	 * render endpoints occupy the same virtual slot. */
+	struct nhlt_tdm_config tdm_config = {
+		.virtual_slot = 0,
+		.config_type = NHLT_TDM_BASIC,
+	};
+	const void *fmt_cfg = headset_cfg;
+	size_t fmt_sz = ARRAY_SIZE(headset_cfg);
+
+	/* Render Endpoint */
+	endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S,
+					NHLT_DIR_RENDER);
+
+	if (endp == NULL)
+		return -1;
+
+	if (nhlt_endpoint_append_config(endp, &tdm_config, sizeof(tdm_config)))
+		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 (nhlt_endpoint_append_config(endp, &tdm_config, sizeof(tdm_config)))
+		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/soc/intel/apollolake/nhlt/max98357.c b/src/soc/intel/apollolake/nhlt/max98357.c
new file mode 100644
index 0000000..8edfe5b
--- /dev/null
+++ b/src/soc/intel/apollolake/nhlt/max98357.c
@@ -0,0 +1,47 @@
+/*
+ * 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 <soc/nhlt.h>
+
+static const struct nhlt_format_config max98357_render_cfg[] = {
+	/* 48 KHz 24-bits per sample. */
+	{
+		.num_channels = 2,
+		.sample_freq_khz = 48,
+		.container_bits_per_sample = 32,
+		.valid_bits_per_sample = 24,
+		.settings_file = "max98357-render-2ch-48khz-24b.bin",
+	},
+};
+
+int nhlt_soc_add_max98357(struct nhlt *nhlt, 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 (nhlt_endpoint_add_formats(endp, max98357_render_cfg,
+					ARRAY_SIZE(max98357_render_cfg)))
+		return -1;
+
+	nhlt_next_instance(nhlt, NHLT_LINK_SSP);
+
+	return 0;
+}
diff --git a/src/soc/intel/apollolake/nhlt/nhlt.c b/src/soc/intel/apollolake/nhlt/nhlt.c
new file mode 100644
index 0000000..f4651f1
--- /dev/null
+++ b/src/soc/intel/apollolake/nhlt/nhlt.c
@@ -0,0 +1,103 @@
+/*
+ * 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 <soc/nhlt.h>
+#include <soc/nvs.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_SSP1:
+	case AUDIO_LINK_SSP5:
+		/* Only Audio devies on SSP1 and SSP5*/
+                if (soc_devtype != AUDIO_DEV_I2S)
+                        return NULL;
+                nhlt_link_type = NHLT_LINK_SSP;
+                break;
+	case AUDIO_LINK_SSP2:
+		/* Only Bluetooth devices on SSP2. */
+		if (soc_devtype != AUDIO_DEV_BT)
+			return NULL;
+		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);
+}



More information about the coreboot-gerrit mailing list