Received: by 2002:ac8:6d01:0:b0:423:7e07:f8e4 with SMTP id o1csp6635540qtt; Mon, 18 Dec 2023 02:15:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHM9shjS/Dj6ClHcgNzk3+mGkuMlzvLT0MD8NaVCjCg5U/iANk9PgZwNcUp7Ha1yvD27Meq X-Received: by 2002:a05:6358:5406:b0:172:e5d2:c312 with SMTP id u6-20020a056358540600b00172e5d2c312mr127671rwe.39.1702894523856; Mon, 18 Dec 2023 02:15:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702894523; cv=none; d=google.com; s=arc-20160816; b=HukC9JQGyxA32n6PKF78/Bhr0VaIhMkJielY2x8aVASL2VfB5O0TrAfkzdYefccpY4 ZV5iMJfnO2er6CNkDoeXbJcGU6z9vy54OJTjYXI2egyRPFQD1LEXDUkXQWhloBqGlVjL v2aN6ZeBGpp44ZdaNufxANbQHag3qG3LA3yR/f3Z0Njzr1qPDnoU9Dl+RAuZGVygFufr Jvcf1vix1WZXp4TPH61jvMHpYWWkqNdQsBLhdf5LIf/iniI8ROcZltbmDdaR3l8fQv9Z QpWU80HUV1Ivc0lh6t4XS1qSmZ7pYB3bCn6fk3zxnbH30QSLXzwG/dY9QOF08B8e7YqF 00Pw== 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=svnR3WkPA1b7i7vFRRQxHgzMUxWRj8zL8rLfY/s15FE=; fh=7R52BhHPm7zGb3JLJx+XW19T6EjLySf5VrXJfOQiNak=; b=zv4JS0ucpPp/iRLRmLxFzqs+Wwj6jm1TjJPgHoTd+v5prC33meZ74nhB77XYB2MEme FgLnHegK0uliOpsVzNqwRLiNhe6vPachZ8f1ly/MQMuCEWppQ+lviRlW/JGmntqd+VeL X1z5WEmWP4Az2UPJ4zUU6PoZnohIa6yDsRgFIBxay1AMEhzQdCJLYFYye06Prb/LiISx uQpmONV1Y5qyjtbDpHlR5jYOT77TtuHE8GtsJ5UEt6x9mcqGeZwHcD6PeqbuWQZuA3qC uh9lSnIfLVDMq0MOT41u0dSUT7YxfkJOjk9i+NMAKkwJHsSkx7uHFqorYt4jvKQS90xS e3iQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-3309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z14-20020a63c04e000000b005c6b4e4abe2si17753058pgi.169.2023.12.18.02.15.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 02:15:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-3309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3309-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E97ECB20ABE for ; Mon, 18 Dec 2023 10:15:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 313B913AC7; Mon, 18 Dec 2023 10:15:16 +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 2AE4B14F7C; Mon, 18 Dec 2023 10:15:13 +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 268B62012CB; Mon, 18 Dec 2023 11:10:01 +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 8C3F22012D6; Mon, 18 Dec 2023 11:10:00 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id DA6B6181D0C0; Mon, 18 Dec 2023 18:09:58 +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] ASoC: fsl_sai: Fix channel swap issue on i.MX8MP Date: Mon, 18 Dec 2023 17:28:51 +0800 Message-Id: <1702891731-3417-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. Signed-off-by: Shengjiu Wang --- 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