ak4554.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * ak4554.c
  3. *
  4. * Copyright (C) 2013 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. */
  11. #include <linux/module.h>
  12. #include <sound/soc.h>
  13. /*
  14. * ak4554 is very simple DA/AD converter which has no setting register.
  15. *
  16. * CAUTION
  17. *
  18. * ak4554 playback format is SND_SOC_DAIFMT_RIGHT_J,
  19. * and, capture format is SND_SOC_DAIFMT_LEFT_J
  20. * on same bit clock, LR clock.
  21. * But, this driver doesn't have snd_soc_dai_ops :: set_fmt
  22. *
  23. * CPU/Codec DAI image
  24. *
  25. * CPU-DAI1 (plaback only fmt = RIGHT_J) --+-- ak4554
  26. * |
  27. * CPU-DAI2 (capture only fmt = LEFT_J) ---+
  28. */
  29. static const struct snd_soc_dapm_widget ak4554_dapm_widgets[] = {
  30. SND_SOC_DAPM_INPUT("AINL"),
  31. SND_SOC_DAPM_INPUT("AINR"),
  32. SND_SOC_DAPM_OUTPUT("AOUTL"),
  33. SND_SOC_DAPM_OUTPUT("AOUTR"),
  34. };
  35. static const struct snd_soc_dapm_route ak4554_dapm_routes[] = {
  36. { "Capture", NULL, "AINL" },
  37. { "Capture", NULL, "AINR" },
  38. { "AOUTL", NULL, "Playback" },
  39. { "AOUTR", NULL, "Playback" },
  40. };
  41. static struct snd_soc_dai_driver ak4554_dai = {
  42. .name = "ak4554-hifi",
  43. .playback = {
  44. .stream_name = "Playback",
  45. .channels_min = 2,
  46. .channels_max = 2,
  47. .rates = SNDRV_PCM_RATE_8000_48000,
  48. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  49. },
  50. .capture = {
  51. .stream_name = "Capture",
  52. .channels_min = 2,
  53. .channels_max = 2,
  54. .rates = SNDRV_PCM_RATE_8000_48000,
  55. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  56. },
  57. .symmetric_rates = 1,
  58. };
  59. static struct snd_soc_codec_driver soc_codec_dev_ak4554 = {
  60. .component_driver = {
  61. .dapm_widgets = ak4554_dapm_widgets,
  62. .num_dapm_widgets = ARRAY_SIZE(ak4554_dapm_widgets),
  63. .dapm_routes = ak4554_dapm_routes,
  64. .num_dapm_routes = ARRAY_SIZE(ak4554_dapm_routes),
  65. },
  66. };
  67. static int ak4554_soc_probe(struct platform_device *pdev)
  68. {
  69. return snd_soc_register_codec(&pdev->dev,
  70. &soc_codec_dev_ak4554,
  71. &ak4554_dai, 1);
  72. }
  73. static int ak4554_soc_remove(struct platform_device *pdev)
  74. {
  75. snd_soc_unregister_codec(&pdev->dev);
  76. return 0;
  77. }
  78. static const struct of_device_id ak4554_of_match[] = {
  79. { .compatible = "asahi-kasei,ak4554" },
  80. {},
  81. };
  82. MODULE_DEVICE_TABLE(of, ak4554_of_match);
  83. static struct platform_driver ak4554_driver = {
  84. .driver = {
  85. .name = "ak4554-adc-dac",
  86. .of_match_table = ak4554_of_match,
  87. },
  88. .probe = ak4554_soc_probe,
  89. .remove = ak4554_soc_remove,
  90. };
  91. module_platform_driver(ak4554_driver);
  92. MODULE_LICENSE("GPL");
  93. MODULE_DESCRIPTION("SoC AK4554 driver");
  94. MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");