0062-ASoC-Add-support-for-PCM5102A-codec.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. From 8d9e66b5c078b9677715362a48e17a55db1e0a41 Mon Sep 17 00:00:00 2001
  2. From: Florian Meier <florian.meier@koalo.de>
  3. Date: Fri, 22 Nov 2013 14:59:51 +0100
  4. Subject: [PATCH] ASoC: Add support for PCM5102A codec
  5. Some definitions to support the PCM5102A codec
  6. by Texas Instruments.
  7. Signed-off-by: Florian Meier <florian.meier@koalo.de>
  8. ---
  9. sound/soc/codecs/Kconfig | 5 ++++
  10. sound/soc/codecs/Makefile | 2 ++
  11. sound/soc/codecs/pcm5102a.c | 70 +++++++++++++++++++++++++++++++++++++++++++++
  12. 3 files changed, 77 insertions(+)
  13. create mode 100644 sound/soc/codecs/pcm5102a.c
  14. --- a/sound/soc/codecs/Kconfig
  15. +++ b/sound/soc/codecs/Kconfig
  16. @@ -89,6 +89,7 @@ config SND_SOC_ALL_CODECS
  17. select SND_SOC_PCM512x_SPI if SPI_MASTER
  18. select SND_SOC_RT286 if I2C
  19. select SND_SOC_RT298 if I2C
  20. + select SND_SOC_PCM5102A if I2C
  21. select SND_SOC_RT5631 if I2C
  22. select SND_SOC_RT5640 if I2C
  23. select SND_SOC_RT5645 if I2C
  24. @@ -549,6 +550,10 @@ config SND_SOC_RT298
  25. tristate
  26. depends on I2C
  27. +config SND_SOC_PCM5102A
  28. + tristate
  29. + depends on I2C
  30. +
  31. config SND_SOC_RT5631
  32. tristate "Realtek ALC5631/RT5631 CODEC"
  33. depends on I2C
  34. --- a/sound/soc/codecs/Makefile
  35. +++ b/sound/soc/codecs/Makefile
  36. @@ -85,6 +85,7 @@ snd-soc-rl6231-objs := rl6231.o
  37. snd-soc-rl6347a-objs := rl6347a.o
  38. snd-soc-rt286-objs := rt286.o
  39. snd-soc-rt298-objs := rt298.o
  40. +snd-soc-pcm5102a-objs := pcm5102a.o
  41. snd-soc-rt5631-objs := rt5631.o
  42. snd-soc-rt5640-objs := rt5640.o
  43. snd-soc-rt5645-objs := rt5645.o
  44. @@ -280,6 +281,7 @@ obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-
  45. obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o
  46. obj-$(CONFIG_SND_SOC_RT286) += snd-soc-rt286.o
  47. obj-$(CONFIG_SND_SOC_RT298) += snd-soc-rt298.o
  48. +obj-$(CONFIG_SND_SOC_PCM5102A) += snd-soc-pcm5102a.o
  49. obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o
  50. obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o
  51. obj-$(CONFIG_SND_SOC_RT5645) += snd-soc-rt5645.o
  52. --- /dev/null
  53. +++ b/sound/soc/codecs/pcm5102a.c
  54. @@ -0,0 +1,70 @@
  55. +/*
  56. + * Driver for the PCM5102A codec
  57. + *
  58. + * Author: Florian Meier <florian.meier@koalo.de>
  59. + * Copyright 2013
  60. + *
  61. + * This program is free software; you can redistribute it and/or
  62. + * modify it under the terms of the GNU General Public License
  63. + * version 2 as published by the Free Software Foundation.
  64. + *
  65. + * This program is distributed in the hope that it will be useful, but
  66. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  67. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  68. + * General Public License for more details.
  69. + */
  70. +
  71. +
  72. +#include <linux/init.h>
  73. +#include <linux/module.h>
  74. +#include <linux/platform_device.h>
  75. +
  76. +#include <sound/soc.h>
  77. +
  78. +static struct snd_soc_dai_driver pcm5102a_dai = {
  79. + .name = "pcm5102a-hifi",
  80. + .playback = {
  81. + .channels_min = 2,
  82. + .channels_max = 2,
  83. + .rates = SNDRV_PCM_RATE_8000_192000,
  84. + .formats = SNDRV_PCM_FMTBIT_S16_LE |
  85. + SNDRV_PCM_FMTBIT_S24_LE |
  86. + SNDRV_PCM_FMTBIT_S32_LE
  87. + },
  88. +};
  89. +
  90. +static struct snd_soc_codec_driver soc_codec_dev_pcm5102a;
  91. +
  92. +static int pcm5102a_probe(struct platform_device *pdev)
  93. +{
  94. + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pcm5102a,
  95. + &pcm5102a_dai, 1);
  96. +}
  97. +
  98. +static int pcm5102a_remove(struct platform_device *pdev)
  99. +{
  100. + snd_soc_unregister_codec(&pdev->dev);
  101. + return 0;
  102. +}
  103. +
  104. +static const struct of_device_id pcm5102a_of_match[] = {
  105. + { .compatible = "ti,pcm5102a", },
  106. + { }
  107. +};
  108. +MODULE_DEVICE_TABLE(of, pcm5102a_of_match);
  109. +
  110. +static struct platform_driver pcm5102a_codec_driver = {
  111. + .probe = pcm5102a_probe,
  112. + .remove = pcm5102a_remove,
  113. + .driver = {
  114. + .name = "pcm5102a-codec",
  115. + .owner = THIS_MODULE,
  116. + .of_match_table = pcm5102a_of_match,
  117. + },
  118. +};
  119. +
  120. +module_platform_driver(pcm5102a_codec_driver);
  121. +
  122. +MODULE_DESCRIPTION("ASoC PCM5102A codec driver");
  123. +MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
  124. +MODULE_LICENSE("GPL v2");