Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework
@ 2026-11-25  7:38 shengjiu.wang
  2026-11-25  8:25 ` Philipp Zabel
  2026-11-25 10:13 ` Daniel Baluta
  0 siblings, 2 replies; 4+ messages in thread
From: shengjiu.wang @ 2026-11-25  7:38 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 syscon regmap-based DSP reset control with the kernel reset
controller framework for i.MX8ULP. The syscon approach requires direct
register access and creates tight coupling to the system controller,
while the reset framework provides a cleaner abstraction and proper
reset sequencing.

Three named reset controls are now consumed: runstall to stall/unstall
the DSP core, softreset for DSP core reset, and dbgreset for the debug
logic which is kept deasserted to allow external debug agent access.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/soc/sof/imx/imx8.c | 73 +++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 35 deletions(-)

diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
index 5cd3f44c90d2..6b01b9aa0528 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,32 @@ 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);
+	/* Controls the HiFi4 DSP Reset */
+	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 +237,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] 4+ messages in thread

* Re: [PATCH] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework
  2026-11-25  7:38 [PATCH] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework shengjiu.wang
@ 2026-11-25  8:25 ` Philipp Zabel
  2026-11-25  9:30   ` Shengjiu Wang
  2026-11-25 10:13 ` Daniel Baluta
  1 sibling, 1 reply; 4+ messages in thread
From: Philipp Zabel @ 2026-11-25  8:25 UTC (permalink / raw)
  To: shengjiu.wang, 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,
	sound-open-firmware, linux-sound, imx, linux-arm-kernel
  Cc: Shengjiu Wang

On Mi, 2026-11-25 at 15:38 +0800, shengjiu.wang@oss.nxp.com wrote:
> From: Shengjiu Wang <shengjiu.wang@nxp.com>
> 
> Replace syscon regmap-based DSP reset control with the kernel reset
> controller framework for i.MX8ULP. The syscon approach requires direct
> register access and creates tight coupling to the system controller,
> while the reset framework provides a cleaner abstraction and proper
> reset sequencing.

What do you mean by the reset framework providing reset sequencing in
this context?

regards
Philipp


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

* Re: [PATCH] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework
  2026-11-25  8:25 ` Philipp Zabel
@ 2026-11-25  9:30   ` Shengjiu Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Shengjiu Wang @ 2026-11-25  9:30 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: shengjiu.wang, 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,
	sound-open-firmware, linux-sound, imx, linux-arm-kernel,
	Shengjiu Wang

On Wed, Nov 25, 2026 at 4:26 PM Philipp Zabel <p.zabel@pengutronix.de> wrote:
>
> On Mi, 2026-11-25 at 15:38 +0800, shengjiu.wang@oss.nxp.com wrote:
> > From: Shengjiu Wang <shengjiu.wang@nxp.com>
> >
> > Replace syscon regmap-based DSP reset control with the kernel reset
> > controller framework for i.MX8ULP. The syscon approach requires direct
> > register access and creates tight coupling to the system controller,
> > while the reset framework provides a cleaner abstraction and proper
> > reset sequencing.
>
> What do you mean by the reset framework providing reset sequencing in
> this context?

It is to use the reset_control_deassert() and reset_control_assert()
these functions.
'reset sequencing' is not accurate here, this commit doesn't touch the
requencing
Should remove these words.


Best regards
Shengjiu Wang


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

* Re: [PATCH] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework
  2026-11-25  7:38 [PATCH] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework shengjiu.wang
  2026-11-25  8:25 ` Philipp Zabel
@ 2026-11-25 10:13 ` Daniel Baluta
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Baluta @ 2026-11-25 10:13 UTC (permalink / raw)
  To: shengjiu.wang, 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

On 11/25/26 09:38, shengjiu.wang@oss.nxp.com wrote:
> From: Shengjiu Wang <shengjiu.wang@nxp.com>
> 
> Replace syscon regmap-based DSP reset control with the kernel reset
> controller framework for i.MX8ULP. The syscon approach requires direct
> register access and creates tight coupling to the system controller,
> while the reset framework provides a cleaner abstraction and proper
> reset sequencing.
> 
> Three named reset controls are now consumed: runstall to stall/unstall
> the DSP core, softreset for DSP core reset, and dbgreset for the debug
> logic which is kept deasserted to allow external debug agent access.


As Philipp pointed the wording here is a little bit unfortunate. The reset
sequence is already correct what this patch does uses a cleaner and standard
reset abstraction.

[...]

>  static int imx8_shutdown(struct snd_sof_dev *sdev)
>  {
>  	int ret;
> @@ -202,42 +201,32 @@ 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);
> +	/* Controls the HiFi4 DSP Reset */

I would remove this comment above, as it is obvious from the function name what
is the action taken. 

> +	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 */

this comment can stay. 

> +	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 */


With that said, 

Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>



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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  7:38 [PATCH] ASoC: SOF: imx8: Switch imx8ulp DSP control to reset framework shengjiu.wang
2026-11-25  8:25 ` Philipp Zabel
2026-11-25  9:30   ` Shengjiu Wang
2026-11-25 10:13 ` Daniel Baluta

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