Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: ti: davinci-i2s: Add handling of BP_FC format

McBSP is able to drive bit clock and consume frame clock but BP_FC
format is not handled by McBSP driver.

Add BP_FC format support.
When BP_FC is selected:
- CLKX and CLKR are configured as outputs
- The sample rate generator is configured to be able to provide bit
clock.

Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Link: https://msgid.link/r/20240402071213.11671-9-bastien.curutchet@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Bastien Curutchet and committed by
Mark Brown
eff21f5f 37e313cd

+23
+23
sound/soc/ti/davinci-i2s.c
··· 310 310 pcr = DAVINCI_MCBSP_PCR_FSRM | DAVINCI_MCBSP_PCR_FSXM; 311 311 pcr |= DAVINCI_MCBSP_PCR_SCLKME; 312 312 break; 313 + case SND_SOC_DAIFMT_BP_FC: 314 + /* cpu is bitclock provider */ 315 + pcr = DAVINCI_MCBSP_PCR_CLKXM | 316 + DAVINCI_MCBSP_PCR_CLKRM; 317 + break; 318 + 313 319 case SND_SOC_DAIFMT_BC_FC: 314 320 if (dev->tdm_slots || dev->slot_width) { 315 321 dev_err(dev->dev, "TDM is not supported for BC_FC format\n"); ··· 503 497 clk_div = dev->clk_div - 1; 504 498 srgr |= DAVINCI_MCBSP_SRGR_FWID(mcbsp_word_length * 8 - 1); 505 499 srgr |= DAVINCI_MCBSP_SRGR_FPER(mcbsp_word_length * 16 - 1); 500 + clk_div &= 0xFF; 501 + srgr |= clk_div; 502 + break; 503 + case SND_SOC_DAIFMT_BP_FC: 504 + if (dev->ext_clk) { 505 + freq = clk_get_rate(dev->ext_clk); 506 + } else { 507 + freq = clk_get_rate(dev->clk); 508 + srgr = DAVINCI_MCBSP_SRGR_CLKSM; 509 + } 510 + if (dev->tdm_slots && dev->slot_width) { 511 + clk_div = freq / (params->rate_num * params->rate_den) 512 + / (dev->tdm_slots * dev->slot_width) - 1; 513 + } else { 514 + clk_div = freq / (mcbsp_word_length * 16) / 515 + params->rate_num * params->rate_den; 516 + } 506 517 clk_div &= 0xFF; 507 518 srgr |= clk_div; 508 519 break;