Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2601846ybk; Tue, 12 May 2020 03:36:41 -0700 (PDT) X-Google-Smtp-Source: APiQypKdiHIa69084krSBxkmYDOg9GPFk9gEqL8Qwa1LaDudnKpqioTWlpfAImte8qRDNsyECGI+ X-Received: by 2002:a50:c60c:: with SMTP id k12mr16837138edg.111.1589279800627; Tue, 12 May 2020 03:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589279800; cv=none; d=google.com; s=arc-20160816; b=jiAwpdhYiX3xLXlSRyHl8Z3HerFUEOGC2aKDkpLESD1koXCzRlEtuRvk+M7kdOX8jx waE387Ijhl3fKllqNtxKoirWQ4aujuzxDZKhGVPUJOMPKT3hfTUVVTqMrcLPtKJrV7uj 79bwqOpT2GAEo9ZUtYsJq2ntW4XHH1VSbs8/nUEyYrucyQqON4xm6UopeDJ3HRQ9XXyc 2YCvA/2e4E0g19aG1ywIzcULFZov2WpZ63q3Ri4rEVZwYCghf+yRDzLOUAIcYnhikyVX GwrB9XMQS1LtnnHead18rdk3PN8KpVoqRB2t9TaINELX+chn0JHncFLe2KPB12IZ03KG H+9A== 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=jyaoBvj7xv9CH168NJ8yFGJTMyNoStXywvCXJF3x+oQ=; b=On6PVmKBd6Q6MyrpExY7l/gyKENRFqywa7YeIIPEcbjzLFiPicMWsMs1mRZV9F0lRJ KbaW0ilGugjCLINvl3aDMeoSczwLW+0kkIJiaN/P6EJ508k3b9Y6exphDMkWGAkknypQ 3e45d1fRo9bHV5MbcLvc7lu/Sdlr+P+iE1xuX/vENfxjzIehJOqAPVanfXcaoBQofbCd QKxnDm64UcXGguco8FyyDe5Atknv6ysNWVa2Rt9R9AOyFKwUZWf6M5I9hMYJZgJwsX4t eX83txf8G3f0QVPXNPQBa/UpmppwGKXRjYlmy0g2/6ExZfK+Ya1k/IjKiiRcPX7rYgKW fSPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id gj20si7179265ejb.48.2020.05.12.03.36.17; Tue, 12 May 2020 03:36:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729508AbgELKci (ORCPT + 99 others); Tue, 12 May 2020 06:32:38 -0400 Received: from inva021.nxp.com ([92.121.34.21]:51996 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729412AbgELKci (ORCPT ); Tue, 12 May 2020 06:32:38 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 72DE0200F2E; Tue, 12 May 2020 12:32:37 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E6ABC200F8B; Tue, 12 May 2020 12:32:32 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 0D4E9402BC; Tue, 12 May 2020 18:32:26 +0800 (SGT) From: Shengjiu Wang To: timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, broonie@kernel.org, alsa-devel@alsa-project.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: fsl_asrc: Set ASR76K and ASR56K based on processing clock Date: Tue, 12 May 2020 18:22:59 +0800 Message-Id: <1589278979-31008-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 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 The processing clock is different for platforms, so it is better to set ASR76K and ASR56K based on processing clock, rather than hard coding the value for them. Signed-off-by: Shengjiu Wang Signed-off-by: Mihai Serban --- sound/soc/fsl/fsl_asrc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 067a54ab554f..ca926915068f 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -858,6 +858,8 @@ static const struct regmap_config fsl_asrc_regmap_config = { */ static int fsl_asrc_init(struct fsl_asrc *asrc) { + unsigned long ipg_rate; + /* Halt ASRC internal FP when input FIFO needs data for pair A, B, C */ regmap_write(asrc->regmap, REG_ASRCTR, ASRCTR_ASRCEN); @@ -875,11 +877,14 @@ static int fsl_asrc_init(struct fsl_asrc *asrc) regmap_update_bits(asrc->regmap, REG_ASRTFR1, ASRTFR1_TF_BASE_MASK, ASRTFR1_TF_BASE(0xfc)); - /* Set the processing clock for 76KHz to 133M */ - regmap_write(asrc->regmap, REG_ASR76K, 0x06D6); - - /* Set the processing clock for 56KHz to 133M */ - return regmap_write(asrc->regmap, REG_ASR56K, 0x0947); + /* + * Set the period of the 76KHz and 56KHz sampling clocks based on + * the ASRC processing clock. + * On iMX6, ipg_clk = 133MHz, REG_ASR76K = 0x06D6, REG_ASR56K = 0x0947 + */ + ipg_rate = clk_get_rate(asrc->ipg_clk); + regmap_write(asrc->regmap, REG_ASR76K, ipg_rate / 76000); + return regmap_write(asrc->regmap, REG_ASR56K, ipg_rate / 56000); } /** -- 2.21.0