mtk-base-afe.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * mtk-base-afe.h -- Mediatek base afe structure
  3. *
  4. * Copyright (c) 2016 MediaTek Inc.
  5. * Author: Garlic Tseng <garlic.tseng@mediatek.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 and
  9. * only version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #ifndef _MTK_BASE_AFE_H_
  17. #define _MTK_BASE_AFE_H_
  18. struct mtk_base_memif_data {
  19. int id;
  20. const char *name;
  21. int reg_ofs_base;
  22. int reg_ofs_cur;
  23. int fs_reg;
  24. int fs_shift;
  25. int fs_maskbit;
  26. int mono_reg;
  27. int mono_shift;
  28. int enable_reg;
  29. int enable_shift;
  30. int hd_reg;
  31. int hd_shift;
  32. int msb_reg;
  33. int msb_shift;
  34. int agent_disable_reg;
  35. int agent_disable_shift;
  36. };
  37. struct mtk_base_irq_data {
  38. int id;
  39. int irq_cnt_reg;
  40. int irq_cnt_shift;
  41. int irq_cnt_maskbit;
  42. int irq_fs_reg;
  43. int irq_fs_shift;
  44. int irq_fs_maskbit;
  45. int irq_en_reg;
  46. int irq_en_shift;
  47. int irq_clr_reg;
  48. int irq_clr_shift;
  49. };
  50. struct device;
  51. struct mtk_base_afe_memif;
  52. struct mtk_base_afe_irq;
  53. struct regmap;
  54. struct snd_pcm_substream;
  55. struct snd_soc_dai;
  56. struct mtk_base_afe {
  57. void __iomem *base_addr;
  58. struct device *dev;
  59. struct regmap *regmap;
  60. struct mutex irq_alloc_lock; /* dynamic alloc irq lock */
  61. unsigned int const *reg_back_up_list;
  62. unsigned int *reg_back_up;
  63. unsigned int reg_back_up_list_num;
  64. int (*runtime_suspend)(struct device *dev);
  65. int (*runtime_resume)(struct device *dev);
  66. bool suspended;
  67. struct mtk_base_afe_memif *memif;
  68. int memif_size;
  69. struct mtk_base_afe_irq *irqs;
  70. int irqs_size;
  71. const struct snd_pcm_hardware *mtk_afe_hardware;
  72. int (*memif_fs)(struct snd_pcm_substream *substream,
  73. unsigned int rate);
  74. int (*irq_fs)(struct snd_pcm_substream *substream,
  75. unsigned int rate);
  76. void *platform_priv;
  77. };
  78. struct mtk_base_afe_memif {
  79. unsigned int phys_buf_addr;
  80. int buffer_size;
  81. struct snd_pcm_substream *substream;
  82. const struct mtk_base_memif_data *data;
  83. int irq_usage;
  84. int const_irq;
  85. };
  86. struct mtk_base_afe_irq {
  87. const struct mtk_base_irq_data *irq_data;
  88. int irq_occupyed;
  89. };
  90. #endif