asoc: wsa88XX: Enable/Disable swr ports based on setbit.

During some concurrencies even though we are not
enabling the swrm port, we are trying to disable it.
which causes problem w.r.t clock disablement,
To avoid that we are updating the set bit only
when port is enabled, based on that bit we are taking
decision to disable or enable the port.

Change-Id: I6707c56c40dd3716917edc097c4b7bcad68261fd
Signed-off-by: Ganapathiraju Sarath Varma <quic_ganavarm@quicinc.com>
This commit is contained in:
Ganapathiraju Sarath Varma
2023-04-04 22:18:14 +05:30
szülő 4b8497c773
commit 7f605534e2
4 fájl változott, egészen pontosan 43 új sor hozzáadva és 8 régi sor törölve

Fájl megtekintése

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
@@ -166,6 +167,11 @@ enum {
WSA883X_NUM_IRQS,
};
enum {
COMP_PORT_EN_STATUS_BIT = 0,
VISENSE_EN_STATUS_BIT,
};
static const struct regmap_irq wsa883x_irqs[WSA883X_NUM_IRQS] = {
REGMAP_IRQ_REG(WSA883X_IRQ_INT_SAF2WAR, 0, 0x01),
REGMAP_IRQ_REG(WSA883X_IRQ_INT_WAR2SAF, 0, 0x02),
@@ -1081,6 +1087,7 @@ static int wsa883x_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
&ch_mask[num_port], &ch_rate[num_port],
&port_type[num_port]);
++num_port;
set_bit(COMP_PORT_EN_STATUS_BIT, &wsa883x->port_status_mask);
}
if (wsa883x->visense_enable) {
wsa883x_set_port(component, SWR_VISENSE_PORT,
@@ -1088,6 +1095,7 @@ static int wsa883x_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
&ch_mask[num_port], &ch_rate[num_port],
&port_type[num_port]);
++num_port;
set_bit(VISENSE_EN_STATUS_BIT, &wsa883x->port_status_mask);
}
swr_connect_port(wsa883x->swr_slave, &port_id[0], num_port,
&ch_mask[0], &ch_rate[0], &num_ch[0],
@@ -1103,19 +1111,23 @@ static int wsa883x_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
&port_type[num_port]);
++num_port;
if (wsa883x->comp_enable) {
if (wsa883x->comp_enable &&
test_bit(COMP_PORT_EN_STATUS_BIT, &wsa883x->port_status_mask)) {
wsa883x_set_port(component, SWR_COMP_PORT,
&port_id[num_port], &num_ch[num_port],
&ch_mask[num_port], &ch_rate[num_port],
&port_type[num_port]);
++num_port;
clear_bit(COMP_PORT_EN_STATUS_BIT, &wsa883x->port_status_mask);
}
if (wsa883x->visense_enable) {
if (wsa883x->visense_enable &&
test_bit(VISENSE_EN_STATUS_BIT, &wsa883x->port_status_mask)) {
wsa883x_set_port(component, SWR_VISENSE_PORT,
&port_id[num_port], &num_ch[num_port],
&ch_mask[num_port], &ch_rate[num_port],
&port_type[num_port]);
++num_port;
clear_bit(VISENSE_EN_STATUS_BIT, &wsa883x->port_status_mask);
}
swr_disconnect_port(wsa883x->swr_slave, &port_id[0], num_port,
&ch_mask[0], &port_type[0]);
@@ -1180,7 +1192,8 @@ static int wsa883x_spkr_event(struct snd_soc_dapm_widget *w,
/* Force remove group */
swr_remove_from_group(wsa883x->swr_slave,
wsa883x->swr_slave->dev_num);
if (wsa883x->comp_enable)
if (wsa883x->comp_enable &&
test_bit(COMP_PORT_EN_STATUS_BIT, &wsa883x->port_status_mask))
snd_soc_component_update_bits(component,
WSA883X_DRE_CTL_0,
0x07,
@@ -1612,7 +1625,8 @@ static int wsa883x_event_notify(struct notifier_block *nb,
WSA883X_IRQ_INT_PDM_WD);
/* Added delay as per HW sequence */
usleep_range(3000, 3100);
if (wsa883x->comp_enable) {
if (wsa883x->comp_enable &&
test_bit(COMP_PORT_EN_STATUS_BIT, &wsa883x->port_status_mask)) {
snd_soc_component_update_bits(wsa883x->component,
WSA883X_DRE_CTL_1,
0x01, 0x00);