From patchwork Mon May 28 19:35:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 921675 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=zonque.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40vnBV5lHBz9s1p for ; Tue, 29 May 2018 05:35:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933562AbeE1TfM (ORCPT ); Mon, 28 May 2018 15:35:12 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:43560 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933558AbeE1TfM (ORCPT ); Mon, 28 May 2018 15:35:12 -0400 Received: from localhost.localdomain (pD95EF57B.dip0.t-ipconnect.de [217.94.245.123]) by mail.bugwerft.de (Postfix) with ESMTPSA id 74F62286596; Mon, 28 May 2018 19:32:31 +0000 (UTC) From: Daniel Mack To: lgirdwood@gmail.com, broonie@kernel.org, kuninori.morimoto.gx@renesas.com Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, Daniel Mack Subject: [PATCH 1/3] ASoC: simple-card: set cpu dai clk in hw_params Date: Mon, 28 May 2018 21:35:01 +0200 Message-Id: <20180528193503.18905-2-daniel@zonque.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180528193503.18905-1-daniel@zonque.org> References: <20180528193503.18905-1-daniel@zonque.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The simple-card driver currently accepts a clock node in the cpu dai sub-node and only uses it as an alternative to the 'system-clock-frequency' property to get the current frequency. This patch adds another use of the passed clock node. If mclk-fs is specified, the clock will be set to the calculated rate (stream rate * mclk_fs) in hw_params. This allows platforms to pass a tuneable clock as phandle that will automatically be set to the right rates. Signed-off-by: Daniel Mack --- Documentation/devicetree/bindings/sound/simple-card.txt | 5 +++++ sound/soc/generic/simple-card.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index 17c13e74667d..a4c72d09cd45 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt @@ -86,6 +86,11 @@ Optional CPU/CODEC subnodes properties: in dai startup() and disabled with clk_disable_unprepare() in dai shutdown(). + If a clock is specified and a + multiplication factor is given with + mclk-fs, the clock will be set to the + calculated mclk frequency when the + stream starts. - system-clock-direction-out : specifies clock direction as 'out' on initialization. It is useful for some aCPUs with fixed clocks. diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 6959a74a6f49..ca529a6cab06 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -154,6 +154,10 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, if (mclk_fs) { mclk = params_rate(params) * mclk_fs; + + if (dai_props->cpu_dai.clk) + clk_set_rate(dai_props->cpu_dai.clk, mclk); + ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, SND_SOC_CLOCK_IN); if (ret && ret != -ENOTSUPP)