From patchwork Fri Jul 27 12:45:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 10316 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 63A3823E23 for ; Fri, 27 Jul 2012 12:46:15 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1D2EAA1912F for ; Fri, 27 Jul 2012 12:46:14 +0000 (UTC) Received: by mail-gg0-f180.google.com with SMTP id f1so3108301ggn.11 for ; Fri, 27 Jul 2012 05:46:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=OktZoBLI9mPdn+Y0ChwXtDzoFuZPe/70gG9RViE1LpU=; b=UJavo0de0fXBGtX+JTliVkUxQEyV+D2hbFwzwl7Sx7jTDlKGNufPHG+ILlv7WVcyjn u6uGv1N6jWTvx2/h1jEPH6K7eTtQ1T07+Kmxn+ekun2vrlYA4PxqJutodw+j6Ckn0zT5 H/gu8YK76zxx4s2R2Nx9Izmg2XnPZoQMggm6xEp7RO0ET635fMaFmNdJj6BT+NxTvD3k 7tsCHsKRODeNlnEP2+ktorBw7vzAkNLfm5IGlEcq6Bw71Kn0Dpr/HIjwteHcPlwPKsUf XlAL27iEXt7iGxd4ilab98Pw2SJZTZve2tmSfRFXrjONEkRuBV3tYwAWKddbeWifrlHI XMlg== Received: by 10.50.87.201 with SMTP id ba9mr4440230igb.66.1343393174420; Fri, 27 Jul 2012 05:46:14 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.43.93.3 with SMTP id bs3csp29838icc; Fri, 27 Jul 2012 05:46:13 -0700 (PDT) Received: by 10.180.98.69 with SMTP id eg5mr21996864wib.3.1343393173032; Fri, 27 Jul 2012 05:46:13 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id v55si2617189wee.145.2012.07.27.05.46.12 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 05:46:13 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by wgbds11 with SMTP id ds11so2665012wgb.31 for ; Fri, 27 Jul 2012 05:46:12 -0700 (PDT) Received: by 10.180.81.38 with SMTP id w6mr5959009wix.10.1343393172527; Fri, 27 Jul 2012 05:46:12 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id dc3sm12342025wib.7.2012.07.27.05.46.11 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 05:46:11 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, olalilja@yahoo.se, ola.o.lilja@stericsson.com, alsa-devel@alsa-project.org, lrg@ti.com, broonie@opensource.wolfsonmicro.com, Lee Jones Subject: [PATCH 03/18] ASoC: Ux500: Enable MOP500 driver for Device Tree Date: Fri, 27 Jul 2012 13:45:47 +0100 Message-Id: <1343393162-11938-4-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343393162-11938-1-git-send-email-lee.jones@linaro.org> References: <1343393162-11938-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkU1jOMvx43slydOV1YdbvA4ooyyDdmPyFX+SEjccEmLqS5LPr+ESvPnHv5V6Nv9mgw20AE Here we ensure that the MOP500 audio driver will be probed during a Device Tree boot. We also parse the sound node to link together the codec, dma and the CPU-side Digital Audio Interface. Signed-off-by: Lee Jones --- sound/soc/ux500/mop500.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c index 31c4d26..d84a073 100644 --- a/sound/soc/ux500/mop500.c +++ b/sound/soc/ux500/mop500.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -56,14 +57,48 @@ static struct snd_soc_card mop500_card = { .num_links = ARRAY_SIZE(mop500_dai_links), }; +static int __devinit mop500_of_probe(struct platform_device *pdev, + struct device_node *np) +{ + struct device_node *codec_np, *platform_np, *msp_np[2]; + int i; + + platform_np = of_parse_phandle(np, "platform-pcm-dma", 0); + msp_np[0] = of_parse_phandle(np, "cpu-dai", 0); + msp_np[1] = of_parse_phandle(np, "cpu-dai", 1); + codec_np = of_parse_phandle(np, "audio-codec", 0); + + if (!(platform_np && msp_np[0] && msp_np[1] && codec_np)) { + dev_err(&pdev->dev, "Phandle missing or invalid\n"); + return -EINVAL; + } + + for (i = 0; i < 2; i++) { + mop500_dai_links[i].platform_of_node = platform_np; + mop500_dai_links[i].platform_name = NULL; + mop500_dai_links[i].cpu_of_node = msp_np[i]; + mop500_dai_links[i].cpu_dai_name = NULL; + mop500_dai_links[i].codec_of_node = codec_np; + mop500_dai_links[i].codec_name = NULL; + } + + return 0; +} static int __devinit mop500_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; int ret; pr_debug("%s: Enter.\n", __func__); dev_dbg(&pdev->dev, "%s: Enter.\n", __func__); + if (np) { + ret = mop500_of_probe(pdev, np); + if (ret) + return ret; + } + mop500_card.dev = &pdev->dev; dev_dbg(&pdev->dev, "%s: Card %s: Set platform drvdata.\n", @@ -101,10 +136,16 @@ static int __devexit mop500_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id snd_soc_mop500_match[] = { + { .compatible = "stericsson,snd-soc-mop500", }, + {}, +}; + static struct platform_driver snd_soc_mop500_driver = { .driver = { .owner = THIS_MODULE, .name = "snd-soc-mop500", + .of_match_table = snd_soc_mop500_match, }, .probe = mop500_probe, .remove = __devexit_p(mop500_remove),