Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework
@ 2026-11-26 10:25 shengjiu.wang
  2026-11-26 10:33 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: shengjiu.wang @ 2026-11-26 10:25 UTC (permalink / raw)
  To: Liam Girdwood, Peter Ujfalusi, Bard Liao, Daniel Baluta,
	Kai Vehmanen, Pierre-Louis Bossart, Vijendar Mukunda, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
	sound-open-firmware, linux-sound, imx, linux-arm-kernel
  Cc: Shengjiu Wang

From: Shengjiu Wang <shengjiu.wang@nxp.com>

Replace direct syscon regmap accesses for i.MX8ULP DSP reset control
with the standard kernel reset controller framework.

Use named reset controls: runstall to stall and unstall the DSP core,
softreset to reset the DSP core, and dbgreset to control the DSP debug
logic. Remove the direct DSP clock-gate writes; the corresponding
SIM_LPAV clocks are managed through the common SOF clock handling.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
---
Changes in v2:
- Reword the commit message to clarify that the patch adopts the
  standard reset controller abstraction. 
- Remove one comment line in code.
- Add Reviewed-by from Daniel

 sound/soc/sof/imx/imx8.c | 72 +++++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 35 deletions(-)

diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
index 5cd3f44c90d2..80326d2eb1fc 100644
--- a/sound/soc/sof/imx/imx8.c
+++ b/sound/soc/sof/imx/imx8.c
@@ -26,19 +26,18 @@
 
 /* imx8ulp macros */
 #define FSL_SIP_HIFI_XRDC       0xc200000e
-#define SYSCTRL0                0x8
-#define EXECUTE_BIT             BIT(13)
-#define RESET_BIT               BIT(16)
-#define HIFI4_CLK_BIT           BIT(17)
-#define PB_CLK_BIT              BIT(18)
-#define PLAT_CLK_BIT            BIT(19)
-#define DEBUG_LOGIC_BIT         BIT(25)
 
 struct imx8m_chip_data {
 	void __iomem *dap;
 	struct reset_control *run_stall;
 };
 
