Saurabh Satija (saurabh.satija@intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15311
-gerrit
commit 68be0094ff8c519bf545bc44e82ee88e7d989313 Author: Saurabh Satija saurabh.satija@intel.com Date: Tue Jun 21 14:22:16 2016 -0700
soc/intel/apollolake: Add NHLT add codec APIs and device/vendor ids
nhlt_soc_add_<codec>() uses an endpoint_descriptor and add the particular codec on a SSP port specified by mainboard. An endpoint descriptor includes codec configuration settings, optional config settings and device & vendor ids for the particular SoC. All the I2S device types also mention a hwlink which is the SSP port number at which the particular codec is present and this hwlink is mainboard specific. The default value id used for DMIC device types. Apollolake supports only 2 channel DMIC array.
Also define vendor id for NHLT and device ids for NHLT Bluetooth, DMIC & SSPs. These ids are used to add NHLT endpoints for different audio codecs. These ids are platform dependent.
Change-Id: Ic9bd26ebe8d6df60af23733e122fd8f3c0432e1f Signed-off-by: Saurabh Satija saurabh.satija@intel.com --- src/soc/intel/apollolake/Makefile.inc | 1 + src/soc/intel/apollolake/include/soc/nhlt.h | 48 ++++++++++ src/soc/intel/apollolake/nhlt.c | 142 ++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+)
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc index 7326f14..037b91a 100644 --- a/src/soc/intel/apollolake/Makefile.inc +++ b/src/soc/intel/apollolake/Makefile.inc @@ -59,6 +59,7 @@ ramstage-y += pmc.c ramstage-y += reset.c ramstage-y += smi.c ramstage-y += spi.c +ramstage-y += nhlt.c
postcar-y += exit_car.S postcar-y += memmap.c 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..aff149d --- /dev/null +++ b/src/soc/intel/apollolake/include/soc/nhlt.h @@ -0,0 +1,48 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2016 Intel Corp. + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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_APOLLOLAKE_NHLT_H_ +#define _SOC_APOLLOLAKE_NHLT_H_ + +#define NHLT_VID 0x8086 +#define NHLT_DID_DMIC 0xae20 +#define NHLT_DID_BT 0xae30 +#define NHLT_DID_SSP 0xae34 + +enum { + AUDIO_LINK_SSP0, + AUDIO_LINK_SSP1, + AUDIO_LINK_SSP2, + AUDIO_LINK_SSP3, + AUDIO_LINK_SSP4, + AUDIO_LINK_SSP5, + AUDIO_LINK_DMIC, +}; + +/* + * NHLT device types. + */ +enum { + AUDIO_DEV_I2S, + AUDIO_DEV_DMIC, + AUDIO_DEV_BT, +}; + +int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels); +int nhlt_soc_add_max98357(struct nhlt *nhlt, int hwlink); +int nhlt_soc_add_da7219(struct nhlt *nhlt, int hwlink); + +#endif diff --git a/src/soc/intel/apollolake/nhlt.c b/src/soc/intel/apollolake/nhlt.c new file mode 100644 index 0000000..d19a19f --- /dev/null +++ b/src/soc/intel/apollolake/nhlt.c @@ -0,0 +1,142 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2016 Intel Corp. + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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 <console/console.h> +#include <nhlt.h> +#include <soc/nhlt.h> + +static const struct nhlt_dmic_array_config mic_config = { + .tdm_config = { + .virtual_slot = 0, + .config_type = NHLT_TDM_MIC_ARRAY, + }, + .array_type = NHLT_MIC_ARRAY_2CH_SMALL, +}; + +static const struct nhlt_tdm_config tdm_basic = { + .virtual_slot = 0, + .config_type = NHLT_TDM_BASIC, +}; + +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", + }, +}; + +static const struct nhlt_endp_descriptor dmic_2ch_endp[] = { + { + .link = NHLT_LINK_PDM, + .device = AUDIO_DEV_DMIC, + .direction = NHLT_DIR_CAPTURE, + .vid = NHLT_VID, + .did = NHLT_DID_DMIC, + .cfg = &mic_config, + .cfg_size = sizeof(mic_config), + .formats = dmic_2ch_cfg, + .num_formats = ARRAY_SIZE(dmic_2ch_cfg), + }, +}; + +static const struct nhlt_format_config da7219_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 = "dialog-2ch-48khz-24b.bin", + }, +}; + +static const struct nhlt_endp_descriptor da7219_endp[] = { + { + .link = NHLT_LINK_SSP, + .device = AUDIO_DEV_I2S, + .direction = NHLT_DIR_RENDER, + .vid = NHLT_VID, + .did = NHLT_DID_SSP, + .cfg = &tdm_basic, + .cfg_size = sizeof(tdm_basic), + .formats = da7219_cfg, + .num_formats = ARRAY_SIZE(da7219_cfg), + }, + { + .link = NHLT_LINK_SSP, + .device = AUDIO_DEV_I2S, + .direction = NHLT_DIR_CAPTURE, + .vid = NHLT_VID, + .did = NHLT_DID_SSP, + .cfg = &tdm_basic, + .cfg_size = sizeof(tdm_basic), + .formats = da7219_cfg, + .num_formats = ARRAY_SIZE(da7219_cfg), + }, + +}; + +static const struct nhlt_format_config max98357_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", + }, +}; + +static const struct nhlt_endp_descriptor max98357_endp[] = { + { + .link = NHLT_LINK_SSP, + .device = AUDIO_DEV_I2S, + .direction = NHLT_DIR_RENDER, + .vid = NHLT_VID, + .did = NHLT_DID_SSP, + .cfg = NULL, + .cfg_size = 0, + .formats = max98357_cfg, + .num_formats = ARRAY_SIZE(max98357_cfg), + }, +}; + +int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels) +{ + if (num_channels != 2) { + printk(BIOS_ERR, "APL only supports 2CH DMIC array.\n"); + return -1; + } + + return nhlt_add_endpoints(nhlt, dmic_2ch_endp, + sizeof(dmic_2ch_endp)); +} + +int nhlt_soc_add_max98357(struct nhlt *nhlt, int hwlink) +{ + return nhlt_add_ssp_endpoints(nhlt, hwlink, max98357_endp, + sizeof(max98357_endp)); +} + +int nhlt_soc_add_da7219(struct nhlt *nhlt, int hwlink) +{ + return nhlt_add_ssp_endpoints(nhlt, hwlink, da7219_endp, + sizeof(da7219_endp)); +}