From patchwork Thu Jul 26 10:28:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 10263 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 AF87223E56 for ; Thu, 26 Jul 2012 10:29:40 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 7FF68A18866 for ; Thu, 26 Jul 2012 10:29:40 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id z12so1774077ghb.11 for ; Thu, 26 Jul 2012 03:29:40 -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=FeJtem5UnF6jEWbnxGMhWW3lDoGiSq1DOUf1/x5aVlA=; b=YrVve/an/fUy2yDp/wpqwFoUOMrCJiCMiayVh/RjIqCWJDAAEZ4RfNk8YGCEARR+eg lw/j13WNPA5lG5VhDeipnbzt4s8ZrpPqDnwW4ZfUtF/yTatCpuDDU+3Jn4qrlNMVSPZO 6hSQy6inpKwqV0FnWSRmFZv9fvGHvfYa4GvUAAtxjK64kXg+YWvZw38VKxaWSSqBeXnO dX5kdO/mUL00hQJ/xDe9V7l8c2tkMm5yrHvgDtRtFlkMqzeOfHfmF0jroEwgVDKJAkqA ck2taspxz1m2b3H7W52CRGVqBBeXIeI8B4lZVeozlbs8Iree3sB7A8xN2jX6f4ZTP/9j OaTQ== Received: by 10.50.209.73 with SMTP id mk9mr1168124igc.66.1343298579993; Thu, 26 Jul 2012 03:29:39 -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 bs3csp133395icc; Thu, 26 Jul 2012 03:29:39 -0700 (PDT) Received: by 10.180.103.4 with SMTP id fs4mr12256639wib.16.1343298578656; Thu, 26 Jul 2012 03:29:38 -0700 (PDT) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx.google.com with ESMTPS id t50si25147012wed.154.2012.07.26.03.29.38 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 03:29:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.170; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by wibhq12 with SMTP id hq12so5304669wib.1 for ; Thu, 26 Jul 2012 03:29:38 -0700 (PDT) Received: by 10.180.98.138 with SMTP id ei10mr12330629wib.1.1343298578053; Thu, 26 Jul 2012 03:29:38 -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 fb20sm11559455wid.1.2012.07.26.03.29.36 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 03:29:37 -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, broonie@opensource.wolfsonmicro.com, sameo@linux.intel.com, olalilja@yahoo.se, ola.o.lilja@stericsson.com, alsa-devel@alsa-project.org, lrg@ti.com, Lee Jones Subject: [PATCH 16/21] ASoC: Ux500: Enable MOP500 driver for Device Tree Date: Thu, 26 Jul 2012 11:28:49 +0100 Message-Id: <1343298534-13611-17-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343298534-13611-1-git-send-email-lee.jones@linaro.org> References: <1343298534-13611-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQmOy4QZ8IDDnRyOpMaV7csTKRcomovgCOVTzV52T3QqCba0xU1ZdjYvk+A3+WQBl5Lqv7mQ In this patch we stop registering the MOP500 driver from platform code and rely solely on Device Tree to do the probing for us. We also parse the sound node to link together the codec, dma and the CPU-side Digital Audio Interface. Signed-off-by: Lee Jones --- arch/arm/mach-ux500/board-mop500-msp.c | 3 --- sound/soc/ux500/mop500.c | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500-msp.c b/arch/arm/mach-ux500/board-mop500-msp.c index a21b9e2..ce7fff9 100644 --- a/arch/arm/mach-ux500/board-mop500-msp.c +++ b/arch/arm/mach-ux500/board-mop500-msp.c @@ -228,9 +228,6 @@ void mop500_of_msp_init(struct device *parent) { struct platform_device *msp1; - pr_info("%s: Register platform-device 'snd-soc-u8500'.\n", __func__); - platform_device_register(&snd_soc_mop500); - pr_info("Initialize MSP I2S-devices.\n"); db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0, &msp0_platform_data); 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),