Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 657e8556 authored by Karthikeyan Mani's avatar Karthikeyan Mani Committed by Gerrit - the friendly Code Review server
Browse files

drivers: swr-wcd-ctrl: Fix wsa mute at boot



Replace pm resume and suspend inside interrupt
with clk enable and disable. Add clk ref count
to not have the clk disabled when in use.

CRs-Fixed: 2079739
Change-Id: I8f7f6e8e3c7cf8fd176a708ba5171a98546db929
Signed-off-by: default avatarVatsal Bucha <vbucha@codeaurora.org>
parent 09a04dab
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -397,11 +397,17 @@ static int swrm_clk_request(struct swr_mstr_ctrl *swrm, bool enable)
		return -EINVAL;

	if (enable) {
		swrm->clk_ref_count++;
		if (swrm->clk_ref_count == 1) {
			swrm->clk(swrm->handle, true);
			swrm->state = SWR_MSTR_UP;
	} else {
		}
	} else if (--swrm->clk_ref_count == 0) {
		swrm->clk(swrm->handle, false);
		swrm->state = SWR_MSTR_DOWN;
	} else if (swrm->clk_ref_count < 0) {
		pr_err("%s: swrm clk count mismatch\n", __func__);
		swrm->clk_ref_count = 0;
	}
	return 0;
}
@@ -1169,7 +1175,10 @@ static irqreturn_t swr_mstr_interrupt(int irq, void *dev)
	u8 devnum = 0;
	int ret = IRQ_HANDLED;

	pm_runtime_get_sync(&swrm->pdev->dev);
	mutex_lock(&swrm->reslock);
	swrm_clk_request(swrm, true);
	mutex_unlock(&swrm->reslock);

	intr_sts = swrm->read(swrm->handle, SWRM_INTERRUPT_STATUS);
	intr_sts &= SWRM_INTERRUPT_STATUS_RMSK;
	for (i = 0; i < SWRM_INTERRUPT_MAX; i++) {
@@ -1257,8 +1266,10 @@ static irqreturn_t swr_mstr_interrupt(int irq, void *dev)
			break;
		}
	}
	pm_runtime_mark_last_busy(&swrm->pdev->dev);
	pm_runtime_put_autosuspend(&swrm->pdev->dev);

	mutex_lock(&swrm->reslock);
	swrm_clk_request(swrm, false);
	mutex_unlock(&swrm->reslock);
	return ret;
}

@@ -1448,6 +1459,7 @@ static int swrm_probe(struct platform_device *pdev)
	swrm->wcmd_id = 0;
	swrm->slave_status = 0;
	swrm->num_rx_chs = 0;
	swrm->clk_ref_count = 0;
	swrm->state = SWR_MSTR_RESUME;
	init_completion(&swrm->reset);
	init_completion(&swrm->broadcast);
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ struct swr_mstr_ctrl {
	struct device *dev;
	struct resource *supplies;
	struct clk *mclk;
	int clk_ref_count;
	struct completion reset;
	struct completion broadcast;
	struct mutex mlock;