wm8960-soundcard.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // ASoC simple sound card support
  4. //
  5. // Copyright (C) 2012 Renesas Solutions Corp.
  6. // Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  7. #include <linux/clk.h>
  8. #include <linux/device.h>
  9. #include <linux/module.h>
  10. #include <linux/of.h>
  11. #include <linux/of_device.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/string.h>
  14. #include <sound/simple_card.h>
  15. #include <sound/soc-dai.h>
  16. #include <sound/soc.h>
  17. #define DPCM_SELECTABLE 1
  18. #define DAI "sound-dai"
  19. #define CELL "#sound-dai-cells"
  20. #define PREFIX "simple-audio-card,"
  21. static const struct snd_soc_ops simple_ops = {
  22. .startup = asoc_simple_startup,
  23. .shutdown = asoc_simple_shutdown,
  24. .hw_params = asoc_simple_hw_params,
  25. };
  26. static int asoc_simple_parse_dai(struct device_node *node,
  27. struct snd_soc_dai_link_component *dlc,
  28. int *is_single_link)
  29. {
  30. struct of_phandle_args args;
  31. int ret;
  32. if (!node)
  33. return 0;
  34. /*
  35. * Get node via "sound-dai = <&phandle port>"
  36. * it will be used as xxx_of_node on soc_bind_dai_link()
  37. */
  38. ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args);
  39. if (ret)
  40. return ret;
  41. /*
  42. * FIXME
  43. *
  44. * Here, dlc->dai_name is pointer to CPU/Codec DAI name.
  45. * If user unbinded CPU or Codec driver, but not for Sound Card,
  46. * dlc->dai_name is keeping unbinded CPU or Codec
  47. * driver's pointer.
  48. *
  49. * If user re-bind CPU or Codec driver again, ALSA SoC will try
  50. * to rebind Card via snd_soc_try_rebind_card(), but because of
  51. * above reason, it might can't bind Sound Card.
  52. * Because Sound Card is pointing to released dai_name pointer.
  53. *
  54. * To avoid this rebind Card issue,
  55. * 1) It needs to alloc memory to keep dai_name eventhough
  56. * CPU or Codec driver was unbinded, or
  57. * 2) user need to rebind Sound Card everytime
  58. * if he unbinded CPU or Codec.
  59. */
  60. ret = snd_soc_of_get_dai_name(node, &dlc->dai_name);
  61. if (ret < 0)
  62. return ret;
  63. dlc->of_node = args.np;
  64. if (is_single_link)
  65. *is_single_link = !args.args_count;
  66. return 0;
  67. }
  68. static void simple_parse_convert(struct device *dev,
  69. struct device_node *np,
  70. struct asoc_simple_data *adata)
  71. {
  72. struct device_node *top = dev->of_node;
  73. struct device_node *node = of_get_parent(np);
  74. asoc_simple_parse_convert(dev, top, PREFIX, adata);
  75. asoc_simple_parse_convert(dev, node, PREFIX, adata);
  76. asoc_simple_parse_convert(dev, node, NULL, adata);
  77. asoc_simple_parse_convert(dev, np, NULL, adata);
  78. of_node_put(node);
  79. }
  80. static void simple_parse_mclk_fs(struct device_node *top,
  81. struct device_node *cpu,
  82. struct device_node *codec,
  83. struct simple_dai_props *props,
  84. char *prefix)
  85. {
  86. struct device_node *node = of_get_parent(cpu);
  87. char prop[128];
  88. snprintf(prop, sizeof(prop), "%smclk-fs", PREFIX);
  89. of_property_read_u32(top, prop, &props->mclk_fs);
  90. snprintf(prop, sizeof(prop), "%smclk-fs", prefix);
  91. of_property_read_u32(node, prop, &props->mclk_fs);
  92. of_property_read_u32(cpu, prop, &props->mclk_fs);
  93. of_property_read_u32(codec, prop, &props->mclk_fs);
  94. of_node_put(node);
  95. }
  96. static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
  97. struct device_node *np,
  98. struct device_node *codec,
  99. struct link_info *li,
  100. bool is_top)
  101. {
  102. struct device *dev = simple_priv_to_dev(priv);
  103. struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
  104. struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
  105. struct asoc_simple_dai *dai;
  106. struct snd_soc_dai_link_component *cpus = dai_link->cpus;
  107. struct snd_soc_dai_link_component *codecs = dai_link->codecs;
  108. struct device_node *top = dev->of_node;
  109. struct device_node *node = of_get_parent(np);
  110. char *prefix = "";
  111. int ret;
  112. /*
  113. * |CPU |Codec : turn
  114. * CPU |Pass |return
  115. * Codec |return|Pass
  116. * np
  117. */
  118. if (li->cpu == (np == codec))
  119. return 0;
  120. dev_dbg(dev, "link_of DPCM (%pOF)\n", np);
  121. li->link++;
  122. /* For single DAI link & old style of DT node */
  123. if (is_top)
  124. prefix = PREFIX;
  125. if (li->cpu) {
  126. int is_single_links = 0;
  127. /* Codec is dummy */
  128. codecs->of_node = NULL;
  129. codecs->dai_name = "snd-soc-dummy-dai";
  130. codecs->name = "snd-soc-dummy";
  131. /* FE settings */
  132. dai_link->dynamic = 1;
  133. dai_link->dpcm_merged_format = 1;
  134. dai =
  135. dai_props->cpu_dai = &priv->dais[li->dais++];
  136. ret = asoc_simple_parse_cpu(np, dai_link, &is_single_links);
  137. if (ret)
  138. goto out_put_node;
  139. ret = asoc_simple_parse_clk_cpu(dev, np, dai_link, dai);
  140. if (ret < 0)
  141. goto out_put_node;
  142. ret = asoc_simple_set_dailink_name(dev, dai_link,
  143. "fe.%s",
  144. cpus->dai_name);
  145. if (ret < 0)
  146. goto out_put_node;
  147. asoc_simple_canonicalize_cpu(dai_link, is_single_links);
  148. } else {
  149. struct snd_soc_codec_conf *cconf;
  150. /* CPU is dummy */
  151. cpus->of_node = NULL;
  152. cpus->dai_name = "snd-soc-dummy-dai";
  153. cpus->name = "snd-soc-dummy";
  154. /* BE settings */
  155. dai_link->no_pcm = 1;
  156. dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup;
  157. dai =
  158. dai_props->codec_dai = &priv->dais[li->dais++];
  159. cconf =
  160. dai_props->codec_conf = &priv->codec_conf[li->conf++];
  161. ret = asoc_simple_parse_codec(np, dai_link);
  162. if (ret < 0)
  163. goto out_put_node;
  164. ret = asoc_simple_parse_clk_codec(dev, np, dai_link, dai);
  165. if (ret < 0)
  166. goto out_put_node;
  167. ret = asoc_simple_set_dailink_name(dev, dai_link,
  168. "be.%s",
  169. codecs->dai_name);
  170. if (ret < 0)
  171. goto out_put_node;
  172. /* check "prefix" from top node */
  173. snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node,
  174. PREFIX "prefix");
  175. snd_soc_of_parse_node_prefix(node, cconf, codecs->of_node,
  176. "prefix");
  177. snd_soc_of_parse_node_prefix(np, cconf, codecs->of_node,
  178. "prefix");
  179. }
  180. simple_parse_convert(dev, np, &dai_props->adata);
  181. simple_parse_mclk_fs(top, np, codec, dai_props, prefix);
  182. asoc_simple_canonicalize_platform(dai_link);
  183. ret = asoc_simple_parse_tdm(np, dai);
  184. if (ret)
  185. goto out_put_node;
  186. ret = asoc_simple_parse_daifmt(dev, node, codec,
  187. prefix, &dai_link->dai_fmt);
  188. if (ret < 0)
  189. goto out_put_node;
  190. snd_soc_dai_link_set_capabilities(dai_link);
  191. dai_link->ops = &simple_ops;
  192. dai_link->init = asoc_simple_dai_init;
  193. out_put_node:
  194. of_node_put(node);
  195. return ret;
  196. }
  197. static int simple_dai_link_of(struct asoc_simple_priv *priv,
  198. struct device_node *np,
  199. struct device_node *codec,
  200. struct link_info *li,
  201. bool is_top)
  202. {
  203. struct device *dev = simple_priv_to_dev(priv);
  204. struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
  205. struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
  206. struct asoc_simple_dai *cpu_dai;
  207. struct asoc_simple_dai *codec_dai;
  208. struct device_node *top = dev->of_node;
  209. struct device_node *cpu = NULL;
  210. struct device_node *node = NULL;
  211. struct device_node *plat = NULL;
  212. char prop[128];
  213. char *prefix = "";
  214. int ret, single_cpu = 0;
  215. /*
  216. * |CPU |Codec : turn
  217. * CPU |Pass |return
  218. * Codec |return|return
  219. * np
  220. */
  221. if (!li->cpu || np == codec)
  222. return 0;
  223. cpu = np;
  224. node = of_get_parent(np);
  225. li->link++;
  226. dev_dbg(dev, "link_of (%pOF)\n", node);
  227. /* For single DAI link & old style of DT node */
  228. if (is_top)
  229. prefix = PREFIX;
  230. snprintf(prop, sizeof(prop), "%splat", prefix);
  231. plat = of_get_child_by_name(node, prop);
  232. cpu_dai =
  233. dai_props->cpu_dai = &priv->dais[li->dais++];
  234. codec_dai =
  235. dai_props->codec_dai = &priv->dais[li->dais++];
  236. ret = asoc_simple_parse_daifmt(dev, node, codec,
  237. prefix, &dai_link->dai_fmt);
  238. if (ret < 0)
  239. goto dai_link_of_err;
  240. simple_parse_mclk_fs(top, cpu, codec, dai_props, prefix);
  241. ret = asoc_simple_parse_cpu(cpu, dai_link, &single_cpu);
  242. if (ret < 0)
  243. goto dai_link_of_err;
  244. ret = asoc_simple_parse_codec(codec, dai_link);
  245. if (ret < 0)
  246. goto dai_link_of_err;
  247. ret = asoc_simple_parse_platform(plat, dai_link);
  248. if (ret < 0)
  249. goto dai_link_of_err;
  250. ret = asoc_simple_parse_tdm(cpu, cpu_dai);
  251. if (ret < 0)
  252. goto dai_link_of_err;
  253. ret = asoc_simple_parse_tdm(codec, codec_dai);
  254. if (ret < 0)
  255. goto dai_link_of_err;
  256. ret = asoc_simple_parse_clk_cpu(dev, cpu, dai_link, cpu_dai);
  257. if (ret < 0)
  258. goto dai_link_of_err;
  259. ret = asoc_simple_parse_clk_codec(dev, codec, dai_link, codec_dai);
  260. if (ret < 0)
  261. goto dai_link_of_err;
  262. ret = asoc_simple_set_dailink_name(dev, dai_link,
  263. "%s-%s",
  264. dai_link->cpus->dai_name,
  265. dai_link->codecs->dai_name);
  266. if (ret < 0)
  267. goto dai_link_of_err;
  268. dai_link->ops = &simple_ops;
  269. dai_link->init = asoc_simple_dai_init;
  270. asoc_simple_canonicalize_cpu(dai_link, single_cpu);
  271. asoc_simple_canonicalize_platform(dai_link);
  272. dai_link_of_err:
  273. of_node_put(plat);
  274. of_node_put(node);
  275. return ret;
  276. }
  277. static int simple_for_each_link(struct asoc_simple_priv *priv,
  278. struct link_info *li,
  279. int (*func_noml)(struct asoc_simple_priv *priv,
  280. struct device_node *np,
  281. struct device_node *codec,
  282. struct link_info *li, bool is_top),
  283. int (*func_dpcm)(struct asoc_simple_priv *priv,
  284. struct device_node *np,
  285. struct device_node *codec,
  286. struct link_info *li, bool is_top))
  287. {
  288. struct device *dev = simple_priv_to_dev(priv);
  289. struct device_node *top = dev->of_node;
  290. struct device_node *node;
  291. uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev);
  292. bool is_top = 0;
  293. int ret = 0;
  294. /* Check if it has dai-link */
  295. node = of_get_child_by_name(top, PREFIX "dai-link");
  296. if (!node) {
  297. node = of_node_get(top);
  298. is_top = 1;
  299. }
  300. /* loop for all dai-link */
  301. do {
  302. struct asoc_simple_data adata;
  303. struct device_node *codec;
  304. struct device_node *plat;
  305. struct device_node *np;
  306. int num = of_get_child_count(node);
  307. /* get codec */
  308. codec = of_get_child_by_name(node, is_top ?
  309. PREFIX "codec" : "codec");
  310. if (!codec) {
  311. ret = -ENODEV;
  312. goto error;
  313. }
  314. /* get platform */
  315. plat = of_get_child_by_name(node, is_top ?
  316. PREFIX "plat" : "plat");
  317. /* get convert-xxx property */
  318. memset(&adata, 0, sizeof(adata));
  319. for_each_child_of_node(node, np)
  320. simple_parse_convert(dev, np, &adata);
  321. /* loop for all CPU/Codec node */
  322. for_each_child_of_node(node, np) {
  323. if (plat == np)
  324. continue;
  325. /*
  326. * It is DPCM
  327. * if it has many CPUs,
  328. * or has convert-xxx property
  329. */
  330. if (dpcm_selectable &&
  331. (num > 2 ||
  332. adata.convert_rate || adata.convert_channels))
  333. ret = func_dpcm(priv, np, codec, li, is_top);
  334. /* else normal sound */
  335. else
  336. ret = func_noml(priv, np, codec, li, is_top);
  337. if (ret < 0) {
  338. of_node_put(codec);
  339. of_node_put(np);
  340. goto error;
  341. }
  342. }
  343. of_node_put(codec);
  344. node = of_get_next_child(top, node);
  345. } while (!is_top && node);
  346. error:
  347. of_node_put(node);
  348. return ret;
  349. }
  350. static int simple_parse_of(struct asoc_simple_priv *priv)
  351. {
  352. struct device *dev = simple_priv_to_dev(priv);
  353. struct device_node *top = dev->of_node;
  354. struct snd_soc_card *card = simple_priv_to_card(priv);
  355. struct link_info li;
  356. int ret;
  357. if (!top)
  358. return -EINVAL;
  359. ret = asoc_simple_parse_widgets(card, PREFIX);
  360. if (ret < 0)
  361. return ret;
  362. ret = asoc_simple_parse_routing(card, PREFIX);
  363. if (ret < 0)
  364. return ret;
  365. ret = asoc_simple_parse_pin_switches(card, PREFIX);
  366. if (ret < 0)
  367. return ret;
  368. /* Single/Muti DAI link(s) & New style of DT node */
  369. memset(&li, 0, sizeof(li));
  370. for (li.cpu = 1; li.cpu >= 0; li.cpu--) {
  371. /*
  372. * Detect all CPU first, and Detect all Codec 2nd.
  373. *
  374. * In Normal sound case, all DAIs are detected
  375. * as "CPU-Codec".
  376. *
  377. * In DPCM sound case,
  378. * all CPUs are detected as "CPU-dummy", and
  379. * all Codecs are detected as "dummy-Codec".
  380. * To avoid random sub-device numbering,
  381. * detect "dummy-Codec" in last;
  382. */
  383. ret = simple_for_each_link(priv, &li,
  384. simple_dai_link_of,
  385. simple_dai_link_of_dpcm);
  386. if (ret < 0)
  387. return ret;
  388. }
  389. ret = asoc_simple_parse_card_name(card, PREFIX);
  390. if (ret < 0)
  391. return ret;
  392. ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs");
  393. return ret;
  394. }
  395. static int simple_count_noml(struct asoc_simple_priv *priv,
  396. struct device_node *np,
  397. struct device_node *codec,
  398. struct link_info *li, bool is_top)
  399. {
  400. li->dais++; /* CPU or Codec */
  401. if (np != codec)
  402. li->link++; /* CPU-Codec */
  403. return 0;
  404. }
  405. static int simple_count_dpcm(struct asoc_simple_priv *priv,
  406. struct device_node *np,
  407. struct device_node *codec,
  408. struct link_info *li, bool is_top)
  409. {
  410. li->dais++; /* CPU or Codec */
  411. li->link++; /* CPU-dummy or dummy-Codec */
  412. if (np == codec)
  413. li->conf++;
  414. return 0;
  415. }
  416. static void simple_get_dais_count(struct asoc_simple_priv *priv,
  417. struct link_info *li)
  418. {
  419. struct device *dev = simple_priv_to_dev(priv);
  420. struct device_node *top = dev->of_node;
  421. /*
  422. * link_num : number of links.
  423. * CPU-Codec / CPU-dummy / dummy-Codec
  424. * dais_num : number of DAIs
  425. * ccnf_num : number of codec_conf
  426. * same number for "dummy-Codec"
  427. *
  428. * ex1)
  429. * CPU0 --- Codec0 link : 5
  430. * CPU1 --- Codec1 dais : 7
  431. * CPU2 -/ ccnf : 1
  432. * CPU3 --- Codec2
  433. *
  434. * => 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec
  435. * => 7 DAIs = 4xCPU + 3xCodec
  436. * => 1 ccnf = 1xdummy-Codec
  437. *
  438. * ex2)
  439. * CPU0 --- Codec0 link : 5
  440. * CPU1 --- Codec1 dais : 6
  441. * CPU2 -/ ccnf : 1
  442. * CPU3 -/
  443. *
  444. * => 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec
  445. * => 6 DAIs = 4xCPU + 2xCodec
  446. * => 1 ccnf = 1xdummy-Codec
  447. *
  448. * ex3)
  449. * CPU0 --- Codec0 link : 6
  450. * CPU1 -/ dais : 6
  451. * CPU2 --- Codec1 ccnf : 2
  452. * CPU3 -/
  453. *
  454. * => 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec
  455. * => 6 DAIs = 4xCPU + 2xCodec
  456. * => 2 ccnf = 2xdummy-Codec
  457. *
  458. * ex4)
  459. * CPU0 --- Codec0 (convert-rate) link : 3
  460. * CPU1 --- Codec1 dais : 4
  461. * ccnf : 1
  462. *
  463. * => 3 links = 1xCPU-Codec + 1xCPU-dummy + 1xdummy-Codec
  464. * => 4 DAIs = 2xCPU + 2xCodec
  465. * => 1 ccnf = 1xdummy-Codec
  466. */
  467. if (!top) {
  468. li->link = 1;
  469. li->dais = 2;
  470. li->conf = 0;
  471. return;
  472. }
  473. simple_for_each_link(priv, li,
  474. simple_count_noml,
  475. simple_count_dpcm);
  476. dev_dbg(dev, "link %d, dais %d, ccnf %d\n",
  477. li->link, li->dais, li->conf);
  478. }
  479. static int simple_soc_probe(struct snd_soc_card *card)
  480. {
  481. struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
  482. int ret;
  483. ret = asoc_simple_init_hp(card, &priv->hp_jack, PREFIX);
  484. if (ret < 0)
  485. return ret;
  486. ret = asoc_simple_init_mic(card, &priv->mic_jack, PREFIX);
  487. if (ret < 0)
  488. return ret;
  489. return 0;
  490. }
  491. static int asoc_simple_probe(struct platform_device *pdev)
  492. {
  493. struct asoc_simple_priv *priv;
  494. struct device *dev = &pdev->dev;
  495. struct device_node *np = dev->of_node;
  496. struct snd_soc_card *card;
  497. struct link_info li;
  498. int ret;
  499. /* Allocate the private data and the DAI link array */
  500. priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  501. if (!priv)
  502. return -ENOMEM;
  503. card = simple_priv_to_card(priv);
  504. card->owner = THIS_MODULE;
  505. card->dev = dev;
  506. card->probe = simple_soc_probe;
  507. memset(&li, 0, sizeof(li));
  508. simple_get_dais_count(priv, &li);
  509. if (!li.link || !li.dais)
  510. return -EINVAL;
  511. ret = asoc_simple_init_priv(priv, &li);
  512. if (ret < 0)
  513. return ret;
  514. if (np && of_device_is_available(np)) {
  515. ret = simple_parse_of(priv);
  516. if (ret < 0) {
  517. if (ret != -EPROBE_DEFER)
  518. dev_err(dev, "parse error %d\n", ret);
  519. goto err;
  520. }
  521. } else {
  522. struct asoc_simple_card_info *cinfo;
  523. struct snd_soc_dai_link_component *cpus;
  524. struct snd_soc_dai_link_component *codecs;
  525. struct snd_soc_dai_link_component *platform;
  526. struct snd_soc_dai_link *dai_link = priv->dai_link;
  527. struct simple_dai_props *dai_props = priv->dai_props;
  528. int dai_idx = 0;
  529. cinfo = dev->platform_data;
  530. if (!cinfo) {
  531. dev_err(dev, "no info for asoc-simple-card\n");
  532. return -EINVAL;
  533. }
  534. if (!cinfo->name ||
  535. !cinfo->codec_dai.name ||
  536. !cinfo->codec ||
  537. !cinfo->platform ||
  538. !cinfo->cpu_dai.name) {
  539. dev_err(dev, "insufficient asoc_simple_card_info settings\n");
  540. return -EINVAL;
  541. }
  542. dai_props->cpu_dai = &priv->dais[dai_idx++];
  543. dai_props->codec_dai = &priv->dais[dai_idx++];
  544. cpus = dai_link->cpus;
  545. cpus->dai_name = cinfo->cpu_dai.name;
  546. codecs = dai_link->codecs;
  547. codecs->name = cinfo->codec;
  548. codecs->dai_name = cinfo->codec_dai.name;
  549. platform = dai_link->platforms;
  550. platform->name = cinfo->platform;
  551. card->name = (cinfo->card) ? cinfo->card : cinfo->name;
  552. dai_link->name = cinfo->name;
  553. dai_link->stream_name = cinfo->name;
  554. dai_link->dai_fmt = cinfo->daifmt;
  555. dai_link->init = asoc_simple_dai_init;
  556. memcpy(dai_props->cpu_dai, &cinfo->cpu_dai,
  557. sizeof(*dai_props->cpu_dai));
  558. memcpy(dai_props->codec_dai, &cinfo->codec_dai,
  559. sizeof(*dai_props->codec_dai));
  560. }
  561. snd_soc_card_set_drvdata(card, priv);
  562. asoc_simple_debug_info(priv);
  563. ret = devm_snd_soc_register_card(dev, card);
  564. if (ret < 0)
  565. goto err;
  566. return 0;
  567. err:
  568. asoc_simple_clean_reference(card);
  569. return ret;
  570. }
  571. static int asoc_simple_remove(struct platform_device *pdev)
  572. {
  573. struct snd_soc_card *card = platform_get_drvdata(pdev);
  574. return asoc_simple_clean_reference(card);
  575. }
  576. static const struct of_device_id simple_of_match[] = {
  577. { .compatible = "simple-audio-card", },
  578. { .compatible = "simple-scu-audio-card",
  579. .data = (void *)DPCM_SELECTABLE },
  580. {},
  581. };
  582. MODULE_DEVICE_TABLE(of, simple_of_match);
  583. static struct platform_driver asoc_simple_card = {
  584. .driver = {
  585. .name = "asoc-simple-card",
  586. .pm = &snd_soc_pm_ops,
  587. .of_match_table = simple_of_match,
  588. },
  589. .probe = asoc_simple_probe,
  590. .remove = asoc_simple_remove,
  591. };
  592. module_platform_driver(asoc_simple_card);
  593. MODULE_ALIAS("platform:asoc-simple-card");
  594. MODULE_LICENSE("GPL v2");
  595. MODULE_DESCRIPTION("ASoC wm8960 Sound Card");
  596. MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");