[alsa-devel] [PATCH 16/21] ASoC: Ux500: Enable MOP500 driver for Device Tree
Lee Jones
lee.jones at linaro.org
Thu Jul 26 12:28:49 CEST 2012
In this patch we stop registering the MOP500 driver from platform
code and rely solely on Device Tree to do the probing for us. We
also parse the sound node to link together the codec, dma and the
CPU-side Digital Audio Interface.
Signed-off-by: Lee Jones <lee.jones at linaro.org>
---
arch/arm/mach-ux500/board-mop500-msp.c | 3 ---
sound/soc/ux500/mop500.c | 41 ++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-ux500/board-mop500-msp.c b/arch/arm/mach-ux500/board-mop500-msp.c
index a21b9e2..ce7fff9 100644
--- a/arch/arm/mach-ux500/board-mop500-msp.c
+++ b/arch/arm/mach-ux500/board-mop500-msp.c
@@ -228,9 +228,6 @@ void mop500_of_msp_init(struct device *parent)
{
struct platform_device *msp1;
- pr_info("%s: Register platform-device 'snd-soc-u8500'.\n", __func__);
- platform_device_register(&snd_soc_mop500);
-
pr_info("Initialize MSP I2S-devices.\n");
db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0,
&msp0_platform_data);
diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c
index 31c4d26..d84a073 100644
--- a/sound/soc/ux500/mop500.c
+++ b/sound/soc/ux500/mop500.c
@@ -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,14 +57,48 @@ 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, *platform_np, *msp_np[2];
+ int i;
+
+ platform_np = of_parse_phandle(np, "platform-pcm-dma", 0);
+ msp_np[0] = of_parse_phandle(np, "cpu-dai", 0);
+ msp_np[1] = of_parse_phandle(np, "cpu-dai", 1);
+ codec_np = of_parse_phandle(np, "audio-codec", 0);
+
+ if (!(platform_np && 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].platform_of_node = platform_np;
+ mop500_dai_links[i].platform_name = NULL;
+ 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;
+ }
+
+ 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__);
dev_dbg(&pdev->dev, "%s: Enter.\n", __func__);
+ if (np) {
+ ret = mop500_of_probe(pdev, np);
+ if (ret)
+ return ret;
+ }
+
mop500_card.dev = &pdev->dev;
dev_dbg(&pdev->dev, "%s: Card %s: Set platform drvdata.\n",
@@ -101,10 +136,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),
--
1.7.9.5
More information about the Alsa-devel
mailing list