lpass-ipq806x.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * lpass-ipq806x.c -- ALSA SoC CPU DAI driver for QTi LPASS
  14. * Splited out the IPQ8064 soc specific from lpass-cpu.c
  15. */
  16. #include <linux/clk.h>
  17. #include <linux/device.h>
  18. #include <linux/err.h>
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include <linux/of.h>
  22. #include <linux/platform_device.h>
  23. #include <sound/pcm.h>
  24. #include <sound/soc.h>
  25. #include <sound/soc-dai.h>
  26. #include "lpass-lpaif-reg.h"
  27. #include "lpass.h"
  28. enum lpaif_i2s_ports {
  29. IPQ806X_LPAIF_I2S_PORT_CODEC_SPK,
  30. IPQ806X_LPAIF_I2S_PORT_CODEC_MIC,
  31. IPQ806X_LPAIF_I2S_PORT_SEC_SPK,
  32. IPQ806X_LPAIF_I2S_PORT_SEC_MIC,
  33. IPQ806X_LPAIF_I2S_PORT_MI2S,
  34. };
  35. enum lpaif_dma_channels {
  36. IPQ806X_LPAIF_RDMA_CHAN_MI2S,
  37. IPQ806X_LPAIF_RDMA_CHAN_PCM0,
  38. IPQ806X_LPAIF_RDMA_CHAN_PCM1,
  39. };
  40. static struct snd_soc_dai_driver ipq806x_lpass_cpu_dai_driver = {
  41. .id = IPQ806X_LPAIF_I2S_PORT_MI2S,
  42. .playback = {
  43. .stream_name = "lpass-cpu-playback",
  44. .formats = SNDRV_PCM_FMTBIT_S16 |
  45. SNDRV_PCM_FMTBIT_S24 |
  46. SNDRV_PCM_FMTBIT_S32,
  47. .rates = SNDRV_PCM_RATE_8000 |
  48. SNDRV_PCM_RATE_16000 |
  49. SNDRV_PCM_RATE_32000 |
  50. SNDRV_PCM_RATE_48000 |
  51. SNDRV_PCM_RATE_96000,
  52. .rate_min = 8000,
  53. .rate_max = 96000,
  54. .channels_min = 1,
  55. .channels_max = 8,
  56. },
  57. .probe = &asoc_qcom_lpass_cpu_dai_probe,
  58. .ops = &asoc_qcom_lpass_cpu_dai_ops,
  59. };
  60. static int ipq806x_lpass_alloc_dma_channel(struct lpass_data *drvdata, int dir)
  61. {
  62. if (dir == SNDRV_PCM_STREAM_PLAYBACK)
  63. return IPQ806X_LPAIF_RDMA_CHAN_MI2S;
  64. else /* Capture currently not implemented */
  65. return -EINVAL;
  66. }
  67. static int ipq806x_lpass_free_dma_channel(struct lpass_data *drvdata, int chan)
  68. {
  69. return 0;
  70. }
  71. static struct lpass_variant ipq806x_data = {
  72. .i2sctrl_reg_base = 0x0010,
  73. .i2sctrl_reg_stride = 0x04,
  74. .i2s_ports = 5,
  75. .irq_reg_base = 0x3000,
  76. .irq_reg_stride = 0x1000,
  77. .irq_ports = 3,
  78. .rdma_reg_base = 0x6000,
  79. .rdma_reg_stride = 0x1000,
  80. .rdma_channels = 4,
  81. .wrdma_reg_base = 0xB000,
  82. .wrdma_reg_stride = 0x1000,
  83. .wrdma_channel_start = 5,
  84. .wrdma_channels = 4,
  85. .dai_driver = &ipq806x_lpass_cpu_dai_driver,
  86. .num_dai = 1,
  87. .alloc_dma_channel = ipq806x_lpass_alloc_dma_channel,
  88. .free_dma_channel = ipq806x_lpass_free_dma_channel,
  89. };
  90. static const struct of_device_id ipq806x_lpass_cpu_device_id[] = {
  91. { .compatible = "qcom,lpass-cpu", .data = &ipq806x_data },
  92. {}
  93. };
  94. MODULE_DEVICE_TABLE(of, ipq806x_lpass_cpu_device_id);
  95. static struct platform_driver ipq806x_lpass_cpu_platform_driver = {
  96. .driver = {
  97. .name = "lpass-cpu",
  98. .of_match_table = of_match_ptr(ipq806x_lpass_cpu_device_id),
  99. },
  100. .probe = asoc_qcom_lpass_cpu_platform_probe,
  101. .remove = asoc_qcom_lpass_cpu_platform_remove,
  102. };
  103. module_platform_driver(ipq806x_lpass_cpu_platform_driver);
  104. MODULE_DESCRIPTION("QTi LPASS CPU Driver");
  105. MODULE_LICENSE("GPL v2");