From patchwork Tue Jul 31 13:38:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 10408 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 CA98923E02 for ; Tue, 31 Jul 2012 13:39:28 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 7DBFAA18CF8 for ; Tue, 31 Jul 2012 13:39:28 +0000 (UTC) Received: by yhpp61 with SMTP id p61so5928853yhp.11 for ; Tue, 31 Jul 2012 06:39:28 -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=3g/ZWsHF8KGtFFGDk5pUgCUf/Htwaxy3vwRn6RkyUAw=; b=emh63rZzzRbvOFgwTShew0sykCd/ZUgAZ7qvPF0gtIzPkRUNUALzXWEERZpisg2X+o HDgnabL7oHXQoLH7rk0zpLivvyH4kRoC7+HjhHWsWvb0ODPFXKcRUgGK4/KBtQdRMWf9 73gRc0uvt9lXYgS8ld4MgbVW6Pub5gIXnlQ3IZ13XEaNr14s77DVK9Y2hIZVnAfjIlv2 KCWlK5HvQ4KcBuRUI5eg2x0/P1JZsxr2IXVa/bDpUG6zb6QJCfY49l+Co2jisxrzjHxq D3frxioExnMLhSggm5Q8l7Bj2tDro9MJxPK+Mo4rTHbLpBa3pe8b9+8RsNJwLdrE/RlD EFlQ== Received: by 10.50.149.134 with SMTP id ua6mr712878igb.11.1343741967784; Tue, 31 Jul 2012 06:39:27 -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.50.87.40 with SMTP id u8csp143496igz; Tue, 31 Jul 2012 06:39:26 -0700 (PDT) Received: by 10.217.1.136 with SMTP id n8mr7118190wes.10.1343741966530; Tue, 31 Jul 2012 06:39:26 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id o47si134493wee.59.2012.07.31.06.39.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 Jul 2012 06:39:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by wibhr14 with SMTP id hr14so2235368wib.13 for ; Tue, 31 Jul 2012 06:39:25 -0700 (PDT) Received: by 10.180.107.103 with SMTP id hb7mr7031665wib.3.1343741965788; Tue, 31 Jul 2012 06:39:25 -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 el6sm22252911wib.8.2012.07.31.06.39.24 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 Jul 2012 06:39:25 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, olalilja@yahoo.se, ola.o.lilja@stericsson.com, alsa-devel@alsa-project.org, lrg@ti.com, broonie@opensource.wolfsonmicro.com Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, Lee Jones Subject: [PATCH 02/19] ASoC: Ux500: Enable MOP500 driver for Device Tree Date: Tue, 31 Jul 2012 14:38:56 +0100 Message-Id: <1343741953-17828-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343741953-17828-1-git-send-email-lee.jones@linaro.org> References: <1343741953-17828-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkhTeID/oOZtm++xoTYx82EupOGpX7CVy/GfUVoBYAxWbTG3rNJ4TqWoC7gdwFRB3sInVoi 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 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c index 31c4d26..821f2a9 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,45 @@ 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, *msp_np[2]; + int i; + + msp_np[0] = of_parse_phandle(np, "stericsson,cpu-dai", 0); + msp_np[1] = of_parse_phandle(np, "stericsson,cpu-dai", 1); + codec_np = of_parse_phandle(np, "stericsson,audio-codec", 0); + + if (!(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].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 +133,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),