blob: 21f1ccbdf58299624816d312a61aff0b8ffa53fb [file] [log] [blame]
Kuninori Morimotof2390882012-04-08 21:17:50 -07001/*
2 * ASoC simple sound card support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
Kuninori Morimotofa558c22013-11-20 15:25:02 +090011#include <linux/clk.h>
Xiubo Li6ff62ee2014-02-14 09:34:36 +080012#include <linux/device.h>
Kuninori Morimotof2390882012-04-08 21:17:50 -070013#include <linux/module.h>
Kuninori Morimotofa558c22013-11-20 15:25:02 +090014#include <linux/of.h>
Kuninori Morimotof2390882012-04-08 21:17:50 -070015#include <linux/platform_device.h>
Xiubo Lica919fe2014-01-14 12:35:32 +080016#include <linux/string.h>
Kuninori Morimotof2390882012-04-08 21:17:50 -070017#include <sound/simple_card.h>
Xiubo Li6ff62ee2014-02-14 09:34:36 +080018#include <sound/soc-dai.h>
19#include <sound/soc.h>
Kuninori Morimotof2390882012-04-08 21:17:50 -070020
Jean-Francois Moine45fce592014-01-15 16:51:56 +010021struct simple_card_data {
22 struct snd_soc_card snd_card;
Jean-Francois Moinecf7dc232014-03-20 10:52:41 +010023 struct simple_dai_props {
24 struct asoc_simple_dai cpu_dai;
25 struct asoc_simple_dai codec_dai;
26 } *dai_props;
27 struct snd_soc_dai_link dai_link[]; /* dynamically allocated */
Jean-Francois Moine45fce592014-01-15 16:51:56 +010028};
29
Kuninori Morimotoa4a29922013-01-10 16:49:11 -080030static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
Xiubo Li30d03412014-01-24 15:43:01 +080031 struct asoc_simple_dai *set)
Kuninori Morimotoa4a29922013-01-10 16:49:11 -080032{
Xiubo Li4763ebe2014-01-24 15:43:00 +080033 int ret;
Kuninori Morimotoa4a29922013-01-10 16:49:11 -080034
Xiubo Li30d03412014-01-24 15:43:01 +080035 if (set->fmt) {
36 ret = snd_soc_dai_set_fmt(dai, set->fmt);
Xiubo Li4763ebe2014-01-24 15:43:00 +080037 if (ret && ret != -ENOTSUPP) {
38 dev_err(dai->dev, "simple-card: set_fmt error\n");
39 goto err;
40 }
Kuninori Morimotoe244bb92013-10-17 22:46:49 -070041 }
42
Xiubo Li4763ebe2014-01-24 15:43:00 +080043 if (set->sysclk) {
Kuninori Morimotoa4a29922013-01-10 16:49:11 -080044 ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0);
Xiubo Li4763ebe2014-01-24 15:43:00 +080045 if (ret && ret != -ENOTSUPP) {
46 dev_err(dai->dev, "simple-card: set_sysclk error\n");
47 goto err;
48 }
49 }
Kuninori Morimotoa4a29922013-01-10 16:49:11 -080050
Xiubo Li6ff62ee2014-02-14 09:34:36 +080051 if (set->slots) {
52 ret = snd_soc_dai_set_tdm_slot(dai, 0, 0,
53 set->slots,
54 set->slot_width);
55 if (ret && ret != -ENOTSUPP) {
56 dev_err(dai->dev, "simple-card: set_tdm_slot error\n");
57 goto err;
58 }
59 }
60
Xiubo Li4763ebe2014-01-24 15:43:00 +080061 ret = 0;
62
63err:
Kuninori Morimotoa4a29922013-01-10 16:49:11 -080064 return ret;
65}
66
Kuninori Morimotof2390882012-04-08 21:17:50 -070067static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
68{
Jean-Francois Moineb367a322014-01-15 16:52:00 +010069 struct simple_card_data *priv =
Xiubo Liba194a42014-01-13 17:08:08 +080070 snd_soc_card_get_drvdata(rtd->card);
Kuninori Morimotof2390882012-04-08 21:17:50 -070071 struct snd_soc_dai *codec = rtd->codec_dai;
72 struct snd_soc_dai *cpu = rtd->cpu_dai;
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +010073 struct simple_dai_props *dai_props;
74 int num, ret;
Kuninori Morimotof2390882012-04-08 21:17:50 -070075
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +010076 num = rtd - rtd->card->rtd;
77 dai_props = &priv->dai_props[num];
78 ret = __asoc_simple_card_dai_init(codec, &dai_props->codec_dai);
Kuninori Morimotoa4a29922013-01-10 16:49:11 -080079 if (ret < 0)
80 return ret;
Kuninori Morimotof2390882012-04-08 21:17:50 -070081
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +010082 ret = __asoc_simple_card_dai_init(cpu, &dai_props->cpu_dai);
Kuninori Morimotoa4a29922013-01-10 16:49:11 -080083 if (ret < 0)
84 return ret;
Kuninori Morimotof2390882012-04-08 21:17:50 -070085
86 return 0;
87}
88
Kuninori Morimotofa558c22013-11-20 15:25:02 +090089static int
90asoc_simple_card_sub_parse_of(struct device_node *np,
Xiubo Li30d03412014-01-24 15:43:01 +080091 unsigned int daifmt,
Kuninori Morimotofa558c22013-11-20 15:25:02 +090092 struct asoc_simple_dai *dai,
Jean-Francois Moine52008472014-01-15 16:51:48 +010093 const struct device_node **p_node,
94 const char **name)
Kuninori Morimotofa558c22013-11-20 15:25:02 +090095{
Jean-Francois Moine201a0ea2014-01-15 16:51:41 +010096 struct device_node *node;
Kuninori Morimotofa558c22013-11-20 15:25:02 +090097 struct clk *clk;
98 int ret;
99
100 /*
101 * get node via "sound-dai = <&phandle port>"
102 * it will be used as xxx_of_node on soc_bind_dai_link()
103 */
Jean-Francois Moine201a0ea2014-01-15 16:51:41 +0100104 node = of_parse_phandle(np, "sound-dai", 0);
105 if (!node)
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900106 return -ENODEV;
Jean-Francois Moine201a0ea2014-01-15 16:51:41 +0100107 *p_node = node;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900108
109 /* get dai->name */
Jean-Francois Moine52008472014-01-15 16:51:48 +0100110 ret = snd_soc_of_get_dai_name(np, name);
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900111 if (ret < 0)
Jean-Francois Moinee512e002014-03-11 10:03:40 +0100112 return ret;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900113
Xiubo Li6ff62ee2014-02-14 09:34:36 +0800114 /* parse TDM slot */
115 ret = snd_soc_of_parse_tdm_slot(np, &dai->slots, &dai->slot_width);
116 if (ret)
Jean-Francois Moinee512e002014-03-11 10:03:40 +0100117 return ret;
Xiubo Li6ff62ee2014-02-14 09:34:36 +0800118
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900119 /*
120 * bitclock-inversion, frame-inversion
121 * bitclock-master, frame-master
122 * and specific "format" if it has
123 */
124 dai->fmt = snd_soc_of_parse_daifmt(np, NULL);
Xiubo Li30d03412014-01-24 15:43:01 +0800125 dai->fmt |= daifmt;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900126
127 /*
128 * dai->sysclk come from
129 * "clocks = <&xxx>" (if system has common clock)
130 * or "system-clock-frequency = <xxx>"
Xiubo Li71467e42013-12-23 15:25:38 +0800131 * or device's module clock.
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900132 */
Xiubo Li71467e42013-12-23 15:25:38 +0800133 if (of_property_read_bool(np, "clocks")) {
134 clk = of_clk_get(np, 0);
135 if (IS_ERR(clk)) {
136 ret = PTR_ERR(clk);
Jean-Francois Moinee512e002014-03-11 10:03:40 +0100137 return ret;
Xiubo Li71467e42013-12-23 15:25:38 +0800138 }
139
140 dai->sysclk = clk_get_rate(clk);
141 } else if (of_property_read_bool(np, "system-clock-frequency")) {
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900142 of_property_read_u32(np,
143 "system-clock-frequency",
144 &dai->sysclk);
Xiubo Li71467e42013-12-23 15:25:38 +0800145 } else {
Jean-Francois Moine201a0ea2014-01-15 16:51:41 +0100146 clk = of_clk_get(node, 0);
Xiubo Lie2a19ac2014-01-06 12:34:36 +0800147 if (!IS_ERR(clk))
148 dai->sysclk = clk_get_rate(clk);
Xiubo Li71467e42013-12-23 15:25:38 +0800149 }
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900150
Jean-Francois Moinee512e002014-03-11 10:03:40 +0100151 return 0;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900152}
153
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100154static int simple_card_cpu_codec_of(struct device_node *node,
155 int daifmt,
156 struct snd_soc_dai_link *dai_link,
157 struct simple_dai_props *dai_props)
158{
159 struct device_node *np;
160 int ret;
161
162 /* CPU sub-node */
163 ret = -EINVAL;
164 np = of_get_child_by_name(node, "simple-audio-card,cpu");
165 if (np) {
166 ret = asoc_simple_card_sub_parse_of(np, daifmt,
167 &dai_props->cpu_dai,
168 &dai_link->cpu_of_node,
169 &dai_link->cpu_dai_name);
170 of_node_put(np);
171 }
172 if (ret < 0)
173 return ret;
174
175 /* CODEC sub-node */
176 ret = -EINVAL;
177 np = of_get_child_by_name(node, "simple-audio-card,codec");
178 if (np) {
179 ret = asoc_simple_card_sub_parse_of(np, daifmt,
180 &dai_props->codec_dai,
181 &dai_link->codec_of_node,
182 &dai_link->codec_dai_name);
183 of_node_put(np);
184 }
185 return ret;
186}
187
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900188static int asoc_simple_card_parse_of(struct device_node *node,
Jean-Francois Moineb367a322014-01-15 16:52:00 +0100189 struct simple_card_data *priv,
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100190 struct device *dev,
191 int multi)
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900192{
Jean-Francois Moineb367a322014-01-15 16:52:00 +0100193 struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link;
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100194 struct simple_dai_props *dai_props = priv->dai_props;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900195 struct device_node *np;
196 char *name;
Jean-Francois Moinec56c4d72014-03-15 11:32:42 +0100197 unsigned int daifmt;
Xiubo Lid4c22092013-12-23 12:57:01 +0800198 int ret;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900199
Xiubo Li27725552014-01-24 15:43:02 +0800200 /* parsing the card name from DT */
201 snd_soc_of_parse_card_name(&priv->snd_card, "simple-audio-card,name");
202
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900203 /* get CPU/CODEC common format via simple-audio-card,format */
Jean-Francois Moinec56c4d72014-03-15 11:32:42 +0100204 daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") &
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900205 (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK);
206
Xiubo Li9d681f52014-02-08 15:59:53 +0800207 /* off-codec widgets */
208 if (of_property_read_bool(node, "simple-audio-card,widgets")) {
209 ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card,
210 "simple-audio-card,widgets");
211 if (ret)
212 return ret;
213 }
214
Xiubo Lid4c22092013-12-23 12:57:01 +0800215 /* DAPM routes */
Xiubo Li8c0b8232014-01-07 09:15:16 +0800216 if (of_property_read_bool(node, "simple-audio-card,routing")) {
Jean-Francois Moineb367a322014-01-15 16:52:00 +0100217 ret = snd_soc_of_parse_audio_routing(&priv->snd_card,
Xiubo Li8c0b8232014-01-07 09:15:16 +0800218 "simple-audio-card,routing");
Xiubo Lif87a3e82014-01-07 09:13:42 +0800219 if (ret)
220 return ret;
221 }
Xiubo Lid4c22092013-12-23 12:57:01 +0800222
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100223 /* loop on the DAI links */
224 np = NULL;
225 for (;;) {
226 if (multi) {
227 np = of_get_next_child(node, np);
228 if (!np)
229 break;
230 }
231
232 ret = simple_card_cpu_codec_of(multi ? np : node,
233 daifmt, dai_link, dai_props);
234 if (ret < 0)
235 goto err;
236
237 /*
238 * overwrite cpu_dai->fmt as its DAIFMT_MASTER bit is based on CODEC
239 * while the other bits should be identical unless buggy SW/HW design.
240 */
241 dai_props->cpu_dai.fmt = dai_props->codec_dai.fmt;
242
243 if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) {
244 ret = -EINVAL;
245 goto err;
246 }
247
248 /* simple-card assumes platform == cpu */
249 dai_link->platform_of_node = dai_link->cpu_of_node;
250
251 name = devm_kzalloc(dev,
252 strlen(dai_link->cpu_dai_name) +
253 strlen(dai_link->codec_dai_name) + 2,
254 GFP_KERNEL);
255 sprintf(name, "%s-%s", dai_link->cpu_dai_name,
256 dai_link->codec_dai_name);
257 dai_link->name = dai_link->stream_name = name;
258
259 if (!multi)
260 break;
261
262 dai_link++;
263 dai_props++;
Jean-Francois Moinee512e002014-03-11 10:03:40 +0100264 }
Xiubo Lidd41e0c2013-12-20 14:39:50 +0800265
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900266 /* card name is created from CPU/CODEC dai name */
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100267 dai_link = priv->snd_card.dai_link;
Xiubo Li27725552014-01-24 15:43:02 +0800268 if (!priv->snd_card.name)
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100269 priv->snd_card.name = dai_link->name;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900270
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100271 dev_dbg(dev, "card-name : %s\n", priv->snd_card.name);
Jean-Francois Moinec56c4d72014-03-15 11:32:42 +0100272 dev_dbg(dev, "platform : %04x\n", daifmt);
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100273 dai_props = priv->dai_props;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900274 dev_dbg(dev, "cpu : %s / %04x / %d\n",
Jean-Francois Moine52008472014-01-15 16:51:48 +0100275 dai_link->cpu_dai_name,
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100276 dai_props->cpu_dai.fmt,
277 dai_props->cpu_dai.sysclk);
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900278 dev_dbg(dev, "codec : %s / %04x / %d\n",
Jean-Francois Moine52008472014-01-15 16:51:48 +0100279 dai_link->codec_dai_name,
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100280 dai_props->codec_dai.fmt,
281 dai_props->codec_dai.sysclk);
Kuninori Morimotof687d902014-02-27 18:25:24 -0800282
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900283 return 0;
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100284
285err:
286 of_node_put(np);
287 return ret;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900288}
289
Jean-Francois Moinee512e002014-03-11 10:03:40 +0100290/* update the reference count of the devices nodes at end of probe */
291static int asoc_simple_card_unref(struct platform_device *pdev)
292{
293 struct snd_soc_card *card = platform_get_drvdata(pdev);
294 struct snd_soc_dai_link *dai_link;
295 struct device_node *np;
296 int num_links;
297
298 for (num_links = 0, dai_link = card->dai_link;
299 num_links < card->num_links;
300 num_links++, dai_link++) {
301 np = (struct device_node *) dai_link->cpu_of_node;
302 if (np)
303 of_node_put(np);
304 np = (struct device_node *) dai_link->codec_of_node;
305 if (np)
306 of_node_put(np);
307 }
308 return 0;
309}
310
Kuninori Morimotof2390882012-04-08 21:17:50 -0700311static int asoc_simple_card_probe(struct platform_device *pdev)
312{
Jean-Francois Moine45fce592014-01-15 16:51:56 +0100313 struct simple_card_data *priv;
Jean-Francois Moine5ca8ba42014-01-15 16:51:45 +0100314 struct snd_soc_dai_link *dai_link;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900315 struct device_node *np = pdev->dev.of_node;
Kuninori Morimotof89983e2012-12-25 22:52:33 -0800316 struct device *dev = &pdev->dev;
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100317 int num_links, multi, ret;
318
319 /* get the number of DAI links */
320 if (np && of_get_child_by_name(np, "simple-audio-card,dai-link")) {
321 num_links = of_get_child_count(np);
322 multi = 1;
323 } else {
324 num_links = 1;
325 multi = 0;
326 }
Kuninori Morimotof2390882012-04-08 21:17:50 -0700327
Jean-Francois Moinecf7dc232014-03-20 10:52:41 +0100328 /* allocate the private data and the DAI link array */
329 priv = devm_kzalloc(dev,
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100330 sizeof(*priv) + sizeof(*dai_link) * num_links,
Jean-Francois Moinecf7dc232014-03-20 10:52:41 +0100331 GFP_KERNEL);
Jean-Francois Moineca65b492014-01-15 16:51:52 +0100332 if (!priv)
Xiubo Lica919fe2014-01-14 12:35:32 +0800333 return -ENOMEM;
334
Jean-Francois Moine201a0ea2014-01-15 16:51:41 +0100335 /*
336 * init snd_soc_card
337 */
Jean-Francois Moineca65b492014-01-15 16:51:52 +0100338 priv->snd_card.owner = THIS_MODULE;
339 priv->snd_card.dev = dev;
Jean-Francois Moinecf7dc232014-03-20 10:52:41 +0100340 dai_link = priv->dai_link;
Jean-Francois Moineca65b492014-01-15 16:51:52 +0100341 priv->snd_card.dai_link = dai_link;
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100342 priv->snd_card.num_links = num_links;
Xiubo Lica919fe2014-01-14 12:35:32 +0800343
Jean-Francois Moinecf7dc232014-03-20 10:52:41 +0100344 /* get room for the other properties */
345 priv->dai_props = devm_kzalloc(dev,
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100346 sizeof(*priv->dai_props) * num_links,
Jean-Francois Moinecf7dc232014-03-20 10:52:41 +0100347 GFP_KERNEL);
348 if (!priv->dai_props)
349 return -ENOMEM;
350
Jean-Francois Moine201a0ea2014-01-15 16:51:41 +0100351 if (np && of_device_is_available(np)) {
352
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100353 ret = asoc_simple_card_parse_of(np, priv, dev, multi);
Xiubo Lica919fe2014-01-14 12:35:32 +0800354 if (ret < 0) {
355 if (ret != -EPROBE_DEFER)
356 dev_err(dev, "parse error %d\n", ret);
Jean-Francois Moinee512e002014-03-11 10:03:40 +0100357 goto err;
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900358 }
Jean-Francois Moine6a91a17bd2014-03-20 11:49:55 +0100359
360 /*
361 * soc_bind_dai_link() will check cpu name
362 * after of_node matching if dai_link has cpu_dai_name.
363 * but, it will never match if name was created by fmt_single_name()
364 * remove cpu_dai_name to escape name matching.
365 * see
366 * fmt_single_name()
367 * fmt_multiple_name()
368 */
369 if (num_links == 1)
370 dai_link->cpu_dai_name = NULL;
371
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900372 } else {
Jean-Francois Moineca65b492014-01-15 16:51:52 +0100373 struct asoc_simple_card_info *cinfo;
374
375 cinfo = dev->platform_data;
376 if (!cinfo) {
Xiubo Li34787d02014-01-09 17:49:40 +0800377 dev_err(dev, "no info for asoc-simple-card\n");
378 return -EINVAL;
379 }
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900380
Jean-Francois Moine7722f832014-01-15 16:51:33 +0100381 if (!cinfo->name ||
Jean-Francois Moine7722f832014-01-15 16:51:33 +0100382 !cinfo->codec_dai.name ||
383 !cinfo->codec ||
384 !cinfo->platform ||
385 !cinfo->cpu_dai.name) {
386 dev_err(dev, "insufficient asoc_simple_card_info settings\n");
387 return -EINVAL;
388 }
Jean-Francois Moine2bee9912014-01-15 16:51:37 +0100389
Kuninori Morimoto12ffa6f2014-03-09 19:37:56 -0700390 priv->snd_card.name = (cinfo->card) ? cinfo->card : cinfo->name;
Jean-Francois Moine5ca8ba42014-01-15 16:51:45 +0100391 dai_link->name = cinfo->name;
392 dai_link->stream_name = cinfo->name;
393 dai_link->platform_name = cinfo->platform;
394 dai_link->codec_name = cinfo->codec;
Jean-Francois Moine52008472014-01-15 16:51:48 +0100395 dai_link->cpu_dai_name = cinfo->cpu_dai.name;
396 dai_link->codec_dai_name = cinfo->codec_dai.name;
Jean-Francois Moinecf7dc232014-03-20 10:52:41 +0100397 memcpy(&priv->dai_props->cpu_dai, &cinfo->cpu_dai,
398 sizeof(priv->dai_props->cpu_dai));
399 memcpy(&priv->dai_props->codec_dai, &cinfo->codec_dai,
400 sizeof(priv->dai_props->codec_dai));
Kuninori Morimoto81985bd2014-03-02 20:32:43 -0800401
Jean-Francois Moinecf7dc232014-03-20 10:52:41 +0100402 priv->dai_props->cpu_dai.fmt |= cinfo->daifmt;
403 priv->dai_props->codec_dai.fmt |= cinfo->daifmt;
Kuninori Morimotof2390882012-04-08 21:17:50 -0700404 }
405
406 /*
407 * init snd_soc_dai_link
408 */
Jean-Francois Moine5ca8ba42014-01-15 16:51:45 +0100409 dai_link->init = asoc_simple_card_dai_init;
Kuninori Morimotof2390882012-04-08 21:17:50 -0700410
Jean-Francois Moineca65b492014-01-15 16:51:52 +0100411 snd_soc_card_set_drvdata(&priv->snd_card, priv);
Xiubo Liba194a42014-01-13 17:08:08 +0800412
Jean-Francois Moinee512e002014-03-11 10:03:40 +0100413 ret = devm_snd_soc_register_card(&pdev->dev, &priv->snd_card);
414
415err:
416 asoc_simple_card_unref(pdev);
417 return ret;
Kuninori Morimotof2390882012-04-08 21:17:50 -0700418}
419
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900420static const struct of_device_id asoc_simple_of_match[] = {
421 { .compatible = "simple-audio-card", },
422 {},
423};
424MODULE_DEVICE_TABLE(of, asoc_simple_of_match);
425
Kuninori Morimotof2390882012-04-08 21:17:50 -0700426static struct platform_driver asoc_simple_card = {
427 .driver = {
428 .name = "asoc-simple-card",
Fabio Estevamc445be32013-08-23 14:35:17 -0300429 .owner = THIS_MODULE,
Kuninori Morimotofa558c22013-11-20 15:25:02 +0900430 .of_match_table = asoc_simple_of_match,
Kuninori Morimotof2390882012-04-08 21:17:50 -0700431 },
432 .probe = asoc_simple_card_probe,
Kuninori Morimotof2390882012-04-08 21:17:50 -0700433};
434
435module_platform_driver(asoc_simple_card);
436
Fabio Estevamc445be32013-08-23 14:35:17 -0300437MODULE_ALIAS("platform:asoc-simple-card");
Kuninori Morimotof2390882012-04-08 21:17:50 -0700438MODULE_LICENSE("GPL");
439MODULE_DESCRIPTION("ASoC Simple Sound Card");
440MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");