From patchwork Wed Apr 30 10:54:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 4092591 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CFA509F39D for ; Wed, 30 Apr 2014 10:53:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0765120265 for ; Wed, 30 Apr 2014 10:53:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D474F20260 for ; Wed, 30 Apr 2014 10:53:15 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id CDE73265083; Wed, 30 Apr 2014 12:53:14 +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 F0FA4261AA4; Wed, 30 Apr 2014 12:52:39 +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 72C14261A0D; Wed, 30 Apr 2014 12:52:36 +0200 (CEST) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1blp0188.outbound.protection.outlook.com [207.46.163.188]) by alsa0.perex.cz (Postfix) with ESMTP id 0A52326072A for ; Wed, 30 Apr 2014 12:52:27 +0200 (CEST) Received: from BY2PR03CA077.namprd03.prod.outlook.com (10.141.249.50) by BY2PR03MB028.namprd03.prod.outlook.com (10.255.240.42) with Microsoft SMTP Server (TLS) id 15.0.934.12; Wed, 30 Apr 2014 10:52:24 +0000 Received: from BY2FFO11FD042.protection.gbl (2a01:111:f400:7c0c::110) by BY2PR03CA077.outlook.office365.com (2a01:111:e400:2c5d::50) with Microsoft SMTP Server (TLS) id 15.0.929.12 via Frontend Transport; Wed, 30 Apr 2014 10:52:24 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.1) by BY2FFO11FD042.mail.protection.outlook.com (10.1.14.227) with Microsoft SMTP Server (TLS) id 15.0.929.8 via Frontend Transport; Wed, 30 Apr 2014 10:52:24 +0000 Received: from rio.ap.freescale.net (rio.ap.freescale.net [10.192.242.9]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s3UAqHbn006317; Wed, 30 Apr 2014 03:52:21 -0700 From: Nicolin Chen To: Date: Wed, 30 Apr 2014 18:54:05 +0800 Message-ID: <05eb492d162ee6173f813dbc6cfda6551de70108.1398853588.git.Guangyu.Chen@freescale.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.1; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009001)(6009001)(428001)(199002)(189002)(77096999)(19580405001)(19580395003)(83322001)(6806004)(44976005)(80976001)(4396001)(77156001)(36756003)(31966008)(80022001)(74502001)(74662001)(47776003)(79102001)(20776003)(81342001)(81542001)(76482001)(77982001)(99396002)(50986999)(76176999)(48376002)(87286001)(89996001)(83072002)(50466002)(92566001)(92726001)(85852003)(62966002)(46102001)(101416001)(88136002)(50226001)(87936001)(86362001)(93916002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB028; H:tx30smr01.am.freescale.net; FPR:; MLV:sfv; PTR:gate-tx3.freescale.com; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Forefront-PRVS: 0197AFBD92 Received-SPF: None (: freescale.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 192.88.168.1) 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/5] ASoC: fsl_spdif: Use clk_set_rate() for spdif root clock only 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 clock mux for the Freescale S/PDIF controller has eight clock sources while most of them are from other moudles and even system clocks that do not allow a rate-changing operation. So we here only allow the clk_set_rate() and clk_round_rate() happened to spdif root clock, the private clock for S/PDIF controller. Signed-off-by: Nicolin Chen --- sound/soc/fsl/fsl_spdif.c | 15 ++++++++++++--- sound/soc/fsl/fsl_spdif.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index e7be6b3..ed4bf75 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -384,6 +384,10 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream, return -EINVAL; } + /* Don't mess up the clocks from other modules */ + if (clk != STC_TXCLK_SPDIF_ROOT) + goto clk_set_bypass; + /* * The S/PDIF block needs a clock of 64 * fs * div. The S/PDIF block * will divide by (div). So request 64 * fs * (div+1) which will @@ -395,6 +399,7 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream, return ret; } +clk_set_bypass: dev_dbg(&pdev->dev, "expected clock rate = %d\n", (64 * sample_rate * div)); dev_dbg(&pdev->dev, "actual clock rate = %ld\n", @@ -1011,7 +1016,7 @@ static struct regmap_config fsl_spdif_regmap_config = { static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv, struct clk *clk, u64 savesub, - enum spdif_txrate index) + enum spdif_txrate index, bool round) { const u32 rate[] = { 32000, 44100, 48000 }; u64 rate_ideal, rate_actual, sub; @@ -1019,7 +1024,10 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv, for (div = 1; div <= 128; div++) { rate_ideal = rate[index] * (div + 1) * 64; - rate_actual = clk_round_rate(clk, rate_ideal); + if (round) + rate_actual = clk_round_rate(clk, rate_ideal); + else + rate_actual = clk_get_rate(clk); arate = rate_actual / 64; arate /= div; @@ -1072,7 +1080,8 @@ static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv, if (!clk_get_rate(clk)) continue; - ret = fsl_spdif_txclk_caldiv(spdif_priv, clk, savesub, index); + ret = fsl_spdif_txclk_caldiv(spdif_priv, clk, savesub, index, + i == STC_TXCLK_SPDIF_ROOT); if (savesub == ret) continue; diff --git a/sound/soc/fsl/fsl_spdif.h b/sound/soc/fsl/fsl_spdif.h index 605a10b..4ec27fc 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 STC_TXCLK_SPDIF_ROOT 1 + /* SPDIF tx rate */ enum spdif_txrate { SPDIF_TXRATE_32000 = 0,