Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2985411ybl; Sun, 11 Aug 2019 12:47:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGyxviJk8rhPd2LJ7XlPe/XPDfbHcpbpgHhMqcvnXKuuAiTg4nXkLnRqmDrK3zuppf4o0L X-Received: by 2002:a17:90a:974b:: with SMTP id i11mr19987455pjw.21.1565552840398; Sun, 11 Aug 2019 12:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565552840; cv=none; d=google.com; s=arc-20160816; b=dQ1huAktwJ6JN8yvLHjfrdE7PCXdGiyT80w4YmB3kCqoFwmPo5nc+BGDKos4YY8pXC 4dSQEo5A4IQiMZ9Hxf4+Prv5oKLct9yIQdS6rcwFcXMGGEM2F4tDqB5C/WnIgneUGDsk 2/89kYQvIpkEDxnSiSOvTy2fxZPRikpTeNkuIaVCNln/qsoloyHiYgUFeEaDwM4JGcBP bTolg4VR+1HORTUWMC8JEyVbG7zxTVx9epTfDmzB9xNi67xhMluVLxeSdb2PrSPwb9k9 aiS8912ggBBTsQrahW2oY+1CYK9F5QFw81zwFqYZjvV8lkKGKZ8JUrqQs8LnJYoADp84 x8Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=z1sHZre6pxBTqsAyIUbGjvI2C09WtXnYzNVoL11mrrY=; b=AfNeCK0krPLFrEUC/G6AE73ex4S+ukQJaVhZHZhAjlOdfw5xWRo/Rd8uVslH3xweXM x2lf5tajdEVSF7C9PPvNS1hjIoLXXrfGxzRhp4bV769lnna8YJ6ykqjcACEj3nK46J5F PbTrKpD5JYTqmBbyzYRxOHJokRVDgursNB1Oa/glcx7Xdd9EgSjJd/BaFiymD0t+ZKZX t3oIUoIfjjvzTmfFlm1P2GM5wKeodAJbZo7wLi9vsM7lKgHDfk+037t+P0IqGpCuM8RS D5CK1j1ouT7DINHt9c2B/V04P5wquZ8buohQVlKnpPQYz+dgwBv0mvtVANsiRp6YpAAO D/9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si50774615pgp.423.2019.08.11.12.46.53; Sun, 11 Aug 2019 12:47:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726452AbfHKTpW (ORCPT + 99 others); Sun, 11 Aug 2019 15:45:22 -0400 Received: from inva021.nxp.com ([92.121.34.21]:48396 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbfHKTpW (ORCPT ); Sun, 11 Aug 2019 15:45:22 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E6C6520010F; Sun, 11 Aug 2019 21:45:19 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id CFE9C20003D; Sun, 11 Aug 2019 21:45:19 +0200 (CEST) Received: from fsr-ub1864-103.ea.freescale.net (fsr-ub1864-103.ea.freescale.net [10.171.82.17]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 72AE520600; Sun, 11 Aug 2019 21:45:19 +0200 (CEST) From: Daniel Baluta To: nicoleotsuka@gmail.com, broonie@kernel.org Cc: festevam@gmail.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, Viorel Suman , Daniel Baluta Subject: [PATCH] ASoC: fsl_sai: Handle slave mode per TX/RX direction Date: Sun, 11 Aug 2019 22:45:17 +0300 Message-Id: <20190811194517.19314-1-daniel.baluta@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Viorel Suman The SAI interface can be a clock supplier or consumer as a function of stream direction. e.g SAI can be master for Tx and slave for Rx. Signed-off-by: Viorel Suman Signed-off-by: Daniel Baluta --- sound/soc/fsl/fsl_sai.c | 18 +++++++++--------- sound/soc/fsl/fsl_sai.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 4a346fcb5630..69cf3678c859 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -273,18 +273,18 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, case SND_SOC_DAIFMT_CBS_CFS: val_cr2 |= FSL_SAI_CR2_BCD_MSTR; val_cr4 |= FSL_SAI_CR4_FSD_MSTR; - sai->is_slave_mode = false; + sai->is_slave_mode[tx] = false; break; case SND_SOC_DAIFMT_CBM_CFM: - sai->is_slave_mode = true; + sai->is_slave_mode[tx] = true; break; case SND_SOC_DAIFMT_CBS_CFM: val_cr2 |= FSL_SAI_CR2_BCD_MSTR; - sai->is_slave_mode = false; + sai->is_slave_mode[tx] = false; break; case SND_SOC_DAIFMT_CBM_CFS: val_cr4 |= FSL_SAI_CR4_FSD_MSTR; - sai->is_slave_mode = true; + sai->is_slave_mode[tx] = true; break; default: return -EINVAL; @@ -326,7 +326,7 @@ static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq) int ret = 0; /* Don't apply to slave mode */ - if (sai->is_slave_mode) + if (sai->is_slave_mode[tx]) return 0; for (id = 0; id < FSL_SAI_MCLK_MAX; id++) { @@ -422,7 +422,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, if (sai->slot_width) slot_width = sai->slot_width; - if (!sai->is_slave_mode) { + if (!sai->is_slave_mode[tx]) { ret = fsl_sai_set_bclk(cpu_dai, tx, slots * slot_width * params_rate(params)); if (ret) @@ -458,7 +458,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, * error. */ - if (!sai->is_slave_mode) { + if (!sai->is_slave_mode[tx]) { if (!sai->synchronous[TX] && sai->synchronous[RX] && !tx) { regmap_update_bits(sai->regmap, FSL_SAI_TCR4(ofs), FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK, @@ -497,7 +497,7 @@ static int fsl_sai_hw_free(struct snd_pcm_substream *substream, struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - if (!sai->is_slave_mode && + if (!sai->is_slave_mode[tx] && sai->mclk_streams & BIT(substream->stream)) { clk_disable_unprepare(sai->mclk_clk[sai->mclk_id[tx]]); sai->mclk_streams &= ~BIT(substream->stream); @@ -581,7 +581,7 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, * This is a hardware bug, and will be fix in the * next sai version. */ - if (!sai->is_slave_mode) { + if (!sai->is_slave_mode[tx]) { /* Software Reset for both Tx and Rx */ regmap_write(sai->regmap, FSL_SAI_TCSR(ofs), FSL_SAI_CSR_SR); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index b89b0ca26053..c2c43a7d9ba1 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -167,7 +167,7 @@ struct fsl_sai { struct clk *bus_clk; struct clk *mclk_clk[FSL_SAI_MCLK_MAX]; - bool is_slave_mode; + bool is_slave_mode[2]; bool is_lsb_first; bool is_dsp_mode; bool synchronous[2]; -- 2.17.1