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

Commit 908583ff authored by Vatsal Bucha's avatar Vatsal Bucha Committed by Gerrit - the friendly Code Review server
Browse files

soc: swr-mstr: Fix random headset detection issue on scuba



When headset is inserted and reboot device sometimes
headset is not detected after reboot as host_irq from
swr slave gets masked. This is because of cmd error seen
after clearing all irq which results in fifo flush.
Read swrslave irq before clearing so as to resolve cmd error.
Also enable slave irq only after clearing enum interrupt at
master which results in proper enabling of irq.

Change-Id: Id66029c65c4d813391bfeb8c0c619560f298eeab
Signed-off-by: default avatarVatsal Bucha <vbucha@codeaurora.org>
parent 08747bef
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -1744,6 +1744,7 @@ static void swrm_enable_slave_irq(struct swr_mstr_ctrl *swrm)
{
{
	int i;
	int i;
	int status = 0;
	int status = 0;
	u32 temp;


	status = swr_master_read(swrm, SWRM_MCP_SLV_STATUS);
	status = swr_master_read(swrm, SWRM_MCP_SLV_STATUS);
	if (!status) {
	if (!status) {
@@ -1754,6 +1755,8 @@ static void swrm_enable_slave_irq(struct swr_mstr_ctrl *swrm)
	dev_dbg(swrm->dev, "%s: slave status: 0x%x\n", __func__, status);
	dev_dbg(swrm->dev, "%s: slave status: 0x%x\n", __func__, status);
	for (i = 0; i < (swrm->master.num_dev + 1); i++) {
	for (i = 0; i < (swrm->master.num_dev + 1); i++) {
		if (status & SWRM_MCP_SLV_STATUS_MASK) {
		if (status & SWRM_MCP_SLV_STATUS_MASK) {
			swrm_cmd_fifo_rd_cmd(swrm, &temp, i, 0x0,
					SWRS_SCP_INT_STATUS_CLEAR_1, 1);
			swrm_cmd_fifo_wr_cmd(swrm, 0xFF, i, 0x0,
			swrm_cmd_fifo_wr_cmd(swrm, 0xFF, i, 0x0,
					SWRS_SCP_INT_STATUS_CLEAR_1);
					SWRS_SCP_INT_STATUS_CLEAR_1);
			swrm_cmd_fifo_wr_cmd(swrm, 0x4, i, 0x0,
			swrm_cmd_fifo_wr_cmd(swrm, 0x4, i, 0x0,
@@ -2069,10 +2072,7 @@ static irqreturn_t swr_mstr_interrupt_v2(int irq, void *dev)
					 * as hw will mask host_irq at slave
					 * as hw will mask host_irq at slave
					 * but will not unmask it afterwards.
					 * but will not unmask it afterwards.
					 */
					 */
					swrm_cmd_fifo_wr_cmd(swrm, 0xFF, devnum, 0x0,
					swrm->enable_slave_irq = true;
						SWRS_SCP_INT_STATUS_CLEAR_1);
					swrm_cmd_fifo_wr_cmd(swrm, 0x4, devnum, 0x0,
						SWRS_SCP_INT_STATUS_MASK_1);
				}
				}
				break;
				break;
			case SWR_ATTACHED_OK:
			case SWR_ATTACHED_OK:
@@ -2080,11 +2080,7 @@ static irqreturn_t swr_mstr_interrupt_v2(int irq, void *dev)
					"%s: device %d got attached\n",
					"%s: device %d got attached\n",
					__func__, devnum);
					__func__, devnum);
				/* enable host irq from slave device*/
				/* enable host irq from slave device*/
				swrm_cmd_fifo_wr_cmd(swrm, 0xFF, devnum, 0x0,
				swrm->enable_slave_irq = true;
					SWRS_SCP_INT_STATUS_CLEAR_1);
				swrm_cmd_fifo_wr_cmd(swrm, 0x4, devnum, 0x0,
					SWRS_SCP_INT_STATUS_MASK_1);

				break;
				break;
			case SWR_ALERT:
			case SWR_ALERT:
				dev_dbg(swrm->dev,
				dev_dbg(swrm->dev,
@@ -2187,6 +2183,12 @@ static irqreturn_t swr_mstr_interrupt_v2(int irq, void *dev)
	swr_master_write(swrm, SWRM_INTERRUPT_CLEAR, intr_sts);
	swr_master_write(swrm, SWRM_INTERRUPT_CLEAR, intr_sts);
	swr_master_write(swrm, SWRM_INTERRUPT_CLEAR, 0x0);
	swr_master_write(swrm, SWRM_INTERRUPT_CLEAR, 0x0);


	if (swrm->enable_slave_irq) {
		/* Enable slave irq here */
		swrm_enable_slave_irq(swrm);
		swrm->enable_slave_irq = false;
	}

	intr_sts = swr_master_read(swrm, SWRM_INTERRUPT_STATUS);
	intr_sts = swr_master_read(swrm, SWRM_INTERRUPT_STATUS);
	intr_sts_masked = intr_sts & swrm->intr_mask;
	intr_sts_masked = intr_sts & swrm->intr_mask;


+1 −0
Original line number Original line Diff line number Diff line
@@ -184,6 +184,7 @@ struct swr_mstr_ctrl {
	u32 disable_div2_clk_switch;
	u32 disable_div2_clk_switch;
	u32 rd_fifo_depth;
	u32 rd_fifo_depth;
	u32 wr_fifo_depth;
	u32 wr_fifo_depth;
	bool enable_slave_irq;
#ifdef CONFIG_DEBUG_FS
#ifdef CONFIG_DEBUG_FS
	struct dentry *debugfs_swrm_dent;
	struct dentry *debugfs_swrm_dent;
	struct dentry *debugfs_peek;
	struct dentry *debugfs_peek;