]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: fsl_sai: Add AUDMIX mode support on i.MX952
authorShengjiu Wang <shengjiu.wang@nxp.com>
Fri, 23 Jan 2026 08:25:01 +0000 (16:25 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 26 Jan 2026 12:09:19 +0000 (12:09 +0000)
One of SAI interfaces is connected to AUDMIX in the i.MX952 chip, but
AUDMIX can be bypassed or not bypassed on the i.MX952 platform.

There are three use cases:
1) SAI -> Codec (No AUDMIX between SAI and Codec)
2) SAI -> Codec (Has AUDMIX, but AUDMIX is bypassed)
3) SAI -> AUDMIX -> Codec (Has AUDMIX and used)

So add 'fsl,sai-amix-mode' property for this feature

fsl,sai-amix-mode = "none": is for case 1)
fsl,sai-amix-mode = "bypass": is for case 2)
fsl,sai-amix-mode = "audmix": is for case 3)

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://patch.msgid.link/20260123082501.4050296-5-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/linux/firmware/imx/sm.h
sound/soc/fsl/fsl_sai.c
sound/soc/fsl/fsl_sai.h

index a33b45027356751f4b8ad9b9136f0dd302a82520..ba5d93bd6158f4ea4417bbe313777bb3c1b13c89 100644 (file)
@@ -26,6 +26,8 @@
 #define SCMI_IMX94_CTRL_SAI3_MCLK      5U      /*!< WAKE SAI3 MCLK */
 #define SCMI_IMX94_CTRL_SAI4_MCLK      6U      /*!< WAKE SAI4 MCLK */
 
+#define SCMI_IMX952_CTRL_BYPASS_AUDMIX 8U      /* WAKE AUDMIX */
+
 #if IS_ENABLED(CONFIG_IMX_SCMI_MISC_DRV)
 int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val);
 int scmi_imx_misc_ctrl_set(u32 id, u32 val);
index 2fa14fbdfe1a8336230b1c7610f2632512711825..148e09e58dfac172b6b3285311027d5ac4a79327 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
+#include <linux/firmware/imx/sm.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/pinctrl/consumer.h>
@@ -1425,10 +1426,12 @@ static int fsl_sai_probe(struct platform_device *pdev)
        struct fsl_sai *sai;
        struct regmap *gpr;
        void __iomem *base;
+       const char *str = NULL;
        char tmp[8];
        int irq, ret, i;
        int index;
        u32 dmas[4];
+       u32 val;
 
        sai = devm_kzalloc(dev, sizeof(*sai), GFP_KERNEL);
        if (!sai)
@@ -1598,6 +1601,24 @@ static int fsl_sai_probe(struct platform_device *pdev)
        if (ret < 0 && ret != -ENOSYS)
                goto err_pm_get_sync;
 
+       if (of_device_is_compatible(np, "fsl,imx952-sai") &&
+           !of_property_read_string(np, "fsl,sai-amix-mode", &str)) {
+               if (!strcmp(str, "bypass"))
+                       val = FSL_SAI_AMIX_BYPASS;
+               else if (!strcmp(str, "audmix"))
+                       val = FSL_SAI_AMIX_AUDMIX;
+               else
+                       val = FSL_SAI_AMIX_NONE;
+
+               if (val < FSL_SAI_AMIX_NONE) {
+                       ret = scmi_imx_misc_ctrl_set(SCMI_IMX952_CTRL_BYPASS_AUDMIX, val);
+                       if (ret) {
+                               dev_err_probe(dev, ret, "Error setting audmix mode\n");
+                               goto err_pm_get_sync;
+                       }
+               }
+       }
+
        /*
         * Register platform component before registering cpu dai for there
         * is not defer probe for platform component in snd_soc_add_pcm_runtime().
index 6c917f79c6b0f9432b373a9aa686ba6dd832b052..7605cbaca3d8984afb4b37f07b0a4119e5ec8fb3 100644 (file)
 #define FSL_SAI_DL_I2S         BIT(0)
 #define FSL_SAI_DL_PDM         BIT(1)
 
+#define FSL_SAI_AMIX_BYPASS    0
+#define FSL_SAI_AMIX_AUDMIX    1
+#define FSL_SAI_AMIX_NONE      2
+
 struct fsl_sai_soc_data {
        bool use_imx_pcm;
        bool use_edma;