Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753412AbdLNQ7B (ORCPT ); Thu, 14 Dec 2017 11:59:01 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:39273 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753003AbdLNQ7A (ORCPT ); Thu, 14 Dec 2017 11:59:00 -0500 From: Olivier Moysan To: , , , , , , , , , , CC: , , Subject: [RFC PATCH 2/2] ASoC: select sysclk clock from mlck clock provider in wm8994 driver Date: Thu, 14 Dec 2017 17:53:58 +0100 Message-ID: <1513270438-18523-3-git-send-email-olivier.moysan@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1513270438-18523-1-git-send-email-olivier.moysan@st.com> References: <1513270438-18523-1-git-send-email-olivier.moysan@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.201.23.16] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-14_10:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1631 Lines: 61 When defined in device tree, MCLK1 and MCLK2 are used as sysclk for aif1 and aif2 interfaces respectively. If clock rate is let 0, the frequency provided by wm8994_set_dai_sysclk() is used instead. Signed-off-by: Olivier Moysan --- sound/soc/codecs/wm8994.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 21ffd64..7a84e37 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -11,6 +11,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -2376,18 +2377,35 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, { struct snd_soc_codec *codec = dai->codec; struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994 *control = wm8994->wm8994; + struct wm8994_pdata *pdata = &control->pdata; + unsigned long rate; int i; switch (dai->id) { case 1: + if (pdata->mclk1) { + rate = clk_get_rate(pdata->mclk1); + if (rate) + freq = (unsigned int)rate; + clk_id = WM8994_SYSCLK_MCLK1; + } + break; case 2: + if (pdata->mclk2) { + rate = clk_get_rate(pdata->mclk2); + if (rate) + freq = (unsigned int)rate; + clk_id = WM8994_SYSCLK_MCLK2; + } break; - default: /* AIF3 shares clocking with AIF1/2 */ return -EINVAL; } + dev_info(codec->dev, "%s:.clock id %d\n", __func__, clk_id); + switch (clk_id) { case WM8994_SYSCLK_MCLK1: wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_MCLK1; -- 1.9.1