summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorShengjiu Wang <shengjiu.wang@nxp.com>2018-08-08 15:05:48 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commit41d7e57f526d0e0d430b3af8a5f6efcbd2a287ad (patch)
tree96adb43f2a68970a32ae127e8f3daecec3b29884 /sound
parent2c85c0bc5e76ce8df03acaaf72264838e2941322 (diff)
MLK-19168-5: ASoC: imx-cs42888: support codec through rpmsg
support codec through rpmsg Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/fsl/Kconfig1
-rw-r--r--sound/soc/fsl/imx-cs42888.c58
2 files changed, 45 insertions, 14 deletions
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 133526580370..5eb4b1dae9bd 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -421,6 +421,7 @@ config SND_SOC_IMX_RPMSG
select SND_SOC_IMX_PCM_RPMSG
select SND_SOC_FSL_RPMSG_I2S
select SND_SOC_RPMSG_WM8960
+ select SND_SOC_RPMSG_CS42XX8
help
SoC Audio support for i.MX boards with rpmsg.
There should be rpmsg devices defined in other core
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);