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