Skip to content

Commit e683cb0

Browse files
SenWang125broonie
authored andcommitted
ASoC: ti: davinci-mcasp: Disambiguate mcasp_is_synchronous function
The current mcasp_is_synchronous() function does more than what it proclaims, it also checks if McASP is a frame producer. Therefore split the original function into two separate ones and replace all occurrences with the new equivalent logic. Signed-off-by: Sen Wang <sen@ti.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com> Tested-by: Paresh Bhagat <p-bhagat@ti.com> Link: https://patch.msgid.link/20260203003703.2334443-3-sen@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f1ef70a commit e683cb0

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

sound/soc/ti/davinci-mcasp.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,16 @@ static void mcasp_set_ctl_reg(struct davinci_mcasp *mcasp, u32 ctl_reg, u32 val)
180180

181181
static bool mcasp_is_synchronous(struct davinci_mcasp *mcasp)
182182
{
183-
u32 rxfmctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG);
184183
u32 aclkxctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG);
185184

186-
return !(aclkxctl & TX_ASYNC) && rxfmctl & AFSRE;
185+
return !(aclkxctl & TX_ASYNC);
186+
}
187+
188+
static bool mcasp_is_frame_producer(struct davinci_mcasp *mcasp)
189+
{
190+
u32 rxfmctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG);
191+
192+
return rxfmctl & AFSRE;
187193
}
188194

189195
static inline void mcasp_set_clk_pdir(struct davinci_mcasp *mcasp, bool enable)
@@ -227,7 +233,7 @@ static void mcasp_start_rx(struct davinci_mcasp *mcasp)
227233
* synchronously from the transmit clock and frame sync. We need to make
228234
* sure that the TX signlas are enabled when starting reception.
229235
*/
230-
if (mcasp_is_synchronous(mcasp)) {
236+
if (mcasp_is_frame_producer(mcasp) && mcasp_is_synchronous(mcasp)) {
231237
mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST);
232238
mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST);
233239
mcasp_set_clk_pdir(mcasp, true);
@@ -240,7 +246,7 @@ static void mcasp_start_rx(struct davinci_mcasp *mcasp)
240246
mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXSMRST);
241247
/* Release Frame Sync generator */
242248
mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXFSRST);
243-
if (mcasp_is_synchronous(mcasp))
249+
if (mcasp_is_frame_producer(mcasp) && mcasp_is_synchronous(mcasp))
244250
mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXFSRST);
245251

246252
/* enable receive IRQs */
@@ -306,7 +312,7 @@ static void mcasp_stop_rx(struct davinci_mcasp *mcasp)
306312
* In synchronous mode stop the TX clocks if no other stream is
307313
* running
308314
*/
309-
if (mcasp_is_synchronous(mcasp) && !mcasp->streams) {
315+
if (mcasp_is_frame_producer(mcasp) && mcasp_is_synchronous(mcasp) && !mcasp->streams) {
310316
mcasp_set_clk_pdir(mcasp, false);
311317
mcasp_set_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, 0);
312318
}
@@ -333,7 +339,7 @@ static void mcasp_stop_tx(struct davinci_mcasp *mcasp)
333339
* In synchronous mode keep TX clocks running if the capture stream is
334340
* still running.
335341
*/
336-
if (mcasp_is_synchronous(mcasp) && mcasp->streams)
342+
if (mcasp_is_frame_producer(mcasp) && mcasp_is_synchronous(mcasp) && mcasp->streams)
337343
val = TXHCLKRST | TXCLKRST | TXFSRST;
338344
else
339345
mcasp_set_clk_pdir(mcasp, false);
@@ -1042,7 +1048,8 @@ static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream,
10421048
* not running already we need to configure the TX slots in
10431049
* order to have correct FSX on the bus
10441050
*/
1045-
if (mcasp_is_synchronous(mcasp) && !mcasp->channels)
1051+
if (mcasp_is_frame_producer(mcasp) && mcasp_is_synchronous(mcasp) &&
1052+
!mcasp->channels)
10461053
mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG,
10471054
FSXMOD(total_slots), FSXMOD(0x1FF));
10481055
}

0 commit comments

Comments
 (0)