From patchwork Mon Dec 29 12:08:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 5550151 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D4F7EBF6C3 for ; Mon, 29 Dec 2014 19:24:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE8EA2011E for ; Mon, 29 Dec 2014 19:24:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 289C220149 for ; Mon, 29 Dec 2014 19:24:46 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A2CB2260639; Mon, 29 Dec 2014 20:24:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 1E4D6260786; Mon, 29 Dec 2014 17:42:49 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id EADB7260786; Mon, 29 Dec 2014 17:42:47 +0100 (CET) Received: from mout.web.de (mout.web.de [212.227.15.14]) by alsa0.perex.cz (Postfix) with ESMTP id E9F1B266CC0 for ; Mon, 29 Dec 2014 13:08:53 +0100 (CET) Received: from kongar.lan.local ([77.64.221.251]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0M57T4-1XwJCv3ggY-00zDYi; Mon, 29 Dec 2014 13:08:52 +0100 From: Alexander Stein To: Jaroslav Kysela , Takashi Iwai Date: Mon, 29 Dec 2014 13:08:39 +0100 Message-Id: <1419854922-29338-1-git-send-email-alexanders83@web.de> X-Mailer: git-send-email 2.2.1 X-Provags-ID: V03:K0:VNf6EQpC/4NkwYVfiU6dC8BzJKny8zGpTvtXFbV5NlMLtfb1Gla q+8cAOT+P5bG0lqm40ZS/TW+xXj0RdEDtNlpkXEFflS5exx514aMITxdk+2bbb9qwQFuzL1 0ALWvfShKgXOcy2ktchcTMcN+x8PPXcqjE9b/uVYMkxK2clblEDUVUy+zhZbPuObXcfassn MIfrMx2vRbxts5KFZ1HEA== X-UI-Out-Filterresults: notjunk:1; Cc: Alexander Stein , alsa-devel@alsa-project.org, Alexandre Belloni , Arnd Bergmann Subject: [alsa-devel] [PATCH v3] ALSA: sound/atmel/ac97c.c: Add device tree support X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This adds device tree support for the AC97 controller. It uses the soc-ac97link bindings, but actually only ac97-reset is used. Signed-off-by: Alexander Stein Acked-By Alexandre Belloni --- Changes in v3: * Renamed the compatible string to atmel,at91sam9263-ac97c * Added 'Acked-By Alexandre Belloni ' Changes in v2: * It now uses the soc-ac97link bindings (partly) instead of defining its own. This should ease the transition to ASoC once a new driver has been written. sound/atmel/ac97c.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 4f6b14d..a0df1b1 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include #include #include @@ -902,6 +905,40 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip) } } +#ifdef CONFIG_OF +static const struct of_device_id atmel_ac97c_dt_ids[] = { + { .compatible = "atmel,at91sam9263-ac97c", }, + { } +}; +MODULE_DEVICE_TABLE(of, atmel_ac97c_dt_ids); + +static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev) +{ + struct ac97c_platform_data *pdata; + struct device_node *node = dev->of_node; + const struct of_device_id *match; + + if (!node) { + dev_err(dev, "Device does not have associated DT data\n"); + return ERR_PTR(-EINVAL); + } + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + pdata->reset_pin = of_get_named_gpio(dev->of_node, "ac97-gpios", 2); + + return pdata; +} +#else +static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev) +{ + dev_err(dev, "no platform data defined\n"); + return ERR_PTR(-ENXIO); +} +#endif + static int atmel_ac97c_probe(struct platform_device *pdev) { struct snd_card *card; @@ -922,10 +959,11 @@ static int atmel_ac97c_probe(struct platform_device *pdev) return -ENXIO; } - pdata = pdev->dev.platform_data; + pdata = dev_get_platdata(&pdev->dev); if (!pdata) { - dev_dbg(&pdev->dev, "no platform data\n"); - return -ENXIO; + pdata = atmel_ac97c_probe_dt(&pdev->dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); } irq = platform_get_irq(pdev, 0); @@ -1204,6 +1242,7 @@ static struct platform_driver atmel_ac97c_driver = { .driver = { .name = "atmel_ac97c", .pm = ATMEL_AC97C_PM_OPS, + .of_match_table = of_match_ptr(atmel_ac97c_dt_ids), }, }; module_platform_driver(atmel_ac97c_driver);