From patchwork Thu Sep 20 12:09:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 11530 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 B08751B4E37 for ; Thu, 20 Sep 2012 12:09:30 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 32B103D098EB for ; Thu, 20 Sep 2012 12:09:30 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so2716784iej.11 for ; Thu, 20 Sep 2012 05:09:30 -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=iUNXWDDQ2cjL/pyzQxUg2ZIe31InluuNbR/hLyIPVY8=; b=b5PGHMcOjXGWg4V4xCexUrtVDlyu/B+pi1bUEhryjSucDM6YpUkMjqT/+s0NFLLC25 Cy1y91guVqGVo/ujl6JpbToHFWRLraueAjPv9VwbvmHcjq7RR3NBConJ804LgTu2eiNu RL8jAjJ0+vTpRMEddYc3qUkxxzmGSx27X5NHh7OAbOdP/t4p0u8Gbml++msHutYe2SEO IQfKz1Qlx2A62sXborbMpnzVtBgJ8vIaH49Ljht2J+kQslVcrMgcYVXnKkasfTBVCxxU fFYeOXTXi2mWJHfaF4ztyd3q/RFiVF8Z31LZY3MCdqdZdhCnJUzNm1CqsjS36EUjx5ei e+Fg== Received: by 10.50.0.193 with SMTP id 1mr1512109igg.0.1348142969971; Thu, 20 Sep 2012 05:09:29 -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.184.232 with SMTP id ex8csp71420igc; Thu, 20 Sep 2012 05:09:28 -0700 (PDT) Received: by 10.180.103.4 with SMTP id fs4mr4100243wib.16.1348142967902; Thu, 20 Sep 2012 05:09:27 -0700 (PDT) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id q52si7276645wea.149.2012.09.20.05.09.27 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Sep 2012 05:09:27 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.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 mail-we0-f178.google.com with SMTP id u7so1479955wey.37 for ; Thu, 20 Sep 2012 05:09:27 -0700 (PDT) Received: by 10.180.82.39 with SMTP id f7mr4161642wiy.2.1348142967371; Thu, 20 Sep 2012 05:09:27 -0700 (PDT) Received: from localhost.localdomain (LPuteaux-156-14-44-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPS id o2sm10403731wiz.11.2012.09.20.05.09.25 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Sep 2012 05:09:26 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, broonie@opensource.wolfsonmicro.com Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, ola.o.lilja@stericsson.com, alsa-devel@alsa-project.org, Lee Jones Subject: [PATCH 2/7] ASoC: Ux500: Enable MOP500 driver for Device Tree Date: Thu, 20 Sep 2012 14:09:11 +0200 Message-Id: <1348142956-1872-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348142956-1872-1-git-send-email-lee.jones@linaro.org> References: <1348142956-1872-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQn1+Kzr6QlMqZjeJagqMkNIpxuBoBX0ryzZunXqniXAho3sdtvjfJBxMHJrl2Zf7edbzfVe 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. Acked-by: Ola Lilja Acked-by: Linus Walleij Signed-off-by: Lee Jones --- sound/soc/ux500/mop500.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c index 31c4d26..6840df7 100644 --- a/sound/soc/ux500/mop500.c +++ b/sound/soc/ux500/mop500.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -56,8 +57,35 @@ 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; + } + + snd_soc_of_parse_card_name(&mop500_card, "stericsson,card-name"); + + 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__); @@ -66,6 +94,12 @@ static int __devinit mop500_probe(struct platform_device *pdev) mop500_card.dev = &pdev->dev; + if (np) { + ret = mop500_of_probe(pdev, np); + if (ret) + return ret; + } + dev_dbg(&pdev->dev, "%s: Card %s: Set platform drvdata.\n", __func__, mop500_card.name); platform_set_drvdata(pdev, &mop500_card); @@ -101,10 +135,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),