[PATCH v2] ASoC: SOF: imx9: use SCMI API for LM management

Laurentiu Mihalcea posted 1 patch 2 months, 3 weeks ago
sound/soc/sof/imx/Kconfig |  1 +
sound/soc/sof/imx/imx9.c  | 36 ++++++++----------------------------
2 files changed, 9 insertions(+), 28 deletions(-)
[PATCH v2] ASoC: SOF: imx9: use SCMI API for LM management
Posted by Laurentiu Mihalcea 2 months, 3 weeks ago
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>

Linux supports NXP's LMM SCMI protocol so switch to using the appropriate
API. The SIPs were intended to act as placeholders until the support for
said protocol was upstreamed.

The underlying CPU protocol command from IMX_SIP_SRC_M_RESET_ADDR_SET is
replaced by a LMM protocol command with the same effect (i.e. setting the
boot address) since using the CPU protocol would require additional
permissions (which TF-A already had). Apart from this, the SIPs are
replaced by their equivalent Linux LMM commands.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
Changes in v2:

* add dependency on CONFIG_IMX_SCMI_LMM_DRV.
* link to v1: https://lore.kernel.org/lkml/20251112144124.680-1-laurentiumihalcea111@gmail.com/

 sound/soc/sof/imx/Kconfig |  1 +
 sound/soc/sof/imx/imx9.c  | 36 ++++++++----------------------------
 2 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/sound/soc/sof/imx/Kconfig b/sound/soc/sof/imx/Kconfig
index 327e2df94a58..09d88ce5b9e6 100644
--- a/sound/soc/sof/imx/Kconfig
+++ b/sound/soc/sof/imx/Kconfig
@@ -35,6 +35,7 @@ config SND_SOC_SOF_IMX8
 config SND_SOC_SOF_IMX9
 	tristate "SOF support for i.MX9"
 	depends on IMX_DSP
+	depends on IMX_SCMI_LMM_DRV
 	select SND_SOC_SOF_IMX_COMMON
 	help
 	  This adds support for Sound Open Firmware for NXP i.MX9 platforms.
diff --git a/sound/soc/sof/imx/imx9.c b/sound/soc/sof/imx/imx9.c
index 853155d5990a..e56e8a1c8022 100644
--- a/sound/soc/sof/imx/imx9.c
+++ b/sound/soc/sof/imx/imx9.c
@@ -3,19 +3,11 @@
  * Copyright 2025 NXP
  */
 
-#include <linux/arm-smccc.h>
+#include <linux/firmware/imx/sm.h>
 
 #include "imx-common.h"
 