+struct imx8ulp_chip_data {
+	struct reset_control *run_stall;
+	struct reset_control *soft_rst;
+	struct reset_control *dbg_rst;
+};
+
 static int imx8_shutdown(struct snd_sof_dev *sdev)
 {
 	int ret;
@@ -202,42 +201,31 @@ static int imx8m_probe(struct snd_sof_dev *sdev)
 
 static int imx8ulp_run(struct snd_sof_dev *sdev)
 {
-	struct regmap *regmap = get_chip_pdata(sdev);
+	struct imx8ulp_chip_data *chip = get_chip_pdata(sdev);
 
-	/* Controls the HiFi4 DSP Reset: 1 in reset, 0 out of reset */
-	regmap_update_bits(regmap, SYSCTRL0, RESET_BIT, 0);
+	reset_control_deassert(chip->soft_rst);
 
-	/* Reset HiFi4 DSP Debug logic: 1 debug reset, 0  out of reset*/
-	regmap_update_bits(regmap, SYSCTRL0, DEBUG_LOGIC_BIT, 0);
+	/* Release HiFi4 DSP Debug logic */
+	reset_control_deassert(chip->dbg_rst);
 
-	/* Stall HIFI4 DSP Execution: 1 stall, 0 run */
-	regmap_update_bits(regmap, SYSCTRL0, EXECUTE_BIT, 0);
+	/* Run HIFI4 DSP Execution */
+	reset_control_deassert(chip->run_stall);
 
 	return 0;
 }
 
 static int imx8ulp_reset(struct snd_sof_dev *sdev)
 {
+	struct imx8ulp_chip_data *chip = get_chip_pdata(sdev);
 	struct arm_smccc_res smc_res;
-	struct regmap *regmap;
-
-	regmap = get_chip_pdata(sdev);
-
-	/* HiFi4 Platform Clock Enable: 1 enabled, 0 disabled */
-	regmap_update_bits(regmap, SYSCTRL0, PLAT_CLK_BIT, PLAT_CLK_BIT);
 
-	/* HiFi4 PBCLK clock enable: 1 enabled, 0 disabled */
-	regmap_update_bits(regmap, SYSCTRL0, PB_CLK_BIT, PB_CLK_BIT);
-
-	/* HiFi4 Clock Enable: 1 enabled, 0 disabled */
-	regmap_update_bits(regmap, SYSCTRL0, HIFI4_CLK_BIT, HIFI4_CLK_BIT);
-
-	regmap_update_bits(regmap, SYSCTRL0, RESET_BIT, RESET_BIT);
+	reset_control_assert(chip->soft_rst);
 
 	usleep_range(1, 2);
 
-	/* Stall HIFI4 DSP Execution: 1 stall, 0 not stall */
-	regmap_update_bits(regmap, SYSCTRL0, EXECUTE_BIT, EXECUTE_BIT);
+	/* Stall HIFI4 DSP Execution: */
+	reset_control_assert(chip->run_stall);
+
 	usleep_range(1, 2);
 
 	arm_smccc_smc(FSL_SIP_HIFI_XRDC, 0, 0, 0, 0, 0, 0, 0, &smc_res);
@@ -248,16 +236,30 @@ static int imx8ulp_reset(struct snd_sof_dev *sdev)
 static int imx8ulp_probe(struct snd_sof_dev *sdev)
 {
 	struct imx_common_data *common;
-	struct regmap *regmap;
+	struct imx8ulp_chip_data *chip;
+
+	chip = devm_kzalloc(sdev->dev, sizeof(*chip), GFP_KERNEL);
+	if (!chip)
+		return -ENOMEM;
 
 	common = sdev->pdata->hw_pdata;
 
-	regmap = syscon_regmap_lookup_by_phandle(sdev->dev->of_node, "fsl,dsp-ctrl");
-	if (IS_ERR(regmap))
-		return dev_err_probe(sdev->dev, PTR_ERR(regmap),
-				     "failed to fetch dsp ctrl regmap\n");
+	chip->run_stall = devm_reset_control_get_exclusive(sdev->dev, "runstall");
+	if (IS_ERR(chip->run_stall))
+		return dev_err_probe(sdev->dev, PTR_ERR(chip->run_stall),
+				     "failed to get dsp runstall reset control\n");
+
+	chip->soft_rst = devm_reset_control_get_optional_exclusive(sdev->dev, "softreset");
+	if (IS_ERR(chip->soft_rst))
+		return dev_err_probe(sdev->dev, PTR_ERR(chip->soft_rst),
+				     "failed to get dsp softreset reset control\n");
 
-	common->chip_pdata = regmap;
+	chip->dbg_rst = devm_reset_control_get_optional_exclusive(sdev->dev, "dbgreset");
+	if (IS_ERR(chip->dbg_rst))
+		return dev_err_probe(sdev->dev, PTR_ERR(chip->dbg_rst),
+				     "failed to get dsp dbgreset reset control\n");
+
+	common->chip_pdata = chip;
 
 	return 0;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework
  2026-11-26 10:25 [PATCH v2] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework shengjiu.wang
@ 2026-11-26 10:33 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-26 10:33 UTC (permalink / raw)
  To: shengjiu.wang, linux-sound, imx; +Cc: Frank.Li

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ASoC: SOF: imx8: undocumented dbgreset and optional resets in
  imx8ulp_probe()
--

commit e612ef7d377466215d3164c95469326c85ff2571
Author: Shengjiu Wang <shengjiu.wang@nxp.com>

ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework

This commit replaces direct syscon regmap accesses in the i.MX8ULP SOF
DSP driver with the reset controller framework using named reset controls.

> diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
> index 5cd3f44c90d2b..80326d2eb1fc0 100644
> --- a/sound/soc/sof/imx/imx8.c
> +++ b/sound/soc/sof/imx/imx8.c
[ ... ]
> @@ -202,42 +201,31 @@ static int imx8m_probe(struct snd_sof_dev *sdev)
>  
>  static int imx8ulp_run(struct snd_sof_dev *sdev)
>  {
> -	struct regmap *regmap = get_chip_pdata(sdev);
> +	struct imx8ulp_chip_data *chip = get_chip_pdata(sdev);
>  
> -	/* Controls the HiFi4 DSP Reset: 1 in reset, 0 out of reset */
> -	regmap_update_bits(regmap, SYSCTRL0, RESET_BIT, 0);
> +	reset_control_deassert(chip->soft_rst);
>  
> -	/* Reset HiFi4 DSP Debug logic: 1 debug reset, 0  out of reset*/
> -	regmap_update_bits(regmap, SYSCTRL0, DEBUG_LOGIC_BIT, 0);
> +	/* Release HiFi4 DSP Debug logic */
> +	reset_control_deassert(chip->dbg_rst);
>  
> -	/* Stall HIFI4 DSP Execution: 1 stall, 0 run */
> -	regmap_update_bits(regmap, SYSCTRL0, EXECUTE_BIT, 0);
> +	/* Run HIFI4 DSP Execution */
> +	reset_control_deassert(chip->run_stall);
>  
>  	return 0;
>  }
>  
>  static int imx8ulp_reset(struct snd_sof_dev *sdev)
>  {
> +	struct imx8ulp_chip_data *chip = get_chip_pdata(sdev);
>  	struct arm_smccc_res smc_res;
> -	struct regmap *regmap;
> -
> -	regmap = get_chip_pdata(sdev);
> -
> -	/* HiFi4 Platform Clock Enable: 1 enabled, 0 disabled */
> -	regmap_update_bits(regmap, SYSCTRL0, PLAT_CLK_BIT, PLAT_CLK_BIT);
>  
> -	/* HiFi4 PBCLK clock enable: 1 enabled, 0 disabled */
> -	regmap_update_bits(regmap, SYSCTRL0, PB_CLK_BIT, PB_CLK_BIT);
> -
> -	/* HiFi4 Clock Enable: 1 enabled, 0 disabled */
> -	regmap_update_bits(regmap, SYSCTRL0, HIFI4_CLK_BIT, HIFI4_CLK_BIT);
> -
> -	regmap_update_bits(regmap, SYSCTRL0, RESET_BIT, RESET_BIT);
> +	reset_control_assert(chip->soft_rst);
>  
>  	usleep_range(1, 2);
>  
> -	/* Stall HIFI4 DSP Execution: 1 stall, 0 not stall */
> -	regmap_update_bits(regmap, SYSCTRL0, EXECUTE_BIT, EXECUTE_BIT);
> +	/* Stall HIFI4 DSP Execution: */
> +	reset_control_assert(chip->run_stall);
> +
>  	usleep_range(1, 2);
>  
>  	arm_smccc_smc(FSL_SIP_HIFI_XRDC, 0, 0, 0, 0, 0, 0, 0, &smc_res);
> @@ -248,16 +236,30 @@ static int imx8ulp_reset(struct snd_sof_dev *sdev)
>  static int imx8ulp_probe(struct snd_sof_dev *sdev)
>  {
>  	struct imx_common_data *common;
> -	struct regmap *regmap;
> +	struct imx8ulp_chip_data *chip;
> +
> +	chip = devm_kzalloc(sdev->dev, sizeof(*chip), GFP_KERNEL);
> +	if (!chip)
> +		return -ENOMEM;
>  
>  	common = sdev->pdata->hw_pdata;
>  
> -	regmap = syscon_regmap_lookup_by_phandle(sdev->dev->of_node, "fsl,dsp-ctrl");
> -	if (IS_ERR(regmap))
> -		return dev_err_probe(sdev->dev, PTR_ERR(regmap),
> -				     "failed to fetch dsp ctrl regmap\n");
> +	chip->run_stall = devm_reset_control_get_exclusive(sdev->dev, "runstall");
> +	if (IS_ERR(chip->run_stall))
> +		return dev_err_probe(sdev->dev, PTR_ERR(chip->run_stall),
> +				     "failed to get dsp runstall reset control\n");
> +
> +	chip->soft_rst = devm_reset_control_get_optional_exclusive(sdev->dev, "softreset");
> +	if (IS_ERR(chip->soft_rst))
> +		return dev_err_probe(sdev->dev, PTR_ERR(chip->soft_rst),
> +				     "failed to get dsp softreset reset control\n");
>  
> -	common->chip_pdata = regmap;
> +	chip->dbg_rst = devm_reset_control_get_optional_exclusive(sdev->dev, "dbgreset");
> +	if (IS_ERR(chip->dbg_rst))
> +		return dev_err_probe(sdev->dev, PTR_ERR(chip->dbg_rst),
> +				     "failed to get dsp dbgreset reset control\n");
> +
> +	common->chip_pdata = chip;
>  
>  	return 0;
>  }

[Severity: Medium]
Does requesting "dbgreset" here match the fsl,dsp.yaml Devicetree binding,
and should chip->soft_rst and chip->dbg_rst be optional on i.MX8ULP?

Documentation/devicetree/bindings/dsp/fsl,dsp.yaml only allows "runstall"
and "softreset" in reset-names:

  reset-names:
    minItems: 1
    items:
      - const: runstall
      - const: softreset

A Devicetree conforming to that schema cannot specify "dbgreset" (and may
omit "softreset"), leaving chip->dbg_rst or chip->soft_rst NULL so
reset_control_assert() in imx8ulp_reset() and reset_control_deassert() in
imx8ulp_run() become no-ops instead of toggling the SIM_LPAV SYSCTRL0 DSP
reset and debug reset bits.  In addition, removing the fsl,dsp-ctrl
syscon lookup without a fallback breaks compatibility with existing DTBs
that still use fsl,dsp-ctrl, and leaves the linux/mfd/syscon.h include in
sound/soc/sof/imx/imx8.c unused.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126102528.1531824-1-shengjiu.wang@oss.nxp.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-26 10:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 10:25 [PATCH v2] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework shengjiu.wang
2026-11-26 10:33 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox