[PATCH 0/5] Create a new sound card to access MICFIL based on rpmsg channel
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.
Chancel Liu (5): ASoC: dt-bindings: fsl_rpmsg: Add a property to assign platform driver name ASoC: imx-audio-rpmsg: Create rpmsg channel for MICFIL ASoC: imx-pcm-rpmsg: Register different platform drivers ASoC: fsl_rpmsg: Register different CPU DAI drivers ASoC: imx-rpmsg: Assign platform driver used by machine driver to link with
.../devicetree/bindings/sound/fsl,rpmsg.yaml | 34 +++++++++++++++++-- sound/soc/fsl/fsl_rpmsg.c | 2 +- sound/soc/fsl/imx-audio-rpmsg.c | 3 +- sound/soc/fsl/imx-pcm-rpmsg.c | 10 ++++-- sound/soc/fsl/imx-rpmsg.c | 6 +++- 5 files changed, 47 insertions(+), 8 deletions(-)
-- 2.25.1
Add a string property to assign ASoC platform driver name. It also represents the 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".
Signed-off-by: Chancel Liu chancel.liu@nxp.com --- .../devicetree/bindings/sound/fsl,rpmsg.yaml | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml index d370c98a62c7..35e3cb9f768b 100644 --- a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml +++ b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml @@ -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,14 @@ properties: This is a boolean property. If present, the receiving function will be enabled.
+ fsl,platform: + $ref: /schemas/types.yaml#/definitions/string + description: | + A string property to assign ASoC platform driver name. It also + represents the 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". + required: - compatible - model @@ -107,3 +118,22 @@ examples: <&clk IMX8MN_AUDIO_PLL2_OUT>; clock-names = "ipg", "mclk", "dma", "pll8k", "pll11k"; }; + + - | + #include <dt-bindings/clock/imx8mm-clock.h> + + rpmsg_micfil: rpmsg_micfil { + compatible = "fsl,imx8mm-rpmsg-audio"; + model = "micfil-audio"; + fsl,platform = "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"; + }; + +...
Add a string property to assign ASoC platform driver name. It also represents the 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".
Signed-off-by: Chancel Liu chancel.liu@nxp.com
.../devicetree/bindings/sound/fsl,rpmsg.yaml | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml index d370c98a62c7..35e3cb9f768b 100644 --- a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml +++ b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml @@ -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,14 @@ properties: This is a boolean property. If present, the receiving function will be enabled.
- fsl,platform:
- $ref: /schemas/types.yaml#/definitions/string
- description: |
A string property to assign ASoC platform driver name. It also
represents the 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".
Please add enum to list supported strings.
Best regards Wang Shengjiu
required:
- compatible
- model
@@ -107,3 +118,22 @@ examples: <&clk IMX8MN_AUDIO_PLL2_OUT>; clock-names = "ipg", "mclk", "dma", "pll8k", "pll11k"; };
- |
- #include <dt-bindings/clock/imx8mm-clock.h>
- rpmsg_micfil: rpmsg_micfil {
compatible = "fsl,imx8mm-rpmsg-audio";
model = "micfil-audio";
fsl,platform = "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";
- };
+...
2.25.1
On 29/08/2022 10:51, Chancel Liu wrote:
Add a string property to assign ASoC platform driver name. It also represents the 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".
Signed-off-by: Chancel Liu chancel.liu@nxp.com
.../devicetree/bindings/sound/fsl,rpmsg.yaml | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml index d370c98a62c7..35e3cb9f768b 100644 --- a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml +++ b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml @@ -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,14 @@ properties: This is a boolean property. If present, the receiving function will be enabled.
- fsl,platform:
- $ref: /schemas/types.yaml#/definitions/string
- description: |
A string property to assign ASoC platform driver name.
No, this is not a property of hardware. Naming of some drivers in some systems does not fit DTS and bindings.
It also
represents the 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".
required:
- compatible
- model
@@ -107,3 +118,22 @@ examples: <&clk IMX8MN_AUDIO_PLL2_OUT>; clock-names = "ipg", "mclk", "dma", "pll8k", "pll11k"; };
- |
- #include <dt-bindings/clock/imx8mm-clock.h>
- rpmsg_micfil: rpmsg_micfil {
Node names should be generic. https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetre...
Also: no underscores in node names.
Best regards, Krzysztof
Rpmsg channel for MICFIL can also be created through rpmsg name service announcement. If this driver is probed, Cortex-A can access MICFIL which is actually controlled by Cortex-M through rpmsg channel for MICFIL.
Signed-off-by: Chancel Liu chancel.liu@nxp.com --- sound/soc/fsl/imx-audio-rpmsg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/imx-audio-rpmsg.c b/sound/soc/fsl/imx-audio-rpmsg.c index 905c3a071300..d5234ac4b09b 100644 --- a/sound/soc/fsl/imx-audio-rpmsg.c +++ b/sound/soc/fsl/imx-audio-rpmsg.c @@ -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" }, { }, };
This patch can register different ASoC platform drivers in reference to "fsl,platform" property of the corresponding node in dts. So sound cards based on different rpmsg channels can link to their respective platform drivers.
Signed-off-by: Chancel Liu chancel.liu@nxp.com --- sound/soc/fsl/imx-pcm-rpmsg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c index 35049043e532..2f310994f7ee 100644 --- a/sound/soc/fsl/imx-pcm-rpmsg.c +++ b/sound/soc/fsl/imx-pcm-rpmsg.c @@ -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
This patch can register different ASoC platform drivers in reference to "fsl,platform" property of the corresponding node in dts. So sound cards based on different rpmsg channels can link to their respective platform drivers.
Signed-off-by: Chancel Liu chancel.liu@nxp.com
sound/soc/fsl/imx-pcm-rpmsg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm- rpmsg.c index 35049043e532..2f310994f7ee 100644 --- a/sound/soc/fsl/imx-pcm-rpmsg.c +++ b/sound/soc/fsl/imx-pcm-rpmsg.c @@ -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);
Please use separate commit for this change, I think the fsl_rpmsg_dai. channels_max Should be updated also?
Best regards Wang shengjiug
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
2.25.1
This patch can register different ASoC CPU DAI drivers. So sound cards based on different rpmsg channels can link to their respective CPU DAI drivers.
Signed-off-by: Chancel Liu chancel.liu@nxp.com --- sound/soc/fsl/fsl_rpmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/fsl/fsl_rpmsg.c b/sound/soc/fsl/fsl_rpmsg.c index bf94838bdbef..fde3d5006ce0 100644 --- a/sound/soc/fsl/fsl_rpmsg.c +++ b/sound/soc/fsl/fsl_rpmsg.c @@ -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)) {
Use "fsl,platform" property to indicate ASoC machine driver which ASoC platform driver should link with.
Signed-off-by: Chancel Liu chancel.liu@nxp.com --- sound/soc/fsl/imx-rpmsg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c index 2e117311e582..c534b638698e 100644 --- a/sound/soc/fsl/imx-rpmsg.c +++ b/sound/soc/fsl/imx-rpmsg.c @@ -36,6 +36,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;
@@ -81,7 +82,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,platform", &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;
participants (3)
-
Chancel Liu
-
Krzysztof Kozlowski
-
S.J. Wang