fsi-ak4642.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * FSI-AK464x sound support for ms7724se
  3. *
  4. * Copyright (C) 2009 Renesas Solutions Corp.
  5. * Kuninori Morimoto <morimoto.kuninori@renesas.com>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/module.h>
  13. #include <sound/sh_fsi.h>
  14. struct fsi_ak4642_data {
  15. const char *name;
  16. const char *card;
  17. const char *cpu_dai;
  18. const char *codec;
  19. const char *platform;
  20. int id;
  21. };
  22. static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd)
  23. {
  24. struct snd_soc_dai *codec = rtd->codec_dai;
  25. struct snd_soc_dai *cpu = rtd->cpu_dai;
  26. int ret;
  27. ret = snd_soc_dai_set_fmt(codec, SND_SOC_DAIFMT_LEFT_J |
  28. SND_SOC_DAIFMT_CBM_CFM);
  29. if (ret < 0)
  30. return ret;
  31. ret = snd_soc_dai_set_sysclk(codec, 0, 11289600, 0);
  32. if (ret < 0)
  33. return ret;
  34. ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_LEFT_J |
  35. SND_SOC_DAIFMT_CBS_CFS);
  36. return ret;
  37. }
  38. static struct snd_soc_dai_link fsi_dai_link = {
  39. .codec_dai_name = "ak4642-hifi",
  40. .init = fsi_ak4642_dai_init,
  41. };
  42. static struct snd_soc_card fsi_soc_card = {
  43. .dai_link = &fsi_dai_link,
  44. .num_links = 1,
  45. };
  46. static struct platform_device *fsi_snd_device;
  47. static int fsi_ak4642_probe(struct platform_device *pdev)
  48. {
  49. int ret = -ENOMEM;
  50. const struct platform_device_id *id_entry;
  51. struct fsi_ak4642_data *pdata;
  52. id_entry = pdev->id_entry;
  53. if (!id_entry) {
  54. dev_err(&pdev->dev, "unknown fsi ak4642\n");
  55. return -ENODEV;
  56. }
  57. pdata = (struct fsi_ak4642_data *)id_entry->driver_data;
  58. fsi_snd_device = platform_device_alloc("soc-audio", pdata->id);
  59. if (!fsi_snd_device)
  60. goto out;
  61. fsi_dai_link.name = pdata->name;
  62. fsi_dai_link.stream_name = pdata->name;
  63. fsi_dai_link.cpu_dai_name = pdata->cpu_dai;
  64. fsi_dai_link.platform_name = pdata->platform;
  65. fsi_dai_link.codec_name = pdata->codec;
  66. fsi_soc_card.name = pdata->card;
  67. platform_set_drvdata(fsi_snd_device, &fsi_soc_card);
  68. ret = platform_device_add(fsi_snd_device);
  69. if (ret)
  70. platform_device_put(fsi_snd_device);
  71. out:
  72. return ret;
  73. }
  74. static int fsi_ak4642_remove(struct platform_device *pdev)
  75. {
  76. platform_device_unregister(fsi_snd_device);
  77. return 0;
  78. }
  79. static struct fsi_ak4642_data fsi_a_ak4642 = {
  80. .name = "AK4642",
  81. .card = "FSIA-AK4642",
  82. .cpu_dai = "fsia-dai",
  83. .codec = "ak4642-codec.0-0012",
  84. .platform = "sh_fsi.0",
  85. .id = FSI_PORT_A,
  86. };
  87. static struct fsi_ak4642_data fsi_b_ak4642 = {
  88. .name = "AK4642",
  89. .card = "FSIB-AK4642",
  90. .cpu_dai = "fsib-dai",
  91. .codec = "ak4642-codec.0-0012",
  92. .platform = "sh_fsi.0",
  93. .id = FSI_PORT_B,
  94. };
  95. static struct fsi_ak4642_data fsi_a_ak4643 = {
  96. .name = "AK4643",
  97. .card = "FSIA-AK4643",
  98. .cpu_dai = "fsia-dai",
  99. .codec = "ak4642-codec.0-0013",
  100. .platform = "sh_fsi.0",
  101. .id = FSI_PORT_A,
  102. };
  103. static struct fsi_ak4642_data fsi_b_ak4643 = {
  104. .name = "AK4643",
  105. .card = "FSIB-AK4643",
  106. .cpu_dai = "fsib-dai",
  107. .codec = "ak4642-codec.0-0013",
  108. .platform = "sh_fsi.0",
  109. .id = FSI_PORT_B,
  110. };
  111. static struct fsi_ak4642_data fsi2_a_ak4642 = {
  112. .name = "AK4642",
  113. .card = "FSI2A-AK4642",
  114. .cpu_dai = "fsia-dai",
  115. .codec = "ak4642-codec.0-0012",
  116. .platform = "sh_fsi2",
  117. .id = FSI_PORT_A,
  118. };
  119. static struct fsi_ak4642_data fsi2_b_ak4642 = {
  120. .name = "AK4642",
  121. .card = "FSI2B-AK4642",
  122. .cpu_dai = "fsib-dai",
  123. .codec = "ak4642-codec.0-0012",
  124. .platform = "sh_fsi2",
  125. .id = FSI_PORT_B,
  126. };
  127. static struct fsi_ak4642_data fsi2_a_ak4643 = {
  128. .name = "AK4643",
  129. .card = "FSI2A-AK4643",
  130. .cpu_dai = "fsia-dai",
  131. .codec = "ak4642-codec.0-0013",
  132. .platform = "sh_fsi2",
  133. .id = FSI_PORT_A,
  134. };
  135. static struct fsi_ak4642_data fsi2_b_ak4643 = {
  136. .name = "AK4643",
  137. .card = "FSI2B-AK4643",
  138. .cpu_dai = "fsib-dai",
  139. .codec = "ak4642-codec.0-0013",
  140. .platform = "sh_fsi2",
  141. .id = FSI_PORT_B,
  142. };
  143. static struct platform_device_id fsi_id_table[] = {
  144. /* FSI */
  145. { "sh_fsi_a_ak4642", (kernel_ulong_t)&fsi_a_ak4642 },
  146. { "sh_fsi_b_ak4642", (kernel_ulong_t)&fsi_b_ak4642 },
  147. { "sh_fsi_a_ak4643", (kernel_ulong_t)&fsi_a_ak4643 },
  148. { "sh_fsi_b_ak4643", (kernel_ulong_t)&fsi_b_ak4643 },
  149. /* FSI 2 */
  150. { "sh_fsi2_a_ak4642", (kernel_ulong_t)&fsi2_a_ak4642 },
  151. { "sh_fsi2_b_ak4642", (kernel_ulong_t)&fsi2_b_ak4642 },
  152. { "sh_fsi2_a_ak4643", (kernel_ulong_t)&fsi2_a_ak4643 },
  153. { "sh_fsi2_b_ak4643", (kernel_ulong_t)&fsi2_b_ak4643 },
  154. {},
  155. };
  156. static struct platform_driver fsi_ak4642 = {
  157. .driver = {
  158. .name = "fsi-ak4642-audio",
  159. },
  160. .probe = fsi_ak4642_probe,
  161. .remove = fsi_ak4642_remove,
  162. .id_table = fsi_id_table,
  163. };
  164. static int __init fsi_ak4642_init(void)
  165. {
  166. return platform_driver_register(&fsi_ak4642);
  167. }
  168. static void __exit fsi_ak4642_exit(void)
  169. {
  170. platform_driver_unregister(&fsi_ak4642);
  171. }
  172. module_init(fsi_ak4642_init);
  173. module_exit(fsi_ak4642_exit);
  174. MODULE_LICENSE("GPL");
  175. MODULE_DESCRIPTION("Generic SH4 FSI-AK4642 sound card");
  176. MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>");