Skip to contentSkip to conversation

ASoC: dt-bindings: fsl-sai: Document RX/TX BCLK swap support

PATCH In review Marek Vasut 2 participants 3 messages Dec 26, 2024 – Jan 2, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ASoC: dt-bindings: fsl-sai: Document RX/TX BCLK swap support

Document support for setting the Bit Clock Swap bit in CR2 register via new "fsl,sai-bit-clock-swap" DT property. This bit swaps the bit clock used by the transmitter or receiver in asynchronous mode, i.e. makes transmitter use RX_BCLK and TX_SYNC, and vice versa, makes receiver use TX_BCLK and RX_SYNC.

---
Cc: Conor Dooley <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Michael Turquette <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Nicolin Chen <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Shengjiu Wang <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Xiubo Li <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 Documentation/devicetree/bindings/sound/fsl,sai.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/sound/fsl,sai.yaml +7 -0
index a5d9c246cc476..7a58df1e3f87c 100644
@@ -132,6 +132,13 @@ properties:
       of transmitter.
     type: boolean
 
+  fsl,sai-bit-clock-swap:
+    description: |
+      Enable Bit Clock Swap, which swaps the bit clock used by the transmitter
+      or receiver in asynchronous mode, i.e. makes transmitter use RX_BCLK and
+      TX_SYNC, and vice versa, makes receiver use TX_BCLK and RX_SYNC.
+    type: boolean
+
   fsl,shared-interrupt:
     description: Interrupt is shared with other modules.
     type: boolean
Signature · 1 line
2.45.2
#1 lore raw

PATCH 2/2 ASoC: fsl_sai: Add RX/TX BCLK swap support

Add support for setting the Bit Clock Swap bit in CR2 register via new "fsl,sai-bit-clock-swap" DT property. This bit swaps the bit clock used by the transmitter or receiver in asynchronous mode, i.e. makes transmitter use RX_BCLK and TX_SYNC, and vice versa, makes receiver use TX_BCLK and RX_SYNC.

---
Cc: Conor Dooley <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Michael Turquette <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Nicolin Chen <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Shengjiu Wang <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Xiubo Li <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 sound/soc/fsl/fsl_sai.c | 7 ++++++-
 sound/soc/fsl/fsl_sai.h | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)
sound/soc/fsl/fsl_sai.c +6 -1
index c4eb87c5d39e4..3b1b51c482d50 100644
@@ -276,6 +276,9 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
 	unsigned int ofs = sai->soc_data->reg_offset;
 	u32 val_cr2 = 0, val_cr4 = 0;
 
+	if (sai->is_bit_clock_swap)
+		val_cr2 |= FSL_SAI_CR2_BCS;
+
 	if (!sai->is_lsb_first)
 		val_cr4 |= FSL_SAI_CR4_MF;
 
@@ -375,7 +378,8 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
 	}
 
 	regmap_update_bits(sai->regmap, FSL_SAI_xCR2(tx, ofs),
-			   FSL_SAI_CR2_BCP | FSL_SAI_CR2_BCD_MSTR, val_cr2);
+			   FSL_SAI_CR2_BCS | FSL_SAI_CR2_BCP | FSL_SAI_CR2_BCD_MSTR,
+			   val_cr2);
 	regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx, ofs),
 			   FSL_SAI_CR4_MF | FSL_SAI_CR4_FSE |
 			   FSL_SAI_CR4_FSP | FSL_SAI_CR4_FSD_MSTR, val_cr4);
@@ -1395,6 +1399,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
 	sai->soc_data = of_device_get_match_data(dev);
 
 	sai->is_lsb_first = of_property_read_bool(np, "lsb-first");
+	sai->is_bit_clock_swap = of_property_read_bool(np, "fsl,sai-bit-clock-swap");
 
 	base = devm_platform_get_and_ioremap_resource(pdev, 0, &sai->res);
 	if (IS_ERR(base))
sound/soc/fsl/fsl_sai.h +2 -0
index 0e25e2fc7ce0d..f58ff39497366 100644
@@ -118,6 +118,7 @@
 
 /* SAI Transmit and Receive Configuration 2 Register */
 #define FSL_SAI_CR2_SYNC	BIT(30)
+#define FSL_SAI_CR2_BCS		BIT(29)
 #define FSL_SAI_CR2_BCI		BIT(28)
 #define FSL_SAI_CR2_MSEL_MASK	(0x3 << 26)
 #define FSL_SAI_CR2_MSEL_BUS	0
@@ -293,6 +294,7 @@ struct fsl_sai {
 	struct fsl_sai_dl_cfg *dl_cfg;
 	unsigned int dl_cfg_cnt;
 	bool mclk_direction_output;
+	bool is_bit_clock_swap;
 
 	unsigned int mclk_id[2];
 	unsigned int mclk_streams;
Signature · 1 line
2.45.2
maintainer
#2 lore raw
In reply to Marek Vasut
Quoted 34 lines · Marek Vasut

Document support for setting the Bit Clock Swap bit in CR2 register via new "fsl,sai-bit-clock-swap" DT property. This bit swaps the bit clock used by the transmitter or receiver in asynchronous mode, i.e. makes transmitter use RX_BCLK and TX_SYNC, and vice versa, makes receiver use TX_BCLK and RX_SYNC.

---
Cc: Conor Dooley <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Michael Turquette <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Nicolin Chen <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Shengjiu Wang <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Xiubo Li <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 Documentation/devicetree/bindings/sound/fsl,sai.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/sound/fsl,sai.yaml +0 -0
index a5d9c246cc476..7a58df1e3f87c 100644

Documentation/devicetree/bindings/sound/fsl,sai.yaml properties: · line 136

Quoted 5 lines
Documentation/devicetree/bindings/sound/fsl,sai.yaml +2 -0
@@ -132,6 +132,13 @@ properties:
       of transmitter.
     type: boolean
 
+  fsl,sai-bit-clock-swap:
+    description: |

Don't need '|'.

Quoted 11 lines
Documentation/devicetree/bindings/sound/fsl,sai.yaml +5 -0
+      Enable Bit Clock Swap, which swaps the bit clock used by the transmitter
+      or receiver in asynchronous mode, i.e. makes transmitter use RX_BCLK and
+      TX_SYNC, and vice versa, makes receiver use TX_BCLK and RX_SYNC.
+    type: boolean
+
   fsl,shared-interrupt:
     description: Interrupt is shared with other modules.
     type: boolean
Signature · 1 line
2.45.2