Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp252179rdh; Mon, 18 Dec 2023 19:12:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpcH9PplrEc6u5Le5PMpsHqY6W+3Ee76lGNGia4F9ptnW5J+pYDyn3nrDc4jEG0IvOXeNv X-Received: by 2002:a17:906:5191:b0:a23:718d:287a with SMTP id y17-20020a170906519100b00a23718d287amr487496ejk.37.1702955554835; Mon, 18 Dec 2023 19:12:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702955554; cv=none; d=google.com; s=arc-20160816; b=Q7inrawE+Hps7RHGLxeD4OhxIKipQDo5gi+6dKYPJYPed4w7VcLjYp9z8lEJaTLh3j hA3n406It2vFH8hWE+v5H134Lvb/CAdf7kTNxMVvel0TN67EBLhpn0WCPB6o8Av+Qprx YEPnVEDDnCWYPbhVAImZjWR0fx1rZvyG4M/IxpQqm6FBoZyjYhZb+96aDsMToRwwqn6r 82MYgraiVAH2HrEEbRhuI+90PaqUbBTGPFUw7unwfrIS3ZSKceD8x8rrxM8/ISSZxDL1 JOcbRwrZB3GG/vOQ/erwJpd79O7NVU47ZacnXARLFR9R1YL4DJKBM4XBuj5wqoyUFcNr TH7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:to:from; bh=b0XBqSCXsrQiuQfCBNvUplId+WnXzZb0zwtGtqg4+gU=; fh=7R52BhHPm7zGb3JLJx+XW19T6EjLySf5VrXJfOQiNak=; b=JtEGOqmjvl3lzWiMrD1Gof34TzmFEchvyBW7hnv6YZTI+PNrh2bpVEnrbfEQlBpSRD rXQ8n+TbmZISt9QrHgyo9c1l3aV6mZfXtH5v7rcRbFuB+AQa3Rn2rIxgAqWjdxYhYuP5 GsmZgdKj3p36OocUBAyijP/6A1gzriSTJaPd+l40lIaCufUH4qaU7gcg2YpJxqNo7spM UcPzm/sv1h7nWxXdQOrlkzmW+mqz5wOAAAhuSHsTAcM0NcwozqomLJHumJcpVcnm6p+m 0BsxxPClXCvruksdeXd5CKTpSOsxqzdXp7K7EoEI/6j/W3ZTaGnR09DJr5maqx3vJCeR WBgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4633-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4633-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lr2-20020a170906fb8200b00a1d991c3a06si6686222ejb.298.2023.12.18.19.12.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 19:12:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4633-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4633-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4633-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 895731F2420E for ; Tue, 19 Dec 2023 03:12:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C54475232; Tue, 19 Dec 2023 03:12:28 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9142881E; Tue, 19 Dec 2023 03:12:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 0AFCF200584; Tue, 19 Dec 2023 04:12:25 +0100 (CET) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id C653C2005A1; Tue, 19 Dec 2023 04:12:24 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 0423E1802201; Tue, 19 Dec 2023 11:12:22 +0800 (+08) From: Shengjiu Wang To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org Subject: [PATCH v2] ASoC: fsl_sai: Fix channel swap issue on i.MX8MP Date: Tue, 19 Dec 2023 10:30:57 +0800 Message-Id: <1702953057-4499-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: When flag mclk_with_tere and mclk_direction_output enabled, The SAI transmitter or receiver will be enabled in very early stage, that if FSL_SAI_xMR is set by previous case, for example previous case is one channel, current case is two channels, then current case started with wrong xMR in the beginning, then channel swap happen. The patch is to clear xMR in hw_free() to avoid such channel swap issue. Fixes: 3e4a82612998 ("ASoC: fsl_sai: MCLK bind with TX/RX enable bit") Signed-off-by: Shengjiu Wang --- changes in v2: - add fixes tag sound/soc/fsl/fsl_sai.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 32bbe5056a63..546bd4e333b5 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -714,6 +714,9 @@ static int fsl_sai_hw_free(struct snd_pcm_substream *substream, bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; unsigned int ofs = sai->soc_data->reg_offset; + /* Clear xMR to avoid channel swap with mclk_with_tere enabled case */ + regmap_write(sai->regmap, FSL_SAI_xMR(tx), 0); + regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx, ofs), FSL_SAI_CR3_TRCE_MASK, 0); -- 2.34.1