From patchwork Tue Nov 6 05:57:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bo Shen X-Patchwork-Id: 1703021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 3E85DDF2A2 for ; Tue, 6 Nov 2012 06:03:33 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TVcE2-0006ua-1N; Tue, 06 Nov 2012 06:01:26 +0000 Received: from newsmtp5.atmel.com ([204.2.163.5] helo=sjogate2.atmel.com) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TVcDg-0006sA-L7 for linux-arm-kernel@lists.infradead.org; Tue, 06 Nov 2012 06:01:05 +0000 Received: from shaarm01.corp.atmel.com ([10.217.6.34]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id qA65tQVY001192; Mon, 5 Nov 2012 21:55:51 -0800 (PST) From: Bo Shen To: broonie@opensource.wolfsonmicro.com, nicolas.ferre@atmel.com Subject: [RFC patch v3 4/4] ASoC: sam9g20-wm8731: convert dt support Date: Tue, 6 Nov 2012 13:57:54 +0800 Message-Id: <1352181474-19597-4-git-send-email-voice.shen@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352181474-19597-1-git-send-email-voice.shen@atmel.com> References: <1352181474-19597-1-git-send-email-voice.shen@atmel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121106_010104_967999_F9C205A0 X-CRM114-Status: GOOD ( 18.28 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: alsa-devel@alsa-project.org, devicetree-discuss@lists.ozlabs.org, linux-sound@vger.kernel.org, Bo Shen , plagnioj@jcrosoft.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org convert sam9g20-wm8731 to device tree support Signed-off-by: Bo Shen Acked-by: Nicolas Ferre --- Change since v2: No change Change since v1: Add sam9g20-wm8731 binding document --- .../bindings/sound/atmel-sam9g20-audio-wm8731.txt | 21 ++++++++ arch/arm/boot/dts/at91sam9260.dtsi | 2 +- arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 20 +++++++- sound/soc/atmel/sam9g20_wm8731.c | 51 +++++++++++++++++++- 4 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/atmel-sam9g20-audio-wm8731.txt diff --git a/Documentation/devicetree/bindings/sound/atmel-sam9g20-audio-wm8731.txt b/Documentation/devicetree/bindings/sound/atmel-sam9g20-audio-wm8731.txt new file mode 100644 index 0000000..ad77fb0 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/atmel-sam9g20-audio-wm8731.txt @@ -0,0 +1,21 @@ +* Atmel sam9g20ek audio complex + +Required properties: + - compatible: "atmel,at91sam9g20-audio" + - atmel,model: The user-visible name of this sound complex. + - atmel,audio-routing: A list of the connections between audio components. + - atmel,ssc-controller: The phandle of the SSC controller + - atmel,audio-codec: The phandle of the WM8731 audio codec + +Example: +sound { + compatible = "atmel,at91sam9g20-audio"; + atmel,model = "wm8731 @ sam9g20ek"; + + atmel,audio-routing = + "Ext Spk", "LHPOUT", + "Int MIC", "MICIN"; + + atmel,ssc-controller = <&ssc0>; + atmel,audio-codec = <&wm8731>; +}; diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi index aaa42d8..d322dae 100644 --- a/arch/arm/boot/dts/at91sam9260.dtsi +++ b/arch/arm/boot/dts/at91sam9260.dtsi @@ -214,7 +214,7 @@ }; ssc0: ssc@fffbc000 { - compatible = "atmel,at91rm9200-ssc"; + compatible = "atmel,at91rm9200-ssc-dai"; reg = <0xfffbc000 0x4000>; interrupts = <14 4 5>; status = "disable"; diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi index b06c0db..05706a3 100644 --- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi +++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi @@ -51,6 +51,10 @@ atmel,vbus-gpio = <&pioC 5 0>; status = "okay"; }; + + ssc0: ssc@fffbc000 { + status = "okay"; + }; }; nand0: nand@40000000 { @@ -114,8 +118,8 @@ reg = <0x50>; }; - wm8731@1b { - compatible = "wm8731"; + wm8731: wm8731@1b { + compatible = "wlf,wm8731"; reg = <0x1b>; }; }; @@ -139,4 +143,16 @@ gpio-key,wakeup; }; }; + + sound { + compatible = "atmel,at91sam9g20-audio"; + atmel,model = "wm8731 @ sam9g20ek"; + + atmel,audio-routing = + "Ext Spk", "LHPOUT", + "Int Mic", "MICIN"; + + atmel,ssc-controller = <&ssc0>; + atmel,audio-codec = <&wm8731>; + }; }; diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index 862cbcc..36f0fb3 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -197,13 +197,17 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = { static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; + struct device_node *codec_np, *cpu_np; struct clk *pllb; struct snd_soc_card *card =&snd_soc_at91sam9g20ek; int ret; - if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) + if (!np) { + if (!(machine_is_at91sam9g20ek() + || machine_is_at91sam9g20ek_2mmc())) return -ENODEV; - + } /* * Codec MCLK is supplied by PCK0 - set it up. */ @@ -230,6 +234,40 @@ static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev) clk_set_rate(mclk, MCLK_RATE); card->dev = &pdev->dev; + + /* Parse device node info */ + if (np) { + ret = snd_soc_of_parse_card_name(card, "atmel,model"); + if (ret) + goto err; + + ret = snd_soc_of_parse_audio_routing(card, + "atmel,audio-routing"); + if (ret) + goto err; + + /* Parse codec dai info */ + at91sam9g20ek_dai.codec_name = NULL; + codec_np = of_parse_phandle(np, "atmel,audio-codec", 0); + if (!codec_np) { + dev_err(&pdev->dev, "codec info missing\n"); + return -EINVAL; + } + at91sam9g20ek_dai.codec_of_node = codec_np; + at91sam9g20ek_dai.cpu_dai_name = NULL; + at91sam9g20ek_dai.platform_name = NULL; + cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0); + if (!cpu_np) { + dev_err(&pdev->dev, "dai info missing\n"); + return -EINVAL; + } + at91sam9g20ek_dai.cpu_of_node = cpu_np; + at91sam9g20ek_dai.platform_of_node = cpu_np; + + of_node_put(codec_np); + of_node_put(cpu_np); + } + ret = snd_soc_register_card(card); if (ret) { printk(KERN_ERR "ASoC: snd_soc_register_card() failed\n"); @@ -255,10 +293,19 @@ static int __devexit at91sam9g20ek_audio_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id sam9g20ek_wm8731_dt_ids[] = { + { .compatible = "atmel,at91sam9g20-audio", }, + { } +}; +MODULE_DEVICE_TABLE(of, sam9g20ek_wm8731_dt_ids); +#endif + static struct platform_driver at91sam9g20ek_audio_driver = { .driver = { .name = "at91sam9g20ek-audio", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(sam9g20ek_wm8731_dt_ids), }, .probe = at91sam9g20ek_audio_probe, .remove = __devexit_p(at91sam9g20ek_audio_remove),