From 39721ca2cca969862b6cf279a3aebc91f40bd0a1 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Wed, 8 Aug 2018 15:05:48 +0800 Subject: MLK-19168-5: ASoC: imx-cs42888: support codec through rpmsg (part 1) support codec through rpmsg Signed-off-by: Shengjiu Wang (cherry picked from commit 8585d67e54c4c3607990a792718992de8be8fe58) [ Aisheng: split rpmsg Kconfig changes ] Signed-off-by: Dong Aisheng --- sound/soc/fsl/imx-cs42888.c | 58 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 14 deletions(-) (limited to 'sound/soc/fsl/imx-cs42888.c') diff --git a/sound/soc/fsl/imx-cs42888.c b/sound/soc/fsl/imx-cs42888.c index 6539aa662c24..39b836fe62de 100644 --- a/sound/soc/fsl/imx-cs42888.c +++ b/sound/soc/fsl/imx-cs42888.c @@ -41,6 +41,7 @@ struct imx_priv { u32 asrc_rate; u32 asrc_format; bool is_codec_master; + bool is_codec_rpmsg; }; static struct imx_priv card_priv; @@ -291,7 +292,6 @@ static int imx_cs42888_probe(struct platform_device *pdev) struct device_node *asrc_np = NULL; struct platform_device *esai_pdev; struct platform_device *asrc_pdev = NULL; - struct i2c_client *codec_dev; struct imx_priv *priv = &card_priv; int ret; u32 width; @@ -299,6 +299,9 @@ static int imx_cs42888_probe(struct platform_device *pdev) priv->pdev = pdev; priv->asrc_pdev = NULL; + if (of_property_read_bool(pdev->dev.of_node, "codec-rpmsg")) + priv->is_codec_rpmsg = true; + esai_np = of_parse_phandle(pdev->dev.of_node, "esai-controller", 0); codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0); if (!esai_np || !codec_np) { @@ -319,16 +322,50 @@ static int imx_cs42888_probe(struct platform_device *pdev) ret = -EINVAL; goto fail; } - codec_dev = of_find_i2c_device_by_node(codec_np); - if (!codec_dev || !codec_dev->dev.driver) { - dev_err(&pdev->dev, "failed to find codec platform device\n"); - ret = -EINVAL; - goto fail; + + if (priv->is_codec_rpmsg) { + struct platform_device *codec_dev; + + codec_dev = of_find_device_by_node(codec_np); + if (!codec_dev || !codec_dev->dev.driver) { + dev_err(&pdev->dev, "failed to find codec platform device\n"); + ret = -EINVAL; + goto fail; + } + + priv->codec_clk = devm_clk_get(&codec_dev->dev, NULL); + if (IS_ERR(priv->codec_clk)) { + ret = PTR_ERR(priv->codec_clk); + dev_err(&codec_dev->dev, "failed to get codec clk: %d\n", ret); + goto fail; + } + + } else { + struct i2c_client *codec_dev; + + codec_dev = of_find_i2c_device_by_node(codec_np); + if (!codec_dev || !codec_dev->dev.driver) { + dev_err(&pdev->dev, "failed to find codec platform device\n"); + ret = -EINVAL; + goto fail; + } + + priv->codec_clk = devm_clk_get(&codec_dev->dev, NULL); + if (IS_ERR(priv->codec_clk)) { + ret = PTR_ERR(priv->codec_clk); + dev_err(&codec_dev->dev, "failed to get codec clk: %d\n", ret); + goto fail; + } } /*if there is no asrc controller, we only enable one device*/ if (!asrc_pdev) { - imx_cs42888_dai[0].codec_of_node = codec_np; + if (priv->is_codec_rpmsg) { + imx_cs42888_dai[0].codec_name = "rpmsg-audio-codec-cs42888"; + imx_cs42888_dai[0].codec_dai_name = "cs42888"; + } else { + imx_cs42888_dai[0].codec_of_node = codec_np; + } imx_cs42888_dai[0].cpu_dai_name = dev_name(&esai_pdev->dev); imx_cs42888_dai[0].platform_of_node = esai_np; snd_soc_card_imx_cs42888.num_links = 1; @@ -365,13 +402,6 @@ static int imx_cs42888_probe(struct platform_device *pdev) priv->asrc_format = SNDRV_PCM_FORMAT_S16_LE; } - priv->codec_clk = devm_clk_get(&codec_dev->dev, NULL); - if (IS_ERR(priv->codec_clk)) { - ret = PTR_ERR(priv->codec_clk); - dev_err(&codec_dev->dev, "failed to get codec clk: %d\n", ret); - goto fail; - } - priv->esai_clk = devm_clk_get(&esai_pdev->dev, "extal"); if (IS_ERR(priv->esai_clk)) { ret = PTR_ERR(priv->esai_clk); -- cgit v1.2.3