Prechádzať zdrojové kódy

soc: swr-mstr-ctrl: disable pcm out/in when all ports are disabled

PCM_DP_OUT/IN enable bit are used for any data_port which supports
word_length larger than 8. Disable these two bits only when all
the ports are disabled.

Change-Id: I2c65e7658bf90ae01203ebb1b15f14db581ffa55
Signed-off-by: Meng Wang <[email protected]>
Meng Wang 3 rokov pred
rodič
commit
2b2d743455
2 zmenil súbory, kde vykonal 15 pridanie a 4 odobranie
  1. 14 4
      soc/swr-mstr-ctrl.c
  2. 1 0
      soc/swr-mstr-ctrl.h

+ 14 - 4
soc/swr-mstr-ctrl.c

@@ -800,9 +800,19 @@ static int swrm_pcm_port_config(struct swr_mstr_ctrl *swrm, u8 port_num,
 	reg_addr = ((dir) ? SWRM_DIN_DP_PCM_PORT_CTRL(port_num) : \
 			SWRM_DOUT_DP_PCM_PORT_CTRL(port_num));
 	reg_val = enable ? 0x3 : 0x0;
-	swr_master_write(swrm, reg_addr, reg_val);
-	dev_dbg(swrm->dev, "%s : pcm port %s, reg_val = %d, for addr %x\n",
-			__func__, enable ? "Enabled" : "disabled", reg_val, reg_addr);
+	if (enable) {
+		if (swrm->pcm_enable_count == 0)
+			swr_master_write(swrm, reg_addr, reg_val);
+		swrm->pcm_enable_count++;
+	} else {
+		if (swrm->pcm_enable_count > 0)
+			swrm->pcm_enable_count--;
+		if (swrm->pcm_enable_count == 0)
+			swr_master_write(swrm, reg_addr, reg_val);
+	}
+	dev_dbg(swrm->dev, "%s : pcm port %s, reg_val = %d, for addr %x, pcm_enable_cnt:%d\n",
+			__func__, enable ? "Enabled" : "disabled", reg_val, reg_addr,
+			swrm->pcm_enable_count);
 	return 0;
 }
 
@@ -2836,7 +2846,7 @@ static int swrm_probe(struct platform_device *pdev)
 		dev_err(swrm->dev, "missing port mapping\n");
 		goto err_pdata_fail;
 	}
-
+	swrm->pcm_enable_count = 0;
 	map_length = map_size / (3 * sizeof(u32));
 	if (num_ports > SWR_MSTR_PORT_LEN) {
 		dev_err(&pdev->dev, "%s:invalid number of swr ports\n",

+ 1 - 0
soc/swr-mstr-ctrl.h

@@ -185,6 +185,7 @@ struct swr_mstr_ctrl {
 	struct clk *lpass_core_hw_vote;
 	struct clk *lpass_core_audio;
 	u8 num_usecase;
+	u32 pcm_enable_count;
 	u32 swr_irq_wakeup_capable;
 	int hw_core_clk_en;
 	int aud_core_clk_en;