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 3090705e872827b2726f71dc0c954400a6267289 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_add_<codec>_on_ssp uses codec configs, tdm configs and add the particular codec on a SSP port specified by mainboard. get_nhlt_link_type() returns a corresponding NHLT link type based on audio soc hardware interface passed as an argument.
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 | 39 +++++++++ src/soc/intel/apollolake/nhlt.c | 130 ++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+)
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc index 38ed07d..c335e39 100644 --- a/src/soc/intel/apollolake/Makefile.inc +++ b/src/soc/intel/apollolake/Makefile.inc @@ -55,6 +55,7 @@ ramstage-y += pmutil.c ramstage-y += pmc.c ramstage-y += smi.c ramstage-y += reset.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..cc6486b --- /dev/null +++ b/src/soc/intel/apollolake/include/soc/nhlt.h @@ -0,0 +1,39 @@ +/* + * 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, +}; + +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..87fc65a --- /dev/null +++ b/src/soc/intel/apollolake/nhlt.c @@ -0,0 +1,130 @@ +/* + * 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_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_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_tdm_config tdm_cfg = { + .virtual_slot = 0, + .config_type = NHLT_TDM_BASIC, +}; + +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", + }, +}; + +int nhlt_soc_get_link_type(int hwlink, int soc_devtype) +{ + int nhlt_link_type; + + switch (hwlink) { + case AUDIO_LINK_SSP0: + case AUDIO_LINK_SSP1: + case AUDIO_LINK_SSP3: + case AUDIO_LINK_SSP4: + case AUDIO_LINK_SSP5: + /* Only I2S devices. */ + if (soc_devtype != AUDIO_DEV_I2S) + return -1; + nhlt_link_type = NHLT_LINK_SSP; + break; + case AUDIO_LINK_SSP2: + /* Only Bluetooth devices on SSP2. */ + if (soc_devtype != AUDIO_DEV_BT) + return -1; + nhlt_link_type = NHLT_LINK_SSP; + break; + case AUDIO_LINK_DMIC: + // Only DMIC devices on DMIC links. + if (soc_devtype != AUDIO_DEV_DMIC) + return -1; + nhlt_link_type = NHLT_LINK_PDM; + break; + default: + return -1; + } + + return nhlt_link_type; +} + +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; + } + + if (nhlt_add_dmic_array(nhlt, num_channels, dmic_2ch_cfg, + ARRAY_SIZE(dmic_2ch_cfg))) { + printk(BIOS_ERR, "Couldn't add 2CH DMIC array.\n"); + return -1; + } + + return 0; +} + +int nhlt_soc_add_max98357(struct nhlt *nhlt, int hwlink) +{ + if (nhlt_add_codec_on_ssp(nhlt, hwlink, max98357_cfg, + ARRAY_SIZE(max98357_cfg), NULL, 0, NULL, 0)) { + printk(BIOS_ERR, "Couldn't add Maxim_98357 codec.\n"); + return -1; + } + + return 0; +} + +int nhlt_soc_add_da7219(struct nhlt *nhlt, int hwlink) +{ + if (nhlt_add_codec_on_ssp(nhlt, hwlink, da7219_cfg, + ARRAY_SIZE(da7219_cfg), da7219_cfg, ARRAY_SIZE(da7219_cfg), &tdm_cfg, + sizeof(tdm_cfg))) { + printk(BIOS_ERR, "Couldn't add Dialog_7219 codec.\n"); + return -1; + } + + return 0; +}