Devicetree
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support
@ 2026-05-26  5:38 Chancel Liu
  2026-05-26  5:38 ` [PATCH 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Chancel Liu @ 2026-05-26  5:38 UTC (permalink / raw)
  To: broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, perex, tiwai,
	Frank.Li, s.hauer, linux-sound, devicetree, linux-arm-kernel, imx,
	linux-kernel

This series adds two features to the i.MX RPMSG ASoC card:
1. Headphone jack detection via GPIO: Introduce the "hp-det-gpios"
   device tree property and use simple_util_init_jack() to
   register a headphone jack with GPIO-based insertion detection.

2. driver_name assignment: Set driver_name on the snd_soc_card to
   "imx-audio-rpmsg", enabling userspace tools such as UCM to reliably
   identify the card by driver name regardless of the board-specific
   card name.

Chancel Liu (3):
  ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property
  ASoC: imx-rpmsg: Support headphone jack detection
  ASoC: imx-rpmsg: Set driver_name for snd_soc_card

 Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml | 4 ++++
 sound/soc/fsl/imx-rpmsg.c                              | 9 +++++++++
 2 files changed, 13 insertions(+)

--
2.50.1


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

* [PATCH 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property
  2026-05-26  5:38 [PATCH 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
@ 2026-05-26  5:38 ` Chancel Liu
  2026-05-26  5:38 ` [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Chancel Liu @ 2026-05-26  5:38 UTC (permalink / raw)
  To: broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, perex, tiwai,
	Frank.Li, s.hauer, linux-sound, devicetree, linux-arm-kernel, imx,
	linux-kernel

Sound cards using the i.MX RPMSG audio interface may connect a
headphone jack with GPIO-based insertion detection. Add the
"hp-det-gpios" property to the fsl,rpmsg binding to support this
configuration.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
index 3a32f7517d0c..e3cadb93c183 100644
--- a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
+++ b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
@@ -98,6 +98,10 @@ properties:
       - rpmsg-audio-channel
       - rpmsg-micfil-channel
 
+  hp-det-gpios:
+    maxItems: 1
+    description: The GPIO that detect headphones are plugged in
+
 required:
   - compatible
 
-- 
2.50.1


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

* [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection
  2026-05-26  5:38 [PATCH 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
  2026-05-26  5:38 ` [PATCH 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
@ 2026-05-26  5:38 ` Chancel Liu
  2026-05-26  6:31   ` sashiko-bot
  2026-05-26 15:34   ` Mark Brown
  2026-05-26  5:38 ` [PATCH 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card Chancel Liu
  2026-05-28  2:07 ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
  3 siblings, 2 replies; 14+ messages in thread
From: Chancel Liu @ 2026-05-26  5:38 UTC (permalink / raw)
  To: broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, perex, tiwai,
	Frank.Li, s.hauer, linux-sound, devicetree, linux-arm-kernel, imx,
	linux-kernel

Add headphone jack detection support for i.MX RPMSG audio cards.
When the "hp-det-gpios" property is present in the device tree node,
use simple_util_init_jack() from the ASoC simple card utilities to
register a headphone jack with GPIO-based insertion detection.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/fsl/imx-rpmsg.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index fd4624786b62..e93ca31e75da 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -12,6 +12,7 @@
 #include <sound/control.h>
 #include <sound/pcm_params.h>
 #include <sound/soc-dapm.h>
+#include <sound/simple_card_utils.h>
 #include "imx-pcm-rpmsg.h"
 
 struct imx_rpmsg {
@@ -19,6 +20,7 @@ struct imx_rpmsg {
 	struct snd_soc_card card;
 	unsigned long sysclk;
 	bool lpa;
+	struct simple_util_jack hp_jack;
 };
 
 static struct dev_pm_ops lpa_pm;
@@ -274,6 +276,12 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
 		goto fail;
 	}
 
+	if (of_property_present(np, "hp-det-gpios")) {
+		ret = simple_util_init_jack(&data->card, &data->hp_jack,
+					    1, NULL, "Headphone Jack");
+		if (ret)
+			goto fail;
+	}
 fail:
 	pdev->dev.of_node = NULL;
 	return ret;
-- 
2.50.1


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

* [PATCH 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card
  2026-05-26  5:38 [PATCH 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
  2026-05-26  5:38 ` [PATCH 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
  2026-05-26  5:38 ` [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
@ 2026-05-26  5:38 ` Chancel Liu
  2026-05-28  2:07 ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
  3 siblings, 0 replies; 14+ messages in thread
From: Chancel Liu @ 2026-05-26  5:38 UTC (permalink / raw)
  To: broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, perex, tiwai,
	Frank.Li, s.hauer, linux-sound, devicetree, linux-arm-kernel, imx,
	linux-kernel

Set driver_name to "imx-audio-rpmsg" for the i.MX RPMSG sound card.
This allows userspace audio configuration tools (e.g., UCM) to match
the card by driver name independently of the card name, which may vary
across board configurations.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/fsl/imx-rpmsg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index e93ca31e75da..14adf55d9cb1 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -241,6 +241,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
 	data->card.dapm_widgets = imx_rpmsg_dapm_widgets;
 	data->card.num_dapm_widgets = ARRAY_SIZE(imx_rpmsg_dapm_widgets);
 	data->card.late_probe = imx_rpmsg_late_probe;
+	data->card.driver_name = "imx-audio-rpmsg";
 	/*
 	 * Inoder to use common api to get card name and audio routing.
 	 * Use parent of_node for this device, revert it after finishing using
-- 
2.50.1


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

* Re: [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection
  2026-05-26  5:38 ` [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
@ 2026-05-26  6:31   ` sashiko-bot
  2026-05-26 15:34   ` Mark Brown
  1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-05-26  6:31 UTC (permalink / raw)
  To: Chancel Liu; +Cc: robh, imx, Frank.Li, conor+dt, devicetree

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Headphone jack is initialized after the sound card is fully registered, causing multiple fatal issues including broken jack registration, kernel bugs, and TOCTOU races with userspace.
- [Medium] The patch uses `simple_util_init_jack()` but fails to select its Kconfig dependency, leading to linker errors.
--

commit 23df7e137d741b3d9989cc72e4eb7cee017f18a1
Author: Chancel Liu <chancel.liu@nxp.com>

ASoC: imx-rpmsg: Support headphone jack detection

This commit adds headphone jack detection support for i.MX RPMSG audio cards.
It uses simple_util_init_jack() to register a headphone jack with GPIO-based
insertion detection when the hp-det-gpios property is present.

> diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
> index 40e0043cfe15e..9c1cf7045381a 100644
> --- a/sound/soc/fsl/imx-rpmsg.c
> +++ b/sound/soc/fsl/imx-rpmsg.c
> @@ -12,6 +12,7 @@
>  #include <sound/control.h>
>  #include <sound/pcm_params.h>
>  #include <sound/soc-dapm.h>
> +#include <sound/simple_card_utils.h>

[Severity: Medium]
Is it possible to hit a linker error here if no other driver selects the
simple card utilities?

This patch uses simple_util_init_jack(), but doesn't appear to update the
Kconfig entry for SND_SOC_IMX_RPMSG to select SND_SIMPLE_CARD_UTILS. If
this driver is built in a configuration where no other selected options
pull in the simple card utilities, it might result in an undefined
reference error.

[ ... ]

> @@ -282,6 +284,12 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
>  		goto fail;
>  	}
>  
> +	if (of_property_present(np, "hp-det-gpios")) {
> +		ret = simple_util_init_jack(&data->card, &data->hp_jack,
> +					    1, NULL, "Headphone Jack");

[Severity: High]
Does initializing the headphone jack after devm_snd_soc_register_card() cause
issues with probe deferral?

If devm_snd_soc_register_card() defers due to a missing component, it queues
the card onto the unbind_card_list and returns 0. The driver then proceeds to
call simple_util_init_jack().

At this point, the snd_card pointer is NULL, which triggers a
snd_BUG_ON(!card) in snd_device_new() and returns -ENXIO. This return
value aborts the probe and breaks probe deferral completely.

Additionally, if the card registers synchronously, snd_card_register() is
called before the jack is initialized. Any ALSA devices added after
registration remain in the SNDRV_DEV_BUILD state and are not exposed to
userspace.

This order also creates a window where userspace daemons might probe the
sound card before the jack is created.

Could this jack initialization be moved to the card's late_probe callback
instead?

> +		if (ret)
> +			goto fail;
> +	}
>  fail:
>  	pdev->dev.of_node = NULL;
>  	return ret;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260526053815.140008-1-chancel.liu@nxp.com?part=2

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

* Re: [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection
  2026-05-26  5:38 ` [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
  2026-05-26  6:31   ` sashiko-bot
@ 2026-05-26 15:34   ` Mark Brown
  2026-05-27  3:05     ` Chancel Liu (OSS)
  1 sibling, 1 reply; 14+ messages in thread
From: Mark Brown @ 2026-05-26 15:34 UTC (permalink / raw)
  To: Chancel Liu
  Cc: lgirdwood, robh, krzk+dt, conor+dt, shengjiu.wang, Xiubo.Lee,
	festevam, nicoleotsuka, perex, tiwai, Frank.Li, s.hauer,
	linux-sound, devicetree, linux-arm-kernel, imx, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 846 bytes --]

On Tue, May 26, 2026 at 02:38:14PM +0900, Chancel Liu wrote:
> Add headphone jack detection support for i.MX RPMSG audio cards.
> When the "hp-det-gpios" property is present in the device tree node,
> use simple_util_init_jack() from the ASoC simple card utilities to
> register a headphone jack with GPIO-based insertion detection.

> +#include <sound/simple_card_utils.h>

We need to ensure that SND_SIMPLE_CARD_UTILS is selected.

> +	if (of_property_present(np, "hp-det-gpios")) {
> +		ret = simple_util_init_jack(&data->card, &data->hp_jack,
> +					    1, NULL, "Headphone Jack");
> +		if (ret)
> +			goto fail;
> +	}
>  fail:

The interaction with deferred probe is a bit fun here, we're doing this
after registering the card which might defer via unbind_card_list now.
late_probe() might be safer, everything should be mostly up by then.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* RE: [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection
  2026-05-26 15:34   ` Mark Brown
@ 2026-05-27  3:05     ` Chancel Liu (OSS)
  0 siblings, 0 replies; 14+ messages in thread
From: Chancel Liu (OSS) @ 2026-05-27  3:05 UTC (permalink / raw)
  To: Mark Brown, Chancel Liu
  Cc: lgirdwood@gmail.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com,
	festevam@gmail.com, nicoleotsuka@gmail.com, perex@perex.cz,
	tiwai@suse.com, Frank Li, s.hauer@pengutronix.de,
	linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
	linux-kernel@vger.kernel.org

> > Add headphone jack detection support for i.MX RPMSG audio cards.
> > When the "hp-det-gpios" property is present in the device tree node,
> > use simple_util_init_jack() from the ASoC simple card utilities to
> > register a headphone jack with GPIO-based insertion detection.
> 
> > +#include <sound/simple_card_utils.h>
> 
> We need to ensure that SND_SIMPLE_CARD_UTILS is selected.
> 

Yes. I will update the Kconfig to ensure this dependency.

> > +	if (of_property_present(np, "hp-det-gpios")) {
> > +		ret = simple_util_init_jack(&data->card, &data->hp_jack,
> > +					    1, NULL, "Headphone Jack");
> > +		if (ret)
> > +			goto fail;
> > +	}
> >  fail:
> 
> The interaction with deferred probe is a bit fun here, we're doing this
> after registering the card which might defer via unbind_card_list now.
> late_probe() might be safer, everything should be mostly up by then.

Agreed. Deferred probe was not considered here. I will move jack setup to
late_probe().

Regards, 
Chancel Liu

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

* [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support
  2026-05-26  5:38 [PATCH 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
                   ` (2 preceding siblings ...)
  2026-05-26  5:38 ` [PATCH 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card Chancel Liu
@ 2026-05-28  2:07 ` Chancel Liu
  2026-05-28  2:07   ` [PATCH v2 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
                     ` (3 more replies)
  3 siblings, 4 replies; 14+ messages in thread
From: Chancel Liu @ 2026-05-28  2:07 UTC (permalink / raw)
  To: broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: shengjiu.wang, shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka,
	perex, tiwai, Frank.Li, s.hauer, linux-sound, devicetree,
	linux-arm-kernel, imx, linux-kernel

This series adds two features to the i.MX RPMSG ASoC card:
1. Headphone jack detection via GPIO: Introduce the "hp-det-gpios"
   device tree property and use simple_util_init_jack() to
   register a headphone jack with GPIO-based insertion detection.

2. driver_name assignment: Set driver_name on the snd_soc_card to
   "imx-audio-rpmsg", enabling userspace tools such as UCM to reliably
   identify the card by driver name regardless of the board-specific
   card name.

Changes in v2:
- Add Kconfig dependency on SND_SOC_SIMPLE_CARD_UTILS
- Moved headphone jack initialization from probe() to late_probe()
to avoid interaction issues with deferred probe

Chancel Liu (3):
  ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property
  ASoC: imx-rpmsg: Support headphone jack detection
  ASoC: imx-rpmsg: Set driver_name for snd_soc_card

 .../devicetree/bindings/sound/fsl,rpmsg.yaml         |  4 ++++
 sound/soc/fsl/Kconfig                                |  1 +
 sound/soc/fsl/imx-rpmsg.c                            | 12 ++++++++++++
 3 files changed, 17 insertions(+)

--
2.50.1


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

* [PATCH v2 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property
  2026-05-28  2:07 ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
@ 2026-05-28  2:07   ` Chancel Liu
  2026-05-28  2:07   ` [PATCH v2 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Chancel Liu @ 2026-05-28  2:07 UTC (permalink / raw)
  To: broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: shengjiu.wang, shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka,
	perex, tiwai, Frank.Li, s.hauer, linux-sound, devicetree,
	linux-arm-kernel, imx, linux-kernel

Sound cards using the i.MX RPMSG audio interface may connect a
headphone jack with GPIO-based insertion detection. Add the
"hp-det-gpios" property to the fsl,rpmsg binding to support this
configuration.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
index 3a32f7517d0c..e3cadb93c183 100644
--- a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
+++ b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
@@ -98,6 +98,10 @@ properties:
       - rpmsg-audio-channel
       - rpmsg-micfil-channel
 
+  hp-det-gpios:
+    maxItems: 1
+    description: The GPIO that detect headphones are plugged in
+
 required:
   - compatible
 
-- 
2.50.1


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

* [PATCH v2 2/3] ASoC: imx-rpmsg: Support headphone jack detection
  2026-05-28  2:07 ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
  2026-05-28  2:07   ` [PATCH v2 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
@ 2026-05-28  2:07   ` Chancel Liu
  2026-05-28  3:01     ` sashiko-bot
  2026-05-28  2:07   ` [PATCH v2 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card Chancel Liu
  2026-05-28 14:12   ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Andrew Lunn
  3 siblings, 1 reply; 14+ messages in thread
From: Chancel Liu @ 2026-05-28  2:07 UTC (permalink / raw)
  To: broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: shengjiu.wang, shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka,
	perex, tiwai, Frank.Li, s.hauer, linux-sound, devicetree,
	linux-arm-kernel, imx, linux-kernel

Add headphone jack detection support for i.MX RPMSG audio cards.
When the "hp-det-gpios" property is present in the device tree node,
use simple_util_init_jack() from the ASoC simple card utilities to
register a headphone jack with GPIO-based insertion detection.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/fsl/Kconfig     |  1 +
 sound/soc/fsl/imx-rpmsg.c | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index ae8774e11873..8ae59c094878 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -358,6 +358,7 @@ config SND_SOC_IMX_RPMSG
 	depends on OF && I2C
 	select SND_SOC_IMX_PCM_RPMSG
 	select SND_SOC_IMX_AUDIO_RPMSG
+	select SND_SIMPLE_CARD_UTILS
 	help
 	  SoC Audio support for i.MX boards with rpmsg.
 	  There should be rpmsg devices defined in other core (M core)
diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index fd4624786b62..48fe471499ba 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -12,6 +12,7 @@
 #include <sound/control.h>
 #include <sound/pcm_params.h>
 #include <sound/soc-dapm.h>
+#include <sound/simple_card_utils.h>
 #include "imx-pcm-rpmsg.h"
 
 struct imx_rpmsg {
@@ -19,6 +20,7 @@ struct imx_rpmsg {
 	struct snd_soc_card card;
 	unsigned long sysclk;
 	bool lpa;
+	struct simple_util_jack hp_jack;
 };
 
 static struct dev_pm_ops lpa_pm;
@@ -86,6 +88,15 @@ static int imx_rpmsg_late_probe(struct snd_soc_card *card)
 	struct device *dev = card->dev;
 	int ret;
 
+	if (of_property_present(card->dev->of_node, "hp-det-gpios")) {
+		ret = simple_util_init_jack(card, &data->hp_jack,
+					    1, NULL, "Headphone Jack");
+		if (ret) {
+			dev_err(dev, "failed to init hp jack\n");
+			return ret;
+		}
+	}
+
 	if (data->lpa) {
 		struct device_node *codec_np;
 		struct device_driver *codec_drv;
-- 
2.50.1


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

* [PATCH v2 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card
  2026-05-28  2:07 ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
  2026-05-28  2:07   ` [PATCH v2 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
  2026-05-28  2:07   ` [PATCH v2 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
@ 2026-05-28  2:07   ` Chancel Liu
  2026-05-28 14:12   ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Andrew Lunn
  3 siblings, 0 replies; 14+ messages in thread
From: Chancel Liu @ 2026-05-28  2:07 UTC (permalink / raw)
  To: broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: shengjiu.wang, shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka,
	perex, tiwai, Frank.Li, s.hauer, linux-sound, devicetree,
	linux-arm-kernel, imx, linux-kernel

Set driver_name to "imx-audio-rpmsg" for the i.MX RPMSG sound card.
This allows userspace audio configuration tools (e.g., UCM) to match
the card by driver name independently of the card name, which may vary
across board configurations.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/fsl/imx-rpmsg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index 48fe471499ba..5f1af258caf2 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -250,6 +250,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
 	data->card.dapm_widgets = imx_rpmsg_dapm_widgets;
 	data->card.num_dapm_widgets = ARRAY_SIZE(imx_rpmsg_dapm_widgets);
 	data->card.late_probe = imx_rpmsg_late_probe;
+	data->card.driver_name = "imx-audio-rpmsg";
 	/*
 	 * Inoder to use common api to get card name and audio routing.
 	 * Use parent of_node for this device, revert it after finishing using
-- 
2.50.1


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

* Re: [PATCH v2 2/3] ASoC: imx-rpmsg: Support headphone jack detection
  2026-05-28  2:07   ` [PATCH v2 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
@ 2026-05-28  3:01     ` sashiko-bot
  0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-05-28  3:01 UTC (permalink / raw)
  To: Chancel Liu; +Cc: Frank.Li, imx, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [High] Headphone jack initialization silently fails on deferred ASoC component binding due to a cleared of_node.
- [Low] Redundant property check prevents fallback to singular '-gpio' binding.

Pre-existing issues:
- [High] Global state corruption by modifying a shared `device_driver`'s PM operations.
--

commit 67115545a4cc25e24605dd54dbe245a56360b94c
Author: Chancel Liu <chancel.liu@nxp.com>

ASoC: imx-rpmsg: Support headphone jack detection

This patch adds headphone jack detection support for i.MX RPMSG audio cards.
It uses simple_util_init_jack() to register a headphone jack with GPIO-based
insertion detection when the "hp-det-gpios" property is present.

[ ... ]

> diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
> index fd4624786b627..48fe471499bac 100644
> --- a/sound/soc/fsl/imx-rpmsg.c
> +++ b/sound/soc/fsl/imx-rpmsg.c

[ ... ]

> @@ -86,6 +88,15 @@ static int imx_rpmsg_late_probe(struct snd_soc_card *card)
>  	struct device *dev = card->dev;
>  	int ret;
>  
> +	if (of_property_present(card->dev->of_node, "hp-det-gpios")) {

[Severity: Low]
Is this of_property_present() check necessary?

Since simple_util_init_jack() calls gpiod_get_optional(), it already safely
returns 0 without side effects if no GPIO is found. By explicitly checking
for "hp-det-gpios", this prevents initialization if the device tree uses the
singular "hp-det-gpio" property instead, breaking standard gpiolib fallback
semantics.

[Severity: High]
Does this headphone jack initialization fail if ASoC component binding is
deferred?

During probe, the platform device's of_node is temporarily set to the CPU
DAI's of_node. When devm_snd_soc_register_card() is called, if a component
is missing, the ASoC core queues the card for deferred binding. The probe
function then falls through to the failure path and clears pdev->dev.of_node
to NULL.

Later, when the missing component appears and imx_rpmsg_late_probe() is
executed asynchronously, card->dev->of_node will be NULL. Consequently,
this of_property_present() check evaluates to false, and the initialization
is silently skipped.

> +		ret = simple_util_init_jack(card, &data->hp_jack,
> +					    1, NULL, "Headphone Jack");
> +		if (ret) {
> +			dev_err(dev, "failed to init hp jack\n");
> +			return ret;
> +		}
> +	}
> +
>  	if (data->lpa) {
>  		struct device_node *codec_np;
>  		struct device_driver *codec_drv;
>  		struct device *codec_dev = NULL;

[ ... ]

>  		if (codec_dev) {
>  			codec_drv = codec_dev->driver;
>  			if (codec_drv->pm) {
>  				memcpy(&lpa_pm, codec_drv->pm, sizeof(lpa_pm));
>  				lpa_pm.suspend = NULL;
>  				lpa_pm.resume = NULL;
>  				lpa_pm.freeze = NULL;
>  				lpa_pm.thaw = NULL;
>  				lpa_pm.poweroff = NULL;
>  				lpa_pm.restore = NULL;
>  				codec_drv->pm = &lpa_pm;

[Severity: High]
This is a pre-existing issue, but does overwriting codec_drv->pm corrupt the
power management operations for all instances of the codec?

The struct device_driver is a shared global structure registered by the codec
module. By modifying its pm pointer to point to the static global lpa_pm, it
corrupts the power management operations for all instances of that codec across
the entire system.

Furthermore, using a single global lpa_pm structure could cause race conditions
if multiple i.MX RPMSG cards are probed concurrently.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260528020725.2265321-1-chancel.liu@nxp.com?part=2

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

* Re: [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support
  2026-05-28  2:07 ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
                     ` (2 preceding siblings ...)
  2026-05-28  2:07   ` [PATCH v2 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card Chancel Liu
@ 2026-05-28 14:12   ` Andrew Lunn
  2026-05-28 14:18     ` Mark Brown
  3 siblings, 1 reply; 14+ messages in thread
From: Andrew Lunn @ 2026-05-28 14:12 UTC (permalink / raw)
  To: Chancel Liu
  Cc: broonie, lgirdwood, robh, krzk+dt, conor+dt, shengjiu.wang,
	shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, perex, tiwai,
	Frank.Li, s.hauer, linux-sound, devicetree, linux-arm-kernel, imx,
	linux-kernel

On Thu, May 28, 2026 at 11:07:22AM +0900, Chancel Liu wrote:
> This series adds two features to the i.MX RPMSG ASoC card:
> 1. Headphone jack detection via GPIO: Introduce the "hp-det-gpios"
>    device tree property and use simple_util_init_jack() to
>    register a headphone jack with GPIO-based insertion detection.

I'm not familiar with ASoC, but have been in a long discussion about
RPMSG and GPIO....

I just want to confirm the GPIO you are talking about is a local GPIO?
You are not tunnelling the GPIO over RPMSG using some vendor protocol?

	Andrew

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

* Re: [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support
  2026-05-28 14:12   ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Andrew Lunn
@ 2026-05-28 14:18     ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2026-05-28 14:18 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Chancel Liu, lgirdwood, robh, krzk+dt, conor+dt, shengjiu.wang,
	shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, perex, tiwai,
	Frank.Li, s.hauer, linux-sound, devicetree, linux-arm-kernel, imx,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 727 bytes --]

On Thu, May 28, 2026 at 04:12:58PM +0200, Andrew Lunn wrote:
> On Thu, May 28, 2026 at 11:07:22AM +0900, Chancel Liu wrote:

> > This series adds two features to the i.MX RPMSG ASoC card:
> > 1. Headphone jack detection via GPIO: Introduce the "hp-det-gpios"
> >    device tree property and use simple_util_init_jack() to
> >    register a headphone jack with GPIO-based insertion detection.

> I'm not familiar with ASoC, but have been in a long discussion about
> RPMSG and GPIO....

> I just want to confirm the GPIO you are talking about is a local GPIO?
> You are not tunnelling the GPIO over RPMSG using some vendor protocol?

This is a GPIO accessed via gpiolib, the driver is for an audio
subsystem accessed via rpmsg.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2026-05-28 14:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26  5:38 [PATCH 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
2026-05-26  5:38 ` [PATCH 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
2026-05-26  5:38 ` [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
2026-05-26  6:31   ` sashiko-bot
2026-05-26 15:34   ` Mark Brown
2026-05-27  3:05     ` Chancel Liu (OSS)
2026-05-26  5:38 ` [PATCH 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card Chancel Liu
2026-05-28  2:07 ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
2026-05-28  2:07   ` [PATCH v2 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
2026-05-28  2:07   ` [PATCH v2 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
2026-05-28  3:01     ` sashiko-bot
2026-05-28  2:07   ` [PATCH v2 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card Chancel Liu
2026-05-28 14:12   ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Andrew Lunn
2026-05-28 14:18     ` Mark Brown

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