Commit 651c304d authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: Intel: sof_es8336: use NHLT information to set dmic and SSP

Since we see a proliferation of devices with various configurations,
we want to automatically set the DMIC and SSP information. This patch
relies on the information extracted from NHLT and partially reverts
existing DMI quirks added by commit a164137c ("ASoC: Intel: add
machine driver for SOF+ES8336")

Note that NHLT can report multiple SSPs, choosing from the
ssp_link_mask in an MSB-first manner was found experimentally to work
fine.

The only thing that cannot be detected is the GPIO type, and users may
want to use the quirk override parameter if the 'wrong' solution is
provided.
Tested-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220308192610.392950-15-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1b528348
...@@ -228,24 +228,25 @@ static int sof_es8336_quirk_cb(const struct dmi_system_id *id) ...@@ -228,24 +228,25 @@ static int sof_es8336_quirk_cb(const struct dmi_system_id *id)
return 1; return 1;
} }
/*
* this table should only be used to add GPIO or jack-detection quirks
* that cannot be detected from ACPI tables. The SSP and DMIC
* information are providing by the platform driver and are aligned
* with the topology used.
*
* If the GPIO support is missing, the quirk parameter can be used to
* enable speakers. In that case it's recommended to keep the SSP and DMIC
* information consistent, overriding the SSP and DMIC can only be done
* if the topology file is modified as well.
*/
static const struct dmi_system_id sof_es8336_quirk_table[] = { static const struct dmi_system_id sof_es8336_quirk_table[] = {
{
.callback = sof_es8336_quirk_cb,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "CHUWI Innovation And Technology"),
DMI_MATCH(DMI_BOARD_NAME, "Hi10 X"),
},
.driver_data = (void *)SOF_ES8336_SSP_CODEC(2)
},
{ {
.callback = sof_es8336_quirk_cb, .callback = sof_es8336_quirk_cb,
.matches = { .matches = {
DMI_MATCH(DMI_SYS_VENDOR, "IP3 tech"), DMI_MATCH(DMI_SYS_VENDOR, "IP3 tech"),
DMI_MATCH(DMI_BOARD_NAME, "WN1"), DMI_MATCH(DMI_BOARD_NAME, "WN1"),
}, },
.driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | .driver_data = (void *)(SOF_ES8336_TGL_GPIO_QUIRK)
SOF_ES8336_TGL_GPIO_QUIRK |
SOF_ES8336_ENABLE_DMIC)
}, },
{} {}
}; };
...@@ -470,11 +471,33 @@ static int sof_es8336_probe(struct platform_device *pdev) ...@@ -470,11 +471,33 @@ static int sof_es8336_probe(struct platform_device *pdev)
card = &sof_es8336_card; card = &sof_es8336_card;
card->dev = dev; card->dev = dev;
if (!dmi_check_system(sof_es8336_quirk_table)) /* check GPIO DMI quirks */
quirk = SOF_ES8336_SSP_CODEC(2); dmi_check_system(sof_es8336_quirk_table);
if (quirk & SOF_ES8336_ENABLE_DMIC) if (!mach->mach_params.i2s_link_mask) {
dmic_be_num = 2; dev_warn(dev, "No I2S link information provided, using SSP0. This may need to be modified with the quirk module parameter\n");
} else {
/*
* Set configuration based on platform NHLT.
* In this machine driver, we can only support one SSP for the
* ES8336 link, the else-if below are intentional.
* In some cases multiple SSPs can be reported by NHLT, starting MSB-first
* seems to pick the right connection.
*/
unsigned long ssp = 0;
if (mach->mach_params.i2s_link_mask & BIT(2))
ssp = SOF_ES8336_SSP_CODEC(2);
else if (mach->mach_params.i2s_link_mask & BIT(1))
ssp = SOF_ES8336_SSP_CODEC(1);
else if (mach->mach_params.i2s_link_mask & BIT(0))
ssp = SOF_ES8336_SSP_CODEC(0);
quirk |= ssp;
}
if (mach->mach_params.dmic_num)
quirk |= SOF_ES8336_ENABLE_DMIC;
if (quirk_override != -1) { if (quirk_override != -1) {
dev_info(dev, "Overriding quirk 0x%lx => 0x%x\n", dev_info(dev, "Overriding quirk 0x%lx => 0x%x\n",
...@@ -483,6 +506,9 @@ static int sof_es8336_probe(struct platform_device *pdev) ...@@ -483,6 +506,9 @@ static int sof_es8336_probe(struct platform_device *pdev)
} }
log_quirks(dev); log_quirks(dev);
if (quirk & SOF_ES8336_ENABLE_DMIC)
dmic_be_num = 2;
sof_es8336_card.num_links += dmic_be_num + hdmi_num; sof_es8336_card.num_links += dmic_be_num + hdmi_num;
dai_links = sof_card_dai_links_create(dev, dai_links = sof_card_dai_links_create(dev,
SOF_ES8336_SSP_CODEC(quirk), SOF_ES8336_SSP_CODEC(quirk),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment