devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <cy_huang@richtek.com>
To: Mark Brown <broonie@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Cc: Conor Dooley <conor+dt@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	ChiYuan Huang <cy_huang@richtek.com>,
	Allen Lin <allen_lin@richtek.com>, <devicetree@vger.kernel.org>,
	<alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] ASoC: codecs: rtq9128: Add TDM input source select
Date: Thu, 28 Sep 2023 11:41:08 +0800	[thread overview]
Message-ID: <1695872468-24433-3-git-send-email-cy_huang@richtek.com> (raw)
In-Reply-To: <1695872468-24433-1-git-send-email-cy_huang@richtek.com>

From: ChiYuan Huang <cy_huang@richtek.com>

Pase the property to decide the TDM input source comes from 'DATA1' or
'DATA2 pin.

Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
 sound/soc/codecs/rtq9128.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rtq9128.c b/sound/soc/codecs/rtq9128.c
index 926b79ed8078..371d622c6214 100644
--- a/sound/soc/codecs/rtq9128.c
+++ b/sound/soc/codecs/rtq9128.c
@@ -14,6 +14,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
@@ -41,6 +42,7 @@
 
 #define RTQ9128_CHSTAT_VAL_MASK	GENMASK(1, 0)
 #define RTQ9128_DOLEN_MASK	GENMASK(7, 6)
+#define RTQ9128_TDMSRCIN_MASK	GENMASK(5, 4)
 #define RTQ9128_AUDBIT_MASK	GENMASK(5, 4)
 #define RTQ9128_AUDFMT_MASK	GENMASK(3, 0)
 #define RTQ9128_MSMUTE_MASK	BIT(0)
@@ -59,6 +61,7 @@ struct rtq9128_data {
 	struct gpio_desc *enable;
 	int tdm_slots;
 	int tdm_slot_width;
+	bool tdm_input_data2_select;
 };
 
 struct rtq9128_init_reg {
@@ -484,7 +487,7 @@ static int rtq9128_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mas
 	struct rtq9128_data *data = snd_soc_dai_get_drvdata(dai);
 	struct snd_soc_component *comp = dai->component;
 	struct device *dev = dai->dev;
-	unsigned int mask, start_loc;
+	unsigned int mask, start_loc, srcin_select;
 	int i, frame_length, ret;
 
 	dev_dbg(dev, "%s: slot %d slot_width %d, tx/rx mask 0x%x 0x%x\n", __func__, slots,
@@ -530,6 +533,14 @@ static int rtq9128_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mas
 		}
 	}
 
+	srcin_select = data->tdm_input_data2_select ? RTQ9128_TDMSRCIN_MASK : 0;
+	ret = snd_soc_component_update_bits(comp, RTQ9128_REG_SDO_SEL, RTQ9128_TDMSRCIN_MASK,
+					    srcin_select);
+	if (ret < 0) {
+		dev_err(dev, "Failed to configure TDM source input select\n");
+		return ret;
+	}
+
 	data->tdm_slots = slots;
 	data->tdm_slot_width = slot_width;
 
@@ -672,6 +683,9 @@ static int rtq9128_probe(struct i2c_client *i2c)
 	else if (data->enable)
 		usleep_range(10000, 11000);
 
+	data->tdm_input_data2_select = device_property_read_bool(dev,
+								 "richtek,tdm-input-data2-select");
+
 	i2c_set_clientdata(i2c, data);
 
 	/*
-- 
2.34.1


  parent reply	other threads:[~2023-09-28  3:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28  3:41 [PATCH 0/2] ASoC: codecs: rtq9128: Add TDM input source select cy_huang
2023-09-28  3:41 ` [PATCH 1/2] ASoC: dt-bindings: rtq9128: Add TDM input source slect property cy_huang
2023-09-28  3:41 ` cy_huang [this message]
2023-09-28 14:51 ` [PATCH 0/2] ASoC: codecs: rtq9128: Add TDM input source select 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=1695872468-24433-3-git-send-email-cy_huang@richtek.com \
    --to=cy_huang@richtek.com \
    --cc=allen_lin@richtek.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.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).