From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC0B7C433DF for ; Mon, 3 Aug 2020 05:41:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 369F1206E2 for ; Mon, 3 Aug 2020 05:41:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="GfabT20C"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K186TuiU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 369F1206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3882B1657; Mon, 3 Aug 2020 07:41:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3882B1657 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1596433314; bh=ASwIW8Y65N21eQHyWXKJPpkl/HLpoVkJnsfB0pxQHnU=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GfabT20CIMWD+N30286jzetApkxPhcgxrfwfdryBXPAI4o7g8KvMjA4zSplcmClnf Yi48iX1GtP0T/G+2xwYqNqfIt8MLwKGpVES9cdpD/EFI9GmqLtL4ldwYR2HVm1o3vX y2FAW+WFQvmvJAJZGmPKsBUOdDY6qWyURr4J2ccg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B0CA7F801F7; Mon, 3 Aug 2020 07:41:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8BF07F80218; Mon, 3 Aug 2020 07:41:01 +0200 (CEST) Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A69C1F80148 for ; Mon, 3 Aug 2020 07:40:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A69C1F80148 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K186TuiU" Received: by mail-pf1-x444.google.com with SMTP id j20so17575458pfe.5 for ; Sun, 02 Aug 2020 22:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FhbpD1GOOiuI1h2KLYGhIc+Q4nrSHyP4h81W7KBJFqA=; b=K186TuiUMKQPdqAxCXhqtmALF9pZVrrem7PSJKHN2TVp6X/DGU7ghf9/BJMgBlUhh9 jS5/KukDzLHwp2Tdh4NSv/i8naoGe9A3lUIZtoYE8DaWtRKIWGLC17qgWRsBuZ3JbkXD oI8zW7cC4xb3BZI+vs/9AmJvJY9r0ii6/sp00L/jDAKIi60G5674s+5a07y3LVR+IYv+ deXVnc3aHNRNX7yQY4FFTNiSAUxBcTIDHNsWd3W3SkG+OiQQgnX8qlAqr3PJu9juma9t ZOSyPHOQaDxAdPbVnDMa/p63b0pwNeNG3aWsDaeHmhNXIVHXLUvlwT1LaFoiZtLXcwQy s+PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FhbpD1GOOiuI1h2KLYGhIc+Q4nrSHyP4h81W7KBJFqA=; b=fB2dd3eT7vpmA+4GjGKCJQyhcf+vzGJ2b5Vlstdy8O/GfuFrAsGs4mrz/49cukcNtf f0voE+uHDHok09VUh4OComLkwfTN6JOGrHzSjWKPPLPp1j2+QpjwCbNhU1c6OcFZ3NNY CwowBuFWHRoCVYWJ2yKTmypoSiaJ4bMh2AEwqkbkpKXQSlyAu97XAI4tTfr4mroLqtqc YFHWzBrCHzI7t6dzvP5k/ScNLRJBbFMD85lDDPdmHy5CMmyrg+I4bbbEwsQep08tzy1f KS1ZNypjUR9+O64c3G5eDLkPKlJuuvRH4jCjIeU0tx8xxbjoZe+8aUf6+P+Mg4Y6jOhb mBHw== X-Gm-Message-State: AOAM533YJCDIOlZjyAwDGOk16bR+83qutY8z4mt3HGrmYUPz5BANazfF /9lv0GSZ18Zs574xeOM8p8g= X-Google-Smtp-Source: ABdhPJwtNZAtl8+czzRAcH8w3sZ9OYQlR+w7v7GG79nlmxqjy27pa7NblOV/FHvTJ6hTl+lyzxlnOg== X-Received: by 2002:a63:444b:: with SMTP id t11mr13955435pgk.134.1596433249969; Sun, 02 Aug 2020 22:40:49 -0700 (PDT) Received: from Asurada-Nvidia (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id m190sm16926096pfm.89.2020.08.02.22.40.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Aug 2020 22:40:49 -0700 (PDT) Date: Sun, 2 Aug 2020 22:40:37 -0700 From: Nicolin Chen To: Shengjiu Wang Subject: Re: [PATCH] ASoC: fsl_sai: Clean code for synchronize mode Message-ID: <20200803054037.GA1056@Asurada-Nvidia> References: <1596424674-32127-1-git-send-email-shengjiu.wang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1596424674-32127-1-git-send-email-shengjiu.wang@nxp.com> User-Agent: Mutt/1.9.4 (2018-02-28) Cc: alsa-devel@alsa-project.org, timur@kernel.org, Xiubo.Lee@gmail.com, linuxppc-dev@lists.ozlabs.org, tiwai@suse.com, lgirdwood@gmail.com, broonie@kernel.org, festevam@gmail.com, linux-kernel@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Mon, Aug 03, 2020 at 11:17:54AM +0800, Shengjiu Wang wrote: > TX synchronous with RX: The RMR is no need to be changed when > Tx is enabled, the other configuration in hw_params() is enough for Probably you should explain why RMR can be removed, like what it really does so as to make it clear that there's no such a relationship between RMR and clock generating. Anyway, this is against the warning comments in the driver: /* * For SAI master mode, when Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will * generate bclk and frame clock for Tx(Rx), we should set RCR4(TCR4), * RCR5(TCR5) and RMR(TMR) for playback(capture), or there will be sync * error. */ So would need to update it. > clock generation. The TCSR.TE is no need to enabled when only RX > is enabled. You are correct if there's only RX running without TX joining. However, that's something we can't guarantee. Then we'd enable TE after RE is enabled, which is against what RM recommends: # From 54.3.3.1 Synchronous mode in IMX6SXRM # If the receiver bit clock and frame sync are to be used by # both the transmitter and receiver, it is recommended that # the receiver is the last enabled and the first disabled. I remember I did this "ugly" design by strictly following what RM says. If hardware team has updated the RM or removed this limitation, please quote in the commit logs. > + if (!sai->synchronous[TX] && sai->synchronous[RX] && !tx) { > + regmap_update_bits(sai->regmap, FSL_SAI_xCSR((!tx), ofs), > + FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); > + } else if (!sai->synchronous[RX] && sai->synchronous[TX] && tx) { > + regmap_update_bits(sai->regmap, FSL_SAI_xCSR((!tx), ofs), > + FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); Two identical regmap_update_bits calls -- both on !tx (RX?) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 887C3C433DF for ; Mon, 3 Aug 2020 05:42:20 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B1D2206E2 for ; Mon, 3 Aug 2020 05:42:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K186TuiU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B1D2206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BKmx66SvRzDqPC for ; Mon, 3 Aug 2020 15:42:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=nicoleotsuka@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=K186TuiU; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BKmvS2vHNzDqGJ for ; Mon, 3 Aug 2020 15:40:52 +1000 (AEST) Received: by mail-pf1-x442.google.com with SMTP id f193so7166760pfa.12 for ; Sun, 02 Aug 2020 22:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FhbpD1GOOiuI1h2KLYGhIc+Q4nrSHyP4h81W7KBJFqA=; b=K186TuiUMKQPdqAxCXhqtmALF9pZVrrem7PSJKHN2TVp6X/DGU7ghf9/BJMgBlUhh9 jS5/KukDzLHwp2Tdh4NSv/i8naoGe9A3lUIZtoYE8DaWtRKIWGLC17qgWRsBuZ3JbkXD oI8zW7cC4xb3BZI+vs/9AmJvJY9r0ii6/sp00L/jDAKIi60G5674s+5a07y3LVR+IYv+ deXVnc3aHNRNX7yQY4FFTNiSAUxBcTIDHNsWd3W3SkG+OiQQgnX8qlAqr3PJu9juma9t ZOSyPHOQaDxAdPbVnDMa/p63b0pwNeNG3aWsDaeHmhNXIVHXLUvlwT1LaFoiZtLXcwQy s+PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FhbpD1GOOiuI1h2KLYGhIc+Q4nrSHyP4h81W7KBJFqA=; b=bgkwPnrNi5EaI20jH6muLuxLk1Q7entvK6uFMsGk9RZPsJEJds1umogPrNCx3FxsML kDyJ9UOKqKhx+rLWQfrdZP8EI7HcGg99I+wQJoppRK2DcWw2gnEVHsBXn7ns/N8iR/iw ai6AKmtGXhOy5qzTK/0joFOpQroLLJrBEO2/GxNDaUDO1hdhAAW7R8g7oVR+JV2qIvgB ccgdLDO+uYhfL63wfBlszqyYIf5izZOijKigXos2B2Wng9KFJrvNV1uNqekePGIeRvAl ejUmsY66jFRhfQE4iUkGLDqznAvX4pUMXJt1UdbixQFqzkOV51TBGwnXQ9w68xrGaZlf wqcQ== X-Gm-Message-State: AOAM530V1MrTHLWOFsdjYSaN1aCrd0e46kTX3JTVJyx+QuE7h04zT1kZ 9pQ1zK26ERrG8L7TeuXcz/DI8oxzZbYUWg== X-Google-Smtp-Source: ABdhPJwtNZAtl8+czzRAcH8w3sZ9OYQlR+w7v7GG79nlmxqjy27pa7NblOV/FHvTJ6hTl+lyzxlnOg== X-Received: by 2002:a63:444b:: with SMTP id t11mr13955435pgk.134.1596433249969; Sun, 02 Aug 2020 22:40:49 -0700 (PDT) Received: from Asurada-Nvidia (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id m190sm16926096pfm.89.2020.08.02.22.40.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Aug 2020 22:40:49 -0700 (PDT) Date: Sun, 2 Aug 2020 22:40:37 -0700 From: Nicolin Chen To: Shengjiu Wang Subject: Re: [PATCH] ASoC: fsl_sai: Clean code for synchronize mode Message-ID: <20200803054037.GA1056@Asurada-Nvidia> References: <1596424674-32127-1-git-send-email-shengjiu.wang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1596424674-32127-1-git-send-email-shengjiu.wang@nxp.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, timur@kernel.org, Xiubo.Lee@gmail.com, linuxppc-dev@lists.ozlabs.org, tiwai@suse.com, lgirdwood@gmail.com, perex@perex.cz, broonie@kernel.org, festevam@gmail.com, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, Aug 03, 2020 at 11:17:54AM +0800, Shengjiu Wang wrote: > TX synchronous with RX: The RMR is no need to be changed when > Tx is enabled, the other configuration in hw_params() is enough for Probably you should explain why RMR can be removed, like what it really does so as to make it clear that there's no such a relationship between RMR and clock generating. Anyway, this is against the warning comments in the driver: /* * For SAI master mode, when Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will * generate bclk and frame clock for Tx(Rx), we should set RCR4(TCR4), * RCR5(TCR5) and RMR(TMR) for playback(capture), or there will be sync * error. */ So would need to update it. > clock generation. The TCSR.TE is no need to enabled when only RX > is enabled. You are correct if there's only RX running without TX joining. However, that's something we can't guarantee. Then we'd enable TE after RE is enabled, which is against what RM recommends: # From 54.3.3.1 Synchronous mode in IMX6SXRM # If the receiver bit clock and frame sync are to be used by # both the transmitter and receiver, it is recommended that # the receiver is the last enabled and the first disabled. I remember I did this "ugly" design by strictly following what RM says. If hardware team has updated the RM or removed this limitation, please quote in the commit logs. > + if (!sai->synchronous[TX] && sai->synchronous[RX] && !tx) { > + regmap_update_bits(sai->regmap, FSL_SAI_xCSR((!tx), ofs), > + FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); > + } else if (!sai->synchronous[RX] && sai->synchronous[TX] && tx) { > + regmap_update_bits(sai->regmap, FSL_SAI_xCSR((!tx), ofs), > + FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); Two identical regmap_update_bits calls -- both on !tx (RX?) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF27CC433DF for ; Mon, 3 Aug 2020 05:40:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7485206F6 for ; Mon, 3 Aug 2020 05:40:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K186TuiU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728139AbgHCFkv (ORCPT ); Mon, 3 Aug 2020 01:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727015AbgHCFku (ORCPT ); Mon, 3 Aug 2020 01:40:50 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81AFDC06174A for ; Sun, 2 Aug 2020 22:40:50 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id d188so11524042pfd.2 for ; Sun, 02 Aug 2020 22:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FhbpD1GOOiuI1h2KLYGhIc+Q4nrSHyP4h81W7KBJFqA=; b=K186TuiUMKQPdqAxCXhqtmALF9pZVrrem7PSJKHN2TVp6X/DGU7ghf9/BJMgBlUhh9 jS5/KukDzLHwp2Tdh4NSv/i8naoGe9A3lUIZtoYE8DaWtRKIWGLC17qgWRsBuZ3JbkXD oI8zW7cC4xb3BZI+vs/9AmJvJY9r0ii6/sp00L/jDAKIi60G5674s+5a07y3LVR+IYv+ deXVnc3aHNRNX7yQY4FFTNiSAUxBcTIDHNsWd3W3SkG+OiQQgnX8qlAqr3PJu9juma9t ZOSyPHOQaDxAdPbVnDMa/p63b0pwNeNG3aWsDaeHmhNXIVHXLUvlwT1LaFoiZtLXcwQy s+PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FhbpD1GOOiuI1h2KLYGhIc+Q4nrSHyP4h81W7KBJFqA=; b=ibi0h9nFxXnXr0aquNnVM1+kJHMiS2IHzZJtM0jPrnzO0/vNUJB60U1aEES3T6KSLf 4Af23xJhG2O96p0lIRhKtdjUpXN2+LJJlKJqL6TpBucydrY2i4jCJOepUoCINV/wBWTk TH51w0gx+uDxEOMhchs5beF8Ob+isV3GVnfcZ6tx/f4ZSORDn5d9Kao1owm2incFzqJM mbgqkgkxGcd1ucAm/I5+Dryk6KQftGrGJQPuFKH2XwM3ngfxDmj+2FOp/Y9IyOEsJkwv 48LEbBGAj1p/evepzCgH25/FYweH1/SR/gX5rF4zRoZW5VJvau44LzZvhQL12W3vwnN+ zi/Q== X-Gm-Message-State: AOAM530ogVtIHnNgNRQivEFmz3h8ZuRWLv/JJxD5lymmnfn76Ns2KkCx +QvtiqX4Kd8XaB5Y6alBPMQ= X-Google-Smtp-Source: ABdhPJwtNZAtl8+czzRAcH8w3sZ9OYQlR+w7v7GG79nlmxqjy27pa7NblOV/FHvTJ6hTl+lyzxlnOg== X-Received: by 2002:a63:444b:: with SMTP id t11mr13955435pgk.134.1596433249969; Sun, 02 Aug 2020 22:40:49 -0700 (PDT) Received: from Asurada-Nvidia (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id m190sm16926096pfm.89.2020.08.02.22.40.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Aug 2020 22:40:49 -0700 (PDT) Date: Sun, 2 Aug 2020 22:40:37 -0700 From: Nicolin Chen To: Shengjiu Wang Cc: timur@kernel.org, Xiubo.Lee@gmail.com, festevam@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 Subject: Re: [PATCH] ASoC: fsl_sai: Clean code for synchronize mode Message-ID: <20200803054037.GA1056@Asurada-Nvidia> References: <1596424674-32127-1-git-send-email-shengjiu.wang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1596424674-32127-1-git-send-email-shengjiu.wang@nxp.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 03, 2020 at 11:17:54AM +0800, Shengjiu Wang wrote: > TX synchronous with RX: The RMR is no need to be changed when > Tx is enabled, the other configuration in hw_params() is enough for Probably you should explain why RMR can be removed, like what it really does so as to make it clear that there's no such a relationship between RMR and clock generating. Anyway, this is against the warning comments in the driver: /* * For SAI master mode, when Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will * generate bclk and frame clock for Tx(Rx), we should set RCR4(TCR4), * RCR5(TCR5) and RMR(TMR) for playback(capture), or there will be sync * error. */ So would need to update it. > clock generation. The TCSR.TE is no need to enabled when only RX > is enabled. You are correct if there's only RX running without TX joining. However, that's something we can't guarantee. Then we'd enable TE after RE is enabled, which is against what RM recommends: # From 54.3.3.1 Synchronous mode in IMX6SXRM # If the receiver bit clock and frame sync are to be used by # both the transmitter and receiver, it is recommended that # the receiver is the last enabled and the first disabled. I remember I did this "ugly" design by strictly following what RM says. If hardware team has updated the RM or removed this limitation, please quote in the commit logs. > + if (!sai->synchronous[TX] && sai->synchronous[RX] && !tx) { > + regmap_update_bits(sai->regmap, FSL_SAI_xCSR((!tx), ofs), > + FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); > + } else if (!sai->synchronous[RX] && sai->synchronous[TX] && tx) { > + regmap_update_bits(sai->regmap, FSL_SAI_xCSR((!tx), ofs), > + FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); Two identical regmap_update_bits calls -- both on !tx (RX?)