Commit a2ddd19f authored by Mark Brown's avatar Mark Brown

Create a new sound card to access MICFIL based on rpmsg channel

Merge series from Chancel Liu <chancel.liu@nxp.com>:

At a previous time, we have successfully created a virtual sound card
based on rpmsg. The sound card works under this mechanism Cortex-A core
tells the Cortex-M core the format, rate, channel, .etc configuration
of the PCM parameters and Cortex-M controls real hardware devices such
as SAI and DMA. From the view of Linux side, the sound card is bound to
a rpmsg channel through which it can access SAI.

Here these patches are introduced to create a new virtual sound card to
access MICFIL based on a new created rpmsg channel. It's easy to create
a new rpmsg channel for MICFIL through rpmsg name service announcment.
Also the other ASoC components bound to this rpmsg MICFIL sound card
will be registered with these patches.

If other sound cards using different hardware devices needs to be
created over rpmsg in the future, these patches can be referred.
parents c39e299a 4b48440e
......@@ -11,8 +11,11 @@ maintainers:
description: |
fsl_rpmsg is a virtual audio device. Mapping to real hardware devices
are SAI, DMA controlled by Cortex M core. What we see from Linux
side is a device which provides audio service by rpmsg channel.
are SAI, MICFIL, DMA controlled by Cortex M core. What we see from
Linux side is a device which provides audio service by rpmsg channel.
We can create different sound cards which access different hardwares
such as SAI, MICFIL, .etc through building rpmsg channels between
Cortex-A and Cortex-M.
properties:
compatible:
......@@ -85,6 +88,16 @@ properties:
This is a boolean property. If present, the receiving function
will be enabled.
fsl,rpmsg-channel-name:
$ref: /schemas/types.yaml#/definitions/string
description: |
A string property to assign rpmsg channel this sound card sits on.
This property can be omitted if there is only one sound card and it sits
on "rpmsg-audio-channel".
enum:
- rpmsg-audio-channel
- rpmsg-micfil-channel
required:
- compatible
- model
......@@ -107,3 +120,22 @@ examples:
<&clk IMX8MN_AUDIO_PLL2_OUT>;
clock-names = "ipg", "mclk", "dma", "pll8k", "pll11k";
};
- |
#include <dt-bindings/clock/imx8mm-clock.h>
rpmsg_micfil: audio-controller {
compatible = "fsl,imx8mm-rpmsg-audio";
model = "micfil-audio";
fsl,rpmsg-channel-name = "rpmsg-micfil-channel";
fsl,enable-lpa;
fsl,rpmsg-in;
clocks = <&clk IMX8MM_CLK_PDM_IPG>,
<&clk IMX8MM_CLK_PDM_ROOT>,
<&clk IMX8MM_CLK_SDMA3_ROOT>,
<&clk IMX8MM_AUDIO_PLL1_OUT>,
<&clk IMX8MM_AUDIO_PLL2_OUT>;
clock-names = "ipg", "mclk", "dma", "pll8k", "pll11k";
};
...
......@@ -117,14 +117,14 @@ static struct snd_soc_dai_driver fsl_rpmsg_dai = {
.playback = {
.stream_name = "CPU-Playback",
.channels_min = 2,
.channels_max = 2,
.channels_max = 32,
.rates = SNDRV_PCM_RATE_KNOT,
.formats = FSL_RPMSG_FORMATS,
},
.capture = {
.stream_name = "CPU-Capture",
.channels_min = 2,
.channels_max = 2,
.channels_max = 32,
.rates = SNDRV_PCM_RATE_KNOT,
.formats = FSL_RPMSG_FORMATS,
},
......@@ -235,7 +235,7 @@ static int fsl_rpmsg_probe(struct platform_device *pdev)
rpmsg->card_pdev = platform_device_register_data(&pdev->dev,
"imx-audio-rpmsg",
PLATFORM_DEVID_NONE,
PLATFORM_DEVID_AUTO,
NULL,
0);
if (IS_ERR(rpmsg->card_pdev)) {
......
......@@ -88,7 +88,7 @@ static int imx_audio_rpmsg_probe(struct rpmsg_device *rpdev)
/* Register platform driver for rpmsg routine */
data->rpmsg_pdev = platform_device_register_data(&rpdev->dev,
IMX_PCM_DRV_NAME,
PLATFORM_DEVID_NONE,
PLATFORM_DEVID_AUTO,
NULL, 0);
if (IS_ERR(data->rpmsg_pdev)) {
dev_err(&rpdev->dev, "failed to register rpmsg platform.\n");
......@@ -110,6 +110,7 @@ static void imx_audio_rpmsg_remove(struct rpmsg_device *rpdev)
static struct rpmsg_device_id imx_audio_rpmsg_id_table[] = {
{ .name = "rpmsg-audio-channel" },
{ .name = "rpmsg-micfil-channel" },
{ },
};
......
......@@ -178,7 +178,7 @@ static int imx_rpmsg_pcm_hw_params(struct snd_soc_component *component,
msg->s_msg.param.channels = RPMSG_CH_STEREO;
break;
default:
ret = -EINVAL;
msg->s_msg.param.channels = params_channels(params);
break;
}
......@@ -684,7 +684,7 @@ static int imx_rpmsg_pcm_probe(struct platform_device *pdev)
info->rpdev = container_of(pdev->dev.parent, struct rpmsg_device, dev);
info->dev = &pdev->dev;
/* Setup work queue */
info->rpmsg_wq = alloc_ordered_workqueue("rpmsg_audio",
info->rpmsg_wq = alloc_ordered_workqueue(info->rpdev->id.name,
WQ_HIGHPRI |
WQ_UNBOUND |
WQ_FREEZABLE);
......@@ -723,11 +723,15 @@ static int imx_rpmsg_pcm_probe(struct platform_device *pdev)
if (ret)
goto fail;
component = snd_soc_lookup_component(&pdev->dev, IMX_PCM_DRV_NAME);
component = snd_soc_lookup_component(&pdev->dev, NULL);
if (!component) {
ret = -EINVAL;
goto fail;
}
/* platform component name is used by machine driver to link with */
component->name = info->rpdev->id.name;
#ifdef CONFIG_DEBUG_FS
component->debugfs_prefix = "rpmsg";
#endif
......
......@@ -58,6 +58,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
struct platform_device *rpmsg_pdev = to_platform_device(dev);
struct device_node *np = rpmsg_pdev->dev.of_node;
struct of_phandle_args args;
const char *platform_name;
struct imx_rpmsg *data;
int ret = 0;
......@@ -109,7 +110,10 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
}
data->dai.cpus->dai_name = dev_name(&rpmsg_pdev->dev);
data->dai.platforms->name = IMX_PCM_DRV_NAME;
if (!of_property_read_string(np, "fsl,rpmsg-channel-name", &platform_name))
data->dai.platforms->name = platform_name;
else
data->dai.platforms->name = "rpmsg-audio-channel";
data->dai.playback_only = true;
data->dai.capture_only = true;
data->card.num_links = 1;
......
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