1
0
Fork 0

MLK-23313-4: ASoC: fsl: Add Audio XCVR machine driver

This patch implements Audio XCVR machine driver for NXP iMX8 SOCs.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Viorel Suman 2020-02-13 11:58:56 +02:00
parent c7aa3b9266
commit bf133eb854
3 changed files with 111 additions and 0 deletions

View File

@ -588,6 +588,14 @@ config SND_SOC_IMX_CDNHDMI
Say Y if you want to add support for SoC audio on an i.MX board with
IMX CDN HDMI.
config SND_SOC_IMX_XCVR
tristate "SoC Audio support for i.MX boards with XCVR"
select SND_SOC_FSL_XCVR
help
SoC Audio support for i.MX boards with Audio Transceiver (XCVR)
Say Y if you want to add support for SoC audio on an i.MX board with
an Audio Transceiver (XCVR).
endif # SND_IMX_SOC
endmenu

View File

@ -102,6 +102,7 @@ snd-soc-imx-si476x-objs := imx-si476x.o
snd-soc-imx-hdmi-objs := imx-hdmi.o
snd-soc-imx-cdnhdmi-objs := imx-cdnhdmi.o
snd-soc-imx-rpmsg-objs := imx-rpmsg.o
snd-soc-imx-xcvr-objs := imx-xcvr.o
obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o
@ -129,5 +130,6 @@ obj-$(CONFIG_SND_SOC_IMX_DSP) += snd-soc-imx-dsp.o
obj-$(CONFIG_SND_SOC_IMX_SI476X) += snd-soc-imx-si476x.o
obj-$(CONFIG_SND_SOC_IMX_HDMI) += snd-soc-imx-hdmi.o
obj-$(CONFIG_SND_SOC_IMX_CDNHDMI) += snd-soc-imx-cdnhdmi.o
obj-$(CONFIG_SND_SOC_IMX_XCVR) += snd-soc-imx-xcvr.o
AFLAGS_hdmi_pcm.o := -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp

View File

@ -0,0 +1,101 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright 2019 NXP
#include <linux/module.h>
#include <linux/of_platform.h>
#include <sound/soc.h>
#include "fsl_xcvr.h"
struct imx_xcvr_data {
struct snd_soc_dai_link dai;
struct snd_soc_card card;
};
static int imx_xcvr_audio_probe(struct platform_device *pdev)
{
struct device_node *xcvr_np, *np = pdev->dev.of_node;
struct snd_soc_dai_link_component *dlc;
struct snd_soc_dai *cpu_dai, *codec_dai;
struct imx_xcvr_data *data;
int ret = 0;
xcvr_np = of_parse_phandle(np, "cpu-dai", 0);
if (!xcvr_np) {
dev_err(&pdev->dev, "failed to find cpu-dai\n");
ret = -EINVAL;
goto end;
}
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) {
ret = -ENOMEM;
goto end;
}
dlc = devm_kzalloc(&pdev->dev, 3 * sizeof(*dlc), GFP_KERNEL);
if (!dlc) {
ret = -ENOMEM;
goto end;
}
data->dai.cpus = &dlc[0];
data->dai.num_cpus = 1;
data->dai.platforms = &dlc[1];
data->dai.num_platforms = 1;
data->dai.codecs = &dlc[2];
data->dai.num_codecs = 1;
data->dai.name = "XCVR PCM";
data->dai.stream_name = "XCVR PCM";
data->dai.codecs->dai_name = "snd-soc-dummy-dai";
data->dai.codecs->name = "snd-soc-dummy";
data->dai.cpus->of_node = xcvr_np;
data->dai.platforms->of_node = xcvr_np;
data->card.dev = &pdev->dev;
data->card.dai_link = &data->dai;
data->card.num_links = 1;
data->card.owner = THIS_MODULE;
cpu_dai = snd_soc_find_dai(data->dai.cpus);
codec_dai = snd_soc_find_dai(data->dai.codecs);
if (cpu_dai && codec_dai) {
codec_dai->driver->playback = cpu_dai->driver->playback;
codec_dai->driver->capture = cpu_dai->driver->capture;
}
ret = snd_soc_of_parse_card_name(&data->card, "model");
if (ret)
goto end;
ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
if (ret) {
dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret);
goto end;
}
end:
of_node_put(xcvr_np);
return ret;
}
static const struct of_device_id imx_xcvr_dt_ids[] = {
{ .compatible = "fsl,imx-audio-xcvr", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, imx_xcvr_dt_ids);
static struct platform_driver imx_xcvr_driver = {
.driver = {
.name = "imx-xcvr",
.pm = &snd_soc_pm_ops,
.of_match_table = imx_xcvr_dt_ids,
},
.probe = imx_xcvr_audio_probe,
};
module_platform_driver(imx_xcvr_driver);
MODULE_AUTHOR("Viorel Suman <viorel.suman@nxp.com>");
MODULE_DESCRIPTION("NXP Audio Transceiver (XCVR) machine driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:imx-xcvr");