1
0
Fork 0

MLK-23702-4: ASoC: imx-rpmsg: support rpmsg audio for i.MX8MP

in i.MX8MP, the audio codec is registered by DT, and we reserve
a memory in DT that we can allocate dma memory from the
reserved pool.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Shengjiu Wang 2020-03-30 14:35:04 +08:00
parent ccb83f789e
commit 3ace7799e9
1 changed files with 23 additions and 3 deletions

View File

@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/of_platform.h>
#include <linux/of_reserved_mem.h>
#include <linux/i2c.h>
#include <linux/of_gpio.h>
#include <linux/slab.h>
@ -39,6 +40,7 @@ static const struct snd_soc_dapm_widget imx_wm8960_dapm_widgets[] = {
static int imx_rpmsg_probe(struct platform_device *pdev)
{
struct device_node *cpu_np;
struct device_node *codec_np = NULL;
struct platform_device *cpu_pdev;
struct imx_rpmsg_data *data;
struct fsl_rpmsg_i2s *rpmsg_i2s;
@ -69,8 +71,21 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
goto fail;
}
ret = of_reserved_mem_device_init_by_idx(&pdev->dev, pdev->dev.of_node, 0);
if (ret)
dev_warn(&pdev->dev, "no reserved DMA memory for rpmsg device\n");
rpmsg_i2s = platform_get_drvdata(cpu_pdev);
if (rpmsg_i2s->codec_in_dt) {
codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0);
if (!codec_np) {
dev_err(&pdev->dev, "phandle missing or invalid\n");
ret = -EINVAL;
goto fail;
}
}
data->dai[0].cpus = &dlc[0];
data->dai[0].num_cpus = 1;
data->dai[0].platforms = &dlc[1];
@ -82,11 +97,16 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
data->dai[0].stream_name = "rpmsg hifi";
data->dai[0].dai_fmt = SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBM_CFM;
SND_SOC_DAIFMT_CBS_CFS;
if (rpmsg_i2s->codec_wm8960) {
data->dai[0].codecs->dai_name = "rpmsg-wm8960-hifi";
data->dai[0].codecs->name = "rpmsg-audio-codec-wm8960";
if (rpmsg_i2s->codec_in_dt) {
data->dai[0].codecs->of_node = codec_np;
data->dai[0].codecs->dai_name = "rpmsg-wm8960-hifi";
} else {
data->dai[0].codecs->dai_name = "rpmsg-wm8960-hifi";
data->dai[0].codecs->name = "rpmsg-audio-codec-wm8960";
}
}
if (rpmsg_i2s->codec_dummy) {