All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Stein <alexanders83@web.de>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>
Cc: Alexander Stein <alexanders83@web.de>,
	alsa-devel@alsa-project.org,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH v3] ALSA: sound/atmel/ac97c.c: Add device tree support
Date: Mon, 29 Dec 2014 13:08:39 +0100	[thread overview]
Message-ID: <1419854922-29338-1-git-send-email-alexanders83@web.de> (raw)

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 <alexanders83@web.de>
Acked-By Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Changes in v3:
* Renamed the compatible string to atmel,at91sam9263-ac97c
* Added 'Acked-By Alexandre Belloni <alexandre.belloni@free-electrons.com>'

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 <linux/gpio.h>
 #include <linux/types.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/of_device.h>
 
 #include <sound/core.h>
 #include <sound/initval.h>
@@ -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);
-- 
2.2.1

             reply	other threads:[~2014-12-29 12:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-29 12:08 Alexander Stein [this message]
     [not found] ` <1419854922-29338-1-git-send-email-alexanders83-S0/GAf8tV78@public.gmane.org>
2014-12-29 12:08   ` [PATCH v3] dt: atmel_ac97c: Add device tree documentation Alexander Stein
2014-12-29 12:08 ` [PATCH v3] ARM: at91/dt: sam9263: Add ac97 device node Alexander Stein
2014-12-29 12:08   ` Alexander Stein
2015-01-08 19:12   ` Alexander Stein
2015-01-08 19:12     ` Alexander Stein
2015-01-08 19:16     ` Alexandre Belloni
2015-01-08 19:16       ` Alexandre Belloni
2015-01-26 16:00       ` Nicolas Ferre
2015-01-26 16:00         ` Nicolas Ferre
2014-12-29 12:08 ` [PATCH v3] ARM: at91/defconfig: add SND_ATMEL_AC97C to at91_dt Alexander Stein
2015-01-06 10:04 ` [PATCH v3] ALSA: sound/atmel/ac97c.c: Add device tree support Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1419854922-29338-1-git-send-email-alexanders83@web.de \
    --to=alexanders83@web.de \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.