Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2d8957f authored by Alexander Stein's avatar Alexander Stein Committed by Takashi Iwai
Browse files

ALSA: sound/atmel/ac97c.c: Add device tree support



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: default avatarAlexander Stein <alexanders83@web.de>
Acked-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ff6defa6
Loading
Loading
Loading
Loading
+42 −3
Original line number Original line Diff line number Diff line
@@ -22,6 +22,9 @@
#include <linux/gpio.h>
#include <linux/gpio.h>
#include <linux/types.h>
#include <linux/types.h>
#include <linux/io.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/core.h>
#include <sound/initval.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)
static int atmel_ac97c_probe(struct platform_device *pdev)
{
{
	struct snd_card			*card;
	struct snd_card			*card;
@@ -922,10 +959,11 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
		return -ENXIO;
		return -ENXIO;
	}
	}


	pdata = pdev->dev.platform_data;
	pdata = dev_get_platdata(&pdev->dev);
	if (!pdata) {
	if (!pdata) {
		dev_dbg(&pdev->dev, "no platform data\n");
		pdata = atmel_ac97c_probe_dt(&pdev->dev);
		return -ENXIO;
		if (IS_ERR(pdata))
			return PTR_ERR(pdata);
	}
	}


	irq = platform_get_irq(pdev, 0);
	irq = platform_get_irq(pdev, 0);
@@ -1204,6 +1242,7 @@ static struct platform_driver atmel_ac97c_driver = {
	.driver		= {
	.driver		= {
		.name	= "atmel_ac97c",
		.name	= "atmel_ac97c",
		.pm	= ATMEL_AC97C_PM_OPS,
		.pm	= ATMEL_AC97C_PM_OPS,
		.of_match_table = of_match_ptr(atmel_ac97c_dt_ids),
	},
	},
};
};
module_platform_driver(atmel_ac97c_driver);
module_platform_driver(atmel_ac97c_driver);