linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Tanure <tanureal@opensource.cirrus.com>
To: James Schulman <james.schulman@cirrus.com>,
	David Rhodes <david.rhodes@cirrus.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>
Cc: <alsa-devel@alsa-project.org>, <patches@opensource.cirrus.com>,
	<linux-kernel@vger.kernel.org>,
	Vitaly Rodionov <vitalyr@opensource.cirrus.com>,
	Lucas Tanure <tanureal@opensource.cirrus.com>
Subject: [PATCH] ASoC: cs42l42: make HSBIAS_SENSE_EN optional
Date: Fri, 7 May 2021 15:17:48 +0100	[thread overview]
Message-ID: <20210507141748.742037-1-tanureal@opensource.cirrus.com> (raw)

From: Vitaly Rodionov <vitalyr@opensource.cirrus.com>

HSBIAS_SENSE_EN configures HSBIAS output current sense through
the external 2.21-k resistor. HSBIAS_SENSE is hardware feature to reduce
the potential pop noise during the headset plug out slowly. But on some
platforms ESD voltage will affect it causing test to fail, especially
with CTIA headset type. For different hardware setups, a designer might
want to tweak default behavior.

Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
---
 .../devicetree/bindings/sound/cs42l42.txt     | 10 ++++++++++
 include/dt-bindings/sound/cs42l42.h           |  3 +++
 sound/soc/codecs/cs42l42.c                    | 20 ++++++++++++++++++-
 sound/soc/codecs/cs42l42.h                    |  1 +
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/sound/cs42l42.txt b/Documentation/devicetree/bindings/sound/cs42l42.txt
index 7dfaa2ab906f..e75f191d2945 100644
--- a/Documentation/devicetree/bindings/sound/cs42l42.txt
+++ b/Documentation/devicetree/bindings/sound/cs42l42.txt
@@ -81,6 +81,16 @@ Optional properties:
   < x1 x2 x3 x4 >
   Default = < 15 8 4 1>
 
+  - cirrus,hs-bias-sense-en: Configures HSBIAS output current sense through
+  the external 2.21-k resistor. HSBIAS_SENSE is hardware feature to reduce
+  the potential pop noise during the headset plug out slowly. But on some
+  platforms ESD voltage will affect it causing test to fail, especially
+  with CTIA headset type. For different hardware setups, a designer might
+  want to tweak default behavior.
+
+  0 - disabled
+  1 - enabled
+  Default = 1
 
 Example:
 
diff --git a/include/dt-bindings/sound/cs42l42.h b/include/dt-bindings/sound/cs42l42.h
index f25d83c6188b..788e1598b15f 100644
--- a/include/dt-bindings/sound/cs42l42.h
+++ b/include/dt-bindings/sound/cs42l42.h
@@ -66,4 +66,7 @@
 #define CS42L42_HSBIAS_RAMP_TIME2			90
 #define CS42L42_HSBIAS_RAMP_TIME3			170
 
+#define CS42L42_HSBIAS_SENSE_ON  1
+#define CS42L42_HSBIAS_SENSE_OFF 0
+
 #endif /* __DT_CS42L42_H */
diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index d9f8da7a68d0..139245c6b720 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -1032,7 +1032,7 @@ static void cs42l42_process_hs_type_detect(struct cs42l42_private *cs42l42)
 			CS42L42_AUTO_HSBIAS_HIZ_MASK |
 			CS42L42_TIP_SENSE_EN_MASK |
 			CS42L42_HSBIAS_SENSE_TRIP_MASK,
-			(1 << CS42L42_HSBIAS_SENSE_EN_SHIFT) |
+			(cs42l42->hs_bias_sense_en << CS42L42_HSBIAS_SENSE_EN_SHIFT) |
 			(1 << CS42L42_AUTO_HSBIAS_HIZ_SHIFT) |
 			(0 << CS42L42_TIP_SENSE_EN_SHIFT) |
 			(3 << CS42L42_HSBIAS_SENSE_TRIP_SHIFT));
@@ -1807,6 +1807,24 @@ static int cs42l42_handle_device_data(struct device *dev,
 			(cs42l42->hs_bias_ramp_rate <<
 			CS42L42_HSBIAS_RAMP_SHIFT));
 
+	ret = device_property_read_u32(dev, "cirrus,hs-bias-sense-en", &val);
+	if (!ret) {
+		switch (val) {
+		case CS42L42_HSBIAS_SENSE_OFF:
+		case CS42L42_HSBIAS_SENSE_ON:
+			cs42l42->hs_bias_sense_en = val;
+			break;
+		default:
+			dev_err(dev,
+				"Wrong cirrus,hs-bias-sense-en DT value %d\n",
+				val);
+			cs42l42->hs_bias_sense_en = CS42L42_HSBIAS_SENSE_ON;
+			break;
+		}
+	} else {
+		cs42l42->hs_bias_sense_en = CS42L42_HSBIAS_SENSE_ON;
+	}
+
 	return 0;
 }
 
diff --git a/sound/soc/codecs/cs42l42.h b/sound/soc/codecs/cs42l42.h
index 2e0d3836bd7e..24f7be228d5f 100644
--- a/sound/soc/codecs/cs42l42.h
+++ b/sound/soc/codecs/cs42l42.h
@@ -787,6 +787,7 @@ struct  cs42l42_private {
 	u8 bias_thresholds[CS42L42_NUM_BIASES];
 	u8 hs_bias_ramp_rate;
 	u8 hs_bias_ramp_time;
+	u8 hs_bias_sense_en;
 	u8 stream_use;
 };
 
-- 
2.31.1


             reply	other threads:[~2021-05-07 14:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 14:17 Lucas Tanure [this message]
2021-05-07 15:38 ` [PATCH] ASoC: cs42l42: make HSBIAS_SENSE_EN optional Mark Brown
2021-05-07 18:14 ` kernel test robot
2021-05-07 18:17 ` kernel test robot
2021-05-11 14:52 Vitaly Rodionov
2021-05-12 17:04 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210507141748.742037-1-tanureal@opensource.cirrus.com \
    --to=tanureal@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=david.rhodes@cirrus.com \
    --cc=james.schulman@cirrus.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=vitalyr@opensource.cirrus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).