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

Commit 0af541ce authored by Lee Jones's avatar Lee Jones
Browse files

ASoC: Ux500: Enable MOP500 driver for Device Tree



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: default avatarOla Lilja <ola.o.lilja@stericsson.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 5ca032ee
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <linux/module.h>
#include <linux/io.h>
#include <linux/spi/spi.h>
#include <linux/of.h>

#include <sound/soc.h>
#include <sound/initval.h>
@@ -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),