-#define IMX_SIP_SRC 0xC2000005
-#define IMX_SIP_SRC_M_RESET_ADDR_SET 0x03
-
-#define IMX95_CPU_VEC_FLAGS_BOOT BIT(29)
-
-#define IMX_SIP_LMM 0xC200000F
-#define IMX_SIP_LMM_BOOT 0x0
-#define IMX_SIP_LMM_SHUTDOWN 0x1
-
+#define IMX95_M7_CPU_ID 0x1
 #define IMX95_M7_LM_ID 0x1
 
 static struct snd_soc_dai_driver imx95_dai[] = {
@@ -38,7 +30,6 @@ static int imx95_ops_init(struct snd_sof_dev *sdev)
 
 static int imx95_chip_probe(struct snd_sof_dev *sdev)
 {
-	struct arm_smccc_res smc_res;
 	struct platform_device *pdev;
 	struct resource *res;
 
@@ -49,31 +40,20 @@ static int imx95_chip_probe(struct snd_sof_dev *sdev)
 		return dev_err_probe(sdev->dev, -ENODEV,
 				     "failed to fetch SRAM region\n");
 
-	/* set core boot reset address */
-	arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M_RESET_ADDR_SET, res->start,
-		      IMX95_CPU_VEC_FLAGS_BOOT, 0, 0, 0, 0, &smc_res);
-
-	return smc_res.a0;
+	return scmi_imx_lmm_reset_vector_set(IMX95_M7_LM_ID, IMX95_M7_CPU_ID,
+					     0, res->start);
 }
 
 static int imx95_core_kick(struct snd_sof_dev *sdev)
 {
-	struct arm_smccc_res smc_res;
-
-	arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_BOOT,
-		      IMX95_M7_LM_ID, 0, 0, 0, 0, 0, &smc_res);
-
-	return smc_res.a0;
+	return scmi_imx_lmm_operation(IMX95_M7_LM_ID, SCMI_IMX_LMM_BOOT, 0);
 }
 
 static int imx95_core_shutdown(struct snd_sof_dev *sdev)
 {
-	struct arm_smccc_res smc_res;
-
-	arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_SHUTDOWN,
-		      IMX95_M7_LM_ID, 0, 0, 0, 0, 0, &smc_res);
-
-	return smc_res.a0;
+	return scmi_imx_lmm_operation(IMX95_M7_LM_ID,
+				      SCMI_IMX_LMM_SHUTDOWN,
+				      SCMI_IMX_LMM_OP_FORCEFUL);
 }
 
 static const struct imx_chip_ops imx95_chip_ops = {
-- 
2.43.0
Re: [PATCH v2] ASoC: SOF: imx9: use SCMI API for LM management
Posted by Mark Brown 2 months, 3 weeks ago
On Fri, 14 Nov 2025 06:35:03 -0800, Laurentiu Mihalcea wrote:
> Linux supports NXP's LMM SCMI protocol so switch to using the appropriate
> API. The SIPs were intended to act as placeholders until the support for
> said protocol was upstreamed.
> 
> The underlying CPU protocol command from IMX_SIP_SRC_M_RESET_ADDR_SET is
> replaced by a LMM protocol command with the same effect (i.e. setting the
> boot address) since using the CPU protocol would require additional
> permissions (which TF-A already had). Apart from this, the SIPs are
> replaced by their equivalent Linux LMM commands.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: SOF: imx9: use SCMI API for LM management
      commit: 94000534e0883b4f4ba9882e4630cfcdf2af539d

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
Re: [PATCH v2] ASoC: SOF: imx9: use SCMI API for LM management
Posted by Iuliana Prodan 2 months, 3 weeks ago
On 11/14/2025 4:35 PM, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> 
> Linux supports NXP's LMM SCMI protocol so switch to using the appropriate
> API. The SIPs were intended to act as placeholders until the support for
> said protocol was upstreamed.
> 
> The underlying CPU protocol command from IMX_SIP_SRC_M_RESET_ADDR_SET is
> replaced by a LMM protocol command with the same effect (i.e. setting the
> boot address) since using the CPU protocol would require additional
> permissions (which TF-A already had). Apart from this, the SIPs are
> replaced by their equivalent Linux LMM commands.
> 
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>

Reviewed-by: Iuliana Prodan <iuliana.prodan@nxp.com>

Thanks,
Iulia

> ---
> Changes in v2:
> 
> * add dependency on CONFIG_IMX_SCMI_LMM_DRV.
> * link to v1: https://lore.kernel.org/lkml/20251112144124.680-1-laurentiumihalcea111@gmail.com/
> 
>   sound/soc/sof/imx/Kconfig |  1 +
>   sound/soc/sof/imx/imx9.c  | 36 ++++++++----------------------------
>   2 files changed, 9 insertions(+), 28 deletions(-)
> 
> diff --git a/sound/soc/sof/imx/Kconfig b/sound/soc/sof/imx/Kconfig
> index 327e2df94a58..09d88ce5b9e6 100644
> --- a/sound/soc/sof/imx/Kconfig
> +++ b/sound/soc/sof/imx/Kconfig
> @@ -35,6 +35,7 @@ config SND_SOC_SOF_IMX8
>   config SND_SOC_SOF_IMX9
>   	tristate "SOF support for i.MX9"
>   	depends on IMX_DSP
> +	depends on IMX_SCMI_LMM_DRV
>   	select SND_SOC_SOF_IMX_COMMON
>   	help
>   	  This adds support for Sound Open Firmware for NXP i.MX9 platforms.
> diff --git a/sound/soc/sof/imx/imx9.c b/sound/soc/sof/imx/imx9.c
> index 853155d5990a..e56e8a1c8022 100644
> --- a/sound/soc/sof/imx/imx9.c
> +++ b/sound/soc/sof/imx/imx9.c
> @@ -3,19 +3,11 @@
>    * Copyright 2025 NXP
>    */
>   
> -#include <linux/arm-smccc.h>
> +#include <linux/firmware/imx/sm.h>
>   
>   #include "imx-common.h"
>   
> -#define IMX_SIP_SRC 0xC2000005
> -#define IMX_SIP_SRC_M_RESET_ADDR_SET 0x03
> -
> -#define IMX95_CPU_VEC_FLAGS_BOOT BIT(29)
> -
> -#define IMX_SIP_LMM 0xC200000F
> -#define IMX_SIP_LMM_BOOT 0x0
> -#define IMX_SIP_LMM_SHUTDOWN 0x1
> -
> +#define IMX95_M7_CPU_ID 0x1
>   #define IMX95_M7_LM_ID 0x1
>   
>   static struct snd_soc_dai_driver imx95_dai[] = {
> @@ -38,7 +30,6 @@ static int imx95_ops_init(struct snd_sof_dev *sdev)
>   
>   static int imx95_chip_probe(struct snd_sof_dev *sdev)
>   {
> -	struct arm_smccc_res smc_res;
>   	struct platform_device *pdev;
>   	struct resource *res;
>   
> @@ -49,31 +40,20 @@ static int imx95_chip_probe(struct snd_sof_dev *sdev)
>   		return dev_err_probe(sdev->dev, -ENODEV,
>   				     "failed to fetch SRAM region\n");
>   
> -	/* set core boot reset address */
> -	arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M_RESET_ADDR_SET, res->start,
> -		      IMX95_CPU_VEC_FLAGS_BOOT, 0, 0, 0, 0, &smc_res);
> -
> -	return smc_res.a0;
> +	return scmi_imx_lmm_reset_vector_set(IMX95_M7_LM_ID, IMX95_M7_CPU_ID,
> +					     0, res->start);
>   }
>   
>   static int imx95_core_kick(struct snd_sof_dev *sdev)
>   {
> -	struct arm_smccc_res smc_res;
> -
> -	arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_BOOT,
> -		      IMX95_M7_LM_ID, 0, 0, 0, 0, 0, &smc_res);
> -
> -	return smc_res.a0;
> +	return scmi_imx_lmm_operation(IMX95_M7_LM_ID, SCMI_IMX_LMM_BOOT, 0);
>   }
>   
>   static int imx95_core_shutdown(struct snd_sof_dev *sdev)
>   {
> -	struct arm_smccc_res smc_res;
> -
> -	arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_SHUTDOWN,
> -		      IMX95_M7_LM_ID, 0, 0, 0, 0, 0, &smc_res);
> -
> -	return smc_res.a0;
> +	return scmi_imx_lmm_operation(IMX95_M7_LM_ID,
> +				      SCMI_IMX_LMM_SHUTDOWN,
> +				      SCMI_IMX_LMM_OP_FORCEFUL);
>   }
>   
>   static const struct imx_chip_ops imx95_chip_ops = {