diff mbox series

[6/6] ASoC: tlv320adcx140: Add channel slot programming

Message ID 20200915190606.1744-6-dmurphy@ti.com
State New
Headers show
Series [1/6] ASoC: tlv320adcx140: Idle the device while writing registers | expand

Commit Message

Dan Murphy Sept. 15, 2020, 7:06 p.m. UTC
Each channel can be assigned a specific slot to transmit data. This
assignment is done in the device tree.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 sound/soc/codecs/tlv320adcx140.c | 17 +++++++++++++++++
 sound/soc/codecs/tlv320adcx140.h |  3 +++
 2 files changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 7fa5c8682c51..666b8f3091d0 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -837,6 +837,8 @@  static int adcx140_codec_probe(struct snd_soc_component *component)
 	int gpi_count;
 	u32 gpi_inputs[ADCX140_NUM_GPI_PINS];
 	u32 gpi_input_val = 0;
+	int slot_count;
+	u32 slot_assignment[ADCX140_NUM_CH];
 	int i;
 	int ret;
 	bool tx_high_z;
@@ -941,6 +943,21 @@  static int adcx140_codec_probe(struct snd_soc_component *component)
 		}
 	}
 
+	slot_count = device_property_count_u32(adcx140->dev, "ti,slot-mapping");
+	if ((slot_count <= ADCX140_NUM_CH) && (slot_count > 0)) {
+		ret = device_property_read_u32_array(adcx140->dev, "ti,slot-mapping",
+						     slot_assignment, slot_count);
+		if (ret)
+			return ret;
+
+		for (i = 0; i < slot_count; i++) {
+			ret = regmap_update_bits(adcx140->regmap, ADCX140_ASI_CH1 + i,
+						 ADCX140_SLOT_MSK, slot_assignment[i]);
+			if (ret)
+				return ret;
+		}
+	}
+
 	adcx140_pwr_ctrl(adcx140, true);
 out:
 	return ret;
diff --git a/sound/soc/codecs/tlv320adcx140.h b/sound/soc/codecs/tlv320adcx140.h
index 107bd7927d9c..5eb27b94aa0a 100644
--- a/sound/soc/codecs/tlv320adcx140.h
+++ b/sound/soc/codecs/tlv320adcx140.h
@@ -147,5 +147,8 @@ 
 #define ADCX140_GPO_DRV_MAX		5
 
 #define ADCX140_TX_FILL    BIT(0)
+#define ADCX140_NUM_CH        8
+
+#define ADCX140_SLOT_MSK	GENMASK(5, 0)
 
 #endif /* _TLV320ADCX140_ */