staging: ozwpan: Add module parameter description
[linux/fpc-iii.git] / sound / soc / ux500 / mop500.c
blobb3b66aa98dce7d8b3f6844eb9f65a7d59a728cd8
1 /*
2 * Copyright (C) ST-Ericsson SA 2012
4 * Author: Ola Lilja (ola.o.lilja@stericsson.com)
5 * for ST-Ericsson.
7 * License terms:
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
14 #include <asm/mach-types.h>
16 #include <linux/module.h>
17 #include <linux/io.h>
18 #include <linux/spi/spi.h>
19 #include <linux/of.h>
21 #include <sound/soc.h>
22 #include <sound/initval.h>
24 #include "ux500_pcm.h"
25 #include "ux500_msp_dai.h"
27 #include "mop500_ab8500.h"
29 /* Define the whole MOP500 soundcard, linking platform to the codec-drivers */
30 static struct snd_soc_dai_link mop500_dai_links[] = {
32 .name = "ab8500_0",
33 .stream_name = "ab8500_0",
34 .cpu_dai_name = "ux500-msp-i2s.1",
35 .codec_dai_name = "ab8500-codec-dai.0",
36 .platform_name = "ux500-msp-i2s.1",
37 .codec_name = "ab8500-codec.0",
38 .init = mop500_ab8500_machine_init,
39 .ops = mop500_ab8500_ops,
42 .name = "ab8500_1",
43 .stream_name = "ab8500_1",
44 .cpu_dai_name = "ux500-msp-i2s.3",
45 .codec_dai_name = "ab8500-codec-dai.1",
46 .platform_name = "ux500-msp-i2s.3",
47 .codec_name = "ab8500-codec.0",
48 .init = NULL,
49 .ops = mop500_ab8500_ops,
53 static struct snd_soc_card mop500_card = {
54 .name = "MOP500-card",
55 .owner = THIS_MODULE,
56 .probe = NULL,
57 .dai_link = mop500_dai_links,
58 .num_links = ARRAY_SIZE(mop500_dai_links),
61 static void mop500_of_node_put(void)
63 int i;
65 for (i = 0; i < 2; i++) {
66 if (mop500_dai_links[i].cpu_of_node)
67 of_node_put((struct device_node *)
68 mop500_dai_links[i].cpu_of_node);
69 if (mop500_dai_links[i].codec_of_node)
70 of_node_put((struct device_node *)
71 mop500_dai_links[i].codec_of_node);
75 static int mop500_of_probe(struct platform_device *pdev,
76 struct device_node *np)
78 struct device_node *codec_np, *msp_np[2];
79 int i;
81 msp_np[0] = of_parse_phandle(np, "stericsson,cpu-dai", 0);
82 msp_np[1] = of_parse_phandle(np, "stericsson,cpu-dai", 1);
83 codec_np = of_parse_phandle(np, "stericsson,audio-codec", 0);
85 if (!(msp_np[0] && msp_np[1] && codec_np)) {
86 dev_err(&pdev->dev, "Phandle missing or invalid\n");
87 mop500_of_node_put();
88 return -EINVAL;
91 for (i = 0; i < 2; i++) {
92 mop500_dai_links[i].cpu_of_node = msp_np[i];
93 mop500_dai_links[i].cpu_dai_name = NULL;
94 mop500_dai_links[i].platform_of_node = msp_np[i];
95 mop500_dai_links[i].platform_name = NULL;
96 mop500_dai_links[i].codec_of_node = codec_np;
97 mop500_dai_links[i].codec_name = NULL;
100 snd_soc_of_parse_card_name(&mop500_card, "stericsson,card-name");
102 return 0;
105 static int mop500_probe(struct platform_device *pdev)
107 struct device_node *np = pdev->dev.of_node;
108 int ret;
110 dev_dbg(&pdev->dev, "%s: Enter.\n", __func__);
112 mop500_card.dev = &pdev->dev;
114 if (np) {
115 ret = mop500_of_probe(pdev, np);
116 if (ret)
117 return ret;
120 dev_dbg(&pdev->dev, "%s: Card %s: Set platform drvdata.\n",
121 __func__, mop500_card.name);
122 platform_set_drvdata(pdev, &mop500_card);
124 snd_soc_card_set_drvdata(&mop500_card, NULL);
126 dev_dbg(&pdev->dev, "%s: Card %s: num_links = %d\n",
127 __func__, mop500_card.name, mop500_card.num_links);
128 dev_dbg(&pdev->dev, "%s: Card %s: DAI-link 0: name = %s\n",
129 __func__, mop500_card.name, mop500_card.dai_link[0].name);
130 dev_dbg(&pdev->dev, "%s: Card %s: DAI-link 0: stream_name = %s\n",
131 __func__, mop500_card.name,
132 mop500_card.dai_link[0].stream_name);
134 ret = snd_soc_register_card(&mop500_card);
135 if (ret)
136 dev_err(&pdev->dev,
137 "Error: snd_soc_register_card failed (%d)!\n", ret);
139 return ret;
142 static int mop500_remove(struct platform_device *pdev)
144 struct snd_soc_card *mop500_card = platform_get_drvdata(pdev);
146 pr_debug("%s: Enter.\n", __func__);
148 snd_soc_unregister_card(mop500_card);
149 mop500_ab8500_remove(mop500_card);
150 mop500_of_node_put();
152 return 0;
155 static const struct of_device_id snd_soc_mop500_match[] = {
156 { .compatible = "stericsson,snd-soc-mop500", },
160 static struct platform_driver snd_soc_mop500_driver = {
161 .driver = {
162 .owner = THIS_MODULE,
163 .name = "snd-soc-mop500",
164 .of_match_table = snd_soc_mop500_match,
166 .probe = mop500_probe,
167 .remove = mop500_remove,
170 module_platform_driver(snd_soc_mop500_driver);