From patchwork Fri Apr 25 11:58:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 4059881 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 69B27BFF02 for ; Fri, 25 Apr 2014 11:57:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 942D3203AB for ; Fri, 25 Apr 2014 11:57:33 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6C8AB2039E for ; Fri, 25 Apr 2014 11:57:32 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 000B3261A34; Fri, 25 Apr 2014 13:57:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id EEF4326546B; Fri, 25 Apr 2014 13:56:55 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 745C326546B; Fri, 25 Apr 2014 13:56:52 +0200 (CEST) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2lp0241.outbound.protection.outlook.com [207.46.163.241]) by alsa0.perex.cz (Postfix) with ESMTP id ED7E8261A34 for ; Fri, 25 Apr 2014 13:56:43 +0200 (CEST) Received: from BLUPR03CA033.namprd03.prod.outlook.com (10.141.30.26) by BLUPR03MB018.namprd03.prod.outlook.com (10.255.208.40) with Microsoft SMTP Server (TLS) id 15.0.934.12; Fri, 25 Apr 2014 11:56:41 +0000 Received: from BN1BFFO11FD056.protection.gbl (2a01:111:f400:7c10::1:188) by BLUPR03CA033.outlook.office365.com (2a01:111:e400:879::26) with Microsoft SMTP Server (TLS) id 15.0.934.12 via Frontend Transport; Fri, 25 Apr 2014 11:56:41 +0000 Received: from az84smr01.freescale.net (192.88.158.246) by BN1BFFO11FD056.mail.protection.outlook.com (10.58.145.11) with Microsoft SMTP Server (TLS) id 15.0.929.8 via Frontend Transport; Fri, 25 Apr 2014 11:56:41 +0000 Received: from rio.ap.freescale.net (rio.ap.freescale.net [10.192.242.9]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s3PBuW2s014052; Fri, 25 Apr 2014 04:56:38 -0700 From: Nicolin Chen To: Date: Fri, 25 Apr 2014 19:58:19 +0800 Message-ID: X-Mailer: git-send-email 1.8.4 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.246; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009001)(6009001)(428001)(199002)(189002)(86362001)(92566001)(93916002)(92726001)(48376002)(62966002)(50466002)(46102001)(80022001)(47776003)(76482001)(87936001)(20776003)(79102001)(85852003)(81342001)(83072002)(74662001)(74502001)(89996001)(4396001)(87286001)(81542001)(88136002)(80976001)(77982001)(99396002)(6806004)(83322001)(19580395003)(44976005)(19580405001)(36756003)(77156001)(77096999)(50226001)(50986999)(76176999)(31966008); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB018; H:az84smr01.freescale.net; FPR:; MLV:sfv; PTR:gate-az5.freescale.com; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Forefront-PRVS: 0192E812EC Received-SPF: None (: freescale.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 192.88.158.246) smtp.mailfrom=guangyu.chen@freescale.com; X-OriginatorOrg: freescale.com Cc: tiwai@suse.de, alsa-devel@alsa-project.org, lgirdwood@gmail.com Subject: [alsa-devel] [PATCH 1/2] ASoC: fsl_spdif: Fix clock source for rxclk rate measurement X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The rxclk rate actually uses sysclk, ipg clock for example, as its reference clock to calculate it. But the driver currently doesn't pass a correct clock source. So fix it. Signed-off-by: Nicolin Chen --- sound/soc/fsl/fsl_spdif.c | 12 +++++++++++- sound/soc/fsl/fsl_spdif.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index e2836b3..4ce4ffa 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -81,6 +81,7 @@ struct fsl_spdif_priv { struct clk *txclk[SPDIF_TXRATE_MAX]; struct clk *rxclk; struct clk *coreclk; + struct clk *sysclk; struct snd_dmaengine_dai_dma_data dma_params_tx; struct snd_dmaengine_dai_dma_data dma_params_rx; @@ -767,7 +768,7 @@ static int spdif_get_rxclk_rate(struct fsl_spdif_priv *spdif_priv, clksrc = (phaseconf >> SRPC_CLKSRC_SEL_OFFSET) & 0xf; if (srpc_dpll_locked[clksrc] && (phaseconf & SRPC_DPLL_LOCKED)) { /* Get bus clock from system */ - busclk_freq = clk_get_rate(spdif_priv->rxclk); + busclk_freq = clk_get_rate(spdif_priv->sysclk); } /* FreqMeas_CLK = (BUS_CLK * FreqMeas) / 2 ^ 10 / GAINSEL / 128 */ @@ -1100,6 +1101,7 @@ static int fsl_spdif_probe(struct platform_device *pdev) struct resource *res; void __iomem *regs; int irq, ret, i; + char tmp[16]; if (!np) return -ENODEV; @@ -1147,6 +1149,14 @@ static int fsl_spdif_probe(struct platform_device *pdev) return ret; } + /* Get system clock for rx clock rate calculation */ + sprintf(tmp, "rxtx%d", SPDIF_CLK_SRC_SYSCLK); + spdif_priv->sysclk = devm_clk_get(&pdev->dev, tmp); + if (IS_ERR(spdif_priv->sysclk)) { + dev_err(&pdev->dev, "no sys clock (%s) in devicetree\n", tmp); + return PTR_ERR(spdif_priv->sysclk); + } + /* Get core clock for data register access via DMA */ spdif_priv->coreclk = devm_clk_get(&pdev->dev, "core"); if (IS_ERR(spdif_priv->coreclk)) { diff --git a/sound/soc/fsl/fsl_spdif.h b/sound/soc/fsl/fsl_spdif.h index 605a10b..f9241e7 100644 --- a/sound/soc/fsl/fsl_spdif.h +++ b/sound/soc/fsl/fsl_spdif.h @@ -157,6 +157,8 @@ enum spdif_gainsel { #define STC_TXCLK_DIV(x) ((((x) - 1) << STC_TXCLK_DIV_OFFSET) & STC_TXCLK_DIV_MASK) #define STC_TXCLK_SRC_MAX 8 +#define SPDIF_CLK_SRC_SYSCLK 5 + /* SPDIF tx rate */ enum spdif_txrate { SPDIF_TXRATE_32000 = 0,