From patchwork Tue Jul 30 10:32:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 2835525 Return-Path: X-Original-To: patchwork-linux-arm@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 A67B9C0319 for ; Tue, 30 Jul 2013 10:54:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E775B20350 for ; Tue, 30 Jul 2013 10:54:07 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D02332030E for ; Tue, 30 Jul 2013 10:54:06 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V47GZ-0004Tw-NG; Tue, 30 Jul 2013 10:34:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V47Fy-0001HN-LZ; Tue, 30 Jul 2013 10:34:18 +0000 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V47Eq-00017z-BJ for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2013 10:33:10 +0000 Received: by mail-wg0-f45.google.com with SMTP id x12so5816901wgg.0 for ; Tue, 30 Jul 2013 03:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=WaZ2XA0GkAKBpT+8sD5ZWu5Cj7N9zMGVWthE3eeq5dg=; b=gM2wSnorV7pWRWYScJYvXhDhFVBm5r/rrfeM+qpchuNFO4anbv+fbvcbZEZvDARTNJ TCQnUSPD/pP4JPtOjtWxuk0JhVQaOsSL3j9/kJcFk/K2KOUpJIx11ODtRrssDhXLvVKC pt/97gHGpOCPC0l27dindHsRKr3hzmZ941URezh3ohQY9dZemZwQA6QSjD+zBsBuzwzy CnHMGmEMfIu2lM+UQVQNppdQVVT6R2N1xko5Mh6Z9ddGhnwSt0JkT1dtmVDZLZXcXsmX MvvX4L+xpWbSUAzSuB91U4LWGc+RQBAAeK48915ewZT0H+HZ0NMKlObEufJomjeAW8um yJyQ== X-Received: by 10.180.160.203 with SMTP id xm11mr449817wib.58.1375180366501; Tue, 30 Jul 2013 03:32:46 -0700 (PDT) Received: from lnx-rg.pr (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPSA id l2sm27502612wif.8.2013.07.30.03.32.44 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Jul 2013 03:32:45 -0700 (PDT) From: Richard Genoud To: Mark Brown , Nicolas Ferre , Liam Girdwood , Stephen Warren Subject: [PATCH v6 8/8] ASoC: sam9x5: get codec MCLK via device tree Date: Tue, 30 Jul 2013 12:32:09 +0200 Message-Id: <1375180329-4860-9-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1375180329-4860-1-git-send-email-richard.genoud@gmail.com> References: <1375180329-4860-1-git-send-email-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130730_063308_544857_0163DC34 X-CRM114-Status: GOOD ( 15.20 ) X-Spam-Score: -2.0 (--) Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Lars-Peter Clausen , Richard Genoud , patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, Bo Shen , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of having the clock rate hard coded, and thus, only compatible with one board, we can make it compatible with other implementations. Signed-off-by: Richard Genoud --- .../bindings/sound/atmel-sam9x5-wm8731-audio.txt | 4 ++++ arch/arm/boot/dts/at91sam9x5ek.dtsi | 8 ++++++++ sound/soc/atmel/sam9x5_wm8731.c | 18 ++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt b/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt index 0720857..114a4c5 100644 --- a/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt +++ b/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt @@ -8,6 +8,8 @@ Required properties: - atmel,audio-routing: A list of the connections between audio components. Each entry is a pair of strings, the first being the connection's sink, the second being the connection's source. + - clocks: Must contain an entry for the codec master clock. + - clock-names : Must be "mclk" (clock that feeds the codec master clock) Available audio endpoints for the audio-routing table: @@ -32,4 +34,6 @@ sound { atmel,ssc-controller = <&ssc0>; atmel,audio-codec = <&wm8731>; + clocks = <&sound_crystal 0>; + clock-names = "mclk"; }; diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index 9afe15b..b5ff17c 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -114,6 +114,12 @@ }; }; + sound_crystal: osc@0 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <12288000>; + }; + sound { compatible = "atmel,sam9x5-wm8731-audio"; @@ -127,5 +133,7 @@ atmel,ssc-controller = <&ssc0>; atmel,audio-codec = <&wm8731>; + clocks = <&sound_crystal 0>; + clock-names = "mclk"; }; }; diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c index 992ae38..f33c181 100644 --- a/sound/soc/atmel/sam9x5_wm8731.c +++ b/sound/soc/atmel/sam9x5_wm8731.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include @@ -31,12 +33,10 @@ #include "../codecs/wm8731.h" #include "atmel_ssc_dai.h" - -#define MCLK_RATE 12288000 - #define DRV_NAME "sam9x5-snd-wm8731" struct sam9x5_drvdata { + struct clk *mclk; int ssc_id; }; @@ -46,6 +46,7 @@ struct sam9x5_drvdata { static int sam9x5_wm8731_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct sam9x5_drvdata *priv = snd_soc_card_get_drvdata(rtd->card); struct device *dev = rtd->dev; int ret; @@ -53,7 +54,8 @@ static int sam9x5_wm8731_init(struct snd_soc_pcm_runtime *rtd) /* set the codec system clock for DAC and ADC */ ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, - MCLK_RATE, SND_SOC_CLOCK_IN); + clk_get_rate(priv->mclk), + SND_SOC_CLOCK_IN); if (ret < 0) { dev_err(dev, "ASoC: Failed to set WM8731 SYSCLK: %d\n", ret); return ret; @@ -142,6 +144,13 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev) priv->ssc_id = of_alias_get_id(cpu_np, "ssc"); + priv->mclk = devm_clk_get(&pdev->dev, "mclk"); + if (IS_ERR(priv->mclk)) { + ret = PTR_ERR(priv->mclk); + dev_err(&pdev->dev, "Failed to get MCLK: %d\n", ret); + goto out; + } + ret = atmel_ssc_set_audio(priv->ssc_id); if (ret != 0) { dev_err(&pdev->dev, @@ -153,6 +162,7 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev) of_node_put(codec_np); of_node_put(cpu_np); + snd_soc_card_set_drvdata(card, priv); platform_set_drvdata(pdev, card); ret = snd_soc_register_card(card);