* [PATCH v2 1/5] arch: arm: dts: cpcap-mapphone: Set VAUDIO regulator always-on
2025-01-22 16:41 [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection Ivaylo Dimitrov
@ 2025-01-22 16:41 ` Ivaylo Dimitrov
2026-05-06 10:59 ` Ivaylo Dimitrov
2025-01-22 16:41 ` [PATCH v2 2/5] ASoC: cpcap: Implement .set_bias_level Ivaylo Dimitrov
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Ivaylo Dimitrov @ 2025-01-22 16:41 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Javier Carrasco
Cc: devicetree, linux-kernel, linux-omap, linux-sound,
Ivaylo Dimitrov
VAUDIO regulator is used by cpcap codec and currently is enabled/disabled
by dapm logic, however, when regulator is turned off, various cpcap
functions (like jack detection) do not work.
Configure VAUDIO regulator-allowed-modes property while at it to enable
low-power regulator mode being set.
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi b/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
index ea02fd403a9b..83fd58157579 100644
--- a/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
+++ b/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
@@ -267,6 +267,8 @@ vaudio: VAUDIO {
regulator-min-microvolt = <2775000>;
regulator-max-microvolt = <2775000>;
regulator-enable-ramp-delay = <1000>;
- regulator-initial-mode = <0x00>; /* NORMAL */
+ regulator-allowed-modes = <0x00>, <0x40>; /* ON, LOW_PWR */
+ regulator-initial-mode = <0x00>; /* ON */
+ regulator-always-on;
};
};
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v2 1/5] arch: arm: dts: cpcap-mapphone: Set VAUDIO regulator always-on
2025-01-22 16:41 ` [PATCH v2 1/5] arch: arm: dts: cpcap-mapphone: Set VAUDIO regulator always-on Ivaylo Dimitrov
@ 2026-05-06 10:59 ` Ivaylo Dimitrov
0 siblings, 0 replies; 14+ messages in thread
From: Ivaylo Dimitrov @ 2026-05-06 10:59 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Javier Carrasco
Cc: devicetree, linux-kernel, linux-omap, linux-sound
Hi,
It looks like this patch from the series may have been missed. Could you
please take another look and consider merging it?
Thanks!
On 22.01.25 г. 18:41 ч., Ivaylo Dimitrov wrote:
> VAUDIO regulator is used by cpcap codec and currently is enabled/disabled
> by dapm logic, however, when regulator is turned off, various cpcap
> functions (like jack detection) do not work.
>
> Configure VAUDIO regulator-allowed-modes property while at it to enable
> low-power regulator mode being set.
>
> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> ---
> arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi b/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
> index ea02fd403a9b..83fd58157579 100644
> --- a/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
> +++ b/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
> @@ -267,6 +267,8 @@ vaudio: VAUDIO {
> regulator-min-microvolt = <2775000>;
> regulator-max-microvolt = <2775000>;
> regulator-enable-ramp-delay = <1000>;
> - regulator-initial-mode = <0x00>; /* NORMAL */
> + regulator-allowed-modes = <0x00>, <0x40>; /* ON, LOW_PWR */
> + regulator-initial-mode = <0x00>; /* ON */
> + regulator-always-on;
> };
> };
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 2/5] ASoC: cpcap: Implement .set_bias_level
2025-01-22 16:41 [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection Ivaylo Dimitrov
2025-01-22 16:41 ` [PATCH v2 1/5] arch: arm: dts: cpcap-mapphone: Set VAUDIO regulator always-on Ivaylo Dimitrov
@ 2025-01-22 16:41 ` Ivaylo Dimitrov
2025-01-22 16:41 ` [PATCH v2 3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts Ivaylo Dimitrov
` (4 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Ivaylo Dimitrov @ 2025-01-22 16:41 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Javier Carrasco
Cc: devicetree, linux-kernel, linux-omap, linux-sound,
Ivaylo Dimitrov
With VAUDIO regulator being always on, we have to put it in low-power mode
when codec is not in use to decrease power usage.
Do so by implementing driver .set_bias_level callback.
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
sound/soc/codecs/cpcap.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c
index 04304a7ad915..53f549ede6a6 100644
--- a/sound/soc/codecs/cpcap.c
+++ b/sound/soc/codecs/cpcap.c
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
#include <linux/mfd/motorola-cpcap.h>
#include <sound/core.h>
#include <sound/soc.h>
@@ -260,6 +261,7 @@ struct cpcap_audio {
int codec_clk_id;
int codec_freq;
int codec_format;
+ struct regulator *vaudio;
};
static int cpcap_st_workaround(struct snd_soc_dapm_widget *w,
@@ -1637,6 +1639,11 @@ static int cpcap_soc_probe(struct snd_soc_component *component)
snd_soc_component_set_drvdata(component, cpcap);
cpcap->component = component;
+ cpcap->vaudio = devm_regulator_get(component->dev, "VAUDIO");
+ if (IS_ERR(cpcap->vaudio))
+ return dev_err_probe(component->dev, PTR_ERR(cpcap->vaudio),
+ "Cannot get VAUDIO regulator\n");
+
cpcap->regmap = dev_get_regmap(component->dev->parent, NULL);
if (!cpcap->regmap)
return -ENODEV;
@@ -1649,6 +1656,27 @@ static int cpcap_soc_probe(struct snd_soc_component *component)
return cpcap_audio_reset(component, false);
}
+static int cpcap_set_bias_level(struct snd_soc_component *component,
+ enum snd_soc_bias_level level)
+{
+ struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component);
+
+ switch (level) {
+ case SND_SOC_BIAS_OFF:
+ break;
+ case SND_SOC_BIAS_PREPARE:
+ regulator_set_mode(cpcap->vaudio, REGULATOR_MODE_NORMAL);
+ break;
+ case SND_SOC_BIAS_STANDBY:
+ regulator_set_mode(cpcap->vaudio, REGULATOR_MODE_STANDBY);
+ break;
+ case SND_SOC_BIAS_ON:
+ break;
+ }
+
+ return 0;
+}
+
static const struct snd_soc_component_driver soc_codec_dev_cpcap = {
.probe = cpcap_soc_probe,
.controls = cpcap_snd_controls,
@@ -1657,6 +1685,7 @@ static const struct snd_soc_component_driver soc_codec_dev_cpcap = {
.num_dapm_widgets = ARRAY_SIZE(cpcap_dapm_widgets),
.dapm_routes = intercon,
.num_dapm_routes = ARRAY_SIZE(intercon),
+ .set_bias_level = cpcap_set_bias_level,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v2 3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts
2025-01-22 16:41 [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection Ivaylo Dimitrov
2025-01-22 16:41 ` [PATCH v2 1/5] arch: arm: dts: cpcap-mapphone: Set VAUDIO regulator always-on Ivaylo Dimitrov
2025-01-22 16:41 ` [PATCH v2 2/5] ASoC: cpcap: Implement .set_bias_level Ivaylo Dimitrov
@ 2025-01-22 16:41 ` Ivaylo Dimitrov
2025-01-23 11:49 ` Mark Brown
2025-01-27 19:00 ` Rob Herring (Arm)
2025-01-22 16:41 ` [PATCH v2 4/5] arch: arm: dts: cpcap-mapphone: Add audio-codec jack detection interrupts Ivaylo Dimitrov
` (3 subsequent siblings)
6 siblings, 2 replies; 14+ messages in thread
From: Ivaylo Dimitrov @ 2025-01-22 16:41 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Javier Carrasco
Cc: devicetree, linux-kernel, linux-omap, linux-sound,
Ivaylo Dimitrov
Add DT binding for the audio-codec headset detection interrupts.
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
Documentation/devicetree/bindings/mfd/motorola-cpcap.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt b/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
index 190230216de8..f00827c9b67f 100644
--- a/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
+++ b/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
@@ -31,6 +31,10 @@ node must be named "audio-codec".
Required properties for the audio-codec subnode:
- #sound-dai-cells = <1>;
+- interrupts : should contain jack detection interrupts, with headset
+ detect interrupt matching "hs" and microphone bias 2
+ detect interrupt matching "mb2" in interrupt-names.
+- interrupt-names : Contains "hs", "mb2"
The audio-codec provides two DAIs. The first one is connected to the
Stereo HiFi DAC and the second one is connected to the Voice DAC.
@@ -52,6 +56,8 @@ Example:
audio-codec {
#sound-dai-cells = <1>;
+ interrupts-extended = <&cpcap 9 0>, <&cpcap 10 0>;
+ interrupt-names = "hs", "mb2";
/* HiFi */
port@0 {
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v2 3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts
2025-01-22 16:41 ` [PATCH v2 3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts Ivaylo Dimitrov
@ 2025-01-23 11:49 ` Mark Brown
2025-01-27 13:27 ` Lee Jones
2025-01-27 19:00 ` Rob Herring (Arm)
1 sibling, 1 reply; 14+ messages in thread
From: Mark Brown @ 2025-01-23 11:49 UTC (permalink / raw)
To: Ivaylo Dimitrov
Cc: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Javier Carrasco, devicetree, linux-kernel, linux-omap,
linux-sound
[-- Attachment #1: Type: text/plain, Size: 177 bytes --]
On Wed, Jan 22, 2025 at 06:41:27PM +0200, Ivaylo Dimitrov wrote:
> Add DT binding for the audio-codec headset detection interrupts.
Lee, would it be OK to merge this via ASoC?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts
2025-01-23 11:49 ` Mark Brown
@ 2025-01-27 13:27 ` Lee Jones
2025-01-27 13:34 ` Mark Brown
0 siblings, 1 reply; 14+ messages in thread
From: Lee Jones @ 2025-01-27 13:27 UTC (permalink / raw)
To: Mark Brown
Cc: Ivaylo Dimitrov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Javier Carrasco, devicetree, linux-kernel, linux-omap,
linux-sound
On Thu, 23 Jan 2025, Mark Brown wrote:
> On Wed, Jan 22, 2025 at 06:41:27PM +0200, Ivaylo Dimitrov wrote:
> > Add DT binding for the audio-codec headset detection interrupts.
>
> Lee, would it be OK to merge this via ASoC?
I'm not sure why you would want to and it may make subsequent changes
more challenging to merge, but if you really want to ...
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts
2025-01-27 13:27 ` Lee Jones
@ 2025-01-27 13:34 ` Mark Brown
0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2025-01-27 13:34 UTC (permalink / raw)
To: Lee Jones
Cc: Ivaylo Dimitrov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Javier Carrasco, devicetree, linux-kernel, linux-omap,
linux-sound
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
On Mon, Jan 27, 2025 at 01:27:25PM +0000, Lee Jones wrote:
> On Thu, 23 Jan 2025, Mark Brown wrote:
> > On Wed, Jan 22, 2025 at 06:41:27PM +0200, Ivaylo Dimitrov wrote:
> > > Add DT binding for the audio-codec headset detection interrupts.
> > Lee, would it be OK to merge this via ASoC?
> I'm not sure why you would want to and it may make subsequent changes
> more challenging to merge, but if you really want to ...
It's the binding documentation for the ASoC change in the final patch.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts
2025-01-22 16:41 ` [PATCH v2 3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts Ivaylo Dimitrov
2025-01-23 11:49 ` Mark Brown
@ 2025-01-27 19:00 ` Rob Herring (Arm)
1 sibling, 0 replies; 14+ messages in thread
From: Rob Herring (Arm) @ 2025-01-27 19:00 UTC (permalink / raw)
To: Ivaylo Dimitrov
Cc: Mark Brown, devicetree, linux-omap, Krzysztof Kozlowski,
Tony Lindgren, linux-sound, Jaroslav Kysela, Liam Girdwood,
Conor Dooley, Takashi Iwai, linux-kernel, Lee Jones,
Javier Carrasco
On Wed, 22 Jan 2025 18:41:27 +0200, Ivaylo Dimitrov wrote:
> Add DT binding for the audio-codec headset detection interrupts.
>
> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> ---
> Documentation/devicetree/bindings/mfd/motorola-cpcap.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 4/5] arch: arm: dts: cpcap-mapphone: Add audio-codec jack detection interrupts
2025-01-22 16:41 [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection Ivaylo Dimitrov
` (2 preceding siblings ...)
2025-01-22 16:41 ` [PATCH v2 3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts Ivaylo Dimitrov
@ 2025-01-22 16:41 ` Ivaylo Dimitrov
2026-05-06 11:07 ` Ivaylo Dimitrov
2025-01-22 16:41 ` [PATCH v2 5/5] ASoC: cpcap: Implement jack detection Ivaylo Dimitrov
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Ivaylo Dimitrov @ 2025-01-22 16:41 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Javier Carrasco
Cc: devicetree, linux-kernel, linux-omap, linux-sound,
Ivaylo Dimitrov
cpcap audio-codec supports headset/micrphone detect interrupts, configure
them.
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi b/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
index 83fd58157579..73e27b95105e 100644
--- a/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
+++ b/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
@@ -69,6 +69,8 @@ cpcap_regulators: regulators {
cpcap_audio: audio-codec {
#sound-dai-cells = <1>;
+ interrupts-extended = <&cpcap 9 0>, <&cpcap 10 0>;
+ interrupt-names = "hs", "mb2";
port@0 {
cpcap_audio_codec0: endpoint {
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v2 4/5] arch: arm: dts: cpcap-mapphone: Add audio-codec jack detection interrupts
2025-01-22 16:41 ` [PATCH v2 4/5] arch: arm: dts: cpcap-mapphone: Add audio-codec jack detection interrupts Ivaylo Dimitrov
@ 2026-05-06 11:07 ` Ivaylo Dimitrov
0 siblings, 0 replies; 14+ messages in thread
From: Ivaylo Dimitrov @ 2026-05-06 11:07 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Javier Carrasco
Cc: devicetree, linux-kernel, linux-omap, linux-sound
Hi,
It looks like this patch from the series may have been missed as well.
Could you please take another look and consider merging it?
Thanks!
On 22.01.25 г. 18:41 ч., Ivaylo Dimitrov wrote:
> cpcap audio-codec supports headset/micrphone detect interrupts, configure
> them.
>
> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> ---
> arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi b/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
> index 83fd58157579..73e27b95105e 100644
> --- a/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
> +++ b/arch/arm/boot/dts/ti/omap/motorola-cpcap-mapphone.dtsi
> @@ -69,6 +69,8 @@ cpcap_regulators: regulators {
>
> cpcap_audio: audio-codec {
> #sound-dai-cells = <1>;
> + interrupts-extended = <&cpcap 9 0>, <&cpcap 10 0>;
> + interrupt-names = "hs", "mb2";
>
> port@0 {
> cpcap_audio_codec0: endpoint {
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 5/5] ASoC: cpcap: Implement jack detection
2025-01-22 16:41 [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection Ivaylo Dimitrov
` (3 preceding siblings ...)
2025-01-22 16:41 ` [PATCH v2 4/5] arch: arm: dts: cpcap-mapphone: Add audio-codec jack detection interrupts Ivaylo Dimitrov
@ 2025-01-22 16:41 ` Ivaylo Dimitrov
2025-02-07 14:02 ` (subset) [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection Mark Brown
2026-05-06 21:22 ` Kevin Hilman
6 siblings, 0 replies; 14+ messages in thread
From: Ivaylo Dimitrov @ 2025-01-22 16:41 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Javier Carrasco
Cc: devicetree, linux-kernel, linux-omap, linux-sound,
Ivaylo Dimitrov
cpcap has headphones/microphone and PTT button detection logic, implement
code to support it.
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
sound/soc/codecs/cpcap.c | 171 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 170 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c
index 53f549ede6a6..3eb862643b53 100644
--- a/sound/soc/codecs/cpcap.c
+++ b/sound/soc/codecs/cpcap.c
@@ -14,9 +14,18 @@
#include <linux/regulator/consumer.h>
#include <linux/mfd/motorola-cpcap.h>
#include <sound/core.h>
+#include <linux/input.h>
+#include <sound/jack.h>
#include <sound/soc.h>
#include <sound/tlv.h>
+/* Register 8 - CPCAP_REG_INTS1 --- Interrupt Sense 1 */
+#define CPCAP_BIT_HS_S 9 /* Headset */
+#define CPCAP_BIT_MB2_S 10 /* Mic Bias2 */
+
+/* Register 9 - CPCAP_REG_INTS2 --- Interrupt Sense 2 */
+#define CPCAP_BIT_PTT_S 11 /* Push To Talk */
+
/* Register 512 CPCAP_REG_VAUDIOC --- Audio Regulator and Bias Voltage */
#define CPCAP_BIT_AUDIO_LOW_PWR 6
#define CPCAP_BIT_AUD_LOWPWR_SPEED 5
@@ -262,6 +271,9 @@ struct cpcap_audio {
int codec_freq;
int codec_format;
struct regulator *vaudio;
+ int hsirq;
+ int mb2irq;
+ struct snd_soc_jack jack;
};
static int cpcap_st_workaround(struct snd_soc_dapm_widget *w,
@@ -1628,14 +1640,105 @@ static int cpcap_audio_reset(struct snd_soc_component *component,
return 0;
}
+static irqreturn_t cpcap_hs_irq_thread(int irq, void *data)
+{
+ struct snd_soc_component *component = data;
+ struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component);
+ struct regmap *regmap = cpcap->regmap;
+ int status = 0;
+ int mask = SND_JACK_HEADSET;
+ int val;
+
+ if (!regmap_test_bits(regmap, CPCAP_REG_INTS1, BIT(CPCAP_BIT_HS_S))) {
+ val = BIT(CPCAP_BIT_MB_ON2) | BIT(CPCAP_BIT_PTT_CMP_EN);
+ regmap_update_bits(regmap, CPCAP_REG_TXI, val, val);
+
+ val = BIT(CPCAP_BIT_ST_HS_CP_EN);
+ regmap_update_bits(regmap, CPCAP_REG_RXOA, val, val);
+
+ regulator_set_mode(cpcap->vaudio, REGULATOR_MODE_NORMAL);
+
+ /* Give PTTS time to settle */
+ msleep(20);
+
+ if (!regmap_test_bits(regmap, CPCAP_REG_INTS2,
+ BIT(CPCAP_BIT_PTT_S))) {
+ /* Headphones detected. (May also be a headset with the
+ * MFB pressed.)
+ */
+ status = SND_JACK_HEADPHONE;
+ dev_info(component->dev, "HP plugged in\n");
+ } else if (regmap_test_bits(regmap, CPCAP_REG_INTS1,
+ BIT(CPCAP_BIT_MB2_S)) == 1) {
+ status = SND_JACK_HEADSET;
+ dev_info(component->dev, "HS plugged in\n");
+ } else
+ dev_info(component->dev, "Unsupported HS plugged in\n");
+ } else {
+ bool mic = cpcap->jack.status & SND_JACK_MICROPHONE;
+
+ dev_info(component->dev, "H%s disconnect\n", mic ? "S" : "P");
+ val = BIT(CPCAP_BIT_MB_ON2) | BIT(CPCAP_BIT_PTT_CMP_EN);
+ regmap_update_bits(cpcap->regmap, CPCAP_REG_TXI, val, 0);
+
+ val = BIT(CPCAP_BIT_ST_HS_CP_EN);
+ regmap_update_bits(cpcap->regmap, CPCAP_REG_RXOA, val, 0);
+
+ regulator_set_mode(cpcap->vaudio, REGULATOR_MODE_STANDBY);
+
+ mask |= SND_JACK_BTN_0;
+ }
+
+ snd_soc_jack_report(&cpcap->jack, status, mask);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t cpcap_mb2_irq_thread(int irq, void *data)
+{
+ struct snd_soc_component *component = data;
+ struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component);
+ struct regmap *regmap = cpcap->regmap;
+ int status = 0;
+ int mb2;
+ int ptt;
+
+ if (regmap_test_bits(regmap, CPCAP_REG_INTS1, BIT(CPCAP_BIT_HS_S)) == 1)
+ return IRQ_HANDLED;
+
+ mb2 = regmap_test_bits(regmap, CPCAP_REG_INTS1, BIT(CPCAP_BIT_MB2_S));
+ ptt = regmap_test_bits(regmap, CPCAP_REG_INTS2, BIT(CPCAP_BIT_PTT_S));
+
+ /* Initial detection might have been with MFB pressed */
+ if (!(cpcap->jack.status & SND_JACK_MICROPHONE)) {
+ if (ptt == 1 && mb2 == 1) {
+ dev_info(component->dev, "MIC plugged in\n");
+ snd_soc_jack_report(&cpcap->jack, SND_JACK_MICROPHONE,
+ SND_JACK_MICROPHONE);
+ }
+
+ return IRQ_HANDLED;
+ }
+
+ if (!mb2 || !ptt)
+ status = SND_JACK_BTN_0;
+
+ snd_soc_jack_report(&cpcap->jack, status, SND_JACK_BTN_0);
+
+ return IRQ_HANDLED;
+}
+
static int cpcap_soc_probe(struct snd_soc_component *component)
{
+ struct platform_device *pdev = to_platform_device(component->dev);
+ struct snd_soc_card *card = component->card;
struct cpcap_audio *cpcap;
int err;
cpcap = devm_kzalloc(component->dev, sizeof(*cpcap), GFP_KERNEL);
if (!cpcap)
return -ENOMEM;
+
snd_soc_component_set_drvdata(component, cpcap);
cpcap->component = component;
@@ -1644,6 +1747,16 @@ static int cpcap_soc_probe(struct snd_soc_component *component)
return dev_err_probe(component->dev, PTR_ERR(cpcap->vaudio),
"Cannot get VAUDIO regulator\n");
+ err = snd_soc_card_jack_new(card, "Headphones",
+ SND_JACK_HEADSET | SND_JACK_BTN_0,
+ &cpcap->jack);
+ if (err < 0) {
+ dev_err(component->dev, "Cannot create HS jack: %i\n", err);
+ return err;
+ }
+
+ snd_jack_set_key(cpcap->jack.jack, SND_JACK_BTN_0, KEY_MEDIA);
+
cpcap->regmap = dev_get_regmap(component->dev->parent, NULL);
if (!cpcap->regmap)
return -ENODEV;
@@ -1653,7 +1766,58 @@ static int cpcap_soc_probe(struct snd_soc_component *component)
if (err)
return err;
- return cpcap_audio_reset(component, false);
+ cpcap->hsirq = platform_get_irq_byname(pdev, "hs");
+ if (cpcap->hsirq < 0)
+ return cpcap->hsirq;
+
+ err = devm_request_threaded_irq(component->dev, cpcap->hsirq, NULL,
+ cpcap_hs_irq_thread,
+ IRQF_TRIGGER_RISING |
+ IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
+ "cpcap-codec-hs",
+ component);
+ if (err) {
+ dev_warn(component->dev, "no HS irq%i: %i\n",
+ cpcap->hsirq, err);
+ return err;
+ }
+
+ cpcap->mb2irq = platform_get_irq_byname(pdev, "mb2");
+ if (cpcap->mb2irq < 0)
+ return cpcap->mb2irq;
+
+ err = devm_request_threaded_irq(component->dev, cpcap->mb2irq, NULL,
+ cpcap_mb2_irq_thread,
+ IRQF_TRIGGER_RISING |
+ IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
+ "cpcap-codec-mb2",
+ component);
+ if (err) {
+ dev_warn(component->dev, "no MB2 irq%i: %i\n",
+ cpcap->mb2irq, err);
+ return err;
+ }
+
+ err = cpcap_audio_reset(component, false);
+ if (err)
+ return err;
+
+ cpcap_hs_irq_thread(cpcap->hsirq, component);
+
+ enable_irq_wake(cpcap->hsirq);
+ enable_irq_wake(cpcap->mb2irq);
+
+ return 0;
+}
+
+static void cpcap_soc_remove(struct snd_soc_component *component)
+{
+ struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component);
+
+ disable_irq_wake(cpcap->hsirq);
+ disable_irq_wake(cpcap->mb2irq);
}
static int cpcap_set_bias_level(struct snd_soc_component *component,
@@ -1661,6 +1825,10 @@ static int cpcap_set_bias_level(struct snd_soc_component *component,
{
struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component);
+ /* VAIDIO should be kept in normal mode in order MIC/PTT to work */
+ if (cpcap->jack.status & SND_JACK_MICROPHONE)
+ return 0;
+
switch (level) {
case SND_SOC_BIAS_OFF:
break;
@@ -1679,6 +1847,7 @@ static int cpcap_set_bias_level(struct snd_soc_component *component,
static const struct snd_soc_component_driver soc_codec_dev_cpcap = {
.probe = cpcap_soc_probe,
+ .remove = cpcap_soc_remove,
.controls = cpcap_snd_controls,
.num_controls = ARRAY_SIZE(cpcap_snd_controls),
.dapm_widgets = cpcap_dapm_widgets,
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: (subset) [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection
2025-01-22 16:41 [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection Ivaylo Dimitrov
` (4 preceding siblings ...)
2025-01-22 16:41 ` [PATCH v2 5/5] ASoC: cpcap: Implement jack detection Ivaylo Dimitrov
@ 2025-02-07 14:02 ` Mark Brown
2026-05-06 21:22 ` Kevin Hilman
6 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2025-02-07 14:02 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Javier Carrasco, Ivaylo Dimitrov
Cc: devicetree, linux-kernel, linux-omap, linux-sound
On Wed, 22 Jan 2025 18:41:24 +0200, Ivaylo Dimitrov wrote:
> cpcap audio codec found on cpcap PMIC supports headset detection
> and PTT button through its 3.5 mm jack. This series implements
> support for those capabilities.
>
> Changelog:
> v2:
> - cpcap.c: fix a typo
> - dt-bindings: fix interrupts description and alignment
> - motorola-cpcap-mapphone.dtsi: fix interrupts alignment
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[2/5] ASoC: cpcap: Implement .set_bias_level
commit: 5b4288792ff246cf2bda0c81cebcc02d1f631ca3
[3/5] dt-bindings: mfd: motorola-cpcap: Document audio-codec interrupts
commit: 02d4a97ce30c0494ce6a614cd54d583caa0f8016
[5/5] ASoC: cpcap: Implement jack detection
commit: 7ed1b265021dd13ce5619501b388e489ddc8e204
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
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: (subset) [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection
2025-01-22 16:41 [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection Ivaylo Dimitrov
` (5 preceding siblings ...)
2025-02-07 14:02 ` (subset) [PATCH v2 0/5] ASoC: cpcap: Implement jack headset detection Mark Brown
@ 2026-05-06 21:22 ` Kevin Hilman
6 siblings, 0 replies; 14+ messages in thread
From: Kevin Hilman @ 2026-05-06 21:22 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Tony Lindgren, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Javier Carrasco, Ivaylo Dimitrov
Cc: devicetree, linux-kernel, linux-omap, linux-sound
On Wed, 22 Jan 2025 18:41:24 +0200, Ivaylo Dimitrov wrote:
> cpcap audio codec found on cpcap PMIC supports headset detection
> and PTT button through its 3.5 mm jack. This series implements
> support for those capabilities.
>
> Changelog:
> v2:
> - cpcap.c: fix a typo
> - dt-bindings: fix interrupts description and alignment
> - motorola-cpcap-mapphone.dtsi: fix interrupts alignment
>
> [...]
Applied, thanks!
[1/5] arch: arm: dts: cpcap-mapphone: Set VAUDIO regulator always-on
commit: 009f64641db3fbfecf92dee910c57a41c3e77a4b
[4/5] arch: arm: dts: cpcap-mapphone: Add audio-codec jack detection interrupts
commit: 164f88cd7e0c0fcb950e8b4ba5d8c26404334c88
Best regards,
--
Kevin Hilman (TI) <khilman@baylibre.com>
^ permalink raw reply [flat|nested] 14+ messages in thread